当前位置:网站首页>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's cereal
Based on MCU, how to realize OTA differential upgrade with zero code and no development?
DS90UB949
Web安全总结
Ripper of vulnhub
vulnhub之narak
uniapp scroll view 解决高度自适应、弹框滚动穿透等问题。
2022 northeast four provinces match VP record / supplementary questions
Mmc5603nj geomagnetic sensor (Compass example)
软考中级软件设计师该怎么备考
随机推荐
How PHP solves the problem of high concurrency
The world's most popular font editor FontCreator tool
一些常用术语
Use typora to draw flow chart, sequence diagram, sequence diagram, Gantt chart, etc. for detailed explanation
Excel表格转到Word中,表格不超边缘纸张范围
简单工厂和工厂方法模式
Cadence background color setting
This article explains the complex relationship between MCU, arm, MCU, DSP, FPGA and embedded system
VS2015的下载地址和安装教程
vulnhub之presidential
.\vmware-vdiskmanager.exe -k “c:\\xxxxx.vmdk”
Qt+VTK+OCCT读取IGES/STEP模型
Software testing weekly (issue 78): the more confident you are about the future, the more patient you are about the present.
金额计算用 BigDecimal 就万无一失了?看看这五个坑吧~~
After watching the video, AI model learned to play my world: cutting trees, making boxes, making stone picks, everything is good
Using onvif protocol to operate the device
R language uses data The table package performs data aggregation statistics, calculates window statistics, calculates the median of sliding groups, and merges the generated statistical data into the o
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
Excel快速跨表复制粘贴
After using the thread pool for so long, do you really know how to reasonably configure the number of threads?