Centos 7部署docker

时间:2021-10-17 10:59:44

master安装:

安装zookeeper

 yum install java-1.8.-openjdk java-1.8.-openjdk-headless
rpm -i packages/mesosphere-zookeeper-3.4.-0.1..centos7.x86_64.rpm

安装mesos和marathon

 yum install subversion cyrus-sasl-md5
rpm -i mesos-0.28.-2.0..centos701406.x86_64.rpm
rpm -i packages/marathon-1.1.-1.0..el7.x86_64.rpm

配置zookeeper

/etc/zookeeper/conf/zoo.cfg 添加如下配置:
server.=1.1.1.1::
server.=2.2.2.2::
server.=3.3.3.3::

/var/lib/zookeeper/myid配置为1,2,3中的一个(根据自己的ip在zoo.cfg中的顺序,如果是server.1,则设置为1)

启动zookeeper服务

 systemctl enable zookeeper
systemctl start zookeeper
Pay attention in particular to the Maintenance section which contains important information about disk space usage and cleanup.

配置mesos-master

 echo "zk://1.1.1.1:2181,2.2.2.2:2181,3.3.3.3:2181/mesos" > /etc/mesos/zk
echo "" > /etc/mesos-master/quorum
echo $myip | tee /etc/mesos-master/ip
cp /etc/mesos-master/ip /etc/mesos-master/hostname

配置marathon

 mkdir -p /etc/marathon/conf
cp /etc/mesos-master/hostname /etc/marathon/conf
cp /etc/mesos/zk /etc/marathon/conf/master
echo "zk://1.1.1.1:2181,2.2.2.2:2181,3.3.3.3:2181/marathon" > /etc/marathon/conf/zk
set task_launch_timeout to minites
echo "" > /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服务
 service rsyslog restart

禁用mesos-slave服务,启动mesos-master、marathon服务

 systemctl disable mesos-slave
systemctl enable mesos-master
systemctl start mesos-master
systemctl enable marathon
systemctl start marathon

slave安装:

安装docker

 yum install docker
如果用户购买了数据盘,配置docker的存储驱动 
 pvcreate /dev/vdc
vgcreate docker-vg /dev/vdc
lvcreate --wipesignatures y -n data docker-vg -l %VG
lvcreate --wipesignatures y -n metadata docker-vg -l %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服务

 systemctl enable docker
service docker start

安装mesos

 wget http://repos.mesosphere.com/el/7/x86_64/RPMS/mesos-0.28.0-2.0.16.centos701406.x86_64.rpm
安装依赖
 yum install subversion cyrus-sasl-md5
rpm -i mesos-0.28.-2.0..centos701406.x86_64.rpm

禁用mesos-master服务

 systemctl stop mesos-master.service
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服务
 service rsyslog restart 

配置并启动mesos-slave服务

 ipaddr=`hostname -I | awk '{print $1}'`
echo $ipaddr | tee /etc/mesos-slave/ip
cp /etc/mesos-slave/ip /etc/mesos-slave/hostname
echo "zk://$MASTER1_IP:2181,$MASTER2_IP:2181,$MASTER3_IP:2181/mesos" | tee /etc/mesos/zk
echo 'docker,mesos' > /etc/mesos-slave/containerizers
echo '20mins' > /etc/mesos-slave/executor_registration_timeout
systemctl enable mesos-slave
service mesos-slave start