ÔõÑùÔÚLinuxÉÏÉèÖÃÈÝÆ÷´æ´¢ÐÔÄÜÓÅ»¯
ÔõÑùÔÚlinuxÉÏÉèÖÃÈÝÆ÷´æ´¢ÐÔÄÜÓÅ»¯
СÐò£º
ÔÚµ±½ñµÄÔÆÅÌËãÇéÐÎÖУ¬ÈÝÆ÷ÊÖÒÕÒѾ³ÉΪ°²ÅźÍÖÎÀíÓ¦ÓóÌÐòµÄÖ÷Òª×é³É²¿·Ö¡£È»¶ø£¬ÓÉÓÚÈÝÆ÷µÄ´æ´¢ÐÔÄÜ¿ÉÄÜ»á³ÉΪƿ¾±£¬Òò´ËÔÚLinuxϵͳÉϾÙÐÐÈÝÆ÷´æ´¢ÐÔÄÜÓÅ»¯ÊǺÜÊÇÒªº¦µÄ¡£±¾ÎĽ«ÏÈÈÝһЩÔÚLinuxÉÏÉèÖÃÈÝÆ÷´æ´¢ÐÔÄÜÓÅ»¯µÄÒªÁ죬²¢ÌṩÏìÓ¦µÄ´úÂëʾÀý¡£
Ò»¡¢Ñ¡ÔñºÏÊʵĴ洢Çý¶¯
Docker×÷ΪÏÖÔÚ×î³£ÓõÄÈÝÆ÷ÒýÇ棬ÌṩÁ˶àÖÖ´æ´¢Çý¶¯¹©Ñ¡Ôñ¡£²î±ðµÄ´æ´¢Çý¶¯ÔÚÐÔÄÜ·½ÃæÓÐËù²î±ð£¬Òò´ËÑ¡ÔñºÏÊʵĴ洢Çý¶¯¹ØÓÚÈÝÆ÷µÄ´æ´¢ÐÔÄÜÓÅ»¯ÖÁ¹ØÖ÷Òª¡£ÒÔÏÂÊǼ¸¸ö³£ÓõĴ洢Çý¶¯¼°ÆäÐÔÄÜÌص㣺
OverlayFS£ºOverlayFSÊÇDockerµÄĬÈÏ´æ´¢Çý¶¯£¬¾ßÓнϸߵÄÐÔÄܺͽϵ͵Ĵ洢¿ªÏú¡£ËüʹÓÃÁËLinuxÄÚºËÖеÄOverlayFSÌØÕ÷£¬Í¨¹ý¶à¸öÖ»¶Á¾µÏñ²ãÓëÒ»¸ö¶Áд¾µÏñ²ãµÄ×éºÏÀ´ÊµÏÖ¡£ÈôÊÇÖ÷ҪĿµÄÊÇÓÅ»¯´æ´¢ÐÔÄÜ£¬OverlayFSÊÇÒ»¸ö²»´íµÄÑ¡Ôñ¡£
AUFS£ºAUFSÊÇÁíÒ»¸öÓëOverlayFSÀàËƵĴ洢Çý¶¯£¬Ò²±»ÆÕ±éÓ¦ÓÃÓÚÈÝÆ÷ÇéÐΡ£AUFSÔÚÐÔÄÜ·½ÃæÓëOverlayFSÏ൱£¬µ«ÔÚijЩ¾É°æ±¾µÄÄÚºËÉÏ¿ÉÄÜʵÏÖ²»²ÇÏë¡£
DeviceMapper£ºDeviceMapperÊÇÒ»¸ö»ùÓÚLVM£¨Âß¼¾íÖÎÀíÆ÷£©ÊÖÒյĴ洢Çý¶¯£¬Ëü¿ÉÒÔΪÈÝÆ÷Ìṩ¸ü¸ßµÄÐÔÄܺ͸üºÃµÄ¿É¿¿ÐÔ¡£DeviceMapperÖ§³Ö¾µÏñ²ãµÄ¿ìÕպͻعö²Ù×÷£¬ÌṩÁ˸ü¶àµÄÊý¾ÝÖÎÀí¹¦Ð§¡£
ƾ֤ÏêϸµÄÓ¦Óó¡¾°ºÍÒªÇó£¬Ñ¡ÔñºÏÊʵĴ洢Çý¶¯ÓÐÖúÓÚÌáÉýÈÝÆ÷µÄ´æ´¢ÐÔÄÜÒÔ¼°ÕûÌåµÄÔËÐÐЧÂÊ¡£
¶þ¡¢Ê¹ÓÃÍâµØ´æ´¢¾í£¨Local Volumes£©
DockerÌṩÁËÍâµØ´æ´¢¾í£¨Local Volumes£©µÄ¿´·¨£¬Ëü¿ÉÒÔ½«ËÞÖ÷»úÉϵÄĿ¼»òÎļþ¹ÒÔص½ÈÝÆ÷ÖУ¬´Ó¶øÌṩ¸ü¸ßµÄIOÐÔÄÜ¡£Ê¹ÓÃÍâµØ´æ´¢¾í¿ÉÒÔ×èÖ¹½«Êý¾Ý´æ´¢ÔÚÈÝÆ÷µÄ¿Éд²ãÖУ¬´Ó¶øïÔÌ´æ´¢²ãµÄIOѹÁ¦£¬ÌáÉýÈÝÆ÷µÄÐÔÄÜ¡£
ÒÔÏÂÊÇʹÓÃÍâµØ´æ´¢¾íµÄÒ»¸öʾÀý£º
docker run -d -v /path/to/local/volume:/path/in/container image:tag
µÇ¼ºó¸´ÖÆ
ÔÚÉÏÊöÏÂÁîÖУ¬/path/to/local/volumeÊÇËÞÖ÷»úÉϵÄĿ¼£¬/path/in/containerÊÇÈÝÆ÷Äڵķ¾¶¡£ÕâÑù£¬ÈÝÆ÷ÄڵĶÁд²Ù×÷¶¼½«Ö±½ÓÔÚËÞÖ÷»úµÄÍâµØ´æ´¢¾íÉϾÙÐУ¬´Ó¶øÌáÉý´æ´¢ÐÔÄÜ¡£
Èý¡¢Ñ¡ÔñÊʵ±µÄ´æ´¢×°±¸ÀàÐÍ
LinuxϵͳÉÏ£¬´æ´¢×°±¸ÀàÐ͹ØÓÚÈÝÆ÷´æ´¢ÐÔÄܵÄÓ°ÏìºÜÊÇÏÔÖø¡£ÒÔÏÂÊǼ¸ÖÖ³£¼ûµÄ´æ´¢×°±¸ÀàÐͼ°ÆäÌص㣺
SATAÓ²ÅÌ£ºSATAÓ²ÅÌÊÇ×î³£¼ûµÄ´æ´¢×°±¸ÀàÐÍÖ®Ò»£¬ËüµÄ¶ÁдÐÔÄÜÏà¶Ô½ÏµÍ£¬ÊÊÓÃÓڽϵ͵ĶÁдÐèÇó¡£
SSD£º¹Ì̬ӲÅÌ£¨SSD£©¾ßÓиü¸ßµÄ¶ÁдÐÔÄܺ͸üµÍµÄÑÓ³Ù£¬ÊÊÓÃÓÚ¶Ô´æ´¢ÐÔÄÜÒªÇó½Ï¸ßµÄÈÝÆ÷³¡¾°¡£
NVMe£ºNVMe£¨Non-Volatile Memory Express£©ÊÇÒ»ÖÖ¸ßÐÔÄÜ¡¢µÍÑӳٵĴ洢װ±¸½Ó¿Ú£¬ÊÊÓÃÓÚ¶Ô´æ´¢ÐÔÄÜÓм«¸ßÒªÇóµÄÈÝÆ÷³¡¾°¡£
Ñ¡ÔñÊʵ±µÄ´æ´¢×°±¸ÀàÐÍ¿ÉÒÔ×î´óÏ޶ȵØÊ©Õ¹ÈÝÆ÷µÄ´æ´¢ÐÔÄÜ¡£
ËÄ¡¢Ê¹Óô洢×ÊÔ´ÏÞÖÆ
ÔÚLinuxϵͳÉÏ£¬¿ÉÒÔͨ¹ýʹÓÃcgroup£¨¿ØÖÆ×飩À´ÎªÈÝÆ÷ÉèÖô洢×ÊÔ´ÏÞÖÆ£¬ÒÔ×èֹij¸öÈÝÆ÷Ì«¹ýʹÓô洢×ÊÔ´¶øÔì³ÉÐÔÄÜϽµ¡£ÒÔÏÂÊÇÒ»¸öʹÓÃcgroupÏÞÖÆÈÝÆ÷´æ´¢×ÊÔ´µÄʾÀý£º
½¨ÉèÒ»¸öcgroup£º
mkdir /sys/fs/cgroup/blkio/your_cgroup
µÇ¼ºó¸´ÖÆ
½«ÈÝÆ÷Ìí¼Óµ½cgroupÖУº
echo <container_id> > /sys/fs/cgroup/blkio/your_cgroup/cgroup.procs
µÇ¼ºó¸´ÖÆ
ÏÞÖÆcgroupµÄ´æ´¢×ÊÔ´£º
echo "8:0 104857600" > /sys/fs/cgroup/blkio/your_cgroup/blkio.throttle.read_bps_device echo "8:0 104857600" > /sys/fs/cgroup/blkio/your_cgroup/blkio.throttle.write_bps_device
µÇ¼ºó¸´ÖÆ
ÔÚÉÏÊöʾÀýÖУ¬ÎÒÃÇÏÞÖÆÁËcgroupµÄIO¶ÁдËÙÂÊΪÀο¿µÄ100MB/s¡£Í¨¹ýÉèÖô洢×ÊÔ´ÏÞÖÆ£¬¿ÉÒÔºÏÀí·ÖÅÉ´æ´¢×ÊÔ´£¬²¢×èֹij¸öÈÝÆ÷¶Ô´æ´¢ÏµÍ³Ôì³É¹ý´óµÄ¸ºÔØ¡£
½áÂÛ£º
ÓÅ»¯ÈÝÆ÷µÄ´æ´¢ÐÔÄܹØÓÚÌáÉýÕûÌåÐÔÄܺÜÊÇÖ÷Òª¡£ÔÚLinuxÉÏ£¬Ñ¡ÔñºÏÊʵĴ洢Çý¶¯¡¢Ê¹ÓÃÍâµØ´æ´¢¾í¡¢Ñ¡ÔñÊʵ±µÄ´æ´¢×°±¸ÀàÐÍÒÔ¼°Ê¹Óô洢×ÊÔ´ÏÞÖƵÈÒªÁ춼¿ÉÒÔ×ÊÖúÓÅ»¯ÈÝÆ÷µÄ´æ´¢ÐÔÄÜ¡£Í¨¹ýºÏÀíÉèÖÃÈÝÆ÷µÄ´æ´¢ÐÔÄÜ£¬ÎÒÃÇ¿ÉÒÔ¸üºÃµØʹÓÃÈÝÆ÷ÊÖÒÕ£¬²¢Ìá¸ßÓ¦ÓóÌÐòÔÚÔÆÅÌËãÇéÐÎÖеÄÔËÐÐЧÂÊ¡£
ÒÔÉϾÍÊÇÔÚLinuxÉÏÉèÖÃÈÝÆ÷´æ´¢ÐÔÄÜÓÅ»¯µÄһЩҪÁìºÍÏìÓ¦µÄ´úÂëʾÀý¡£Ï£Íû±¾ÎĶԸ÷ÈËÔÚʹÓÃÈÝÆ÷ÊÖÒÕʱÄܹ»ÓÐËù×ÊÖú¡£
ÒÔÉϾÍÊÇÔõÑùÔÚLinuxÉÏÉèÖÃÈÝÆ÷´æ´¢ÐÔÄÜÓÅ»¯µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