Mesos 3 主 3 从(Docker-compose部署)
资源清单
依赖
ZooKeeper
集群,需要先部署ZooKeeper
主机 | IP |
---|---|
mesos节点1 | 10.0.0.1 |
mesos节点2 | 10.0.0.2 |
mesos节点3 | 10.0.0.3 |
软件 | 版本 |
---|---|
docker | 20.10.12 |
docker-compose | 1.23.1 |
mesos-master镜像 | mesosphere/mesos-master:1.7.1 |
mesos-slave镜像 | mesosphere/mesos-slave:1.7.1 |
服务 | 端口 |
---|---|
mesos-master | 5050 |
mesos-slave | 5051 |
一、Docker
安装
1. 使用国内 yum
源
# yum install -y yum-utils device-mapper-persistent-data lvm2
# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
2. 卸载旧版本的 docker
## 如果主机上已经有docker存在且不是想要安装的版本,需要先进行卸载。
# yum remove -y docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine \
container*
3. 安装 Docker20.10
版本
# yum -y install docker-ce-20.10.12-3.el7 docker-ce-cli-20.10.12-3.el7 vim
4. 设置镜像加速
# mkdir /etc/docker
# vi /etc/docker/daemon.json
{
"registry-mirrors": ["https://xxxxxxxxx.mirror.aliyuncs.com"]
}
5. 启动 docker
# systemctl start docker
# systemctl enable docker
# systemctl status docker
二、Docker-compose
安装
1. Docker-compose
安装
## github.com 可能访问超时,可以使用下面的获取下载下来后上传服务器即可
# curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# curl -k "https://dl.cactifans.com/zabbix_docker/docker-compose" -o /usr/bin/docker-compose
# chmod a+x /usr/bin/docker-compose
2. 查看 docker-compose
版本
# docker-compose version
三、Mesos
3主3从
安装
1. 详细的 docker-compose.yml
文件信息
其他
2个
主机节点修改对应的参数即可
version: '3'
services:
mesos-master1: # [ mesos-master2 | mesos-master3 ]
#image: mesoscloud/mesos-master:0.28.1-centos-7
image: mesosphere/mesos-master:1.7.1
restart: always
network_mode: "host"
hostname: mesos-master1 # [ mesos-master2 | mesos-master3 ]
container_name: mesos-master1 # [ mesos-master2 | mesos-master3 ]
volumes: # 挂载日志
- /data/mesos/master/log:/var/log/mesos
environment:
MESOS_HOSTNAME: 10.0.0.1 # [ 10.0.0.2 | 10.0.0.3 ]
MESOS_IP: 10.0.0.1 # [ 10.0.0.2 | 10.0.0.3 ]
MESOS_PORT: 5050
MESOS_LOG_DIR: /var/log/mesos
MESOS_QUORUM: 2
MESOS_REGISTRY: in_memory
MESOS_WORK_DIR: /var/lib/mesos
MESOS_ZK: zk://javaDev:edocyunjavaDev@zk1:2181,zk2:2181,zk3:2181/mesos
extra_hosts: # 设置容器 hosts
- "zk1:10.0.0.1"
- "zk2:10.0.0.2"
- "zk3:10.0.0.3"
mesos-slave1: # [ mesos-slave2 | mesos-slave3 ]
#image: mesoscloud/mesos-slave:0.28.1-centos-7
image: mesosphere/mesos-slave:1.7.1
restart: always
privileged: true
network_mode: "host"
hostname: mesos-slave1 # [ mesos-slave2 | mesos-slave3 ]
container_name: mesos-slave1 # [ mesos-slave2 | mesos-slave3 ]
volumes: # 挂载日志和数据
- /data/mesos/slave/log:/var/log/mesos
- /data/mesos/slave/tmp:/var/tmp/mesos
- /sys:/sys
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/local/bin/docker
environment:
MESOS_HOSTNAME: 10.0.0.1 # [ 10.0.0.2 | 10.0.0.3 ]
MESOS_IP: 10.0.0.1 # [ 10.0.0.2 | 10.0.0.3 ]
MESOS_PORT: 5051
MESOS_SWITCH_USER: 0
MESOS_CONTAINERIZERS: docker,mesos
MESOS_LOG_DIR: /var/log/mesos
MESOS_WORK_DIR: /var/tmp/mesos
MESOS_SYSTEMD_ENABLE_SUPPORT: "false"
MESOS_MASTER: zk://javaDev:edocyunjavaDev@zk1:2181,zk2:2181,zk3:2181/mesos
extra_hosts: # 设置容器 hosts
- "zk1:10.0.0.1"
- "zk2:10.0.0.2"
- "zk3:10.0.0.3"
2. 安装服务
3台主机
中执行以下命令
# mkdir /data/mesos -pv
# cd /data/mesos
# cat << EOF >> docker-compose.yml
version: '3'
services:
mesos-master1:
#image: mesoscloud/mesos-master:0.28.1-centos-7
image: mesosphere/mesos-master:1.7.1
restart: always
network_mode: "host"
hostname: mesos-master1
container_name: mesos-master1
volumes: # 挂载日志
- /data/mesos/master/log:/var/log/mesos
environment:
MESOS_HOSTNAME: 10.0.0.1
MESOS_IP: 10.0.0.1
MESOS_PORT: 5050
MESOS_LOG_DIR: /var/log/mesos
MESOS_QUORUM: 2
MESOS_REGISTRY: in_memory
MESOS_WORK_DIR: /var/lib/mesos
MESOS_ZK: zk://javaDev:edocyunjavaDev@zk1:2181,zk2:2181,zk3:2181/mesos
extra_hosts: # 设置容器 hosts
- "zk1:10.0.0.1"
- "zk2:10.0.0.2"
- "zk3:10.0.0.3"
mesos-slave1:
#image: mesoscloud/mesos-slave:0.28.1-centos-7
image: mesosphere/mesos-slave:1.7.1
restart: always
privileged: true
network_mode: "host"
hostname: mesos-slave1
container_name: mesos-slave1
volumes: # 挂载日志和数据
- /data/mesos/slave/log:/var/log/mesos
- /data/mesos/slave/tmp:/var/tmp/mesos
- /sys:/sys
- /var/run/docker.sock:/var/run/docker.sock
- /usr/bin/docker:/usr/local/bin/docker
environment:
MESOS_HOSTNAME: 10.0.0.1
MESOS_IP: 10.0.0.1
MESOS_PORT: 5051
MESOS_SWITCH_USER: 0
MESOS_CONTAINERIZERS: docker,mesos
MESOS_LOG_DIR: /var/log/mesos
MESOS_WORK_DIR: /var/tmp/mesos
MESOS_SYSTEMD_ENABLE_SUPPORT: "false"
MESOS_MASTER: zk://javaDev:edocyunjavaDev@zk1:2181,zk2:2181,zk3:2181/mesos
extra_hosts: # 设置容器 hosts
- "zk1:10.0.0.1"
- "zk2:10.0.0.2"
- "zk3:10.0.0.3"
EOF
# docker-compose up -d
3. 配置集群
Mesos
高可用设计中,引入了ZooKeeper
集群来辅助Leader的选举
访问任意节点url地址:http://10.0.0.1:5050/