×ðÁú¿­Ê±

LinuxºÍDocker£ºÔõÑù¾ÙÐÐÈÝÆ÷µÄ³¤ÆÚ»¯´æ´¢ºÍÊý¾ÝÖÎÀí£¿

linuxºÍdocker£ºÔõÑù¾ÙÐÐÈÝÆ÷µÄ³¤ÆÚ»¯´æ´¢ºÍÊý¾ÝÖÎÀí£¿

ÔÚÈÝÆ÷»¯ÊÖÒÕµÄÓ¦ÓÃÖУ¬ÈÝÆ÷µÄ³¤ÆÚ»¯´æ´¢ºÍÊý¾ÝÖÎÀíÊǺÜÊÇÖ÷ÒªµÄÒ»»·¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚLinuxºÍDockerÖÐʵÏÖÈÝÆ÷µÄ³¤ÆÚ»¯´æ´¢£¬²¢ÌṩÏìÓ¦µÄ´úÂëʾÀý¡£

Ò»¡¢DockerÖеÄÈÝÆ÷³¤ÆÚ»¯´æ´¢

ÔÚDockerÖУ¬ÈÝÆ÷ÊÇͨ¹ý¾µÏñÀ´½¨ÉèµÄ£¬¶ø¾µÏñ×Ô¼ºÊÇÖ»¶ÁµÄ¡£Òò´Ë£¬µ±ÈÝÆ÷±»É¾³ýºó£¬ÆäÄÚ²¿µÄÊý¾ÝÒ²»áËæ֮ɥʧ¡£ÎªÁËʵÏÖÈÝÆ÷µÄ³¤ÆÚ»¯´æ´¢£¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔϼ¸ÖÖÒªÁì¡£

ʹÓÃÊý¾Ý¾í£¨Volume£©

Êý¾Ý¾íÊÇDockerÖÐ×îΪ³£Óõij¤ÆÚ»¯´æ´¢·½·¨Ö®Ò»¡£Í¨¹ý½¨ÉèÒ»¸öÊý¾Ý¾í£¬²¢½«Æä¹ÒÔص½ÈÝÆ÷µÄÖ¸¶¨Â·¾¶£¬ÎÒÃÇ¿ÉÒÔʵÏÖÈÝÆ÷Êý¾ÝµÄ³¤ÆÚ»¯´æ´¢¡£

Ê×ÏÈ£¬ÎÒÃǽ¨ÉèÒ»¸öÊý¾Ý¾í£º

$ docker volume create myvolume

µÇ¼ºó¸´ÖÆ

½Ó×Å£¬ÎÒÃÇ¿ÉÒÔͨ¹ýdocker runÏÂÁÊý¾Ý¾í¹ÒÔص½ÈÝÆ÷ÖУ¬ÈçÏÂËùʾ£º

$ docker run -v myvolume:/data myimage

µÇ¼ºó¸´ÖÆ

ÕâÑù£¬ÈÝÆ÷ÖеÄ/data·¾¶¾Í»á±»Ó³Éäµ½ÃûΪmyvolumeµÄÊý¾Ý¾íÉÏ¡£µ±ÈÝÆ÷±»É¾³ýʱ£¬¸ÃÊý¾Ý¾í²¢²»»á±»×Ô¶¯É¾³ý£¬Êý¾Ý½«»á±£´æÏÂÀ´¡£

ʹÓð󶨹ÒÔØ£¨Bind Mount£©

°ó¶¨¹ÒÔØÊÇÖ¸½«Ö÷»úÉϵÄÒ»¸öĿ¼¹ÒÔص½ÈÝÆ÷ÖеÄÖ¸¶¨Â·¾¶ÉÏ£¬´Ó¶øʵÏÖÈÝÆ÷Êý¾ÝµÄ³¤ÆÚ»¯´æ´¢¡£

ÎÒÃÇ¿ÉÒÔͨ¹ýdocker runÏÂÁîÀ´¾ÙÐа󶨹ÒÔØ£¬ÈçÏÂËùʾ£º

$ docker run -v /host/path:/container/path myimage

µÇ¼ºó¸´ÖÆ

ÕâÑù£¬Ö÷»úÉϵÄ/host/pathĿ¼¾Í»á±»Ó³Éäµ½ÈÝÆ÷ÖеÄ/container/path·¾¶ÉÏ¡£µ±ÈÝÆ÷±»É¾³ýʱ£¬Ö÷»úÉϵÄÊý¾Ý½«»á±£´æÏÂÀ´¡£

¶þ¡¢LinuxÖеÄÈÝÆ÷³¤ÆÚ»¯´æ´¢

³ýÁËÔÚDockerÖоÙÐÐÈÝÆ÷µÄ³¤ÆÚ»¯´æ´¢Í⣬ÎÒÃÇ»¹¿ÉÒÔͨ¹ýLinuxµÄµ×²ãÊÖÒÕÀ´ÊµÏÖÈÝÆ÷µÄÊý¾ÝÖÎÀí¡£

ʹÓù²ÏíÎļþϵͳ

