-
安裝前準(zhǔn)備
所有機(jī)器需要安裝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
需要注意的是筆者的運(yùn)行環(huán)境為centos7.1盗棵,在centos中默認(rèn)不會(huì)將新增用戶添加到文件/etc/sudoers中,需要在playbook中添加task來完成
參考文檔
ansible create a new user
-
關(guān)閉防火墻指定端口
有待完善卦溢,考慮采用配置iptables的方式來開放端口,參考一下幾個(gè)鏈接
How To Set Up a Basic Iptables Firewall on Centos 6
IPTables
Firewalld - How to Dynamically Manage Firewall in RHEL/CentOS 7.0
-
更改所有機(jī)器的hosts文件
為了便于服務(wù)器之間的溝通,以及后續(xù)軟件的正常使用,需要更改所有機(jī)器的hosts文件屈雄,依據(jù)一下規(guī)則
- master節(jié)點(diǎn)記錄所有機(jī)器的hostname和ip
- slave節(jié)點(diǎn)記錄master節(jié)點(diǎn)的信息和自己的信息
-
安裝并配置zookeeper集群
編寫ansible腳本,復(fù)制安裝文件到master節(jié)點(diǎn)官套,解壓,更改配置文件蚁孔,并啟動(dòng)奶赔,參考以下文檔,部署zookeeper集群
在安裝zookeeper杠氢、mesos站刑、marathon時(shí)需要對軟件進(jìn)行yum安裝,這時(shí)需要在task中添加sudo:yes屬性鼻百,另外需要更改ansible中的配置文件绞旅,將屬性ask-become-pass添加進(jìn)group中
ZooKeeper Administrator's Guide
-
安裝mesos dns
兩種方案
通過ansible復(fù)制安裝包到指定機(jī)器,并更改剩余機(jī)器的 /etc/resolv.conf文件
通過marathon進(jìn)行部署温艇,保證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安裝時(shí)碰到一下問題:
- /etc/mesos-master路徑下缺失hostname文件,導(dǎo)致訪問出錯(cuò)問題
- 防火墻開放端口參考這篇文章: 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é)點(diǎn)安裝etcd集群晃琳,slave節(jié)點(diǎn)安裝flannel和docker
在安裝docker時(shí),遇到存儲(chǔ)問題琐鲁,在docker systemd的配置文件中(/usr/lib/systemd/system/docker.service),發(fā)現(xiàn)/etc/sysconfig/docker這個(gè)配置文件卫旱,在其中添加一行變量 OPTIONS='--selinux-enabled -g /aifs01/docker'
為了保證docker 服務(wù)的發(fā)現(xiàn),需要安裝etcd围段、flannel和haproxy顾翼。具體做法如下:
docker service discovery
bamboo
一篇文章帶你了解Flannel
安裝etcd時(shí),遇到no route to host錯(cuò)誤奈泪,需要提前開放機(jī)器上的80端口适贸,參考文章如下:
Security considerations
安裝flannel參考以下文章,且需要開放端口flannel uses UDP port 8285
Configuring flannel for Container Networking
配置flannel碰到如下問題段磨,flannel默認(rèn)/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é)點(diǎn)信息時(shí)要這樣
etcdctl -C=http://10.1.241.127:2379 set /cluster-01/web/config '{"Network": "172.18.0.0/16", "Backend": { "Type": "udp","Port": 8472 } }'
-
部署測試程序取逾,保證集群的正常運(yùn)轉(zhuǎn)