准备:两台主机安装docker并运行,关闭防火墙 1.主节点创建swarm集群 1.1初始化swarm集群 [root@localhost centos-jdk]# docker swarm init --advertise-addr 192.168.100.10 2.配置时间同步 两个节点都安装chrony yum install chrony -y 两个节点都注释文件里以server开头的行 sed -i 's/^server/#&/' /etc/chrony.conf 主节点修改/etc/chrony.conf
[root@localhost centos-jdk]# cat >> /etc/chrony.conf <<EOF > local stratum 10 > server master iburst > allow all > EOF从节点修改/etc/chrony.conf
[root@localhost ~]# echo server 192.168.100.10 iburst >> /etc/chrony.conf两个节点都重启chrony systemctl restart chronyd 从节点查看结果
[root@localhost ~]# chronyc sources 210 Number of sources = 1 MS Name/IP address Stratum Poll Reach LastRx Last sample =============================================================================== ^* 192.168.100.10 10 6 17 1 -16us[ -99us] +/- 195us3.从节点加入swarm集群 2.1从节点加入swarm集群 [root@localhost ~]# docker swarm join --token SWMTKN-1-174bac84fmh6qiozsduurp0dpdh9qh800yudhg37xb2mk6o9au-cs45v74iermjwdyl8pps8j3lb 192.168.100.10:2377 2.2验证swarm集群
[root@localhost centos-jdk]# docker node list ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ENGINE VERSION fo069pvqt918d8ql8mxe3jdvr * localhost.localdomain Ready Active Leader 18.09.6 zjl79qg7g1a45jpxplzkzmptf localhost.localdomain Ready Active 18.09.63.部署portainer 我们有两种方式运行portainer,一种是容器(container)的方式,一种是服务(service)的方式,这里采用容器的方式运行portainer 3.1运行portainer容器 3.1.1标记portainer [root@localhost centos-jdk]# docker tag 4cda95efb0e4 portainer:latest 3.1.2运行portainer容器 [root@localhost centos-jdk]# docker run -itd -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock portainer:latest 3.1.1验证结果 在浏览器输入网址http://192.168.100.10:9000/, 然后创建用户和密码 选择local 进入管理界面 标签:容器,swarm,chrony,编排,portainer,docker,root,localhost From: https://www.cnblogs.com/xiaobaige/p/16951721.html