参考文章:
http://www.xuliangwei.com/xubusi/422.html
https://open.mesosphere.com/getting-started/install/#master-setup
https://www.digitalocean.com/community/tutorials/how-to-configure-a-production-ready-mesosphere-cluster-on-ubuntu-14-04
安装环境:
3台server
192.168.100.10 mesos-master Mesos-master slave、Zookeeper、Marathon、(marathon-lb)
192.168.100.20 mesos-node1 Mesos-master slave、Zookeeper、Marathon
192.168.100.30 mesos-node2 Mesos-master slave、Zookeeper、Marathon
hosts:
192.168.100.10 mesos-master
192.168.100.20 mesos-node1
192.168.100.30 mesos-node2
1、yum安装软件包
在3台服务上分别操作:
rpm -Uvh http://repos.mesosphere.io/el/7/noarch/RPMS/mesosphere-el-repo-7-1.noarch.rpm
yum -y install mesos marathon
yum -y install mesosphere-zookeeper
2、添加myid文件
分别在3台机器上操作
vim /var/lib/zookeeper/myid
分别编辑内容,分别添加上 1 ,2,3进去
[[email protected] ~]# cat /var/lib/zookeeper/myid
1
[[email protected] ~]# cat /var/lib/zookeeper/myid
2
[[email protected] ~]# cat /var/lib/zookeeper/myid
3
3、分别编辑3台服务器的 /etc/zookeeper/conf/zoo.cfg文件
添加:
server.1=192.168.100.10:2888:3888
server.2=192.168.100.20:2888:3888
server.3=192.168.100.30:2888:3888
4、分别在3台机器上重启 zookeeper服务
systemctl restart zookeeper
5、检测zookeeper启动状态
ps -ef|grep zookeeper
[[email protected] ~]# ps -ef|grep zookeeper
root 2674 1 7 18:39 ? 00:00:00 java -Dzookeeper.log.dir=. -Dzookeeper.root.logger=INFO,CONSOLE -cp /opt/mesosphere/zookeeper/bin/../build/classes:/opt/mesosphere/zookeeper/bin/../build/lib/*.jar:/opt/mesosphere/zookeeper/bin/../lib/slf4j-log4j12-1.6.1.jar:/opt/mesosphere/zookeeper/bin/../lib/slf4j-api-1.6.1.jar:/opt/mesosphere/zookeeper/bin/../lib/netty-3.7.0.Final.jar:/opt/mesosphere/zookeeper/bin/../lib/log4j-1.2.16.jar:/opt/mesosphere/zookeeper/bin/../lib/jline-0.9.94.jar:/opt/mesosphere/zookeeper/bin/../zookeeper-3.4.6.jar:/opt/mesosphere/zookeeper/bin/../src/java/lib/*.jar:/etc/zookeeper/conf: -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /etc/zookeeper/conf/zoo.cfg
root 2721 2255 0 18:39 pts/0 00:00:00 grep --color=auto zookeeper
6、分别编辑3台服务器的/etc/mesos/zk配置文件,添加
zk://192.168.100.10:2181,192.168.100.20:2181,192.168.100.30:2181/mesos
7、 分别编辑3台服务器,修改判断值 /etc/mesos-master/quorum
添加内容为: 2
说明:
如果3台主mesos,这里的值就是取节点的数量除以2再加1,取整数部分。如果是3台节点,这里的值就是2;如果是4台主mesos,这里的值就是3.
编辑mesos-master:
[[email protected] mesos-master]# pwd
/etc/mesos-master
[[email protected] mesos-master]# cat hostname
192.168.100.10 (其他2台为20,30)
[[email protected] mesos-master]# cat ip
192.168.100.10 (其他2台为20,30)
[[email protected] mesos-master]# cat quorum
2
编辑 mesos-slave:
[[email protected] mesos-slave]# pwd
/etc/mesos-slave
[[email protected] mesos-slave]# cat hostname
192.168.100.30
[[email protected] mesos-slave]# cat ip
192.168.100.30
8、分别编辑3台服务器的marathon,修改配置如下:
mkdir -p /etc/marathon/conf
cd /etc/marathon/conf
vim hostname
添加:
192.168.100.10 (其他2台为20,30)
最后重启各个服务:
systemctl restart mesos-master
systemctl restart zookeeper
systemctl restart marathon.service
systemctl restart mesos-slave
设置开机自启动:
systemctl enable mesos-master
systemctl enable zookeeper
systemctl enable marathon.service
systemctl enable mesos-slave
访问看效果:
这里如果客户端显示不了的话,可以尝试清理mesos日志:
清理mesos:rm -rf /var/lib/mesos/*
9、配置marathon,使其可以创建docker容器:
在这3台服务上安装docker服务
yum install -y docker
systemctl start docker
systemctl enable docker
安装镜像: 例如nginx
在所有mesos-slave上增加配置参数,并重启
# echo ‘docker,mesos‘ | tee /etc/mesos-slave/containerizers
# systemctl restart mesos-slave #重启Mesos-slave
之后可以在marathon的页面进行创建docker容器: