2016年5月18日 星期三

DC/OS on CentOS

Update system packages 

$ sudo yum udate -y && sudo yum upgrade -y
Please check your kernel version
$ uname -r
3.10.0-327.10.1.el7.x86_64
Docker requirements
  • Docker 1.7 or greater must be installed on all bootstrap and cluster nodes.
Docker recommendations
  • Docker 1.9 or greater is recommended for stability reasons.
  • Do not use Docker devicemapper storage driver in loop-lvm mode.
  • Prefer OverlayFS or devicemapper in direct-lvm mode when choosing a production storage driver.
  • Manage Docker on CentOS with systemd.
  • Run Docker commands as the root user (with sudo) or as a user in the docker user group.
Setting Overlay script for CentOS7
#!/bin/bash
 
#####
# Basic tool
#####
 
yum -y install curl git tig tree vim wget
yum -y groupinstall "Development Tools"
 
#####
# Docker Repo
#####
 
DOCKER_REPO="/etc/yum.repos.d/docker.repo"
 
if [ -f ${DOCKER_REPO} ]; then
    echo -e "\033[0;33;40mDocker Repo exist\033[0m"
    echo -e "\033[0;36;40mInstall Docker Engine\033[0m"
    yum install -y docker-engine
    echo -e "\033[0;32;40mdone\033[0m"
else
    echo -e "\033[0;36;40mSetting Docker Repo\033[0m"
    tee ${DOCKER_REPO} <<- -e="" -y="" 2="" baseurl="https://yum.dockerproject.org/repo/main/centos/7/" docker-engine="" docker="" dockerrepo="" echo="" enable="" enabled="1" engine="" eof="" fi="" gpgcheck="1" gpgkey="https://yum.dockerproject.org/gpg" grep="" install="" lsmod="" m="" mdone="" minstall="" module="" name="Docker" overlay="" repository="" sleep="" yum="">> /dev/null
check_overlay=$?
 
if [ ${check_overlay} = 0 ]; then
    echo -e "\033[0;33;40mAlready Enabled overlay module\033[0m"
else
    echo -e "\033[0;36;40mEnable overlay module\033[0m"
    modprobe overlay
    echo -e "\033[0;32;40mdone\033[0m"
fi
 
sleep 2
#####
# Setting Disk and mount
####
 
HDD_DEVICE="`cat /var/log/messages | grep 'unknown partition table' | awk '{print $6}' | cut -d: -f1 | head -n 1`"
OVERLAY_DIR="/var/lib/docker/overlay"
 
if [ -b /dev/${HDD_DEVICE}1 ]; then
    echo -e "\033[0;33;40m${HDD_DEVICE}1 exist\033[0m"
else
    echo -e "\033[0;36;40mFormate Disk\033[0m"
    echo "n
p
1
 
 
w
"|fdisk /dev/${HDD_DEVICE}; mkfs.ext4 /dev/${HDD_DEVICE}1
    echo -e "\033[0;32;40mdone\033[0m"
fi
 
sleep 2
 
if [ -d ${OVERLAY_DIR} ]; then
    echo -e "\033[0;33;40m${OVERLAY_DIR} exist\033[0m"
else
    echo -e "\033[0;36;40mCreating ${OVERLAY_DIR} directoy\033[0m"
    mkdir -p ${OVERLAY_DIR}
    echo -e "\033[0;32;40mdone\033[0m"
fi
 
sleep 2
 
cat /etc/fstab | grep 'overlay' >> /dev/null
check_uuid=$?
HDD_UUID_1="`blkid  /dev/${HDD_DEVICE}1 | awk '{print $2}' | sed 's/\"//g'`"
 
if [ ${check_uuid} = 0 ]; then
    echo -e "\033[0;33;40mfstab OK\033[0m"
else
    echo -e "\033[0;36;40mSetting fstab\033[0m"
    echo -n "${HDD_UUID_1}    ${OVERLAY_DIR}  ext4 defaults 0 2" >> /etc/fstab
    mount -a
    echo -e "\033[0;32;40mdone\033[0m"
fi
 
sleep 2
#####
# Setting Docker Engine
####
 
DOCKER_SERVICE="/usr/lib/systemd/system/docker.service"
 
grep '\-\-storage-driver=overlay' ${DOCKER_SERVICE} >> /dev/null
check_storage_driver=$?
 
if [ ${check_storage_driver} = 0 -a -f ${DOCKER_SERVICE} ]; then
  echo -e "\033[0;33;40mDocker Storage nothing to do\033[0m"
