准备4台服务器
部署 harbor 安装docker compose
curl -L https://github.com/docker/compose/releases/download/1.25.0/docker-compose-Linux-x86_64 -o /usr/local/bin/docker-compose # 等效上面的命令
chmod +x /usr/local/bin/docker-compose
安装harbor
wget https://github.com/goharbor/harbor/releases/download/v2.2.1/harbor-offline-installer-v2.2.1.tgz
tar -zxvf harbor-offline-installer-v2.2.1.tgz
配置harbor
cd /usr/local/harbor/ #进入到harbor目录
cp harbor.yml.tmpl harbor.yml
vim harbor.yml #编辑harbor的配置文件
#修改以下内容
hostname = 192.168.100.204 #修改harbor的启动ip,这里需要依据系统ip设置
port: 80 #harbor的端口,有两个端口,http协议(80)和https协议(443)
harbor_admin_password = harbor12345 #修改harbor的admin用户的密码
data_volume: /harbor/data #修改harbor存储位置
# https related config
#如果有安全密匙自行配置 没有就注
# https:
# # https port for harbor, default is 443
# port: 443
# # The path of cert and key files for nginx
# certificate: /your/certificate/path
# private_key: /your/private/key/path
安装harbor
./prepare
./install.sh
关闭防火墙
systemctl stop firewalld.service
设置docker
yum install -y yum-utils
sudo yum-config-manager \ --add-repo \http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io
sudo systemctl restart docker
启动了docker
设置docker国内镜像 (harbor 为私有仓库ip)
sudo mkdir -p /etc/docker
sudo vi /etc/docker/daemon.json
{
"registry-mirrors": ["http://hub-mirror.c.163.com"]
, "insecure-registries": [ "harborip"]
}
sudo systemctl daemon-reload
sudo systemctl restart docker
安装zookeeper(服务器2)
docker pull zookeeper:latest
docker run --privileged=true -d --name zookeeper --publish 2181:2181 -d zookeeper:latest
设置mesos master镜像(服务器1)
docker pull mesosphere/mesos-master:1.7.1
mesos master配置(服务器1)
docker run -d --net=host \
--hostname= 本机ip \
-e MESOS_PORT=5050 \
-e MESOS_ZK=zk://zookeeperip/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)/mesos/log/mesos:/var/log/mesos" \
-v "$(pwd)/mesos/tmp/mesos:/var/tmp/mesos" \
mesosphere/mesos-master:1.7.1 --no-hostname_lookup --ip=本机ip
http://mesosmaster:5050/#/ 查看 服务器状态
设置mesos slave1(服务器3)
docker pull mesosphere/mesos-master:1.7.1
docker run -d --net=host --privileged \
--hostname=本机ip \
-e MESOS_PORT=5051 \
-e MESOS_MASTER=zk://zookeeperip/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)/mesos/log/mesos:/var/log/mesos" \
-v "$(pwd)/mesos/tmp/mesos:/var/tmp/mesos" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /sys:/sys \
-v /usr/bin/docker:/usr/local/bin/docker \
mesosphere/mesos-slave:1.7.1 --no-systemd_enable_support \
--no-hostname_lookup --ip=本机ip
设置mesos slave2(服务器4)
docker pull mesosphere/mesos-master:1.7.1
docker run -d --net=host --privileged \
--hostname=本机ip \
-e MESOS_PORT=5051 \
-e MESOS_MASTER=zk://zookeeperip/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)/mesos/log/mesos:/var/log/mesos" \
-v "$(pwd)/mesos/tmp/mesos:/var/tmp/mesos" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /sys:/sys \
-v /usr/bin/docker:/usr/local/bin/docker \
mesosphere/mesos-slave:1.7.1 --no-systemd_enable_support \
--no-hostname_lookup --ip=本机ip
设置 marathon(服务器1)
docker run -d --net=host \
mesosphere/marathon:v1.7.230-plain-tasks \
--master zk://zookeeperip:2181/mesos \
--zk zk://zookeeperip:2181/marathon
设置marathon-lb(服务器2)
docker run -d -p 9090:9090 \
-e PORTS=9090 \
mesosphere/marathon-lb:v1.12.3 sse \
--group external \
--marathon http://marathonip:8080
方法二
{
"id": "/marathon-lb",
"cmd": "apt-get install curl -y && /marathon-lb/run sse --marathon http://marathonip:8080 --group external",
"cpus": 1,
"mem": 128,
"disk": 0,
"instances": 1,
"constraints": [
[
"hostname",
"LIKE",
"指定主机ip"
]
],
"acceptedResourceRoles": [
"*"
],
"container": {
"type": "DOCKER",
"docker": {
"forcePullImage": false,
"image": "docker.io/mesosphere/marathon-lb",
"parameters": [],
"privileged": true
},
"volumes": []
},
"portDefinitions": [
{
"port": 10001,
"name": "default",
"protocol": "tcp"
}
]
}
http://marathon-lb:9090/haproxy?stats 应用分组状态
可能出现问题marathon 部署应用bridge 网络报错
mesos-slave重启docker
其他工具性命令
1.启动docker,命令:systemctl start docker
2.验证docker是否启动成功,命令:dockers version
3.重启docker,命令:systemctl restart docker
4.关闭docker,命令:systemctl stop docker END
安装
yum -y install vim*
启动所有
docker start $(docker ps -a | awk '{ print $1}' | tail -n +2)
所有停止
docker stop $(docker ps -q)
删除 所有
docker rm $(docker ps -aq)
防火墙
firewall-cmd --zone=public --add-port=5050/tcp --permanent
firewall-cmd --reload