ºìÁªLinuxÃÅ»§
Linux°ïÖú
µ±Ç°Î»ÖÃ: ºìÁªLinuxÃÅ»§ > Ubuntu

ʹÓà LXD ÈÝÆ÷ÔËÐÐ Ubuntu Core

·¢²¼Ê±¼ä:2017-11-25 18:17:07À´Ô´:ºìÁª×÷Õß:Ronny
µ¼¶Á Ubuntu Core ÊÇÍêÈ«»ùÓÚ snap °ü¹¹½¨£¬²¢ÇÒÍêÈ«ÊÂÎñ»¯µÄ Ubuntu °æ±¾¡£¸Ãϵͳ´ó²¿·ÖÊÇÖ»¶ÁµÄ£¬ËùÓÐÒÑ°²×°µÄÓ¦ÓÃÈ«²¿À´×Ô snap °ü£¬ÍêȫʹÓÃÊÂÎñ»¯¸üС£ÕâÒâζ×Ų»¹ÜÔÚϵͳ¸üл¹ÊÇ°²×°Èí¼þµÄʱºòÓöµ½ÎÊÌ⣬Õû¸öϵͳ¶¼¿ÉÒÔ»ØÍ˵½Ö®Ç°µÄ״̬²¢ÇҼǼÕâ¸ö´íÎó¡£×îаæÊÇÔÚ 2016 Äê 11 Ô·¢²¼µÄ Ubuntu Core 16¡£

