尊龙凯时人生就是博

LinuxºÍDocker£ºÔõÑùʵÏָ߿ÉÓõÄÈÝÆ÷¼¯Èº£¿

linuxºÍdocker£ºÔõÑùʵÏָ߿ÉÓõÄÈÝÆ÷¼¯Èº£¿

ÕªÒª£ºËæ×ÅÈÝÆ÷ÊÖÒÕµÄÉú³¤£¬Ô½À´Ô½¶àµÄÆóÒµÖð½¥½«Ó¦ÓóÌÐò°²Åŵ½ÈÝÆ÷ÖС£ÔÚÉú²úÇéÐÎÖУ¬ÊµÏÖÈÝÆ÷¼¯ÈºµÄ¸ß¿ÉÓÃÐÔÊÇÖÁ¹ØÖ÷ÒªµÄ¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃLinuxºÍDockerÀ´¹¹½¨¸ß¿ÉÓõÄÈÝÆ÷¼¯Èº£¬²¢Í¨¹ý´úÂëʾÀýÀ´ÑÝʾÏêϸʵÏÖÒªÁì¡£

´î½¨Docker Swarm¼¯Èº

Docker SwarmÊÇDockerÌṩµÄÔ­ÉúÈÝÆ÷¼¯ÈºÖÎÀí¹¤¾ß¡£ËüÔÊÐíÎÒÃǽ«¶à¸öDockerÖ÷»ú×é³ÉÒ»¸ö¼¯Èº£¬²¢Í³Ò»ÖÎÀíÈÝÆ÷µÄ°²ÅźÍÔËÐС£

Ê×ÏÈ£¬ÔÚÿ¸öÒª¼ÓÈ뼯ȺµÄDockerÖ÷»úÉÏ×°ÖÃDocker¡£È»ºó£¬Ñ¡ÔñÒ»¸öÖ÷»ú×÷ΪSwarm¼¯ÈºµÄÖÎÀí½Úµã£¬ÔËÐÐÒÔÏÂÏÂÁîÀ´³õʼ»¯¼¯Èº£º

$ docker swarm init --advertise-addr <MANAGER-IP>

µÇ¼ºó¸´ÖÆ

ÆäÖУ¬ ÊÇÖÎÀí½ÚµãµÄIPµØµã¡£Í¨¹ýÉÏÊöÏÂÁÎÒÃǽ«»ñµÃÒ»¸ötoken£¬ÓÃÓÚÆäËûÖ÷»ú¼ÓÈ뼯Ⱥ¡£½ÓÏÂÀ´£¬ÔÚÆäËûÒª¼ÓÈ뼯ȺµÄÖ÷»úÉÏÔËÐÐÒÔÏÂÏÂÁ

$ docker swarm join --token <TOKEN> <MANAGER-IP>:<PORT>

µÇ¼ºó¸´ÖÆ

ÆäÖУ¬ ÊÇÉÏÒ»°ì·¨»ñµÃµÄtoken£¬ ºÍ »®·ÖÊÇÖÎÀí½ÚµãµÄIPµØµãºÍ¶Ë¿ÚºÅ¡£

ÉèÖÃЧÀÍ·¢Ã÷

ÈÝÆ÷¼¯ÈºÖеÄÿ¸ö½Úµã¶¼ÐèÒªÄܹ»·¢Ã÷²¢»á¼ûµ½ÆäËû½Úµã¡£ÎªÁËʵÏÖЧÀÍ·¢Ã÷£¬ÎÒÃÇ¿ÉÒÔʹÓÃConsul»òEtcdµÈ¹¤¾ß¡£ÕâÀïÒÔConsulΪÀý¡£

Ê×ÏÈ£¬ÔÚËùÓеÄDockerÖ÷»úÉÏ×°Öò¢Æô¶¯Consul¡£È»ºó£¬ÔËÐÐÒÔÏÂÏÂÁîÀ´½¨ÉèÒ»¸öConsulЧÀÍ£º

$ docker service create --name consul --publish 8500:8500 --constraint 'node.role == manager' gliderlabs/consul-server -bootstrap

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

¸ÃÏÂÁîÔÚSwarm¼¯ÈºµÄÖÎÀí½ÚµãÉϽ¨ÉèÒ»¸öÃûΪconsulµÄЧÀÍ£¬²¢½«ÈÝÆ÷µÄ8500¶Ë¿ÚÓ³Éäµ½Ö÷»úµÄ8500¶Ë¿Ú¡£

½ÓÏÂÀ´£¬ÔÚÆäËû½ÚµãÉÏÔËÐÐÒÔÏÂÏÂÁîÀ´¼ÓÈëConsulЧÀÍ£º

$ docker service create --name consul --network <NETWORK> gliderlabs/consul-agent -join consul

µÇ¼ºó¸´ÖÆ

ÆäÖУ¬ ÊÇSwarm¼¯ÈºµÄÍøÂçÃû³Æ¡£

½¨ÉèÈÝÆ÷ЧÀÍ

