实验环境
主机名 |
IP地址 |
运行服务 |
安装组件 |
mesos1 |
172.16.138.201 |
zookeeper |
mesos |
mesos2 |
172.16.138.202 |
zookeeper |
mesos |
mesos3 |
172.16.138.203 |
zookeeper |
mesos |
mesos4 |
172.16.138.204 |
mesos-slave |
mesos docker-engine |
mesos5 |
172.16.138.205 |
mesos-slave |
mesos docker-engine |
# setenforce 0
# sed -i '/^SELINUX=/c SELINUX=disabled'/etc/selinux/config
# systemctl stop firewalld
# systemctl disable firewalld
[root@mesos1 ~]# vi /etc/hosts
172.16.138.201 mesos1
172.16.138.202 mesos2
172.16.138.203 mesos3
172.16.138.204 mesos4
172.16.138.205 mesos5
mesos-0.28.2-2.0.27.centos701406.x86_64.rpm
mesosphere-zookeeper-3.4.6-0.1.20141204175332.centos7.x86_64.rpm
marathon-1.1.1-1.0.472.el7.x86_64.rpm
docker-1.8.2-10.el7.centos.x86_64.rpm
docker-selinux-1.8.2-10.el7.centos.x86_64.rpm
[root@mesos1 ~]# yum -y install mesosmarathon mesosphere-zookeeper
[root@mesos1 ~]# echo 1 >/var/lib/zookeeper/myid
几个ZooKeeper就按照顺序编辑,第一个是1,第二个是2,第三个是3,以此类推
[root@mesos1 ~]# vi/etc/zookeeper/conf/zoo.cfg
server.1=172.16.138.201:2888:3888
server.2=172.16.138.202:2888:3888
server.3=172.16.138.203:2888:3888
[root@mesos1 ~]# mkdir –p /opt/mesosphere/zookeeper/etc/zookeeper
[root@mesos1~]#ln -s /etc/zookeeper/conf/zoo.cfg/opt/mesosphere/zookeeper/etc/zookeeper/zoo.cfg
[root@mesos1 ~]# vi ~/.bash_profile
PATH=$PATH:$HOME/bin:/opt/mesosphere/zookeeper/bin
[root@mesos1 ~]# source ~/.bash_profile
[root@mesos1 ~]# systemctl start zookeeper
[root@mesos1 ~]# vi /etc/mesos/zk
zk://172.16.138.201:2181,172.16.138.202:2181,172.16.138.203:2181/mesos
[root@mesos1 ~]# vi /etc/mesos-master/ip
172.16.138.201
[root@mesos1 ~]# vi/etc/mesos-master/hostname
172.16.138.201
[root@mesos1 ~]# vi /etc/mesos-master/quorum
1
[root@mesos1 ~]# vi /etc/mesos-master/work_dir
/var/lib/mesos
[root@mesos1 ~]# systemctl startmesos-master
[root@mesos1 ~]# mkdir -p/etc/marathon/conf
[root@mesos1 ~]# cd /etc/marathon/conf
[root@mesos1 conf]# vi hostname
172.16.138.201
[root@mesos1 conf]# vi master
zk://172.16.138.201:2181,172.16.138.202:2181,172.16.138.203:2181/mesos
[root@mesos1 conf]# vi zk
zk://172.16.138.201:2181,172.16.138.202:2181,172.16.138.203:2181/marathon
[root@mesos1 conf]# systemctl startmarathon
将上述操作在所有mesos-master节点上执行。
至此mesos-master节点已配置完毕,可以通过浏览器查看WEB页面查看mesos及marathon。
mesos:http://172.16.138.201:5050
marathon:http://172.16.138.201:8080/ui/
[root@mesos2 ~]# yum -y install mesos docker
[root@mesos4 ~]# cd /etc/mesos-slave/
[root@mesos4 mesos-slave]# vi hostname
172.16.138.204
[root@mesos4 mesos-slave]# vi ip
172.16.138.204
[root@mesos4 mesos-slave]# vi containerizers
docker,mesos
[root@mesos4 mesos-slave]# vi executor_registration_timeout
15mins
[root@mesos4 mesos-slave]# vi attributes
rack_id:rack-1
[root@mesos4 mesos-slave]# vi /etc/mesos/zk
zk://172.16.138.201:2181,172.16.138.202:2181,172.16.138.203:2181/mesos
[root@mesos4 mesos-slave]# systemctl start mesos-slave
[root@mesos4 mesos-slave]# systemctlstart docker
到mesos管理端,去查看slave的注册情况。
创建容器有两种方式: WEB GUI / API
下面通过WEB GUI方式创建一个简单示例,演示创建应用容器的流程。
进入marathon管理控制台http://172.16.138.201:8080/ui
进入mesos管理控制台http://172.16.138.201:5050
[root@mesos1 ~]# echo ‘http_callback’>/etc/marathon/conf/event_subscriber
[root@mesos1 ~]# systemctl restart marathon