1:规划(5master+3slave)
master:
10.64.5.184 ---master1
10.64.5.185 ---master2
10.64.5.186 ---master3
10.64.5.187 ---master4
10.64.5.188 ---master5
slave:
10.64.5.170 ---slave1
10.64.5.172 ---slave2
10.64.5.167 ---slave3
2:配置master节点
(1)关闭防火墙
master1 master2 master3 master4 master5
#systemctl stop firewalld && systemctl disable firewalld
(2)添加mesos的yum源
master1 master2 master3 master4 master5
#sudo rpm -Uvh http://repos.mesosphere.io/el/7/noarch/RPMS/mesosphere-el-repo-7-1.noarch.rpm
(3)安装mesos,marathon,zookeeper
master1 master2 master3 master4 master5
#yum -y install mesos marathon mesosphere-zookeeper
(4)配置zookeeper
#设置文件[/var/lib/zookeeper/myid]为当前mesos master节点的id,id必须为1-255之中的整数,例如:1
master1
#echo 1 > /var/lib/zookeeper/myid
master2
#echo 2 > /var/lib/zookeeper/myid
master3
#echo 3 > /var/lib/zookeeper/myid
master4
#echo 4 > /var/lib/zookeeper/myid
master5
#echo 5 > /var/lib/zookeeper/myid
#master_node_id为master节点id同该节点[/var/lib/zookeeper/myid]文件的配置,master_node_ip为master节点的ip地址:server.$master_node_id=$master_node_ip:2888:3888
其中第一个端口2888用来集群成员的信息交换,第二个端口3888是在leader挂掉时专门用来进行选举leader所用。
master1 master2 master3 master4 master5
#vim /etc/zookeeper/conf/zoo.cfg 结尾添加内容 server.1=10.64.5.184:2888:3888 server.2=10.64.5.185:2888:3888 server.3=10.64.5.186:2888:3888 server.4=10.64.5.187:2888:3888 server.5=10.64.5.188:2888:3888
#vim /etc/mesos/zk 完全替换原来内容: zk://10.64.5.184:2181,10.64.5.185:2181,10.64.5.186:2181,10.64.5.187:2181,10.64.5.188:2181 /mesos
#设置文件[/etc/mesos-master/quorum]内容为一个大于(master节点数除以2)的整数。
#echo 3 >/etc/mesos-master/quorum 完全替换原来内容: 3
(5)配置mesos和marathon
#主机名和ip要在hosts中写入,不能全部使用localhost,否则会出现slave不能识别,以及marathon任务下发不正常等现象。
master1
# mkdir -p /etc/marathon/conf # echo 10.64.5.184 > /etc/mesos-master/hostname # echo 10.64.5.184 > /etc/marathon/conf/hostname #hostnamectl --static set-hostname master-1.com #echo "10.64.5.184 master-1 master-1.com" >/etc/hosts
master2
# mkdir -p /etc/marathon/conf # echo 10.64.5.185 > /etc/mesos-master/hostname # echo 10.64.5.185 > /etc/marathon/conf/hostname #hostnamectl --static set-hostname master-2.com #echo "10.64.5.185 master-2 master-2.com" >/etc/hosts
master3
# mkdir -p /etc/marathon/conf # echo 10.64.5.186 > /etc/mesos-master/hostname # echo 10.64.5.186> /etc/marathon/conf/hostname #hostnamectl --static set-hostname master-3.com #echo "10.64.5.186 master-3 master-3.com" >/etc/hosts
master4
# mkdir -p /etc/marathon/conf # echo 10.64.5.187 > /etc/mesos-master/hostname # echo 10.64.5.187 > /etc/marathon/conf/hostname #hostnamectl --static set-hostname master-4.com #echo "10.64.5.187 master-4 master-4.com" >/etc/hosts
master5
# mkdir -p /etc/marathon/conf # echo 10.64.5.188 > /etc/mesos-master/hostname # echo 10.64.5.188 > /etc/marathon/conf/hostname #hostnamectl --static set-hostname master-5.com #echo "10.64.5.188 master-5 master-5.com" >/etc/hosts
master1 master2 master3 master4 master5
# cp /etc/mesos/zk /etc/marathon/conf/master # cp /etc/mesos/zk /etc/marathon/conf/zk # sed -i 's|mesos|marathon|g' /etc/marathon/conf/zk
(6)启动mesos,marathon,zookeeper
master1 master2 master3 master4 master5
# systemctl start zookeeper && systemctl start mesos-master && systemctl start marathon # systemctl disable mesos-slave
(7)检查配置
#配置过程中出错,为了方便检查对比各master配置,直接执行如下命令。
cat /var/lib/zookeeper/myid && \ tail -6 /etc/zookeeper/conf/zoo.cfg && \ cat /etc/mesos/zk && cat /etc/mesos-master/quorum && \ cat /etc/mesos-master/hostname&& cat /etc/marathon/conf/hostname&& \ cat /etc/marathon/conf/master&&cat /etc/marathon/conf/zk
还可以创建 /etc/mesos-master/cluster 文件,写入集群的别名。
2:配置slave节点
(1)关闭防火墙
slave1 slave2 slave3
#systemctl stop firewalld && systemctl disable firewalld
(2)添加mesos的yum源
slave1 slave2 slave3
#sudo rpm -Uvh http://repos.mesosphere.io/el/7/noarch/RPMS/mesosphere-el-repo-7-1.noarch.rpm
(3)安装mesos,marathon,zookeeper
slave1 slave2 slave3
#yum -y install mesos
(4)配置master信息
slave1
#echo 10.64.5.167 > /etc/mesos-slave/hostname #hostnamectl --static set-hostname slave-1.com #echo "10.64.5.167 slave-1 slave-1.com" >/etc/hosts
slave2
#echo 10.64.5.170 > /etc/mesos-slave/hostname #hostnamectl --static set-hostname slave-2.com #echo "10.64.5.170 slave-2 slave-2.com " >/etc/hosts
slave3
#echo 10.64.5.172 > /etc/mesos-slave/hostname #hostnamectl --static set-hostname slave-1.com #echo "10.64.5.172 slave-3 slave-3.com " >/etc/hosts
slave1 slave2 slave3
#vi /etc/mesos/zk 增加: zk://10.64.5.184:2181,10.64.5.185:2181,10.64.5.186:2181,10.64.5.187:2181,10.64.5.188:2181/mesos
(5)启动slave
#systemctl start mesos-slave && systemctl enable mesos-slave #systemctl disable mesos-master
3:访问web管理页面
访问mesos的管理页面。master_ip:5050
#master_ip是这5个master中的任意一个就行,经过zookeeper选主喉,会自动跳到了leader的页面,如图mesos的leader为187。
在Frameworks中已经能够识别marathon,此时marathon的leader为10.64.5.186.
#mesos和marathon都是有zookeeper来选举leader,但是选主过程彼此独立,就是mesos的leader为187,但是marathon的leader为186(如图)。
已经能够识别三个slave。
访问marathon的管理页面。master_ip:8080