当前位置:网站首页>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+]
边栏推荐
- 2022年中南大学夏令营面试经验
- (数据库提权——Redis)Redis未授权访问漏洞总结
- MySQL searches and sorts out common methods according to time
- vulnhub之cereal
- uniapp实现点击加载更多
- Some common terms
- Numpy np.max和np.maximum实现relu函数
- Software testing weekly (issue 78): the more confident you are about the future, the more patient you are about the present.
- Excel快速跨表复制粘贴
- R语言ggplot2可视化:gganimate包创建动态折线图动画(gif)、使用transition_reveal函数在动画中沿给定维度逐步显示数据、在折线移动方向添加数据点
猜你喜欢
金额计算用 BigDecimal 就万无一失了?看看这五个坑吧~~
The uniapp scroll view solves the problems of high adaptability and bullet frame rolling penetration.
Gut | Yu Jun group of the Chinese University of Hong Kong revealed that smoking changes intestinal flora and promotes colorectal cancer (do not smoke)
PHP Basics
vulnhub之presidential
小鹏 P7 撞护栏安全气囊未弹出,官方回应称撞击力度未达到弹出要求
PHP基础
vulnhub之GeminiInc
软考中级软件设计师该怎么备考
Web安全总结
随机推荐
libvirt 中体验容器
Excel快速跨表复制粘贴
This article explains the complex relationship between MCU, arm, MCU, DSP, FPGA and embedded system
Some common terms
Vulnhub geminiinc V2
Uniapp implementation Click to load more
并发编程-单例
软考中级软件设计师该怎么备考
一些常用术语
Redis things
利用Zabbix动态监控磁盘I/O
vulnhub之cereal
Qt+VTK+OCCT读取IGES/STEP模型
Numpy np. Max and np Maximum implements the relu function
抓包整理外篇fiddler———— 会话栏与过滤器[二]
外插散点数据
vulnhub之narak
Linear table sequence table comprehensive application problem p18
量化计算调研
CSRF