企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
[TOC] ## 设置 host ``` # cat /etc/hosts 127.0.0.1 localhost 192.168.0.110 swarm01 192.168.0.111 swarm02 192.168.0.229 swarm03 ``` ## 在管理节点配置 ssh ``` # ssh-keygen -t rsa -P '' # ssh-copy-id -i .ssh/id_rsa.pub root@192.168.0.111 # ssh-copy-id -i .ssh/id_rsa.pub root@192.168.0.229 ``` 把管理节点生成的 ssh 发送到其他节点上 ## 安装 ansible 方便批量修改 ``` # yum -y install ansible # cat /etc/ansible/hosts | grep -v ^# | grep -v ^$ [node] 192.168.0.111 192.168.0.229 # sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config # ansible node -m copy -a 'src=/etc/selinux/config dest=/etc/selinux/" # 把修改好的文件发送到所有节点 # systemctl stop firewalld # 以下操作关闭防火墙, 也可根据实际需要开放端口 # systemctl disable firewalld # ansible node -a 'systemctl stop firewalld' # ansible node -a 'systemctl disable firewalld' ``` ## 创建 swarm 集群 ``` # docker swarm init --listen-addr 0.0.0.0 Swarm initialized: current node (a1tno675d14sm6bqlc512vf10) is now a manager. To add a worker to this swarm, run the following command: docker swarm join --token SWMTKN-1-3sp9uxzokgr252u1jauoowv74930s7f8f5tsmm5mlk5oim359e-dk52k5uul50w49gbq4j1y7zzb 192.168.139.175:2377 To add a manager to this swarm, run 'docker swarm join-token manager' and follow the instructions. ``` ### 批量加入其他节点 ``` ansible node -a "docker swarm join --token SWMTKN-1-5h4qmjjt6kcioxzth5n4alf4dxmdz64a4m0f0ldqpl5lzzoct3-7jq900h8mg1recydraj91qgts 192.168.0.110:2377" ``` ### 查看节点 ``` # docker node ls ``` 之后与 docker-machine 的操作一致