Docker Swanm闆嗙兢閰嶇疆

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Docker Swanm闆嗙兢閰嶇疆相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/ISE' title='ISE'>ISE   stop   list   rip   erro   瑙e喅鏂规硶   firewall   leader   pre   

  棣栧厛 鍙互鐢–ontOS铏氭嫙鏈?nbsp;  鍏嬮殕  5涓櫄鎷熸満锛?span style="background-color: #ffffff; color: #800000;">娉ㄦ剰锛?/span>鍏嬮殕涓绘満蹇呴』瑁呬簡Docker,鍏嬮殕鍚庯紝鍏嬮殕鏈洪兘浼氭湁Docker锛?/span>

   閰嶇疆 缃戠粶

鎶€鏈浘鐗? src=

 

 

鍏嬮殕CentOS铏氭嫙鏈?nbsp;

鎶€鏈浘鐗? src=

 

 

 鏈€鍚庡拰鍒板涓嬬粨鏋?/p>

鎶€鏈浘鐗? src=

鎵撳紑2377绔彛 

 firewall-cmd --zone=public --add-port=2377/tcp --permanent

鐒跺悗杩涘叆CentOS 7 64浣?/p>

鍒濆鍖?nbsp;Swarm

sudo docker swarm init --advertise-addr 192.168.0.102:2377 --listen-addr 192.168.0.102:2377  

   A:    锛堝垵濮嬪寲鍚嶴warm鍚庡彲浠ラ€氳繃   docker swarm join-token worker 鏌ョ湅Swarm鐨凾oken淇℃伅 )

  鎶€鏈浘鐗? src=

        涓婂浘涓嬬澶村嵆鏄坊鍔犲姛鑳借妭鐐瑰懡浠わ紝浠g爜濡備笅锛?/p>

      sudo docker swarm join --token SWMTKN-1-1fmeankvtj5x8483gsxuhgwvhrdt2yt6japzopemjcucv8ykit-4xj0shobna3bu2u1tk377z2ch 192.168.0.102:2377   --advertise-addr 192.168.0.105:2377 --listen-addr 192.168.0.105:2377

  B: 鏌ョ湅娣荤鐞嗚兘鑺傜偣鍛戒护  

            docker swarm join-token manager

鎶€鏈浘鐗? src=

 

     涓婂浘涓嬬澶村嵆鏄坊鍔犵鐞嗚妭鐐瑰懡浠?nbsp; 锛堟敞鎰?nbsp;鍏堝叧闂坊鍔犵鐞嗚妭鐐规満鍣ㄧ殑闃茬伀澧欙紝涓嶇劧鍙兘涓嶆垚鍔燂級锛屼唬鐮佸涓嬶細

 

     sudo docker swarm join --token SWMTKN-1-1fmeankvtj5x8483gsxuhgwvhrdt2yt6japzopemjcucv8ykit-4xj0shobna3bu2u1tk377z2ch 192.168.0.102:2377 --advertise-addr 192.168.0.104:2377 --listen-addr 192.168.0.104:2377

 

鍙互閫氳繃Docker info鏌ョ湅鐩稿叧淇℃伅

鎶€鏈浘鐗? src=

 

 

 娣诲姞绠$悊鑺傜偣  锛堟敞鎰?nbsp;鍏堝叧闂?04鐨?/p>

 

闃茬伀澧欙紝涓嶇劧鍙兘涓嶆垚鍔燂級

      鍏堢櫥鍏ュ彟涓€鍙拌櫄鎷熸満

鎶€鏈浘鐗? src=

鍏抽棴闃茬伀澧?/p>

systemctl stop firewalld

鎶€鏈浘鐗? src=

娣诲姞绠$悊鑺傜偣

sudo docker swarm join --token SWMTKN-1-1fmeankvtj5x8483gsxuhgwvhrdt2yt6japzopemjcucv8ykit-4xj0shobna3bu2u1tk377z2ch 192.168.0.102:2377 --advertise-addr 192.168.0.104:2377 --listen-addr 192.168.0.104:2377

鎶€鏈浘鐗? src=

娣诲姞鍔熻兘鑺傜偣

 sudo docker swarm join --token SWMTKN-1-1fmeankvtj5x8483gsxuhgwvhrdt2yt6japzopemjcucv8ykit-4xj0shobna3bu2u1tk377z2ch 192.168.0.102:2377   --advertise-addr 192.168.0.105:2377 --listen-addr 192.168.0.105:2377

鎶€鏈浘鐗? src=

 

 

鍒涘缓Swarm  Service

鎶€鏈浘鐗? src=

 

 

 杩欓噷鐨刦ive鏄垜鐢?net Core鍒涘缓鐨処mage,鐜板湪鎴戣鐢ㄨ繖涓鍍忓垱寤?涓猄warm Servie瀹瑰櫒

     sudo docker service create --name myfiveweb -p 8080:5000 --replicas 5 five

鎶€鏈浘鐗? src=

 

 鏌ョ湅Swarm Service 杩愯鎯呭喌

 docker service ls

鎶€鏈浘鐗? src=

 

 璇︽儏    

docker service ps myfiveweb

鎶€鏈浘鐗? src=

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  鏌ョ湅Docker 鑺傜偣淇℃伅

         docker node ls 

鎶€鏈浘鐗? src=

 

 

 濡傛灉鎶?nbsp;docker node ls閿欙細

Error response from daemon: rpc error: code = Unknown desc = The swarm does not have a leader. It鈥榮 possible that too few managers are online. Make sure more than half of the managers are online.

瑙e喅鏂规硶锛?/p>

docker swarm init --force-new-cluster

 

 

鎻愬崌涓虹鐞嗚妭鐐瑰懡浠?/p>

sudo docker node promote fhdpncl3ay8vl5ogmbdh42ia8

灏嗙鐞嗚妭鐐归檷绾?/p>

docker node demote 0nbt  闄嶇骇

鍒犱簡鑺傜偣

   鍏堝湪鑺傜偣鏈哄櫒涓婃墽琛?nbsp;    

        sudo docker swarm leave --force

   鐒跺悗鍐峉warm涓荤鐞嗘満涓婃墽琛?/p>

    docker node rm ablwad6b   鍒犻櫎

 

以上是关于Docker Swanm闆嗙兢閰嶇疆的主要内容,如果未能解决你的问题,请参考以下文章

闆跺熀纭€瀛ginx銆?銆憒 Nginx 甯哥敤鐨勫懡浠ゅ拰閰嶇疆鏂囦欢

Docker涔媠warm閮ㄧ讲闆嗙兢

閫氳繃docker鎼缓ELK闆嗙兢

flink1.10 Linux 闆嗙兢瀹夎

Redis闆嗙兢閮芥湁鍝簺妯″紡

linux闆嗙兢