尊龙凯时人生就是博

ÔõÑùʹÓÃDocker¾ÙÐи߿ÉÓú͸ºÔØƽºâµÄÉèÖÃ

DockerÊÇÒ»ÖÖÇáÁ¿¼¶µÄÐéÄ⻯ÊÖÒÕ £¬ËüÄܹ»¿ìËÙ½¨Éè¡¢ÔËÐкͰ²ÅÅÓ¦ÓóÌÐò £¬Ê¹µÃÓ¦ÓóÌÐòµÄ°²ÅźÍÖÎÀí±äµÃÔ½·¢¼òÆӺ͸ßЧ¡£ÔÚÏÖʵµÄÓ¦Óó¡¾°ÖÐ £¬ÎÒÃÇͨ³£ÐèҪʹÓÃDocker¾ÙÐи߿ÉÓú͸ºÔØƽºâµÄÉèÖà £¬ÒÔÈ·±£Ó¦ÓóÌÐò¾ßÓÐÎȹÌÐԺͿÉÉìËõÐÔ¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃDocker¾ÙÐи߿ÉÓú͸ºÔØƽºâµÄÉèÖà £¬²¢ÌṩÏêϸµÄ´úÂëʾÀý¡£

ʹÓÃDocker¾ÙÐи߿ÉÓõÄÉèÖÃ

¸ß¿ÉÓÃÊÇÖ¸Ò»¸öϵͳ»òЧÀÍÔÚÓöµ½Ó²¼þ»òÈí¼þ¹ÊÕÏʱ £¬ÈÔÄܹ»¼á³ÖÎȹÌÔËÐеÄÄÜÁ¦¡£ÔÚDockerÖÐ £¬ÎÒÃÇ¿ÉÒÔʹÓöàÖÖ·½·¨ÊµÏָ߿ÉÓà £¬ÆäÖÐ×î³£Óõķ½·¨ÊÇʹÓÃDocker SwarmºÍDocker Compose¡£

Docker SwarmÊÇDockerÄÚÖõÄÈÝÆ÷±àÅŹ¤¾ß £¬Ëü¿ÉÒÔ½«Ò»×éDockerÖ÷»ú×é³ÉÒ»¸ö¼¯Èº £¬ÊµÏÖÈÝÆ÷µÄ¸ß¿ÉÓÃÐÔºÍÉìËõÐÔ¡£Ê¹ÓÃDocker SwarmÐèÒªÏȳõʼ»¯Ò»¸öSwarm¼¯Èº £¬²¢Ö¸¶¨SwarmµÄÖÎÀí½Úµã¡£È»ºóÎÒÃÇ¿ÉÒÔʹÓÃDocker CLI»òDocker APIÀ´ÖÎÀíSwarm¼¯ÈºÖеĸ÷¸ö½ÚµãºÍЧÀÍ¡£

ÏÂÃæÊÇÒ»¸öʹÓÃDocker SwarmʵÏָ߿ÉÓõÄʾÀý£º

³õʼ»¯Docker Swarm¼¯Èº

docker swarm init

°²ÅÅÒ»¸öNginxЧÀÍ

docker service create –name nginx –replicas 3 -p 80:80 nginx

Éó²éÔËÐÐÖеÄЧÀÍ

docker service ls

ʹÓÃDocker Swarm¿ÉÒÔ¿ìËÙ¡¢¼òÆÓµØʵÏÖÈÝÆ÷µÄ¸ß¿ÉÓÃÐÔºÍÉìËõÐÔ £¬¿ÉÊÇËüµÄ¹¦Ð§Ïà¶ÔÓÐÏÞ £¬¹ØÓÚÖØ´óµÄ³¡¾°¿ÉÄÜÎÞ·¨Öª×ãÐèÇó¡£´ËʱÎÒÃÇ¿ÉÒÔ˼Á¿Ê¹ÓÃDocker Compose¡£

Docker ComposeÊÇÒ»ÖÖÓÃÓÚ½ç˵ºÍÔËÐжà¸öDockerÈÝÆ÷µÄ¹¤¾ß £¬¿ÉÒÔ×Ô¶¯·ÖÅÉÍøÂç¡¢´æ´¢¾íµÈ×ÊÔ´ £¬²¢Ö§³ÖÈÝÆ÷µÄÀ©ÈÝ¡¢»Ø¹öµÈ²Ù×÷¡£Ê¹ÓÃDocker ComposeÐèÒªÏȽç˵һ¸öÓ¦ÓóÌÐòµÄÉèÖÃÎļþ £¬È»ºóʹÓÃdocker-composeÏÂÁîÀ´Æô¶¯ºÍÖÎÀíÓ¦ÓóÌÐòÈÝÆ÷¡£

ÏÂÃæÊÇÒ»¸öʹÓÃDocker ComposeʵÏָ߿ÉÓõÄʾÀý£º

½ç˵һ¸öNginxЧÀÍ

version: ‘2’

services:

nginx:

image: nginx
restart: always
ports:
  - "80:80"
environment:
  - VIRTUAL_HOST=www.example.com
  - VIRTUAL_PORT=80
volumes:
  - /data/nginx/conf:/etc/nginx
  - /data/nginx/logs:/var/log/nginx

µÇ¼ºó¸´ÖÆ

Æô¶¯NginxЧÀÍ

docker-compose up -d

Éó²éÔËÐÐÖеÄЧÀÍ

docker-compose ps

ʹÓÃDocker Compose¿ÉÒÔÔ½·¢ÎÞаµØ½ç˵ÈÝÆ÷ºÍÓ¦ÓóÌÐòµÄÉèÖà £¬Í¬Ê±Ö§³Ö¸ü¶àµÄ¸ß¼¶ÌØÕ÷¡£

ʹÓÃDocker¾ÙÐиºÔØƽºâµÄÉèÖÃ

¸ºÔØƽºâÊÇÖ¸½«ÍøÂçÇëÇó·Ö·¢¸ø¶à¸öЧÀÍÆ÷¾ÙÐд¦Àí £¬ÒÔÌá¸ßϵͳµÄÈÝ´íÄÜÁ¦ºÍ´¦ÀíÄÜÁ¦¡£ÔÚDockerÖÐ £¬ÎÒÃÇ¿ÉÒÔʹÓöàÖÖ·½·¨ÊµÏÖ¸ºÔØƽºâ £¬ÆäÖÐ×î³£Óõķ½·¨ÊÇʹÓÃDocker Swarm¡¢Docker ComposeºÍNginx¡£

ʹÓÃDocker SwarmºÍDocker ComposeʵÏÖ¸ºÔØƽºâÐèҪʹÓÃÆäÄÚÖõĸºÔØƽºâÆ÷ £¬ÔÚSwarm¼¯Èº»òComposeµØÓßÉÏ×Ô¶¯·Ö·¢ÇëÇó¡£Ê¹ÓÃNginxʵÏÖ¸ºÔØƽºâÐèÒªÉèÖÃNginxµÄ·´ÏòÊðÀí¹¦Ð§ £¬½«ÇëÇó·Ö·¢µ½¶à¸öºǫ́ЧÀÍÆ÷ÉÏ¡£

ÏÂÃæÊÇÒ»¸öʹÓÃNginxʵÏÖ¸ºÔØƽºâµÄʾÀý£º

×°ÖÃNginxºÍÒÀÀµÄ£¿é

apt-get install nginx

apt-get install libnginx-mod-http-upstream-hash

apt-get install libnginx-mod-http-upstream-fair

ÉèÖÃNginxµÄ·´ÏòÊðÀí

upstream backend {

hash $remote_addr consistent;
server node1.example.com:80;
server node2.example.com:80;
server node3.example.com:80;

µÇ¼ºó¸´ÖÆ

}

server {

listen 80;
server_name www.example.com;
location / {
    proxy_pass http://backend;
}

µÇ¼ºó¸´ÖÆ

}

ÖØÆôNginxЧÀÍ

systemctl restart nginx

ʹÓÃNginx¿ÉÒÔºÜÊÇÀû±ãµØʵÏÖÈÝÆ÷µÄ¸ºÔØƽºâ £¬Í¬Ê±»¹Ö§³Ö¸ü¶àµÄ¸ß¼¶ÌØÕ÷ £¬ÀýÈ翵½¡¼ì²é¡¢ÈÝ´í´¦ÀíµÈ¡£

×ܽá

±¾ÎÄÏÈÈÝÁËÔõÑùʹÓÃDocker¾ÙÐи߿ÉÓú͸ºÔØƽºâµÄÉèÖà £¬²¢ÌṩÁËÏêϸµÄ´úÂëʾÀý¡£ÔÚÏÖʵӦÓÃÖÐ £¬ÎÒÃÇÐèҪƾ֤ÏÖʵÐèÇóÑ¡ÔñÊʺϵŤ¾ßºÍÊÖÒÕ £¬Í¬Ê±Ò²ÐèҪעÖØÇå¾²¡¢¿É¿¿ºÍ¿ÉÀ©Õ¹ÐԵȷ½ÃæµÄÎÊÌâ¡£Docker×÷ΪһÖÖÐÂÐ˵ÄÐéÄ⻯ÊÖÒÕ £¬½«ÔÚδÀ´µÄÓ¦Óó¡¾°ÖÐÊ©Õ¹Ô½À´Ô½Ö÷ÒªµÄ×÷Óá£

ÒÔÉϾÍÊÇÔõÑùʹÓÃDocker¾ÙÐи߿ÉÓú͸ºÔØƽºâµÄÉèÖõÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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