当前位置:网站首页>Experience container in libvirt
Experience container in libvirt
2022-07-03 11:49:00 【Brother Xing plays with the clouds】
libvirt Is a general virtualization framework , Support xen,kvm,lxc A variety of virtualization technologies , This article is a note .
Set up LXC As the default ( The default is qemu)
export LIBVIRT_DEFAULT_URI=lxc:///
virsh -c lxc:/// Omission
Network settings
NAT
NAT yes libvirt Default by oneself , be called default, Through the following Command view
virsh net-list
Suppose the host has two network cards ,eth0 For the intranet ,eth1 For the Internet , We can bridge out two interfaces for the container :
#cat lan.xml
<network>
<name>lan</name>
<forward mode="bridge" />
<interface dev="eth0" />
</network>
#cat wan.xml
<network>
<name>wan</name>
<forward mode="bridge" />
<interface dev="eth1" />
</network>
Import configuration
virsh net-define lan.xm
virsh net-define wan.xml
Open network card
virsh net-start lan
virsh net-autostart lan
virsh net-start wan
virsh net-autostart wan
Application container
The application container shares various resources of the host , Include kernel , Various software packages , Various libraries , It only has an independent running space , Like a sandbox environment .
Create a file called web Application container for
cat web.xml
<domain type="lxc">
<name>web</name>
<memory>102400</memory>
<os>
<type>exec</type>
<init>/bin/sh</init>
</os>
<device>
<console type="pty" />
</device>
</domain>
Import virsh
virsh define web.xml
Boot up
virsh autostart web
Into the container
virsh console web
Edit container configuration
virsh edit web
Delete container
virsh undefine web
Operating system container
Operating system container except Linux kernel , It includes a complete set of operating environment , It's like a chroot Environmental Science .
Operating system container creation is a little more complicated
1、 Create the root directory
mkdir -p /lxc/CentOS7
2、 Download and unzip the image http://images.linuxcontainers.org/images/centos/7/amd64/default/20140807_02:37/rootfs.tar.xz
cd /lxc/centos7
wget xxx
xz -d rootfs.tar.xz
tar xvf rootfs.tar
3、 establish xml Templates
cat centos7.xml
<domain type="lxc">
<name>centos7</name>
<memory unit="KiB">1048576</memory>
<currentMemory unit="KiB">1048576</currentMemory>
<resource>
<partition>/machine</partition>
</resource>
<os>
<clock offset='utc' />
<on_poweroff>destory</on_poweroff>
<on_reboot>restart</on_reboot>
<on_crash>restart<on_crash>
</devices>
<emulator>/usr/lib/libvirt/libvirt_lxc</emulator>
<filesystem type='mount' accessmode='passthrough'>
<source dir='/lxc/centos7'/>
<target dir='/'/>
</filesystem>
<interface type='network'>
<mac address='00:16:3e:52:87:f1'/>
<source network='lan'/>
</interface>
<console type='pty'>
<target type='lxc' port='0'/>
</console>
</devices>
</domain>
Import container
virsh define centos7.xml
Start the container
virsh start centos7
virsh autostart centos7
Into the container
virsh console centos7
Stop and start
virsh autostart --disable centos7
sign out lxc console
ctrl+]
边栏推荐
- vulnhub之cereal
- Spl06-007 air pressure sensor (example of barometer)
- Linear table sequence table comprehensive application problem p18
- 鸿蒙第四次培训
- Understand go language context in one article
- Machine learning 3.2 decision tree model learning notes (to be supplemented)
- 银泰百货点燃城市“夜经济”
- R语言使用gridExtra包的grid.arrange函数将lattice包的多个可视化图像横向组合起来,ncol参数自定义组合图列数、nrow参数自定义组合图行数
- Multi dimensional monitoring: the data base of intelligent monitoring
- VS2015的下载地址和安装教程
猜你喜欢

836. 合并集合(DAY 63)并查集

vulnhub之Ripper

C language AES encryption and decryption

Analysis of EPS electric steering system

导师对帮助研究生顺利完成学业提出了20条劝告:第一,不要有度假休息的打算.....

Spl06-007 air pressure sensor (example of barometer)

STL tutorial 10 container commonalities and usage scenarios

牛牛的组队竞赛

Hongmeng third training (project training)

vulnhub之narak
随机推荐
2022年湖南工学院ACM集训第二次周测题解
OpenStack中的测试分类
Stm32hal library upgrades firmware based on flash analog U disk (detailed explanation)
Kibana~Kibana的安装和配置
R语言ggplot2可视化:gganimate包创建动态折线图动画(gif)、使用transition_reveal函数在动画中沿给定维度逐步显示数据、在折线移动方向添加数据点
The tutor put forward 20 pieces of advice to help graduate students successfully complete their studies: first, don't plan to take a vacation
聊聊Flink框架中的状态管理机制
【学习笔记】dp 状态与转移
Multi dimensional monitoring: the data base of intelligent monitoring
Web安全总结
Linear table sequence table comprehensive application problem p18
Vulnhub's cereal
Go语言实现静态服务器
Sheet1$.输出[Excel 源输出].列[XXX] 出错。返回的列状态是:“文本被截断,或者一个或多个字符在目标代码页中没有匹配项。”。
Spl06-007 air pressure sensor (example of barometer)
Dynamic programming (interval DP)
《剑指offer 04》二维数组查找
VS2015的下载地址和安装教程
Vulnhub geminiinc V2
CSRF