您的位置:首页 > 其它

DC/OS 安装部署

2016-06-24 15:28 246 查看

Table of Contents

安装部署

硬件条件

准备阶段

bootstrap node

Cluster nodes

Master nodes

Agent nodes

部署阶段

部署 Master/Agent nodes

部署 bootstrap node

Created by gh-md-toc

安装部署

硬件条件

安装 DC/OS 需要准备 1 台 bootstrap node (这个就是我们的工作机), 1台 或多台Mesos master nodes, 1 台 或多台 Mesos Agents。它们的配置需求也不大一样。

准备阶段

bootstrap node

一般可用我们的开发机用做 boostrap node,需要至少 2 cores, 16 G RAM, 60 G HDD,且在其上装下如下软件:

如果使用 DC/OS CLI 的话,需要安装 Python, pip, virtualenv。 pip 需要配置一下,使其可以从 PyPI 或者我们自己的私有 PyPI 下载安装包

一个 HA 的负载均衡,比如 HAProxy,用于将 80,443,8080,8181,2181,5050 等 TCP 端口均衡到所有的 mesos master 节点上

一个未加密的 SSH key ,用它来访问所有的集群节点。目前,加密的还不支持

接下来对开发机做如下配置:

1、新建
genconf
目录

$ mkdir -p genconf


2、在
genconf
目录下创建
ip-detect
脚本文件,在安装 DC/OS 的时候,就是通过它进行找到 Mesos master,Agent 进行自动绑定 5050, 5051 等端口的。很重要

官方提供的版本在我们的环境中不可用,所以需要修改一下:

#!/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.]*')


3、创建配置文件并保存为
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


4、复制 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

1、为简单方便,我们可以在新的所有 Cluster nodes 上部署
dep
tag 即可。

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


2、DC/OS 需要使用dns port 53, 由于在 dep 中 dnsmasq 会占用该端口, 所以暂停该端口。

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


部署 bootstrap node

1、下载或通过本项目生成 DC/OS Installer 到开发机的 根目录。自己生成的话,可参见官方
README.md
进行。

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


2、接下来可以通过网页安装或者命令行安装。

网页安装较简单,只需要执行如下命令,然后打开浏览器进入
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>/
)的页面一睹芳容了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  dcos-安装 dcos mesos