Ôڸ߿ÉÓõÄÈÝÆ÷¼¯ÈºÖУ¬ÎÒÃÇÐèÒª½«Ó¦ÓóÌÐò°²Åŵ½¶à¸öÈÝÆ÷ʵÀýÖУ¬²¢Í¨¹ý¸ºÔØƽºâÀ´·Ö·¢ÇëÇó¡£Docker SwarmÌṩÁËÒ»¸öÃûΪserviceµÄ¿´·¨£¬ÓÃÓÚÖÎÀíÈÝÆ÷ЧÀÍ¡£

Ê×ÏÈ£¬×¼±¸Ò»¸öDocker¾µÏñ£¬°üÀ¨ÁËÎÒÃÇÒª°²ÅŵÄÓ¦ÓóÌÐò¡£È»ºó£¬ÔËÐÐÒÔÏÂÏÂÁîÀ´½¨ÉèÒ»¸öЧÀÍ£º

$ docker service create --name <SERVICE-NAME> --replicas <REPLICAS> --publish <PORT> <IMAGE>

µÇ¼ºó¸´ÖÆ

ÆäÖУ¬ ÊÇЧÀ͵ÄÃû³Æ£¬ ÊÇÒª°²ÅŵÄÈÝÆ÷ʵÀýÊýÄ¿£¬ ÊÇÒªÓ³ÉäµÄ¶Ë¿ÚºÅ£¬ÊÇÓ¦ÓóÌÐòËùÔÚµÄDocker¾µÏñ¡£

ÔËÐÐÈÝÆ÷ЧÀÍ

ͨ¹ýÉÏÒ»°ì·¨½¨ÉèµÄЧÀͽ«»áÔÚ¼¯ÈºÖеĶà¸ö½ÚµãÉÏ×Ô¶¯°²ÅÅÈÝÆ÷ʵÀý¡£

¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´Éó²éЧÀ͵ÄÔËÐÐ״̬ºÍÈÝÆ÷ʵÀýµÄÂþÑÜÇéÐΣº

$ docker service ls
$ docker service ps <SERVICE-NAME>

µÇ¼ºó¸´ÖÆ

ʵÏÖ¸ºÔØƽºâ

ΪÁËʵÏÖ¸ºÔØƽºâ£¬ÎÒÃÇ¿ÉÒÔʹÓÃDocker SwarmÄÚÖõĸºÔØƽºâ¹¦Ð§¡£Í¨¹ýЧÀ͵ÄÃû³ÆºÍ¶Ë¿ÚºÅ£¬¿ÉÒÔ»á¼ûµ½Ð§ÀͺóÃæµÄ¶à¸öÈÝÆ÷ʵÀý¡£

ʵÏÖ×Ô¶¯À©Õ¹

µ±ÈÝÆ÷¼¯ÈºÖеĸºÔرä´óʱ£¬ÎÒÃÇ¿ÉÒÔͨ¹ýÔöÌíÈÝÆ÷ʵÀýµÄÊýÄ¿À´ÊµÏÖ×Ô¶¯À©Õ¹¡£

¿ÉÒÔʹÓÃÒÔÏÂÏÂÁîÀ´À©Õ¹Ð§À͵ÄʵÀýÊýÄ¿£º

$ docker service scale <SERVICE-NAME>=<REPLICAS>

µÇ¼ºó¸´ÖÆ

ÆäÖУ¬ ÊÇЧÀ͵ÄÃû³Æ£¬ ÊÇÒªÀ©Õ¹µ½µÄÈÝÆ÷ʵÀýÊýÄ¿¡£

×ܽ᣺ʹÓÃLinuxºÍDockerÀ´¹¹½¨¸ß¿ÉÓõÄÈÝÆ÷¼¯Èº£¬¼ÈÌá¸ßÁËÓ¦ÓóÌÐòµÄ¿ÉÓÃÐÔ£¬ÓÖÌṩÁ˵¯ÐÔÉìËõºÍ¸ºÔØƽºâµÄÄÜÁ¦¡£Í¨¹ýºÏÀíµØÉèÖúÍÖÎÀí£¬ÎÒÃÇ¿ÉÒÔʵÏÖ¸ßЧÎȹ̵ÄÈÝÆ÷ЧÀÍ¡£

´úÂëʾÀý£º

³õʼ»¯Swarm¼¯Èº£º

$ docker swarm init --advertise-addr 192.168.0.1

µÇ¼ºó¸´ÖÆ

¼ÓÈëSwarm¼¯Èº£º

$ docker swarm join --token <TOKEN> 192.168.0.1:2377

µÇ¼ºó¸´ÖÆ

½¨ÉèConsulЧÀÍ£º

$ docker service create --name consul --publish 8500:8500 --constraint 'node.role == manager' gliderlabs/consul-server -bootstrap

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

¼ÓÈëConsulЧÀÍ£º

$ docker service create --name consul --network my-network gliderlabs/consul-agent -join consul

µÇ¼ºó¸´ÖÆ

½¨ÉèÓ¦ÓóÌÐòЧÀÍ£º

$ docker service create --name my-service --replicas 3 --publish 8080:8080 my-app

µÇ¼ºó¸´ÖÆ

À©Õ¹Ð§ÀÍʵÀýÊýÄ¿£º

$ docker service scale my-service=5

µÇ¼ºó¸´ÖÆ

ÒÔÉϾÍÊÇLinuxºÍDocker£ºÔõÑùʵÏָ߿ÉÓõÄÈÝÆ÷¼¯Èº£¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