LinuxÖпÉÒÔͨ¹ýʹÓù²ÏíÎļþϵͳÀ´ÊµÏÖÈÝÆ÷µÄ³¤ÆÚ»¯´æ´¢¡£ÎÒÃÇ¿ÉÒÔÔÚÖ÷»úÉϽ¨ÉèÒ»¸öÎļþϵͳ£¬²¢½«Æä¹ÒÔص½ÈÝÆ÷ÖУ¬´Ó¶øʵÏÖÈÝÆ÷Êý¾ÝµÄ³¤ÆÚ»¯´æ´¢¡£

Ê×ÏÈ£¬ÎÒÃÇÐèÒªÔÚÖ÷»úÉϽ¨ÉèÒ»¸öÎļþϵͳ£¬ÀýÈçʹÓÃext4Îļþϵͳ£¬¿ÉÒÔʹÓÃÒÔÏÂÏÂÁ

$ mkfs.ext4 /dev/sdb1

µÇ¼ºó¸´ÖÆ

½Ó×Å£¬ÎÒÃÇ¿ÉÒÔͨ¹ýmountÏÂÁ¸ÃÎļþϵͳ¹ÒÔص½ÈÝÆ÷ÖеÄÖ¸¶¨Â·¾¶£º

$ mount /dev/sdb1 /container/path

µÇ¼ºó¸´ÖÆ

ÕâÑù£¬ÈÝÆ÷ÖеÄ/container/path·¾¶¾Í»á±»¹ÒÔØΪ¹²ÏíÎļþϵͳ£¬µ±ÈÝÆ÷±»É¾³ýʱ£¬Êý¾Ý½«»á±£´æÏÂÀ´¡£

ʹÓô洢¾íÖÎÀíÆ÷£¨Storage Volume Manager£©

´æ´¢¾íÖÎÀíÆ÷ÊÇLinuxÖеÄÒ»¸ö¸ß¼¶ÌØÕ÷£¬¿ÉÒÔʵÏÖÊý¾ÝµÄ¿ìÕÕ¡¢¿Ë¡¡¢Ç¨áãµÈ¹¦Ð§¡£ÎÒÃÇ¿ÉÒÔʹÓô洢¾íÖÎÀíÆ÷À´ÊµÏÖÈÝÆ÷µÄÊý¾ÝÖÎÀí¡£

Ê×ÏÈ£¬ÎÒÃÇÐèҪװÖô洢¾íÖÎÀíÆ÷µÄÈí¼þ°ü£¬ÀýÈçLVM£¨Logical Volume Manager£©£º

$ apt-get install lvm2

µÇ¼ºó¸´ÖÆ

½Ó×Å£¬ÎÒÃÇ¿ÉÒÔʹÓÃlvcreateÏÂÁÉèÒ»¸öÂß¼­¾í£¨Logical Volume£©£º

$ lvcreate -L 1G -n myvolume myvg

µÇ¼ºó¸´ÖÆ

ÕâÑù£¬ÎÒÃǾͽ¨ÉèÁËÒ»¸ö¾ÞϸΪ1GBµÄÂß¼­¾í£¬²¢½«ÆäÃüÃûΪmyvolume¡£

½ÓÏÂÀ´£¬ÎÒÃÇ¿ÉÒÔʹÓÃmkfsÏÂÁîÔÚÂß¼­¾íÉϽ¨ÉèÒ»¸öÎļþϵͳ£º

$ mkfs.ext4 /dev/myvg/myvolume

µÇ¼ºó¸´ÖÆ

×îºó£¬ÎÒÃÇ¿ÉÒÔͨ¹ýmountÏÂÁÂß¼­¾í¹ÒÔص½ÈÝÆ÷ÖеÄÖ¸¶¨Â·¾¶£º

$ mount /dev/myvg/myvolume /container/path

µÇ¼ºó¸´ÖÆ

ÕâÑù£¬ÈÝÆ÷ÖеÄ/container/path·¾¶¾Í»á±»¹ÒÔØΪÂß¼­¾í£¬µ±ÈÝÆ÷±»É¾³ýʱ£¬Êý¾Ý½«»á±£´æÏÂÀ´¡£

×ÛÉÏËùÊö£¬ÎÞÂÛÊÇÔÚDockerÖÐÕÕ¾ÉÔÚLinuxÖУ¬ÎÒÃǶ¼¿ÉÒÔͨ¹ý²î±ðµÄÒªÁìʵÏÖÈÝÆ÷µÄ³¤ÆÚ»¯´æ´¢ºÍÊý¾ÝÖÎÀí¡£Í¨¹ýºÏÀíÑ¡ÔñºÏÊʵÄÒªÁ죬ÎÒÃÇ¿ÉÒÔ¸üºÃµØÖÎÀíºÍά»¤ÈÝÆ÷ÖеÄÊý¾Ý¡£

Ï£Íû±¾ÎĶÔÄúÃ÷È·ºÍʹÓÃÈÝÆ÷µÄ³¤ÆÚ»¯´æ´¢ºÍÊý¾ÝÖÎÀíÓÐËù×ÊÖú£¡

²Î¿¼ÎÄÏ×£º

Docker Documentation: https://docs.docker.com/storage/

Linux Documentation: https://www.kernel.org/doc/html/latest/admin-guide/devices/lvm.html

ÒÔÉϾÍÊÇLinuxºÍDocker£ºÔõÑù¾ÙÐÐÈÝÆ÷µÄ³¤ÆÚ»¯´æ´¢ºÍÊý¾ÝÖÎÀí£¿µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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