else
  echo -e "\033[0;36;40mSetting docker storage\033[0m"
  sed 12d -i ${DOCKER_SERVICE}
  sed "11 aExecStart=/usr/bin/docker daemon --storage-driver=overlay -H fd://" -i ${DOCKER_SERVICE} >> /dev/null
  echo -e "\033[0;32;40mdone\033[0m"
fi
 
#####
# Enable Docker
#####
 
systemctl daemon-reload
systemctl start docker
On CentOS 7, firewalld must be stopped and disabled.
$ sudo systemctl stop firewalld && sudo systemctl disable firewalld
Data compression (advanced installer),to install these utilities on CentOS7 and RHEL7:
$ sudo yum install -y tar xz unzip curl ipset
Cluster permissions (advanced installer)
On each of your cluster nodes, use the following command to:
  • Disable SELinux or set it to permissive mode.
  • Add nogroup to each of your Mesos masters and agents.
  • Disable IPV6.
$ sudo sed -i s/SELINUX=enforcing/SELINUX=permissive/g /etc/selinux/config &&
  sudo groupadd nogroup &&
  sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1 &&
  sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1 &&
  sudo reboot
  • Download the DC/OS installer
curl -O https://downloads.dcos.io/dcos/EarlyAccess/dcos_generate_config.sh
  • Create a directory named genconf on your bootstrap each node.
sudo mkdir -p genconf && cd genconf
  • Create a ip-detect script
#!/usr/bin/env bash
set -o nounset -o errexit
export PATH=/usr/sbin:/usr/bin:$PATH
echo $(ip addr show eth0 | grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' | head -1)
  • Create config.yaml. for exammple
---
agent_list:
- 
- 
- 
bootstrap_url: file:///opt/dcos_install_tmp
cluster_name: DCOS
exhibitor_storage_backend: static
ip_detect_filename: /genconf/ip-detect
master_discovery: static
master_list:
- 
- 
- 
process_timeout: 10000
resolvers:
- 8.8.8.8
ssh_port: 22
ssh_user: 
  • Copy your private SSH key to genconf/ssh_key
$ cp  genconf/ssh_key && chmod 0600 genconf/ssh_key
Now you genconf will be like this and copy to each node
genconf/
├── config.yaml
├── ip-detect
└── ssh_key
$ scp -rp genconf username@:
Check help
$ sudo bash dcos_generate_config.sh --help
Running mesosphere/dcos-genconf docker with BUILD_DIR set to /home/centos/genconf
usage:
Install DC/OS
 
dcos_installer [-h] [-f LOG_FILE] [--hash-password HASH_PASSWORD] [-v]
[--web | --genconf | --preflight | --deploy | --postflight | --uninstall | --validate-config | --test]
 
Environment Settings:
 
  PORT                  Set the :port to run the web UI
  CHANNEL_NAME          ADVANCED - Set build channel name
  BOOTSTRAP_ID          ADVANCED - Set bootstrap ID for build
 
optional arguments:
  -h, --help            show this help message and exit
  -v, --verbose         Verbose log output (DEBUG).
  --offline             Do not install preflight prerequisites on CentOS7,
                        RHEL7 in web mode
  --web                 Run the web interface.
  --genconf             Execute the configuration generation (genconf).
  --preflight           Execute the preflight checks on a series of nodes.
  --install-prereqs     Install preflight prerequisites. Works only on CentOS7
                        and RHEL7.
  --deploy              Execute a deploy.
  --postflight          Execute postflight checks on a series of nodes.
  --uninstall           Execute uninstall on target hosts.
  --validate-config     Validate the configuration in config.yaml
  --test                Performs tests on the dcos_installer application
  • Run this command for each master and node.
sudo bash dcos_generate_config.sh --install-prereqs
  • Run docker nginx for download install dcos_install.sh on master, and other node just download dcos_install.sh
sudo bash dcos_generate_config.sh
sudo docker run -d -p :80 -v $PWD/genconf/serve:/usr/share/nginx/html:ro nginx
Create /tmp/dcos directory and download dcos_install.sh
mkdir -p /tmp/dcos && cd /tmp/dcos
curl -O http://:/dcos_install.sh
sudo bash dcos_install.sh 
role must be master or slave
Now You can check
ZooKeeper http://IP:8181/exhibitor/v1/ui/index.html
Mesos http://IP:5050
DC/OShttp://IP

沒有留言:

張貼留言