当前位置:网站首页>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+]
边栏推荐
- uniapp实现点击加载更多
- 同事写了一个责任链模式,bug无数...
- Numpy np.max和np.maximum实现relu函数
- 2022 东北四省赛 VP记录/补题
- 小鹏 P7 撞护栏安全气囊未弹出,官方回应称撞击力度未达到弹出要求
- phpcms 提示信息頁面跳轉showmessage
- Machine learning 3.2 decision tree model learning notes (to be supplemented)
- 软考中级软件设计师该怎么备考
- MySQL uses the method of updating linked tables with update
- P3250 [hnoi2016] Network + [necpc2022] f.tree path tree section + segment tree maintenance heap
猜你喜欢

ftp登录时,报错“530 Login incorrect.Login failed”

Yintai department store ignites the city's "night economy"

(database authorization - redis) summary of unauthorized access vulnerabilities in redis

Numpy np.max和np.maximum实现relu函数

STL教程10-容器共性和使用场景

Multi dimensional monitoring: the data base of intelligent monitoring

Web security summary

STL教程9-容器元素深拷贝和浅拷贝问题

Vulnhub geminiinc V2

量化计算调研
随机推荐
Key switch: press FN when pressing F1-F12
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
Phpcms prompt message page Jump showmessage
P3250 [hnoi2016] Network + [necpc2022] f.tree path tree section + segment tree maintenance heap
Uniapp implementation Click to load more
This article explains the complex relationship between MCU, arm, MCU, DSP, FPGA and embedded system
【学习笔记】dp 状态与转移
剑指offer专项32-96题做题笔记
MySQL union和union all区别
Nestjs configuration service, configuring cookies and sessions
PHP server interacts with redis with a large number of close_ Wait analysis
Viewing binary bin files with notepad++ editor
DS90UB949
typeScript
The R language uses the hist function in the native package (basic import package, graphics) to visualize the histogram plot
软考中级软件设计师该怎么备考
Hongmeng third training (project training)
cgroup简介
.\vmware-vdiskmanager.exe -k “c:\\xxxxx.vmdk”
P3250 [HNOI2016] 网络 + [NECPC2022] F.Tree Path 树剖+线段树维护堆