您的位置:首页 > 其它

Mesos实践:基于MZM的PAAS的构建(4):环境搭建

2017-01-13 08:30 681 查看
为分布式微服务框架提供合适的PAAS平台,使用成熟的M(Mesos)Z(Zookeeper)M(Marathon)可以作为选择之一。本文将介绍一下如何在CentOS7下进行环境的搭建,同时将搭建的脚本放到了github上的Easypack项目中,使用这个脚本能够简化目前稍微繁琐的安装流程。



机器构成



6台机器构成:3主3从。详细信息如下:

项番类别hostnameIP需装软件
No.1Masterhost32192.168.32.32MESOS+MARATHON+ZOOKEEPER
No.2Masterhost33192.168.32.33MESOS+MARATHON+ZOOKEEPER
No.3Masterhost34192.168.32.34MESOS+MARATHON+ZOOKEEPER
No.4Slavehost42192.168.32.42MESOS
No.5Slavehost43192.168.32.43MESOS
No.6Slavehost44192.168.32.44MESOS

准备事项

对上述6台机器,作如下准备:

项番事项
No.1OS: CentOS7(1511即可) 最小安装即可
No.2关闭防火墙:systemctl stop firewalld && systemctl disable firewalld
No.3清空iptables规则:iptables -F

安装

Master节点安装

各Master节点作如下安装

项番详细
No.1rpm -Uvh http://repos.mesosphere.com/el/7/noarch/RPMS/mesosphere-el-repo-7-1.noarch.rpm
No.2yum install -y mesos
No.3yum install -y marathon
No.4yum install -y mesosphere-zookeeper

Slave节点安装

各Slave节点作如下安装

项番详细
No.1rpm -Uvh http://repos.mesosphere.com/el/7/noarch/RPMS/mesosphere-el-repo-7-1.noarch.rpm
No.2yum install -y mesos

设定Master节点

Mesos相关设定

设定/etc/hosts

需要将hostname和IP的mapping加入到hosts中,本文情况设定内容如下:

# Mesos Master
192.168.32.32 host32
192.168.32.33 host33
192.168.32.34 host34

# Mesos Slave
192.168.32.42 host42
192.168.32.43 host43
192.168.32.44 host44


设定Zookeeper

相关设定等详细信息在Zookeeper相关的介绍中已经说过,此处不再赘述。各机器的/etc/zookeeper/conf/zoo.cfg追加如下信息

[root@host32 log]# cat /etc/zookeeper/conf/zoo.cfg |tail -n3
server.1=192.168.32.32:2888:3888
server.2=192.168.32.33:2888:3888
server.3=192.168.32.34:2888:3888
[root@host32 log]#


/etc/mesos/zk

[root@host32 log]# cat /etc/mesos/zk
zk://192.168.32.32:2181,192.168.32.33:2181,192.168.32.34:2181/mesos
[root@host32 log]#


/etc/mesos-master/quorum

因为三台的机器,quorum为2,5台的话就是3了

[root@host32 log]# cat /etc/mesos-master/quorum
2
[root@host32 log]#


设定各机器唯一的ID和IP以及Hostname: 比如host32的Master1节点

[root@host32 log]# cat /var/lib/zookeeper/myid
1
[root@host32 log]# cat /etc/mesos-master/ip
192.168.32.32
[root@host32 log]# cat /etc/mesos-master/hostname
192.168.32.32
[root@host32 log]#


设定Marathon

/etc/marathon/conf/zk

[root@host32 log]# cat /etc/marathon/conf/zk
zk://192.168.32.32:2181,192.168.32.33:2181,192.168.32.34:2181/marathon
[root@host32 log]#


设定Slave节点

设定各机器IP以及Hostname: 比如host44的Slave3节点

[root@host44 ~]# cat /etc/mesos-slave/ip
192.168.32.44
[root@host44 ~]# cat /etc/mesos-slave/hostname
192.168.32.44
[root@host44 ~]#


/etc/mesos/zk

[root@host44 ~]# cat /etc/mesos/zk
zk://192.168.32.32:2181,192.168.32.33:2181,192.168.32.34:2181/mesos
[root@host44 ~]#


启动Master服务

各Master节点作如下操作,初期化服务设定以及启动服务

项番详细
No.1systemctl stop mesos-slave
No.2systemctl disable mesos-slave
No.3systemctl start zookeeper
No.4systemctl start marathon
No.6systemctl start mesos-master

启动Slave服务

各Slave节点作如下操作,初期化服务设定以及启动服务

项番详细
No.1systemctl stop mesos-master
No.2systemctl disable mesos-master
No.3systemctl enable mesos-slave
No.4systemctl start mesos-slave

Mesos启动确认

Home



Frameworks



Agents



Offers



Marathon启动确认

Applications



Deployments



Easypack

在搭建的过程中顺手把脚本写下来了放到了github上:https://github.com/liumiaocn/easypack/blob/master/mesos/easypack_mesos.sh

有需要的可以自行参照。

使用这个把上面的步骤进行简化,每台机器只需要INSTALL和INIT两个步骤。

使用方法

[root@host33 tmp]# sh easypack_mesos.sh INSTALL MASTER
Usage: easypack_mesos.sh ACTION TYPE NODE
ACTION: INSTALL|INIT|UNINSTALL|STATUS|START|STOP|RESTART
TYPE  : MASTER|SLAVE
NODE  : 1|2|3|ALL
[root@host33 tmp]#


Master节点

[root@host33 tmp]# sh easypack_mesos.sh INSTALL MASTER 2
## Intall Log file : /tmp/tmp_log_file.10340.log
## Install for Master Node:            :OK
## Config for Master Node: /etc/hosts  :OK
## Config   for Master Node:           :OK
[root@host33 tmp]#
[root@host33 tmp]# sh /tmp/easypack_mesos.sh INIT MASTER 1
## Intall Log file : /tmp/tmp_log_file.10753.log
## Init     for Master Node:           :OK
[root@host33 tmp]#


Slave节点

root@host43 ~]# sh /tmp/easypack_mesos.sh INSTALL SLAVE 2
## Intall Log file : /tmp/tmp_log_file.1751.log
## Install for Slave   Node:             OK
## Config   for Slave   Node:            OK
[root@host43 ~]# sh /tmp/easypack_mesos.sh INIT SLAVE 3
## Intall Log file : /tmp/tmp_log_file.2011.log
## Init     for Slave   Node:            OK
[root@host43 ~]#
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息