×ðÁú¿­Ê±

ÔõÑùÔÚLinuxÉÏÉèÖÃÈÝÆ÷±àÅÅƽ̨£¨ÈçDocker Swarm£©

ÔõÑùÔÚlinuxÉÏÉèÖÃÈÝÆ÷±àÅÅƽ̨£¨Èçdocker swarm£©

СÐò£º

Ëæ×ÅÔÆÅÌËãºÍÈÝÆ÷»¯ÊÖÒÕµÄÆÕ±éÓ¦Óã¬ÈÝÆ÷±àÅÅƽ̨³ÉΪÁËÖÎÀíÈÝÆ÷»¯Ó¦ÓõÄÖ÷Òª¹¤¾ß¡£ÆäÖУ¬Docker Swarm×÷Ϊһ¸öÊ¢ÐеÄÈÝÆ÷±àÅÅƽ̨£¬ÌṩÁ˼òÆÓÒ×ÓõÄÈÝÆ÷±àÅźÍÖÎÀí¹¦Ð§¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚLinuxÉÏÉèÖÃDocker Swarm£¬²¢ÌṩÏìÓ¦µÄ´úÂëʾÀý¡£

Ò»¡¢×°ÖÃDocker

ÔÚ×îÏÈÉèÖÃDocker Swarm֮ǰ£¬Ê×ÏÈÐèÒªÔÚLinuxÉÏ×°ÖÃDocker¡£ÒÔÏÂÊÇÔÚUbuntuÉÏ×°ÖÃDockerµÄʾÀý´úÂ룺

# ¸üÐÂaptÈí¼þ°üË÷Òý
sudo apt-get update

# ×°ÖÃDockerÒÀÀµ¿â
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common

# Ìí¼ÓDocker¹Ù·½GPGÃÜÔ¿
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

# Ìí¼ÓDocker¹Ù·½APT¿ÍÕ»
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

# ¸üÐÂaptÈí¼þ°üË÷Òý
sudo apt-get update

# ×°ÖÃDocker
sudo apt-get install docker-ce

# Æô¶¯Docker²¢ÉèÖÿª»ú×ÔÆô
sudo systemctl start docker
sudo systemctl enable docker

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂ뽫ÔÚUbuntuÉÏ×°Öò¢Æô¶¯Docker¡£

¶þ¡¢ÉèÖÃSwarmÖÎÀí½Úµã

ÒªÉèÖÃÒ»¸öDocker Swarm¼¯Èº£¬Ê×ÏÈÐèҪѡÔñ²¢ÉèÖÃÒ»¸öSwarmÖÎÀí½Úµã¡£ÒÔÏÂÊÇÑ¡Ôñ²¢ÉèÖÃSwarmÖÎÀí½ÚµãµÄʾÀý´úÂ룺

# ½¨ÉèÒ»¸öSwarmÖÎÀí½Úµã
docker swarm init

# »ñÈ¡Swarm¼¯ÈºµÄ¼ÓÈëÁîÅÆ
docker swarm join-token -q worker

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂ뽫½¨ÉèÒ»¸öSwarmÖÎÀí½Úµã£¬²¢ÌìÉúÒ»¸öÓÃÓÚ¼ÓÈëÆäËû½ÚµãµÄÁîÅÆ¡£

Èý¡¢¼ÓÈëÆäËû½Úµã

ÔÚÉèÖÃSwarm¼¯ÈºÖ®Ç°£¬ÐèÒª½«ÆäËû½Úµã¼ÓÈ뼯Ⱥ¡£ÒÔÏÂÊǽ«ÆäËû½Úµã¼ÓÈëSwarm¼¯ÈºµÄʾÀý´úÂ룺

# ÔÚÒª¼ÓÈëµÄ½ÚµãÉÏÖ´ÐÐÒÔÏÂÏÂÁî
docker swarm join --token <SWMTKN> <MANAGER_IP>:<PORT>

µÇ¼ºó¸´ÖÆ

ÆäÖУ¬ ÊÇÔÚ°ì·¨¶þÖÐÌìÉúµÄSwarm¼¯Èº¼ÓÈëÁîÅÆ£¬ : ÊÇSwarmÖÎÀí½ÚµãµÄIPµØµãºÍ¶Ë¿Ú¡£

