DC/OS 安裝部署

Table of Contents

Created by gh-md-tochtml

安裝部署

硬件條件


安裝 DC/OS 須要準備 1 臺 bootstrap node (這個就是咱們的工做機), 1臺 或多臺Mesos master nodes, 1 臺 或多臺 Mesos Agents。它們的配置需求也不大同樣。node

準備階段


bootstrap node


通常可用咱們的開發機用作 boostrap node,須要至少 2 cores, 16 G RAM, 60 G HDD,且在其上裝下以下軟件:linux

  • 若是使用 DC/OS CLI 的話,須要安裝 Python, pip, virtualenv。 pip 須要配置一下,使其能夠從 PyPI 或者咱們本身的私有 PyPI 下載安裝包git

  • 一個 HA 的負載均衡,好比 HAProxy,用於將 80,443,8080,8181,2181,5050 等 TCP 端口均衡到全部的 mesos master 節點上github

  • 一個未加密的 SSH key ,用它來訪問全部的集羣節點。目前,加密的還不支持web

接下來對開發機作以下配置:docker

一、新建 genconf 目錄shell

$ mkdir -p genconfjson

二、在 genconf 目錄下建立 ip-detect 腳本文件,在安裝 DC/OS 的時候,就是經過它進行找到 Mesos master,Agent 進行自動綁定 5050, 5051 等端口的。很重要bootstrap

官方提供的版本在咱們的環境中不可用,因此須要修改一下:

#!/usr/bin/env bash
set -o nounset -o errexit

MASTER_IP=10.221.82.185

# 官方版本
# echo $(/usr/sbin/ip route show to match 10.221.82.185 | grep -Eo '[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}' | tail -1)

# 內部使用版本
echo $(ip -d route get 10.221.82.185 | egrep -o 'src ([0-9.]*)' | grep -o '[0-9.]*')

三、建立配置文件並保存爲 genconf/config.yaml

示例參考以下:

---
agent_list:
- 10.221.78.22
- 10.221.78.23
- 10.221.78.26
bootstrap_url: file:///opt/dcos_install_tmp
cluster_name: shgq-chenqiang-dcos
exhibitor_storage_backend: static
ip_detect_filename: /genconf/ip-detect
log_directory: /genconf/logs
master_discovery: static
master_list:
- 10.221.82.185
- 10.221.82.186
- 10.221.82.187
oauth_enabled: 'false'
process_timeout: 10000
resolvers:
- 10.121.32.85
- 10.121.32.86
ssh_port: 22
ssh_user: root

四、複製 ssh key 到 genconf 目錄下,並命令爲 genconf/ssh_key

$ cp <path-to-key> genconf/ssh_key && chmod 0600 genconf/ssh_key

Cluster nodes


Cluster nodes 主要是指集羣中的 Master nodes 和 Agent nodes

Master nodes


須要至少 4 cores, 32 G RAM, 120 G HDD,因爲在 master 節點上會有不少混合負載,好比 replicated log 和 ZooKeeper,還有一些是文件同步操做,比較耗 I/O,有條件的話,可使用:

  • 固態硬盤

  • 有 BBU 的 RAID 卡

  • 有回寫模式的 RAID 緩存配置

Agent nodes


須要至少 2 cores, 16 G RAM, 60 G HDD,它必須須要以下的東西:

  • 至少 10 G 的 /var 目錄,這個主要存放 Docker 和 Mesos Containerizer 的 sandbox
  • 可訪問外網 Docker repo 或者內網的 Docker registry

操做系統使用最新的 centos 7.2

$ sudo yum upgrade -y

禁掉防火牆

$ sudo systemctl stop firewalld && sudo systemctl disable firewalld

DC/OS 安裝在 /opt/mesosphere 目錄下,須要確保它不是在一個 LVM 的邏輯卷或者共享的存儲上。

高級安裝的話,須要在 Cluster nodes 上, 即 Master , Agent 節點上完成以下事項:

  • 須要有 UnZip, GNU tar, XZ Utils 等數據壓縮工具

    $ sudo yum install -y tar xz unzip curl ipset

  • 禁掉 SELinux,將 nogroup 添加到 Mesos masters 和 Agents 中,而後重啓機器

    $ sudo sed -i s/SELINUX=enforcing/SELINUX=permissive/g /etc/selinux/config &&
    sudo groupadd nogroup &&
    sudo reboot

部署階段


部署 Master/Agent nodes


一、爲簡單方便,咱們能夠在新的全部 Cluster nodes 上部署 dep tag 便可。

$ ansible-playbook --limit=nodes -i hosts/xxx mesos.yaml --tags unguard

二、DC/OS 須要使用dns port 53, 因爲在 dep 中 dnsmasq 會佔用該端口, 因此暫停該端口。

$ ansible nodes -i hosts/xxx -m shell -a "systemctl stop dnsmasq"

部署 bootstrap node


一、下載或經過本項目生成 DC/OS Installer 到開發機的 根目錄。本身生成的話,可參見官方 README.md 進行。

$ curl -O https://downloads.dcos.io/dcos/EarlyAccess/dcos_generate_config.sh

二、接下來能夠經過網頁安裝或者命令行安裝。

網頁安裝較簡單,只須要執行以下命令,而後打開瀏覽器進入 http://<bootstrap-node-public-ip>:9000便可:

$ sudo bash dcos_generate_config.sh --web

