当前位置:网站首页>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+]
边栏推荐
- R语言使用原生包(基础导入包、graphics)中的hist函数可视化直方图(histogram plot)
- Cacti监控Redis实现过程
- OpenStack中的测试分类
- mysql使用update联表更新的方法
- Ripper of vulnhub
- Phpcms prompt message page Jump showmessage
- 同事写了一个责任链模式,bug无数...
- 鸿蒙第三次培训(项目实训)
- Visual Studio 2022下载及配置OpenCV4.5.5
- This article explains the complex relationship between MCU, arm, MCU, DSP, FPGA and embedded system
猜你喜欢

Based on MCU, how to realize OTA differential upgrade with zero code and no development?

软考中级软件设计师该怎么备考

Multi dimensional monitoring: the data base of intelligent monitoring

Hongmeng third training (project training)

Machine learning 3.2 decision tree model learning notes (to be supplemented)

量化计算调研

Cadence background color setting

《剑指offer 04》二维数组查找

2022年湖南工学院ACM集训第二次周测题解

vulnhub之cereal
随机推荐
量化计算调研
(database authorization - redis) summary of unauthorized access vulnerabilities in redis
The excel table is transferred to word, and the table does not exceed the edge paper range
鸿蒙第四次培训
DS90UB949
Phpcms prompt message page Jump showmessage
Excel表格转到Word中,表格不超边缘纸张范围
AOSP ~ NTP ( 网络时间协议 )
How should intermediate software designers prepare for the soft test
Solicitation for JGG special issue: spatio-temporal omics
Linear table sequence table comprehensive application problem p18
外插散点数据
Web安全总结
Using onvif protocol to operate the device
R language uses the aggregate function to calculate the mean value (sum) of dataframe data grouping aggregation without setting na The result of RM calculation. If the group contains the missing value
OpenStack中的测试分类
Modular programming of single chip microcomputer
R语言使用原生包(基础导入包、graphics)中的hist函数可视化直方图(histogram plot)
FL Studio 20 unlimited trial fruit arranger Download
PHP基础