×¢Ò⣬Ubuntu Core ÏÞÖÆÖ»Äܹ»°²×° snap °ü£¨¶ø·Ç ¡°´«Í³¡± Èí¼þ°ü£©£¬²¢ÇÒÓÐÏ൱ÊýÁ¿µÄ snap °üÔÚµ±Ç°»·¾³Ï²»ÄÜÕý³£ÔËÐУ¬»òÕßÐèÒªÈ˹¤¸ÉÔ¤£¨´´½¨Óû§ºÍÓû§×éµÈ£©²ÅÄÜÕý³£ÔËÐС£Ëæ×ÅаæµÄ snapd ºÍ ¡°core¡± snap °ü·¢²¼£¬Ubuntu Core ÿÖܶ¼»áµÃµ½¸Ä½ø¡£
»·¾³ÐèÇó
¾Í LXD ¶øÑÔ£¬Ubuntu Core ½ö½öÏ൱ÓÚÁíÒ»¸ö Linux ·¢Ðа档Ҳ¾ÍÊÇ˵£¬snapd ÐèÒª¹ÒÔØÎÞÌØȨµÄ FUSE ºÍ AppArmor ÃüÃû¿Õ¼äÒÔ¼°Èí¼þÕ»£¬ÏñÏÂÃæÕâÑù£º
Ò»¸öаæµÄʹÓà Ubuntu ¹Ù·½Äں˵Äϵͳ
Ò»¸öаæµÄ LXD
´´½¨Ò»¸ö Ubuntu Core ÈÝÆ÷
µ±Ç° Ubuntu Core ¾µÏñ·¢²¼ÔÚÉçÇøµÄ¾µÏñ·þÎñÆ÷¡£Äã¿ÉÒÔÏñÕâÑùÆô¶¯Ò»¸öеÄÈÝÆ÷£º
stgraber@dakara:~$ lxc launch images:ubuntu-core/16 ubuntu-core Creating ubuntu-core Starting ubuntu-core
Õâ¸öÈÝÆ÷Æô¶¯ÐèÒªÒ»µãµãʱ¼ä£¬Ëü»áÏÈÖ´ÐеÚÒ»½×¶ÎµÄ¼ÓÔسÌÐò£¬¼ÓÔسÌÐò»áÈ·¶¨Ê¹ÓÃÄÄÒ»¸ö¾µÏñ£¨¾µÏñÊÇÖ»¶ÁµÄ£©£¬²¢ÇÒÔÚϵͳÉÏÉèÖÃÒ»¸ö¿É¶Á²ã£¬Äã²»ÒªÔÚÕâÒ»½×¶ÎÖжÏÈÝÆ÷Ö´ÐУ¬Õâ¸öʱºòʲô¶¼Ã»ÓУ¬ËùÒÔÖ´ÐÐlxc exec ½«»á³ö´í¡£
¼¸ÃëÖÓÖ®ºó£¬Ö´ÐÐ lxc list ½«»áչʾÈÝÆ÷µÄ IP µØÖ·£¬Õâ±íÃ÷ÒѾ­Æô¶¯ÁË Ubuntu Core£º
stgraber@dakara:~$ lxc list +-------------+---------+----------------------+----------------------------------------------+------------+-----------+ | NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | +-------------+---------+----------------------+----------------------------------------------+------------+-----------+ | ubuntu-core | RUNNING | 10.90.151.104 (eth0) | 2001:470:b368:b2b5:216:3eff:fee1:296f (eth0) | PERSISTENT | 0 | +-------------+---------+----------------------+----------------------------------------------+------------+-----------+
Ö®ºóÄã¾Í¿ÉÒÔÏñʹÓÃÆäËûµÄ½»»¥Ò»ÑùºÍÕâ¸öÈÝÆ÷½øÐн»»¥£º
stgraber@dakara:~$ lxc exec ubuntu-core bash root@ubuntu-core:~# snap list Name Version Rev Developer Notes core 16.04.1 394 canonical - pc 16.04-0.8 9 canonical - pc-kernel 4.4.0-45-4 37 canonical - root@ubuntu-core:~#
¸üÐÂÈÝÆ÷
Èç¹ûÄãÒ»Ö±¹Ø×¢×Å Ubuntu Core µÄ¿ª·¢£¬ÄãÓ¦¸ÃÖªµÀÉÏÃæµÄ°æ±¾ÒѾ­ºÜÀÏÁË¡£ÕâÊÇÒòΪ±»ÓÃ×÷ Ubuntu LXD ¾µÏñµÄ´úÂëÿ¸ô¼¸¸öÔ²Żá¸üС£Ubuntu Core ϵͳÔÚÖØÆôʱ»á¼ì²é¸üв¢½øÐÐ×Ô¶¯¸üУ¨¸üÐÂʧ°Ü»á»ØÍË£©¡£
Èç¹ûÄãÏëÏÖÔÚÇ¿ÖƸüУ¬Äã¿ÉÒÔÕâÑù×ö£º
stgraber@dakara:~$ lxc exec ubuntu-core bash root@ubuntu-core:~# snap refresh pc-kernel (stable) 4.4.0-53-1 from 'canonical' upgraded core (stable) 16.04.1 from 'canonical' upgraded root@ubuntu-core:~# snap version snap 2.17 snapd 2.17 series 16 root@ubuntu-core:~# È»ºóÖØÆôһϠUbuntu Core ϵͳ£¬È»ºó¿´¿´ snapd µÄ°æ±¾¡£ root@ubuntu-core:~# reboot root@ubuntu-core:~# stgraber@dakara:~$ lxc exec ubuntu-core bash root@ubuntu-core:~# snap version snap 2.21 snapd 2.21 series 16 root@ubuntu-core:~#
ÄãÒ²¿ÉÒÔÏñÏÂÃæÕâÑù²é¿´ËùÓÐ snapd µÄÀúÊ·¼Ç¼£º
stgraber@dakara:~$ lxc exec ubuntu-core snap changes ID Status Spawn Ready Summary 1 Done 2017-01-31T05:14:38Z 2017-01-31T05:14:44Z Initialize system state 2 Done 2017-01-31T05:14:40Z 2017-01-31T05:14:45Z Initialize device 3 Done 2017-01-31T05:21:30Z 2017-01-31T05:22:45Z Refresh all snaps in the system
°²×° Snap Èí¼þ°ü
ÒÔÒ»¸ö×î¼òµ¥µÄÀý×Ó¿ªÊ¼£¬¾­µäµÄ Hello World£º
stgraber@dakara:~$ lxc exec ubuntu-core bash root@ubuntu-core:~# snap install hello-world hello-world 6.3 from 'canonical' installed root@ubuntu-core:~# hello-world Hello World!
½ÓÏÂÀ´ÈÃÎÒÃÇ¿´Ò»Ð©¸üÓÐÓõģº
stgraber@dakara:~$ lxc exec ubuntu-core bash root@ubuntu-core:~# snap install nextcloud nextcloud 11.0.1snap2 from 'nextcloud' installed
Ö®ºóͨ¹ý HTTP ·ÃÎÊÄãµÄÈÝÆ÷¾Í¿ÉÒÔ¿´µ½¸Õ²Å²¿ÊðµÄ Nextcloud ʵÀý¡£
Èç¹ûÄãÏëÖ±½Óͨ¹ý git ²âÊÔ×îаæ LXD£¬Äã¿ÉÒÔÕâÑù×ö£º
stgraber@dakara:~$ lxc config set ubuntu-core security.nesting true stgraber@dakara:~$ lxc exec ubuntu-core bash root@ubuntu-core:~# snap install lxd --edge lxd (edge) git-c6006fb from 'canonical' installed root@ubuntu-core:~# lxd init Name of the storage backend to use (dir or zfs) [default=dir]: We detected that you are running inside an unprivileged container. This means that unless you manually configured your host otherwise, you will not have enough uid and gid to allocate to your containers. LXD can re-use your container's own allocation to avoid the problem. Doing so makes your nested containers slightly less safe as they could in theory attack their parent container and gain more privileges than they otherwise would. Would you like to have your containers share their parent's allocation (yes/no) [default=yes]? Would you like LXD to be available over the network (yes/no) [default=no]? Would you like stale cached images to be updated automatically (yes/no) [default=yes]? Would you like to create a new network bridge (yes/no) [default=yes]? What should the new bridge be called [default=lxdbr0]? What IPv4 address should be used (CIDR subnet notation, ¡°auto¡± or ¡°none¡±) [default=auto]? What IPv6 address should be used (CIDR subnet notation, ¡°auto¡± or ¡°none¡±) [default=auto]? LXD has been successfully configured.
ÒѾ­ÉèÖùýµÄÈÝÆ÷²»ÄÜ»ØÍË°æ±¾£¬µ«ÊÇ¿ÉÒÔÔÚ Ubuntu Core 16 ÖÐÔËÐÐÁíÒ»¸ö Ubuntu Core 16 ÈÝÆ÷£º
root@ubuntu-core:~# lxc launch images:ubuntu-core/16 nested-core Creating nested-core Starting nested-core root@ubuntu-core:~# lxc list +-------------+---------+---------------------+-----------------------------------------------+------------+-----------+ | NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | +-------------+---------+---------------------+-----------------------------------------------+------------+-----------+ | nested-core | RUNNING | 10.71.135.21 (eth0) | fd42:2861:5aad:3842:216:3eff:feaf:e6bd (eth0) | PERSISTENT | 0 | +-------------+---------+---------------------+-----------------------------------------------+------------+-----------+
дÔÚ×îºó
Èç¹ûÄãÖ»ÊÇÏëÊÔÓÃһϠUbuntu Core£¬ÕâÊÇÒ»¸ö²»´íµÄ·½·¨¡£¶ÔÓÚ snap °ü¿ª·¢ÕßÀ´Ëµ£¬ÕâÒ²ÊÇÒ»¸ö²»´íµÄ¹¤¾ßÀ´²âÊÔÄãµÄ snap °üÄÜ·ñÔÚ²»Í¬µÄ»·¾³ÏÂÕý³£ÔËÐС£
Èç¹ûÄãÏ£ÍûÄãµÄϵͳ×ÜÊÇ×îеģ¬²¢ÇÒÕûÌå¿É¸´ÖÆ£¬Ubuntu Core ÊÇÒ»¸öºÜ²»´íµÄ·½°¸£¬²»¹ýÕâÒ²»á´øÀ´Ò»Ð©ÏàÓ¦µÄÏÞÖÆ£¬ËùÒÔ¿ÉÄܲ»Ì«ÊʺÏÄã¡£
×îºóÊÇÒ»¸ö¾¯¸æ£¬¶ÔÓÚ²âÊÔÀ´Ëµ£¬ÕâЩ¾µÏñÊÇ×ã¹»µÄ£¬µ«Êǵ±Ç°²¢Ã»Óб»ÕýʽµÄÖ§³Ö¡£ÔÚ²»¾ÃµÄ½«À´£¬¹Ù·½µÄ Ubuntu server ¿ÉÒÔÍêÕûµÄÖ§³Ö Ubuntu Core LXD ¾µÏñ¡£
¸½Â¼
LXD Ö÷Õ¾£ºhttps://linuxcontainers.org/lxd
Github£ºhttps://github.com/lxc/lxd
ÓʼþÁÐ±í£ºhttps://lists.linuxcontainers.org
IRC£º#lxcontainers on irc.freenode.net
ÔÚÏßÊÔÓãºhttps://linuxcontainers.org/lxd/try-it
±¾ÎÄתÔØ×Ô£ºhttp://www.linuxprobe.com/lxd-ubuntucore.html
Ãâ·ÑÌṩ×îÐÂLinux¼¼Êõ½Ì³ÌÊé¼®£¬Îª¿ªÔ´¼¼Êõ°®ºÃÕßŬÁ¦×öµÃ¸ü¶à¸üºÃ£¬¿ªÔ´Õ¾µã£ºhttp://www.linuxprobe.com/
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 1 ÌõÆÀÂÛ

  1. Ronny ÓÚ 2017-11-25 18:17:11·¢±í:

    ʹÓà LXD ÈÝÆ÷ÔËÐÐ Ubuntu Core