Notas de instalación de CentOS7 de LXC
1. Instale la fuente epel de CentOS
El paquete de instalación de LXC se proporciona en la fuente epel de CentOS, y es necesario instalar un paquete de software para utilizar la fuente epel del sitio web oficial.
-
Referencia uno
- Autor: brisa de principios de verano
- Fuente: https://blog.csdn.net/gzqiang08/article/details/81708656
yum -y install epel-release #这个软件包里包含epelyum源和GPG的配置
-
Referencia dos
- Autor: liumiaocn
- Fuente: https://blog.csdn.net/liumiaocn/article/details/52348219
# 在Linux上安装LXC Virtualization yum install epel-release yum install debootstrap perl libvirt yum install lxc lxc-templates systemctl status lxc.service systemctl start lxc.service systemctl start libvirtd systemctl status lxc.service
-
proceso
[root@localhost ~]# yum -y install epel-release
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 epel-release.noarch.0.7-11 将被 安装
--> 解决依赖关系完成
====================================================================================================================================
Package 架构 版本 源 大小
====================================================================================================================================
正在安装:
epel-release noarch 7-11 extras 15 k
事务概要
====================================================================================================================================
...
Running transaction
正在安装 : epel-release-7-11.noarch 1/1
验证中 : epel-release-7-11.noarch 1/1
已安装:
epel-release.noarch 0:7-11
完毕!
2. Instale plantillas lxc y lxc
1) lxc
[root@localhost ~]# yum -y install lxc
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 7.7 kB 00:00:00
* epel: epel.scopesky.iq
epel | 4.7 kB 00:00:00
(1/3): epel/x86_64/group_gz | 88 kB 00:00:00
(2/3): epel/x86_64/primary_db | 6.6 MB 00:00:04
(3/3): epel/x86_64/updateinfo | 960 kB 00:00:11
正在解决依赖关系
--> 正在检查事务
---> 软件包 lxc.x86_64.0.1.0.11-1.el7 将被 安装
--> 正在处理依赖关系 lua-lxc(x86-64) = 1.0.11-1.el7,它被软件包 lxc-1.0.11-1.el7.x86_64 需要
--> 正在处理依赖关系 lua-alt-getopt,它被软件包 lxc-1.0.11-1.el7.x86_64 需要
--> 正在处理依赖关系 liblxc.so.1()(64bit),它被软件包 lxc-1.0.11-1.el7.x86_64 需要
--> 正在检查事务
---> 软件包 lua-alt-getopt.noarch.0.0.7.0-4.el7 将被 安装
---> 软件包 lua-lxc.x86_64.0.1.0.11-1.el7 将被 安装
--> 正在处理依赖关系 lua-filesystem,它被软件包 lua-lxc-1.0.11-1.el7.x86_64 需要
---> 软件包 lxc-libs.x86_64.0.1.0.11-1.el7 将被 安装
--> 正在检查事务
---> 软件包 lua-filesystem.x86_64.0.1.6.2-2.el7 将被 安装
--> 解决依赖关系完成
====================================================================================================================================
Package 架构 版本 源 大小
====================================================================================================================================
正在安装:
lxc x86_64 1.0.11-1.el7 epel 140 k
为依赖而安装:
lua-alt-getopt noarch 0.7.0-4.el7 epel 7.4 k
lua-filesystem x86_64 1.6.2-2.el7 epel 28 k
lua-lxc x86_64 1.0.11-1.el7 epel 17 k
lxc-libs x86_64 1.0.11-1.el7 epel 275 k
事务概要
====================================================================================================================================
...
警告:/var/cache/yum/x86_64/7/epel/packages/lua-filesystem-1.6.2-2.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID 352c64e5: NOKEY
lua-filesystem-1.6.2-2.el7.x86_64.rpm 的公钥尚未安装
(1/5): lua-filesystem-1.6.2-2.el7.x86_64.rpm | 28 kB 00:00:00
(2/5): lua-alt-getopt-0.7.0-4.el7.noarch.rpm | 7.4 kB 00:00:00
(3/5): lua-lxc-1.0.11-1.el7.x86_64.rpm | 17 kB 00:00:00
(4/5): lxc-1.0.11-1.el7.x86_64.rpm | 140 kB 00:00:02
(5/5): lxc-libs-1.0.11-1.el7.x86_64.rpm | 275 kB 00:00:13
------------------------------------------------------------------------------------------------------------------------------------
总计 35 kB/s | 467 kB 00:00:13
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7 检索密钥
导入 GPG key 0x352C64E5:
用户ID : "Fedora EPEL (7) <[email protected]>"
指纹 : 91e9 7d7c 4a5e 96f1 7f3e 888f 6a2f aea2 352c 64e5
软件包 : epel-release-7-11.noarch (@extras)
来自 : /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : lxc-libs-1.0.11-1.el7.x86_64 1/5
正在安装 : lua-filesystem-1.6.2-2.el7.x86_64 2/5
正在安装 : lua-lxc-1.0.11-1.el7.x86_64 3/5
正在安装 : lua-alt-getopt-0.7.0-4.el7.noarch 4/5
正在安装 : lxc-1.0.11-1.el7.x86_64 5/5
验证中 : lua-alt-getopt-0.7.0-4.el7.noarch 1/5
验证中 : lxc-1.0.11-1.el7.x86_64 2/5
验证中 : lxc-libs-1.0.11-1.el7.x86_64 3/5
验证中 : lua-filesystem-1.6.2-2.el7.x86_64 4/5
验证中 : lua-lxc-1.0.11-1.el7.x86_64 5/5
已安装:
lxc.x86_64 0:1.0.11-1.el7
作为依赖被安装:
lua-alt-getopt.noarch 0:0.7.0-4.el7 lua-filesystem.x86_64 0:1.6.2-2.el7 lua-lxc.x86_64 0:1.0.11-1.el7
lxc-libs.x86_64 0:1.0.11-1.el7
完毕!
2) lxc-templates puente-utils lxc-libs libcgroup libvirt
[root@localhost ~]# yum -y install lxc lxc-templates bridge-utils lxc-libs libcgroup libvirt
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* epel: epel.scopesky.iq
软件包 lxc-1.0.11-1.el7.x86_64 已安装并且是最新版本
软件包 bridge-utils-1.5-9.el7.x86_64 已安装并且是最新版本
软件包 lxc-libs-1.0.11-1.el7.x86_64 已安装并且是最新版本
软件包 libcgroup-0.41-20.el7.x86_64 已安装并且是最新版本
正在解决依赖关系
--> 正在检查事务
---> 软件包 libvirt.x86_64.0.4.5.0-10.el7_6.4 将被 安装
--> 正在处理依赖关系 libvirt-daemon-driver-lxc = 4.5.0-10.el7_6.4,它被软件包 libvirt-4.5.0-10.el7_6.4.x86_64 需要
--> 正在处理依赖关系 libvirt-daemon-config-nwfilter = 4.5.0-10.el7_6.4,它被软件包 libvirt-4.5.0-10.el7_6.4.x86_64 需要
--> 正在处理依赖关系 libvirt-client = 4.5.0-10.el7_6.4,它被软件包 libvirt-4.5.0-10.el7_6.4.x86_64 需要
---> 软件包 lxc-templates.x86_64.0.1.0.11-1.el7 将被 安装
--> 正在检查事务
---> 软件包 libvirt-client.x86_64.0.4.5.0-10.el7_6.4 将被 安装
--> 正在处理依赖关系 libvirt-bash-completion = 4.5.0-10.el7_6.4,它被软件包 libvirt-client-4.5.0-10.el7_6.4.x86_64 需要
--> 正在处理依赖关系 gnutls-utils,它被软件包 libvirt-client-4.5.0-10.el7_6.4.x86_64 需要
---> 软件包 libvirt-daemon-config-nwfilter.x86_64.0.4.5.0-10.el7_6.4 将被 安装
---> 软件包 libvirt-daemon-driver-lxc.x86_64.0.4.5.0-10.el7_6.4 将被 安装
--> 正在检查事务
---> 软件包 gnutls-utils.x86_64.0.3.3.29-8.el7 将被 安装
--> 正在处理依赖关系 gnutls-dane(x86-64) = 3.3.29-8.el7,它被软件包 gnutls-utils-3.3.29-8.el7.x86_64 需要
--> 正在处理依赖关系 libgnutls-dane.so.0(DANE_0_0)(64bit),它被软件包 gnutls-utils-3.3.29-8.el7.x86_64 需要
--> 正在处理依赖关系 libgnutls-dane.so.0()(64bit),它被软件包 gnutls-utils-3.3.29-8.el7.x86_64 需要
---> 软件包 libvirt-bash-completion.x86_64.0.4.5.0-10.el7_6.4 将被 安装
--> 正在检查事务
---> 软件包 gnutls-dane.x86_64.0.3.3.29-8.el7 将被 安装
--> 解决依赖关系完成
====================================================================================================================================
Package 架构 版本 源 大小
====================================================================================================================================
正在安装:
libvirt x86_64 4.5.0-10.el7_6.4 updates 182 k
lxc-templates x86_64 1.0.11-1.el7 epel 81 k
为依赖而安装:
gnutls-dane x86_64 3.3.29-8.el7 base 36 k
gnutls-utils x86_64 3.3.29-8.el7 base 238 k
libvirt-bash-completion x86_64 4.5.0-10.el7_6.4 updates 183 k
libvirt-client x86_64 4.5.0-10.el7_6.4 updates 479 k
libvirt-daemon-config-nwfilter x86_64 4.5.0-10.el7_6.4 updates 189 k
libvirt-daemon-driver-lxc x86_64 4.5.0-10.el7_6.4 updates 314 k
事务概要
====================================================================================================================================
安装 2 软件包 (+6 依赖软件包)
......
Downloading packages:
(1/8): gnutls-dane-3.3.29-8.el7.x86_64.rpm | 36 kB 00:00:00
(2/8): libvirt-4.5.0-10.el7_6.4.x86_64.rpm | 182 kB 00:00:00
(3/8): libvirt-bash-completion-4.5.0-10.el7_6.4.x86_64.rpm | 183 kB 00:00:00
(4/8): libvirt-daemon-config-nwfilter-4.5.0-10.el7_6.4.x86_64.rpm | 189 kB 00:00:00
(5/8): libvirt-client-4.5.0-10.el7_6.4.x86_64.rpm | 479 kB 00:00:00
(6/8): gnutls-utils-3.3.29-8.el7.x86_64.rpm | 238 kB 00:00:00
(7/8): libvirt-daemon-driver-lxc-4.5.0-10.el7_6.4.x86_64.rpm | 314 kB 00:00:00
(8/8): lxc-templates-1.0.11-1.el7.x86_64.rpm | 81 kB 00:00:00
------------------------------------------------------------------------------------------------------------------------------------
总计 1.3 MB/s | 1.7 MB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在安装 : libvirt-daemon-driver-lxc-4.5.0-10.el7_6.4.x86_64 1/8
正在安装 : libvirt-daemon-config-nwfilter-4.5.0-10.el7_6.4.x86_64 2/8
正在安装 : gnutls-dane-3.3.29-8.el7.x86_64 3/8
正在安装 : gnutls-utils-3.3.29-8.el7.x86_64 4/8
正在安装 : libvirt-bash-completion-4.5.0-10.el7_6.4.x86_64 5/8
正在安装 : libvirt-client-4.5.0-10.el7_6.4.x86_64 6/8
正在安装 : libvirt-4.5.0-10.el7_6.4.x86_64 7/8
正在安装 : lxc-templates-1.0.11-1.el7.x86_64 8/8
验证中 : libvirt-bash-completion-4.5.0-10.el7_6.4.x86_64 1/8
验证中 : lxc-templates-1.0.11-1.el7.x86_64 2/8
验证中 : gnutls-dane-3.3.29-8.el7.x86_64 3/8
验证中 : libvirt-daemon-config-nwfilter-4.5.0-10.el7_6.4.x86_64 4/8
验证中 : libvirt-client-4.5.0-10.el7_6.4.x86_64 5/8
验证中 : libvirt-daemon-driver-lxc-4.5.0-10.el7_6.4.x86_64 6/8
验证中 : libvirt-4.5.0-10.el7_6.4.x86_64 7/8
验证中 : gnutls-utils-3.3.29-8.el7.x86_64 8/8
已安装:
libvirt.x86_64 0:4.5.0-10.el7_6.4 lxc-templates.x86_64 0:1.0.11-1.el7
作为依赖被安装:
gnutls-dane.x86_64 0:3.3.29-8.el7 gnutls-utils.x86_64 0:3.3.29-8.el7
libvirt-bash-completion.x86_64 0:4.5.0-10.el7_6.4 libvirt-client.x86_64 0:4.5.0-10.el7_6.4
libvirt-daemon-config-nwfilter.x86_64 0:4.5.0-10.el7_6.4 libvirt-daemon-driver-lxc.x86_64 0:4.5.0-10.el7_6.4
完毕!
3. Prueba
- systemctl status lxc.service
[root@localhost ~]# systemctl status lxc.service
● lxc.service - LXC Container Initialization and Autoboot Code
Loaded: loaded (/usr/lib/systemd/system/lxc.service; disabled; vendor preset: disabled)
Active: inactive (dead)
- systemctl start lxc.service
[root@localhost ~]# systemctl start lxc.service
[root@localhost ~]# systemctl start libvirtd
- systemctl status lxc.service
[root@localhost ~]# systemctl status lxc.service
● lxc.service - LXC Container Initialization and Autoboot Code
Loaded: loaded (/usr/lib/systemd/system/lxc.service; disabled; vendor preset: disabled)
Active: active (exited) since 六 2019-03-02 11:19:41 CST; 18s ago
Process: 23161 ExecStart=/usr/libexec/lxc/lxc-autostart-helper start (code=exited, status=0/SUCCESS)
Process: 23152 ExecStartPre=/usr/libexec/lxc/lxc-devsetup (code=exited, status=0/SUCCESS)
Main PID: 23161 (code=exited, status=0/SUCCESS)
Tasks: 0
Memory: 0B
CGroup: /system.slice/lxc.service
3月 02 11:19:41 localhost.localdomain systemd[1]: Starting LXC Container Initialization and Autoboot Code...
3月 02 11:19:41 localhost.localdomain lxc-devsetup[23152]: Creating /dev/.lxc
3月 02 11:19:41 localhost.localdomain lxc-devsetup[23152]: /dev is devtmpfs
3月 02 11:19:41 localhost.localdomain lxc-devsetup[23152]: Creating /dev/.lxc/user
3月 02 11:19:41 localhost.localdomain lxc-autostart-helper[23161]: Starting LXC autoboot containers: [ 确定 ]
3月 02 11:19:41 localhost.localdomain systemd[1]: Started LXC Container Initialization and Autoboot Code.
- lxc-checkconfig
[root@localhost ~]# lxc-checkconfig
Kernel configuration not found at /proc/config.gz; searching...
Kernel configuration found at /boot/config-3.10.0-693.el7.x86_64
--- Namespaces ---
Namespaces: enabled
Utsname namespace: enabled
Ipc namespace: enabled
Pid namespace: enabled
User namespace: enabled
newuidmap is not installed
newgidmap is not installed
Network namespace: enabled
Multiple /dev/pts instances: enabled
--- Control groups ---
Cgroup: enabled
Cgroup clone_children flag: enabled
Cgroup device: enabled
Cgroup sched: enabled
Cgroup cpu account: enabled
Cgroup memory controller: enabled
Cgroup cpuset: enabled
--- Misc ---
Veth pair device: enabled
Macvlan: enabled
Vlan: enabled
Bridges: enabled
Advanced netfilter: enabled
CONFIG_NF_NAT_IPV4: enabled
CONFIG_NF_NAT_IPV6: enabled
CONFIG_IP_NF_TARGET_MASQUERADE: enabled
CONFIG_IP6_NF_TARGET_MASQUERADE: enabled
CONFIG_NETFILTER_XT_TARGET_CHECKSUM: enabled
--- Checkpoint/Restore ---
checkpoint restore: enabled
CONFIG_FHANDLE: enabled
CONFIG_EVENTFD: enabled
CONFIG_EPOLL: enabled
CONFIG_UNIX_DIAG: enabled
CONFIG_INET_DIAG: enabled
CONFIG_PACKET_DIAG: enabled
CONFIG_NETLINK_DIAG: enabled
File capabilities: enabled
Note : Before booting a new kernel, you can check its configuration
usage : CONFIG=/path/to/config /usr/bin/lxc-checkconfig
----- EL FIN -----