Apache Mesos, Marathon, Zookeeper, Docker with Debian 8
- Category: 電腦相關
- Last Updated: Monday, 17 July 2017 17:57
- Published: Thursday, 01 June 2017 16:03
- Written by sam
Apache Mesos, Marathon, Zookeeper, Docker with Debian 8
mesos-m1 Mesos master 10.0.252.235
mesos-m2 Mesos master 10.0.252.236
mesos-m3 Mesos master 10.0.252.234
mesos-s1 Mesos slave 10.0.252.237
mesos-s2 Mesos slave 10.0.252.238
mesos-s3 Mesos slave 10.0.252.233
root@mesos-m3:~# apt-get -y update
root@mesos-m3:~# apt-key adv --keyserver keyserver.ubuntu.com --recv E56151BF
root@mesos-m3:~# cat /etc/apt/sources.list.d/mesosphere.list
deb http://repos.mesosphere.com/debian jessie main
deb http://repos.mesosphere.com/debian jessie-testing main
Modify hosts and hostname (each server
root@mesos-m3:~# cat /etc/hosts
127.0.0.1 localhost
10.0.252.233 mesos-s3
10.0.252.234 mesos-m3
10.0.252.235 mesos-m1
10.0.252.236 mesos-m2
10.0.252.237 mesos-s1
10.0.252.238 mesos-s2
root@mesos-m3:~# cat /etc/hostname
mesos-m3
Install mesos, zookeeper, marathon (on master and slave
root@mesos-m3:~# apt-get install mesos zookeeper marathon chronos
Config mesos (on master, replace your master ip
root@mesos-m3:~# cat /etc/mesos/zk
zk://10.0.252.235:2181,10.0.252.236:2181,10.0.252.234:2181/mesos
Config zookeeper (on master, replace id 1 to 255 and it's must be unique number for each your master server, in my case, mesos-m3 is 3, mesos-m2 is 2, mesos-m1 is 1.
root@mesos-m3:~# cat /etc/zookeeper/conf/myid
3
Config zookeeper (on master, replace your master ip
root@mesos-m3:~# cat /etc/zookeeper/conf/zoo.cfg
server.1=10.0.252.235:2888:3888
server.2=10.0.252.236:2888:3888
server.3=10.0.252.234:2888:3888
Config quorum (on master, the number should be over 50% of the master members, I have three master, so the number is 2.
root@mesos-m3:~# cat /etc/mesos-master/quorum
2
Config Hostname and IP (on master, echo your ip to master ip file
root@mesos-m3:~# echo 10.0.252.233 | tee /etc/mesos-master/ip
root@mesos-m3:~# cp /etc/mesos-master/ip /etc/mesos-master/hostname
Config marathon (on master
root@mesos-m3:~# mkdir -p /etc/marathon/conf
root@mesos-m3:~# cp /etc/mesos-master/hostname /etc/marathon/conf
root@mesos-m3:~# cp /etc/mesos/zk /etc/marathon/conf/master
root@mesos-m3:~# cp /etc/marathon/conf/master /etc/marathon/conf/zk
root@mesos-m3:~# cat /etc/marathon/conf/zk --- replace meos to marathon
zk://10.0.252.235:2181,10.0.252.236:2181,10.0.252.234:2181/marathon
Stop service (on master
root@mesos-m3:~# systemctl stop mesos-slave.service && systemctl disable mesos-slave.service
Restart service (on master
systemctl restart zookeeper.service && systemctl restart mesos-master.service && systemctl restart marathon.service
Open your browser with 5050 port
And browser with 8080 port (marathon
Stop service (on slave
root@mesos-m3:~# systemctl stop mesos-master.service &;& systemctl disable mesos-master.service && systemctl stop zookeeper.service && systemctl disable zookeeper.service && systemctl stop marathon.service && systemctl disable marathon.service
Config ip to mesos-slave ip file (on slave
root@mesos-m3:~# echo 10.0.252.237 | tee /etc/mesos-slave/ip
root@mesos-m3:~# cp /etc/mesos-slave/ip /etc/mesos-slave/hostname
Start service (on slave
root@mesos-m3:~# systemctl restart mesos-slave.service
Open browser to your master server and port 5050
Done
If you need java 8
And set up Docker (on slave, and please install docker first
root@mesos-s3:~# echo "docker,mesos" | tee /etc/mesos-slave/containerizers
Test it
root@mesos-m1:~# cat b
{
"id": "httpd",
"cpus": 0.2,
"mem": 32,
"disk": 0,
"instances": 1,
"constraints": [
[
"hostname",
"UNIQUE",
""
]
],
"container": {
"type": "DOCKER",
"docker": {
"image": "httpd",
"network": "BRIDGE",
"portMappings": [
{
"containerPort": 80,
"protocol": "tcp",
"name": "http"
}
]
}
}
}
root@mesos-m1:~# curl -X POST http://10.0.252.234:8080/v2/apps -d @b -H "Content-Type: application/json"
Check web
Check docker images
root@mesos-s1:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd latest e0645af13ada 3 weeks ago 177MB
root@mesos-s1:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
24821565fe7d httpd "httpd-foreground" 2 hours ago Up 2 hours 0.0.0.0:31941->80/tcp mesos-99071bed-6d56-40b2-8e6c-a9c7b50612cd-S1.f3136a57-d0df-4e83-a539-93e0f0a64d86
Scale it