作者:692-LCP_207 | 来源:互联网 | 2023-07-09 20:40
使用Docker部署Mesos
部署环境
宿主机: macOS Sierra 10.12.1
VirtualBox: Version 5.1.8 r111374 (Qt5.5.1)
Vagrant: 1.8.7
Vagrant Box: CentOS/7
虚拟机启动环境
Host
IP
作用
mesos-01
172.20.201.101
master,slave1,marathon
mesos-02
172.20.201.102
slave2
mesos-03
172.20.201.103
slave3
Vagrantfile内容如下:
$num_instances = 3
$vm_gui = false
$vm_memory = 1024
$vm_cpus = 1
$instance_name_prefix = "mesos"
$vb_cpuexecutioncap = 100
def vm_gui
$vb_gui .nil ? ? $vm_gui : $vb_gui
end
def vm_memory
$vb_memory .nil ? ? $vm_memory : $vb_memory
end
def vm_cpus
$vb_cpus .nil ? ? $vm_cpus : $vb_cpus
end
Vagrant .configure("2" ) do |config|
config.vm.box = "centos/7"
(1 ..$num_instances ).each do |i|
config.vm.define vm_name = "%s-%02d" % [$instance_name_prefix , i] do |config|
config.vm.hostname = vm_name
config.vm.provider :virtualbox do |vb|
vb.gui = vm_gui
vb.memory = vm_memory
vb.cpus = vm_cpus
vb.customize ["modifyvm" , :id , "--cpuexecutioncap" , "#{$vb_cpuexecutioncap } " ]
end
ip = "172.20.201.#{i+100 } "
config.vm.network :private_network , ip: ip
end
config.vm.provision "shell" , inline: <<-SHELL
curl -s https: //get.docker.com/ | sudo sh
SHELL
end
end
启动虚拟机
vagrant up
执行上述命令后,虚拟机在启动之后将自动安装最新版本Docker
ZooKeeper启动
只是为了测试,启单节点的ZooKeeper
docker run --name zookeeper
--restart always
-d
-p 2181 : 2181
zookeeper
master安装
# 登录mesos-01:
vagrant ssh mesos-01
# 启动Docker
sudo systemctl enable docker && systemctl restart docker
启动Master
docker run -d --net=host
--name mesos_master
-e MESOS_PORT =5050
-e MESOS_ZK =zk: //172.20.201.101:2181/mesos
-e MESOS_QUORUM =1
-e MESOS_REGISTRY =in_memory
-e MESOS_LOG_DIR =/var/log /mesos
-e MESOS_WORK_DIR =/var/tmp /mesos
-v "$(pwd)/log/mesos:/var/log/mesos"
-v "$(pwd)/tmp/mesos:/var/tmp/mesos"
mesosphere/mesos-master:1.1.0-2.0.107.ubuntu1404
--ip=172.20 .201.101
--advertise_ip=172.20 .201.101
启动slave
docker run -d --net=host --privileged
--name mesos_slave
-e MESOS_PORT =5051
-e MESOS_MASTER =zk: //172.20.201.101:2181/mesos
-e MESOS_SWITCH_USER =0
-e MESOS_CONTAINERIZERS =docker,mesos
-e MESOS_LOG_DIR =/var/log /mesos
-e MESOS_WORK_DIR =/var/tmp /mesos
-v "$(pwd)/log/mesos:/var/log/mesos"
-v "$(pwd)/tmp/mesos:/var/tmp/mesos"
-v /var/run/docker.sock: /var/run/docker.sock
-v /sys/fs/cgroup: /cgroup
-v /sys: /sys
-v /usr/bin/docker: /usr/local/bin/docker
mesosphere/mesos-slave:1.1.0-2.0.107.ubuntu1404
--ip=172.20 .201.101
--launcher=posix
启动marathon
docker run -d --net=host --privileged
--name mesos_marathon
mesosphere/marathon:latest
--master zk: //172.20.201.101:2181/mesos
--zk zk: //172.20.201.101:2181/marathon
--http_port 8080
--http_address 172.20 .201.101
安装其他节点
docker run -d --net=host --privileged
--name mesos_slave
-e MESOS_PORT =5051
-e MESOS_MASTER =zk: //172.20.201.101:2181/mesos
-e MESOS_SWITCH_USER =0
-e MESOS_CONTAINERIZERS =docker,mesos
-e MESOS_LOG_DIR =/var/log /mesos
-e MESOS_WORK_DIR =/var/tmp /mesos
-v "$(pwd)/log/mesos:/var/log/mesos"
-v "$(pwd)/tmp/mesos:/var/tmp/mesos"
-v /var/run/docker.sock: /var/run/docker.sock
-v /sys/fs/cgroup: /cgroup
-v /sys: /sys
-v /usr/bin/docker: /usr/local/bin/docker
mesosphere/mesos-slave:1.1.0-2.0.107.ubuntu1404
--ip=[其他节点IP ]
--launcher=posix
检查
安装完成后,打开地址http://172.20.201.101:5050,打开如下页面:
打开marathon地址http://172.20.201.101:8080,显示如下: