×ðÁú¿­Ê±

LinuxºÍDocker£ºÔõÑùʵÏÖÈÝÆ÷µÄ×Ô¶¯À©ËõÈݺ͸ºÔØƽºâ£¿

linuxºÍdocker£ºÔõÑùʵÏÖÈÝÆ÷µÄ×Ô¶¯À©ËõÈݺ͸ºÔØƽºâ£¿

СÐò£º

ÔÚÏÖ´úÈí¼þ¿ª·¢Àú³ÌÖÐ £¬ÈÝÆ÷»¯ÊÖÒÕÒѾ­³ÉΪÁ˺ÜÊÇÊ¢ÐеĽâ¾ö¼Æ»®¡£¶øÆäÖÐ×îÊܽӴýµÄÈÝÆ÷ƽ̨֮һ¼´ÊÇDocker¡£DockerµÄʹÓÿÉÒÔ´øÀ´Ðí¶àÓÅÊÆ £¬Èç¸ü¸ßµÄ¿ÉÒÆÖ²ÐÔ¡¢¸ü¿ìµÄ°²ÅÅËÙÂʺ͸ü¸ßµÄ×ÊԴʹÓÃÂʵÈ¡£È»¶ø £¬ÔÚÏÖʵ°²ÅźÍÖÎÀí´ó¹æÄ£Ó¦ÓóÌÐòʱ £¬ÈÝÆ÷µÄ×Ô¶¯À©ËõÈݺ͸ºÔØƽºâ±äµÃÓÈΪÖ÷Òª¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃLinuxºÍDockerʵÏÖÈÝÆ÷µÄ×Ô¶¯À©ËõÈݺ͸ºÔØƽºâ¡£

Ò»¡¢ÈÝÆ÷×Ô¶¯À©ËõÈÝ

ÈÝÆ÷µÄ×Ô¶¯À©ËõÈÝ¿ÉÒÔƾ֤ӦÓóÌÐòµÄ¸ºÔØÇéÐÎÀ´¶¯Ì¬µØÔöÌí»òïÔÌ­ÈÝÆ÷µÄÊýÄ¿ £¬´Ó¶ø¸üºÃµØÓ¦¶ÔÁ÷Á¿á¯Áë»òµÍ¹ÈµÄÇéÐΡ£

ÔÚDockerÖÐ £¬ÎÒÃÇ¿ÉÒÔʹÓÃDocker ComposeºÍDocker SwarmÀ´ÊµÏÖÈÝÆ÷µÄ×Ô¶¯À©ËõÈÝ¡£Docker ComposeÊÇÒ»¸ö½ç˵ºÍÔËÐжà¸öÈÝÆ÷Ó¦ÓõŤ¾ß £¬¶øDocker SwarmÊÇÒ»¸öÓÃÓÚÔÚ¶à¸öDockerÖ÷»úÉϾÙÐÐÈÝÆ÷±àÅźÍÖÎÀíµÄ¹¤¾ß¡£

ÏÂÃæÊÇÒ»¸öʹÓÃDocker ComposeºÍDocker SwarmʵÏÖÈÝÆ÷×Ô¶¯À©ËõÈݵÄʾÀý£º

version: '3'
services:
  web:
    build: .
    image: myapp
    deploy:
      replicas: 3
      resources:
        limits:
          cpus: '0.5'
          memory: 512M
      restart_policy:
        condition: on-failure

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÊöʾÀýÖÐ £¬ÎÒÃǽç˵ÁËÒ»¸öÃûΪwebµÄЧÀÍ £¬Ö¸¶¨ÁËÓ¦ÓóÌÐòµÄ¾µÏñ¡¢¸±±¾ÊýÒÔ¼°×ÊÔ´ÏÞÖƵÈ¡£Í¨¹ýʹÓÃreplicas: 3²ÎÊý £¬ÎÒÃÇÖ¸¶¨Á˳õʼµÄÈÝÆ÷¸±±¾ÊýΪ3¸ö¡£µ±ÐèҪƾ֤¸ºÔØÇéÐξÙÐÐÀ©ËõÈÝʱ £¬ÎÒÃÇ¿ÉÒÔʹÓùٷ½ÌṩµÄdocker service scaleÏÂÁîÀ´ÐÞ¸ÄÈÝÆ÷µÄ¸±±¾Êý¡£

ÀýÈç £¬Òª½«¸±±¾ÊýÀ©´óµ½5¸ö £¬ÎÒÃÇ¿ÉÒÔÔËÐÐÒÔÏÂÏÂÁ

$ docker service scale web=5

µÇ¼ºó¸´ÖÆ

ÕâÑù £¬Docker Swarm¾Í»áƾ֤Ŀ½ñµÄ¸ºÔØÇéÐÎ×Ô¶¯ÔöÌí»òïÔÌ­ÈÝÆ÷µÄÊýÄ¿ £¬´Ó¶øʵÏÖÈÝÆ÷µÄ×Ô¶¯À©ËõÈÝ¡£

¶þ¡¢¸ºÔØƽºâ

ÔÚDockerÖÐ £¬¸ºÔØƽºâ¿ÉÒÔͨ¹ý¶àÖÖ·½·¨À´ÊµÏÖ £¬ÈçʹÓÃDocker SwarmµÄÄÚÖøºÔØƽºâÆ÷¡¢Ê¹ÓõÚÈý·½¸ºÔØƽºâÆ÷ÈçNginx»òHAProxyµÈ¡£

ÏÂÃæÊÇÒ»¸öʹÓÃDocker SwarmÄÚÖøºÔØƽºâÆ÷ʵÏÖ¸ºÔØƽºâµÄʾÀý£º

version: '3'
services:
  web:
    build: .
    image: myapp
    deploy:
      replicas: 3
      resources:
        limits:
          cpus: '0.5'
          memory: 512M
      restart_policy:
        condition: on-failure
    ports:
      - target: 80
        published: 8080
        protocol: tcp
        mode: host

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÊöʾÀýÖÐ £¬ÎÒÃǽç˵ÁËÒ»¸öÃûΪwebµÄЧÀÍ £¬²¢½«Ó¦ÓóÌÐòµÄÈÝÆ÷¼àÌý¶Ë¿ÚÓ³Éäµ½ÁËËÞÖ÷»úµÄ8080¶Ë¿Ú¡£ÕâÑù £¬ËÞÖ÷»ú¾Í¿ÉÒÔͨ¹ý»á¼û8080¶Ë¿ÚÀ´»á¼ûÓ¦ÓóÌÐò¡£

Docker Swarm»á×Ô¶¯½«ÇëÇóͨ¹ý¸ºÔØƽºâÆ÷·Ö·¢µ½¶à¸öÈÝÆ÷ʵÀýÖÐ £¬´Ó¶øʵÏÖ¸ºÔØƽºâ¡£ÈôÊÇij¸öÈÝÆ÷ʵÀý±¬·¢¹ÊÕÏ £¬Docker Swarm»á×Ô¶¯½«ÇëÇóת·¢µ½ÆäËûÕý³£ÔËÐеÄÈÝÆ÷ʵÀýÉÏ £¬´Ó¶øÌá¸ßÁËÓ¦ÓóÌÐòµÄ¿ÉÓÃÐԺͿɿ¿ÐÔ¡£

ËäÈ» £¬ÎÒÃÇÒ²¿ÉÒÔʹÓõÚÈý·½¸ºÔØƽºâÆ÷ÈçNginx»òHAProxyÀ´ÊµÏÖ¸üÖØ´óµÄ¸ºÔØƽºâÕ½ÂÔ¡£ÔÚÕâÖÖÇéÐÎÏ £¬ÎÒÃÇÐèÒªµ¥¶À°²ÅźÍÉèÖøºÔØƽºâÆ÷ £¬²¢½«ÇëÇóת·¢µ½¶à¸öDockerÈÝÆ÷ʵÀýÉÏ¡£

½áÂÛ£º

ʹÓÃLinuxºÍDocker £¬ÎÒÃÇ¿ÉÒÔºÜÀû±ãµØʵÏÖÈÝÆ÷µÄ×Ô¶¯À©ËõÈݺ͸ºÔØƽºâ¡£Í¨¹ýʹÓÃDocker ComposeºÍDocker Swarm £¬ÎÒÃÇ¿ÉÒÔÇáËɵؽç˵ºÍÖÎÀí¶à¸öÈÝÆ÷Ó¦Ó᣶øͨ¹ýʹÓÃDocker SwarmÄÚÖõĸºÔØƽºâÆ÷»òÕßµÚÈý·½¸ºÔØƽºâÆ÷ £¬ÎÒÃÇ¿ÉÒÔΪӦÓóÌÐòÌṩ¸ß¿ÉÓÃÐԺͿɿ¿ÐÔ¡£

ÕÆÎÕÁËÈÝÆ÷µÄ×Ô¶¯À©ËõÈݺ͸ºÔØƽºâµÄÊÖÒÕ £¬ÎÒÃÇÄܹ»¸üºÃµØÓ¦¶Ô²î±ð¹æÄ£ºÍ¸ºÔØÇéÐÎϵÄÓ¦ÓóÌÐòÐèÇó £¬´Ó¶øÌá¸ßÕûÌåµÄÐÔÄܺͿÉÓÃÐÔ¡£

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

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

Ïà¹ØÐÂÎÅ

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

13452372176

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

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

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