创建3台虚拟机
还是通过vagrant + virtualbox的方式来创建
源码文件夹
查看创建虚拟机的源码
# -*- mode: ruby -*-# vi: set ft=ruby :Vagrant.require_version ">= 1.6.0"boxes = [ { :name => "swarm-manager", :mem => "1024", :cpu => "1" }, { :name => "swarm-worker1", :mem => "1024", :cpu => "1" }, { :name => "swarm-worker2", :mem => "1024", :cpu => "1" } ] Vagrant.configure(2) do |config| config.vm.box = "centos/7" boxes.each do |opts| config.vm.define opts[:name] do |config| config.vm.hostname = opts[:name] config.vm.provider "vmware_fusion" do |v| v.vmx["memsize"] = opts[:mem] v.vmx["numvcpus"] = opts[:cpu] end config.vm.provider "virtualbox" do |v| v.customize ["modifyvm", :id, "--memory", opts[:mem]] v.customize ["modifyvm", :id, "--cpus", opts[:cpu]] end config.vm.network :private_network, type: "dhcp" end end config.vm.synced_folder "./labs", "/home/vagrant/labs" config.vm.provision "shell", privileged: true, path: "./setup.sh"end
用SecureCRT连接着3个虚拟机
查看每个虚拟机的ip地址
vagrant ssh swarm-manager#swarm-manager的ip是172.28.128.3ip a
vagrant ssh swarm-worker1#swarm-worker1的ip是172.28.128.4ip a
vagrant ssh swarm-worker2#swarm-worker2的ip是172.28.128.5ip a
创建docker-swarm集群
swarm-manager 建立manager
sudo docker swarm init --help sudo docker swarm init --advertise-addr=172.28.128.3
swarm-worker1 和 swam-worker2 连接manager
sudo service docker restart docker swarm join --token SWMTKN-1-1vafvfucsur6iqd6ba5i2njty6djvzxnhwefsmar4sivcg8isi-dgm1aigtcu1rtotfc8y43j17m 172.28.128.3:2377
image.png
swarm-manager 查看连接状态
docker node ls
PS:这样基本上通过docker-swarm完成集群管理。
作者:IT人故事会
链接:https://www.jianshu.com/p/9968e050af96
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