KVM虚拟机常用操作(2)
2018-01-06 18:46
267 查看
一、创建虚拟机
命令行创建
virt-install --graphics none --name=centos2 --ram=1024 --disk path=/home/kvm/centos2.img,format=qcow2,size=20 --vcpus 1 --os-type linux --os-variant rhel6 --network bridge=br0 --console pty,target_type=serial --location /home/iso/CentOS-6.8-x86_64-bin-DVD1.iso --extra-args 'console=ttyS0,115200n8 serial'
图形界面创建
1.
2.
3.
4.
5.
二、 重命名虚拟机
停止虚拟机
[root@localhost qemu]# virsh shutdown moban1
Domain moban1 is being shutdown
更改配置文件
[root@localhost qemu]# virsh dumpxml moban1 > test1.xml
[root@localhost qemu]# sed -i 's/>moban1</>test1</g' test1.xml
[root@localhost qemu]# virsh undefine moban1
Domain moban1 has been undefined
[root@localhost qemu]# virsh define test1.xml
Domain test1 defined from test1.xml
[root@localhost qemu]# virsh start test1
4.图形界面,关机直接改名字
三、虚拟机快照管理
虚拟机创建快照,快照一定需要qcow2格式
创建测试文件
[root@moban1 ~]# ls
anaconda-ks.cfg install.log install.log.syslog
[root@moban1 ~]# touch snapshotfortest
[root@moban1 ~]# echo "hello world" > snapshotfortest
[root@moban1 ~]# cat snapshotfortest
hello world
3.创建快照、查看快照、恢复快照、删除快照
创建快照
[root@localhost qemu]# virsh snapshot-create test1
Domain snapshot 1515234198 created
查看快照
恢复快照
[root@localhost qemu]# virsh snapshot-revert test1 1515234198
验证
删除快照
命令行创建
virt-install --graphics none --name=centos2 --ram=1024 --disk path=/home/kvm/centos2.img,format=qcow2,size=20 --vcpus 1 --os-type linux --os-variant rhel6 --network bridge=br0 --console pty,target_type=serial --location /home/iso/CentOS-6.8-x86_64-bin-DVD1.iso --extra-args 'console=ttyS0,115200n8 serial'
图形界面创建
1.
2.
3.
4.
5.
二、 重命名虚拟机
停止虚拟机
[root@localhost qemu]# virsh shutdown moban1
Domain moban1 is being shutdown
更改配置文件
[root@localhost qemu]# virsh dumpxml moban1 > test1.xml
[root@localhost qemu]# sed -i 's/>moban1</>test1</g' test1.xml
[root@localhost qemu]# virsh undefine moban1
Domain moban1 has been undefined
[root@localhost qemu]# virsh define test1.xml
Domain test1 defined from test1.xml
[root@localhost qemu]# virsh start test1
4.图形界面,关机直接改名字
三、虚拟机快照管理
虚拟机创建快照,快照一定需要qcow2格式
创建测试文件
[root@moban1 ~]# ls
anaconda-ks.cfg install.log install.log.syslog
[root@moban1 ~]# touch snapshotfortest
[root@moban1 ~]# echo "hello world" > snapshotfortest
[root@moban1 ~]# cat snapshotfortest
hello world
3.创建快照、查看快照、恢复快照、删除快照
创建快照
[root@localhost qemu]# virsh snapshot-create test1
Domain snapshot 1515234198 created
查看快照
恢复快照
[root@localhost qemu]# virsh snapshot-revert test1 1515234198
验证
删除快照
相关文章推荐
- kvm虚拟机操作常用命令
- shell常用操作
- 常用vi操作
- Oracle - 用户相关常用操作语句
- mysql常用操作总结
- 文本建模常用的预处理方法——删除停顿词和stem操作的处理顺序
- Mysql的常用操作
- vi常用操作
- ASP编程中连接数据库和数据库操作的常用代码
- swift3.0常用操作包含删除字符串(string),更换字符串,插入字符串
- lua堆栈操作常用函数学习二
- 常用的几种文件读写操作
- 玩转Linux - 常用的命令和操作
- POI操作Excel常用方法总结
- Java之Javassist对类的常用操作小结-yellowcong
- ASP.NET中Gridview读取数据表列表页面常用操作-序号,编辑,删除,删除确认
- MongoDB使用小结:一些常用操作分享
- string.h中常用字符串操作函数
- DataGridView新特色、常用操作
- POI操作Excel常用方法总结