-
安裝前準備
所有機器需要安裝python 2.7,go 1.5 以上版本
-
創(chuàng)建用戶
密碼生成需要依據(jù)python的加密模塊(python 2.7)
密碼生成
yum -y install python-pip
pip install passlib
python -c "from passlib.hash import sha512_crypt; import getpass; print sha512_crypt.encrypt(getpass.getpass())"
---
- hosts: test
user: root
vars:
password: $6$rounds=656000$FRp.ftd4Z/fZhAhq$wF8Nzv5.UdpSenYCZvv7veG7ApbZdgD4olsBrwUYULDv116i7QBOIMx1JkmiAOHaZ.B44chCZwII1Umkk.5Kz/
name: phoenix
tasks:
- user: name={{name}}
state=present
groups="root"
password={{password}}
- name: copy sudoers file for safety
command: cp -f /etc/sudoers /etc/sudoers.tmp
- name: create sudoers file backup
command: cp -f /etc/sudoers /etc/sudoers.bak
- file: path=/etc/sudoers.tmp owner=root group=root mode=0744
- lineinfile: dest=/etc/sudoers.tmp insertafter="root *" line="{{name}} ALL=(ALL) ALL"
- name: final sudoers file check
shell: visudo -q -c -f /etc/sudoers.tmp && cp -f /etc/sudoers.tmp /etc/sudoers
需要注意的是筆者的運行環(huán)境為centos7.1,在centos中默認不會將新增用戶添加到文件/etc/sudoers中,需要在playbook中添加task來完成
參考文檔
ansible create a new user
-
關(guān)閉防火墻指定端口
有待完善,考慮采用配置iptables的方式來開放端口,參考一下幾個鏈接
How To Set Up a Basic Iptables Firewall on Centos 6
IPTables
Firewalld - How to Dynamically Manage Firewall in RHEL/CentOS 7.0
-
更改所有機器的hosts文件
為了便于服務(wù)器之間的溝通,以及后續(xù)軟件的正常使用,需要更改所有機器的hosts文件,依據(jù)一下規(guī)則
- master節(jié)點記錄所有機器的hostname和ip
- slave節(jié)點記錄master節(jié)點的信息和自己的信息
-
安裝并配置zookeeper集群
編寫ansible腳本,復(fù)制安裝文件到master節(jié)點,解壓,更改配置文件,并啟動,參考以下文檔,部署zookeeper集群
在安裝zookeeper、mesos、marathon時需要對軟件進行yum安裝,這時需要在task中添加sudo:yes屬性,另外需要更改ansible中的配置文件,將屬性ask-become-pass添加進group中
ZooKeeper Administrator's Guide
-
安裝mesos dns
兩種方案
通過ansible復(fù)制安裝包到指定機器,并更改剩余機器的 /etc/resolv.conf文件
通過marathon進行部署,保證mesos dns的高可用
參考文檔
Installing and running Mesos-DNS-
安裝并配置mesos和marathon集群
- hosts: test user: river vars: ansible_become_pass: root tasks: - name: yum install mesos,zookeeper yum: name=mesos state=latest sudo: yes - name: yum install marathon yum: name=marathon state=latest sudo: yes
通過rpm 安裝mesos,主要參考以下文檔
Setting up a Mesos and Marathon Cluster
How To Configure a Production-Ready Mesosphere Cluster on Ubuntu 14.04
mesos安裝時碰到一下問題:
- /etc/mesos-master路徑下缺失hostname文件,導(dǎo)致訪問出錯問題
- 防火墻開放端口參考這篇文章: http://stackoverflow.com/questions/24729024/centos-7-open-firewall-port
- https://www.digitalocean.com/community/tutorials/how-to-set-up-a-firewall-using-firewalld-on-centos-7
-
安裝etcd、flannel和haproxy
master節(jié)點安裝etcd集群,slave節(jié)點安裝flannel和docker
在安裝docker時,遇到存儲問題,在docker systemd的配置文件中(/usr/lib/systemd/system/docker.service),發(fā)現(xiàn)/etc/sysconfig/docker這個配置文件,在其中添加一行變量 OPTIONS='--selinux-enabled -g /aifs01/docker'
為了保證docker 服務(wù)的發(fā)現(xiàn),需要安裝etcd、flannel和haproxy。具體做法如下:
docker service discovery
bamboo
一篇文章帶你了解Flannel
安裝etcd時,遇到no route to host錯誤,需要提前開放機器上的80端口,參考文章如下:
Security considerations
安裝flannel參考以下文章,且需要開放端口flannel uses UDP port 8285
Configuring flannel for Container Networking
配置flannel碰到如下問題,flannel默認/config后綴
配置文件如下
[root@mesos-slave1 log]# more /etc/sysconfig/flanneld
FLANNEL_ETCD=http://10.1.241.127:2379,http://10.1.241.128:2379,http://10.1.241.129:2379
FLANNEL_ETCD_KEY="/cluster-01/web
但是在用etcd發(fā)送節(jié)點信息時要這樣
etcdctl -C=http://10.1.241.127:2379 set /cluster-01/web/config '{"Network": "172.18.0.0/16", "Backend": { "Type": "udp","Port": 8472 } }'
-
部署測試程序,保證集群的正常運轉(zhuǎn)