私有云安装思考

2015-12-24  本文已影响265人  riverphoenix

所有机器需要安装python 2.7,go 1.5 以上版本

密码生成需要依据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

需要注意的是笔者的运行环境为centos7.1,在centos中默认不会将新增用户添加到文件/etc/sudoers中,需要在playbook中添加task来完成
参考文档
ansible create a new user

有待完善,考虑采用配置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文件,依据一下规则

编写ansible脚本,复制安装文件到master节点,解压,更改配置文件,并启动,参考以下文档,部署zookeeper集群
在安装zookeeper、mesos、marathon时需要对软件进行yum安装,这时需要在task中添加sudo:yes属性,另外需要更改ansible中的配置文件,将属性ask-become-pass添加进group中
ZooKeeper Administrator's Guide

两种方案

通过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文件,导致访问出错问题
- 防火墙开放端口参考这篇文章: 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

master节点安装etcd集群,slave节点安装flannel和docker
在安装docker时,遇到存储问题,在docker systemd的配置文件中(/usr/lib/systemd/system/docker.service),发现/etc/sysconfig/docker这个配置文件,在其中添加一行变量 OPTIONS='--selinux-enabled -g /aifs01/docker'
为了保证docker 服务的发现,需要安装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发送节点信息时要这样
etcdctl -C=http://10.1.241.127:2379 set /cluster-01/web/config '{"Network": "172.18.0.0/16", "Backend": { "Type": "udp","Port": 8472 } }'

上一篇 下一篇

猜你喜欢

热点阅读