Dcos環境步驟搭建html
1、DCOS介紹node
· DC/OS(DataCenter Operating System)是以Apache Mesos 爲分佈式系統內核的分佈式數據中心操做系統linux
· DC/OS可使企業像使用一臺主機同樣使用分佈式數據中心的多個集羣資源,進行彈性地擴容與縮容nginx
· DC/OS實現資源自動化管理、進程調度、方便內部進程通信、簡化分佈式服務的安裝和管理docker
· DC/OS提供網頁界面和 CLI ,方便對集羣和其中的服務進行遠程地管理和監控bootstrap
2、節點介紹vim
Dcos環境分爲三個節點, bootstrapnode、master nodes、agent nodes(slave nodes)。centos
· bootstrap nodebash
操做系統硬件資源符合最低CPU 2 Cores、內存16 GB RAM、硬盤60 GB HDD。並須要聽從TCP/IP協議,必須和master nodes的tcp端口80, 443, 8080, 8181, 2181, 5050要通訊。網絡
注:bootstrap 節點是再也不dcos節點範疇內。
· master nodes
最小配資源 |
最大支持資源 |
Nodes: 1 |
Nodes: 3 |
master nodes 最少一個節點,最多3個節點
· agent nodes(slave nodes)
最小配資源 |
最大支持資源 |
Nodes: 1 |
Nodes: 6 or more |
slave nodes 一個節點,最多6個或以上節點。而且最少分區/var有10G的空間。由於docker須要的到這個,dokcer容器,鏡像都是在這個目錄下。
3、防火牆設置
對於RHEL 7和 CentOS 7操做系統,必需要把firewalld防火牆關閉掉,firewalld的防火牆和docker之間並不友好,注意的是不要把iptables關了,由於docker容器和宿主機以前通訊是要用到iptables的功能。各個節點都要關閉firewalld。
# sudo systemctl stop firewalld &&sudo systemctl disable firewalld
4、DC/OS目錄介紹
dc/os安裝完成後的目錄在/opt/mesosphere,該節點正確並須要存在,不能是一個單獨的LVM邏輯卷或者共享存儲。
Master nodes 和slave nodes存放的重要信息放在/var/lib/mesos目錄
/tmp目錄掛在屬性不能有noexec,由於後續要在/tmp目錄下建立一個目錄並運行一個腳本。
注意:目錄/var/lib/mesos和目錄/var/lib/docker不能遠程掛載。
5、端口和協議網絡配置
· 全部節點相互之間能SSH鏈接。
· 全部節點相互之間能ICMP鏈接。
· 全部節點相互之間的網絡能訪問bootstrap node鏈接。
· UDP端口53必須打開。Agent node (slave node)的服務dcos-mesos-slave會使用53端口會找leader.mesos。
· 高速率訪問:最低速率要10 Mbit。其中安裝完後/opt/mesosphere/etc/mesos-slave-common目錄裏面的MESOS_EXECUTOR_REGISTRATION_TIMEOUT參數定義最低速率爲10 Mbit。
6、初始化腳本配置
初始化腳本
安裝在DC/OS mastersand agents 上。(請看附件)
7、docker配置
適用於全部節點的docker配置
· 1.7.x
· 1.8.x
· 1.9.x
· 1.10.x
· 1.11.x
注意重要: 版本 1.12.x 不支持。我原先就在這裏跳了一個大坑。
· Virtual networks 要求 Docker1.11.。
8、sudo權限配置
更改這個文件/etc/sudoers,以下一行。如須要給yingjiahulian這個普通用戶使用sudo免密碼。即全部節點都操做,包括bootstrap節點。
%yingjiahulian ALL=(ALL) NOPASSWD: ALL
9、NTP開啓
全部節點須要NTP時鐘同步
#sudoyum install -y ntpdate ntp
#ntptime
#adjtimex –p&&timedatectl
10、安裝docker
備註:從第10步開始,有些步驟是否是必須的,由於第6步的初始化腳本里的步驟包括了的。詳細查看第6步的腳本內容。全部節點都須要操做,包括bootstrap節點。
查看 kernel is atleast 3.10:
1.uname -r
3.10.0-327.10.1.el7.x86_64
2. 開啓 OverlayFS模塊
sudo tee /etc/modules-load.d/overlay.conf <<-'EOF'
overlay
EOF
3. 重啓並加載模塊
reboot
4. 查看 OverlayFS是否開啓
lsmod | grep overlay
overlay
5. 配置Docker yum 源:
sudo tee /etc/yum.repos.d/docker.repo <<-'EOF'
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF
6. Configure systemd to run theDocker Daemon with OverlayFS:
sudo mkdir -p /etc/systemd/system/docker.service.d && sudo tee/etc/systemd/system/docker.service.d/override.conf <<- 'EOF'
[Service]
ExecStart=
ExecStart=/usr/bin/docker daemon --storage-driver=overlay -H fd://
EOF
7. Install the Docker engine,daemon, and service.
Important: Docker version 1.12.x isnot supported.
sudo yum install -y docker-engine-1.11.2
sudo systemctl start docker
sudo systemctl enable docker
When the process completes, you should see:
Complete!
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.serviceto/usr/lib/systemd/system/docker.service.
8. Test that Docker is properlyinstalled:
sudo docker ps
11、pull下載nginx
#該操做只在bootstrap節點上操做.
#sudo docker pull nginx
12、其餘操做
#全部節點操做,包括bootstrap節點。
#sudo yum install -y tar xz unzip curl ipset
#sudo sed -is/SELINUX=enforcing/SELINUX=permissive/g /etc/selinux/config &&
sudogroupadd nogroup &&
sudo reboot
#確保LANG爲en_US.utf-8。
13、dc/os安裝開始
備註:13-18步都是在bootstrap節點上操做。
以下是官網的給出目錄做用列表
The DC/OS installation createsthesefolders:
Folder |
Description |
/opt/mesosphere |
Contains all the DC/OS binaries, libraries, cluster configuration. Do not modify. |
/etc/systemd/system/dcos.target.wants |
Contains the systemd services which start the things that make up systemd. They must live outside of /opt/mesospherebecause of systemd constraints. |
/etc/systemd/system/dcos.<units> |
Contains copies of the units in/etc/systemd/system/dcos.target.wants. They must be at the top folder as well as inside dcos.target.wants. |
/var/lib/dcos/exhibitor/zookeeper |
Contains the ZooKeeper data. |
/var/lib/docker |
Contains the Docker data. |
/var/lib/dcos |
Contains the DC/OS data. |
/var/lib/mesos |
Contains the Mesos data. |
14、建立genconf目錄
#sudo mkdir -p genconf
15、建立genconf/config.yaml文件
官網的列子是這樣
#vim genconf/config.yaml
---
bootstrap_url:http://<bootstrap_ip>:<your_port>
cluster_name:'<cluster-name>'
exhibitor_storage_backend:static
ip_detect_filename:/genconf/ip-detect
master_discovery:static
master_list:
-<master-private-ip-1>
-<master-private-ip-2>
-<master-private-ip-3>
resolvers:
-8.8.4.4
-8.8.8.8
use_proxy:'true'
http_proxy:http://<user>:<pass>@<proxy_host>:<http_proxy_port>
https_proxy:https://<user>:<pass>@<proxy_host>:<https_proxy_port>
no_proxy:
-'foo.bar.com'
-'.baz.com'
我這裏部署的時候文件內容
---
bootstrap_url:http://192.168.30.37:8799
cluster_name:'bingo_cluster'
exhibitor_storage_backend:static
ip_detect_filename:/genconf/ip-detect
master_discovery: static
master_list:
- 192.168.30.30
resolvers:
- 192.168.30.37
- 8.8.8.8
查看resolv
$ cat /etc/resolv.conf
# Generated byNetworkManager
search example
nameserver 192.168.30.37
nameserver 8.8.8.8
16、建立genconf/ ip-detect文件
# vim genconf/ip-detect
#!/usr/bin/env bash
set -onounset -o errexit
exportPATH=/usr/sbin:/usr/bin:$PATH
echo$(ip addr show eno33557248| grep -Eo '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' |head -1)
備註:eno33557248 爲各節點通訊的網卡名字
17、下載 並運行DC/OS 安裝包腳本
sudo curl -O \
https://downloads.dcos.io/dcos/stable/dcos_generate_config.sh
#sudo bashdcos_generate_config.sh
運行萬結構後目錄結構應該這樣
├──dcos-genconf.<HASH>.tar
├──dcos_generate_config.sh
├──genconf
│ ├── config.yaml
│ ├── ip-detect
18、啓動nginx容器資源
#sudo docker run -d -p 8799:80 -v \
$PWD/genconf/serve:/usr/share/nginx/html:ronginx
#sudo docker p_w_picpaths
#sudo docker ps
並查看本機8799端口是否啓用
$ netstat -tlnpu|grep 8799
(No info could be read for "-p":geteuid()=1001 but you should be root.)
tcp6 0 0 :::8799 :::* LISTEN -
19、master節點配置
$sudo mkdir /tmp/dcos&& cd /tmp/dcos
$ sudo curl -O http://192.168.30.37:8799/dcos_install.sh
$ sudo bash dcos_install.shmaster
20、agent(slave)節點配置
$sudo mkdir /tmp/dcos&& cd /tmp/dcos
$ sudo curl -O http://192.168.30.37:8799/dcos_install.sh
$ sudo bash dcos_install.shslave
22、dc/os環境搭建成功