当前位置:网站首页>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+]
边栏推荐
- Capturing and sorting out external Fiddler -- Conversation bar and filter [2]
- R语言使用原生包(基础导入包、graphics)中的hist函数可视化直方图(histogram plot)
- CSRF
- Ripper of vulnhub
- typeScript
- (database authorization - redis) summary of unauthorized access vulnerabilities in redis
- 机器学习 3.2 决策树模型 学习笔记(待补)
- DNS多点部署IP Anycast+BGP实战分析
- 剑指offer专项32-96题做题笔记
- Program process management tool -go Supervisor
猜你喜欢

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

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

聊聊Flink框架中的状态管理机制

Analysis of EPS electric steering system

This article explains the complex relationship between MCU, arm, MCU, DSP, FPGA and embedded system
![Capturing and sorting out external Fiddler -- Conversation bar and filter [2]](/img/04/e9cc027d753e7049f273d866eefdce.png)
Capturing and sorting out external Fiddler -- Conversation bar and filter [2]

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

Xml的(DTD,xml解析,xml建模)

ASP. Net hotel management system

Hongmeng third training (project training)
随机推荐
R语言使用原生包(基础导入包、graphics)中的hist函数可视化直方图(histogram plot)
This article explains the complex relationship between MCU, arm, MCU, DSP, FPGA and embedded system
Nestjs configuration service, configuring cookies and sessions
2022年中南大学夏令营面试经验
剑指offer专项32-96题做题笔记
2022年湖南工学院ACM集训第二次周测题解
mysql使用update联表更新的方法
Program process management tool -go Supervisor
Phpcms prompt message page Jump showmessage
MCDF实验1
Machine learning 3.2 decision tree model learning notes (to be supplemented)
Excel表格转到Word中,表格不超边缘纸张范围
Unity3D学习笔记5——创建子Mesh
typeScript
Yintai department store ignites the city's "night economy"
cgroup简介
量化计算调研
Xml的(DTD,xml解析,xml建模)
Programmers' entrepreneurial trap: taking private jobs
Phpcms prompt message page Jump to showmessage