Centos 7部署docker
master安装:
安装zookeeper
1 yum install java-1.8.0-openjdk java-1.8.0-openjdk-headless 2 rpm -i packages/mesosphere-zookeeper-3.4.6-0.1.20141204175332.centos7.x86_64.rpm
安装mesos和marathon
1 yum install subversion cyrus-sasl-md5 2 rpm -i mesos-0.28.0-2.0.16.centos701406.x86_64.rpm 3 rpm -i packages/marathon-1.1.1-1.0.472.el7.x86_64.rpm
配置zookeeper
/etc/zookeeper/conf/zoo.cfg 添加如下配置:
server.1=1.1.1.1:2888:3888 server.2=2.2.2.2:2888:3888 server.3=3.3.3.3:2888:3888
/var/lib/zookeeper/myid配置为1,2,3中的一个(根据自己的ip在zoo.cfg中的顺序,如果是server.1,则设置为1)
启动zookeeper服务
1 systemctl enable zookeeper 2 systemctl start zookeeper
Pay attention in particular to the Maintenance section which contains important information about disk space usage and cleanup.
配置mesos-master
1 echo "zk://1.1.1.1:2181,2.2.2.2:2181,3.3.3.3:2181/mesos" > /etc/mesos/zk 2 echo "2" > /etc/mesos-master/quorum 3 echo $myip | tee /etc/mesos-master/ip 4 cp /etc/mesos-master/ip /etc/mesos-master/hostname
配置marathon
1 mkdir -p /etc/marathon/conf 2 cp /etc/mesos-master/hostname /etc/marathon/conf 3 cp /etc/mesos/zk /etc/marathon/conf/master 4 echo "zk://1.1.1.1:2181,2.2.2.2:2181,3.3.3.3:2181/marathon" > /etc/marathon/conf/zk 5 set task_launch_timeout to 30 minites 6 echo "1800000" > /etc/marathon/conf/task_launch_timeout
rsyslog配置
创建/etc/rsyslog.d/mesos.conf,内容如下:
if $programname == 'marathon' then { action(type="omfile" file="/var/log/mesos/marathon.log") } if $programname == 'chronos' then { action(type="omfile" file="/var/log/mesos/chronos.log") } if $programname == 'mesos-master' then { action(type="omfile" file="/var/log/mesos/mesos-master.log") } if $programname == 'mesos-slave' then { action(type="omfile" file="/var/log/mesos/mesos-slave.log")}
重启rsyslog服务
1 service rsyslog restart
禁用mesos-slave服务,启动mesos-master、marathon服务
1 systemctl disable mesos-slave 2 systemctl enable mesos-master 3 systemctl start mesos-master 4 systemctl enable marathon 5 systemctl start marathon
slave安装:
安装docker
1 yum install docker
如果用户购买了数据盘,配置docker的存储驱动
1 pvcreate /dev/vdc 2 vgcreate docker-vg /dev/vdc 3 lvcreate --wipesignatures y -n data docker-vg -l 95%VG 4 lvcreate --wipesignatures y -n metadata docker-vg -l 5%VG
配置/etc/sysconfig/docker-storage
DOCKER_STORAGE_OPTIONS= -s devicemapper --storage-opt dm.datadev=/dev/docker-vg/data --storage-opt dm.metadatadev=/dev/docker-vg/metadata
如果没有数据盘,/etc/sysconfig/docker-storage配置为:
DOCKER_STORAGE_OPTIONS= --storage-opt dm.no_warn_on_loop_devices=true
启动docker服务
1 systemctl enable docker 2 service docker start
安装mesos
下载最新版本mesos:http://open.mesosphere.com/downloads/mesos/
1 wget http://repos.mesosphere.com/el/7/x86_64/RPMS/mesos-0.28.0-2.0.16.centos701406.x86_64.rpm
安装依赖
1 yum install subversion cyrus-sasl-md5 2 rpm -i mesos-0.28.0-2.0.16.centos701406.x86_64.rpm
禁用mesos-master服务
1 systemctl stop mesos-master.service 2 systemctl disable mesos-master.service
日志配置
创建/etc/rsyslog.d/mesos.conf,内容如下:
if $programname == 'marathon' then { action(type="omfile" file="/var/log/mesos/marathon.log") } if $programname == 'chronos' then { action(type="omfile" file="/var/log/mesos/chronos.log") } if $programname == 'mesos-master' then { action(type="omfile" file="/var/log/mesos/mesos-master.log") } if $programname == 'mesos-slave' then { action(type="omfile" file="/var/log/mesos/mesos-slave.log")}
重启syslog服务
1 service rsyslog restart
配置并启动mesos-slave服务
1 ipaddr=`hostname -I | awk '{print $1}'` 2 echo $ipaddr | tee /etc/mesos-slave/ip 3 cp /etc/mesos-slave/ip /etc/mesos-slave/hostname 4 echo "zk://$MASTER1_IP:2181,$MASTER2_IP:2181,$MASTER3_IP:2181/mesos" | tee /etc/mesos/zk 5 echo 'docker,mesos' > /etc/mesos-slave/containerizers 6 echo '20mins' > /etc/mesos-slave/executor_registration_timeout 7 systemctl enable mesos-slave 8 service mesos-slave start