咱們採用命令行安裝,將執行以下命令:

  • Step1:在 home 目錄運行 DC/OS Installer 腳原本生成 DC/OS Build ,這個腳本會提取出一個 Docker 容器,並將經過的 DC/OS 安裝文件爲咱們本地環境生成定製化的 DC/OS Build。 這個 Build 會放在 ./genconf/serve/ 目錄下。

    $ sudo bash dcos_generate_config.sh --genconf

    執行該命令時,輸出大概是這樣的。

    Extracting image from this script and loading into docker daemon, this step can take a few minutes
    dcos-genconf.e060aa49ac4ab62d5e-1e14856f55e5d5d07b.tar
    Running mesosphere/dcos-genconf docker with BUILD_DIR set to /home/centos/genconf
    ====> EXECUTING CONFIGURATION GENERATION
    ...

    這個時候,咱們的目錄結構大概是這樣的:

    ├── dcos-genconf.<HASH>.tar
    ├── dcos_generate_config.sh
    ├── genconf
    │   ├── config.yaml
    │   ├── ip-detect
    │   ├── cluster_packages.json
    │   ├── serve
    │   ├── ssh_key
    │   ├── state
  • Step2:安裝一些集羣所需的必要包

    $ sudo bash dcos_generate_config.sh --install-prereqs

    輸出示例:

    Running mesosphere/dcos-genconf docker with BUILD_DIR set to /home/centos/genconf
    ====> dcos_installer.action_lib.prettyprint:: ====> EXECUTING INSTALL PREREQUISITES
    ====> dcos_installer.action_lib.prettyprint:: ====> START install_prereqs
    ====> dcos_installer.action_lib.prettyprint:: ====> STAGE install_prereqs
    ====> dcos_installer.action_lib.prettyprint:: ====> STAGE install_prereqs
    ====> dcos_installer.action_lib.prettyprint:: ====> END install_prereqs with returncode: 0
    ====> dcos_installer.action_lib.prettyprint:: ====> SUMMARY
    ====> dcos_installer.action_lib.prettyprint:: 2 out of 2 hosts successfully completed install_prereqs stage.
  • Step3: 執行 preflight 校驗安裝過程

    $ sudo bash dcos_generate_config.sh --preflight

    想看得詳細一點的話,能夠加上 -v 參數。

    示例輸出:

    Running mesosphere/dcos-genconf docker with BUILD_DIR set to /home/centos/genconf
    ====> dcos_installer.action_lib.prettyprint:: ====> EXECUTING PREFLIGHT
    ====> dcos_installer.action_lib.prettyprint:: ====> START run_preflight
    ====> dcos_installer.action_lib.prettyprint:: ====> STAGE preflight
    ====> dcos_installer.action_lib.prettyprint:: ====> STAGE preflight
    ====> dcos_installer.action_lib.prettyprint:: ====> STAGE preflight_cleanup
    ====> dcos_installer.action_lib.prettyprint:: ====> STAGE preflight_cleanup
    ====> dcos_installer.action_lib.prettyprint:: ====> END run_preflight with returncode: 0
    ====> dcos_installer.action_lib.prettyprint:: ====> SUMMARY
    ====> dcos_installer.action_lib.prettyprint:: 2 out of 2 hosts successfully completed run_preflight stage.
  • Step 4: 開始安裝 DC/OS 到咱們的集羣中了

    $ sudo bash dcos_generate_config.sh --deploy

    示例輸出:

    Running mesosphere/dcos-genconf docker with BUILD_DIR set to /home/centos/genconf
    ====> dcos_installer.action_lib.prettyprint:: ====> EXECUTING DC/OS INSTALLATION
    ====> dcos_installer.action_lib.prettyprint:: ====> START deploy_master
    ====> dcos_installer.action_lib.prettyprint:: ====> STAGE deploy_master
    ====> dcos_installer.action_lib.prettyprint:: ====> STAGE deploy_master_cleanup
    ====> dcos_installer.action_lib.prettyprint:: ====> END deploy_master with returncode: 0
    ====> dcos_installer.action_lib.prettyprint:: ====> SUMMARY
    ====> dcos_installer.action_lib.prettyprint:: 1 out of 1 hosts successfully completed deploy_master stage.
    ====> dcos_installer.action_lib.prettyprint:: ====> START deploy_agent
    ====> dcos_installer.action_lib.prettyprint:: ====> STAGE deploy_agent
    ====> dcos_installer.action_lib.prettyprint:: ====> STAGE deploy_agent_cleanup
    ====> dcos_installer.action_lib.prettyprint:: ====> END deploy_agent with returncode: 0
    ====> dcos_installer.action_lib.prettyprint:: ====> SUMMARY
    ====> dcos_installer.action_lib.prettyprint:: 1 out of 1 hosts successfully completed deploy_agent stage.
  • Step5:運行 DC/OS 診斷腳原本覈實服務是否起來並在運行

    $ sudo bash dcos_generate_config.sh --postflight

    示例輸出:

    unning mesosphere/dcos-genconf docker with BUILD_DIR set to /home/centos/genconf
    ====> dcos_installer.action_lib.prettyprint:: ====> EXECUTING POSTFLIGHT
    ====> dcos_installer.action_lib.prettyprint:: ====> START run_postflight
    ====> dcos_installer.action_lib.prettyprint:: ====> STAGE postflight
    ====> dcos_installer.action_lib.prettyprint:: ====> STAGE postflight
    ====> dcos_installer.action_lib.prettyprint:: ====> STAGE postflight_cleanup
    ====> dcos_installer.action_lib.prettyprint:: ====> STAGE postflight_cleanup
    ====> dcos_installer.action_lib.prettyprint:: ====> END run_postflight with returncode: 0
    ====> dcos_installer.action_lib.prettyprint:: ====> SUMMARY
    ====> dcos_installer.action_lib.prettyprint:: 2 out of 2 hosts successfully completed run_postflight stage.
  • Step6:這個時候能夠去頁面上 http://<master-public-ip>:8181/exhibitor/v1/ui/index.html 看看 ZK 了

  • Step7:此時安裝完成, 能夠登陸 DC/OS (http://<public-master-ip>/)的頁面一睹芳容了。

相關文章
相關標籤/搜索