ËÄ¡¢ÉèÖÃÍøÂç

Docker SwarmÌṩÁ˶àÖÖÍøÂçÇý¶¯³ÌÐò£¬Ê¹µÃÈÝÆ÷Ö®¼ä¿ÉÒÔ¾ÙÐÐͨѶ¡£ÒÔÏÂÊÇÉèÖÃSwarmÍøÂçµÄʾÀý´úÂ룺

# ½¨ÉèÒ»¸öoverlayÍøÂç
docker network create -d overlay my_network

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂ뽫½¨ÉèÒ»¸öÃûΪmy_networkµÄoverlayÍøÂç¡£

Îå¡¢°²ÅÅЧÀÍ

ÔÚÉèÖÃÍêSwarm¼¯ÈººÍÍøÂçÖ®ºó£¬¿ÉÒÔ×îÏÈ°²ÅÅЧÀÍ¡£ÒÔÏÂÊÇ°²ÅÅЧÀ͵ÄʾÀý´úÂ룺

# ÔÚSwarmÖÎÀí½ÚµãÉϽ¨ÉèÒ»¸öЧÀÍ
docker service create --replicas 3 --name my_service --network my_network nginx:latest

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂ뽫ÔÚSwarm¼¯ÈºÖн¨ÉèÒ»¸öÃûΪmy_serviceµÄЧÀÍ£¬²¢Ê¹ÓÃnginx:latest¾µÏñ½¨Éè3¸ö¸±±¾¡£

Áù¡¢Éó²éЧÀÍ״̬

¿ÉÒÔʹÓÃÒÔÏÂʾÀý´úÂëÀ´Éó²éЧÀ͵Ä״̬£º

# Éó²éЧÀÍ״̬
docker service ps my_service

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂ뽫ÏÔʾmy_serviceЧÀ͵Ä״̬£¬°üÀ¨¸±±¾ÊýÄ¿¡¢ÔËÐÐ״̬µÈÐÅÏ¢¡£

Æß¡¢À©Õ¹Ð§ÀÍ

ÒªÀ©Õ¹Ð§À͵ĸ±±¾ÊýÄ¿£¬¿ÉÒÔʹÓÃÒÔÏÂʾÀý´úÂ룺

# À©Õ¹Ð§À͸±±¾ÊýÄ¿
docker service scale my_service=5

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂ뽫½«my_serviceЧÀ͵ĸ±±¾ÊýÄ¿À©Õ¹µ½5¸ö¡£

°Ë¡¢É¾³ýЧÀͺͼ¯Èº

ÈôÊÇÐèҪɾ³ýЧÀͺÍSwarm¼¯Èº£¬¿ÉÒÔʹÓÃÒÔÏÂʾÀý´úÂ룺

# ɾ³ýЧÀÍ
docker service rm my_service

# ɾ³ýSwarm¼¯Èº
docker swarm leave --force

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂ뽫ɾ³ýmy_serviceЧÀͺÍSwarm¼¯Èº¡£

½áÂÛ£º

±¾ÎÄÏÈÈÝÁËÔõÑùÔÚLinuxÉÏÉèÖÃÈÝÆ÷±àÅÅƽ̨Docker Swarm£¬²¢ÌṩÁËÏìÓ¦µÄ´úÂëʾÀý¡£Í¨¹ýÕâЩʾÀý´úÂ룬¶ÁÕß¿ÉÒÔÏàʶµ½ÔõÑù×°ÖÃDocker¡¢ÉèÖÃSwarmÖÎÀí½Úµã¡¢¼ÓÈëÆäËû½Úµã¡¢ÉèÖÃÍøÂç¡¢°²ÅÅЧÀ͵ȲÙ×÷¡£Ï£Íû±¾ÎĹØÓÚ¶ÁÕßÔÚÉèÖÃÈÝÆ÷±àÅÅƽ̨·½ÃæÓÐËù×ÊÖú¡£

ÒÔÉϾÍÊÇÔõÑùÔÚLinuxÉÏÉèÖÃÈÝÆ÷±àÅÅƽ̨£¨ÈçDocker Swarm£©µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

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

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

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