kmv 学习笔记 工具
qemu:kmv的文本管理工具,包括qemu-kvm、qemu-img
libvirt:是一套免费、开源的支持Linux下主流虚拟化工具的C函数库,libvirtd是运行的守护进程的名称。包括GUI: virt-manager, virt-viewer,CLI: virt-install, virsh
使用virsh测试各命令及创建虚拟机
1. 获取各命令帮助
virsh help KEYWORD
#virsh help list
2. 查看域,–all选项可查看关机的虚拟机域,域id每次开关机后可能不一样
root@localhost ~]# virsh list –all
Id Name State
—————————————————-
– debian8 shut off
3. 查看虚拟机配置文件
注意为xml格式,可以到处到某处查看或以此为模板创建其他虚拟机
虚拟机以域(domain)为单位创建
# virsh dumpxml debian8 > /tmp/mytemplate.xml
4. 创建域
create
virsh create <file> [–console] [–paused] [–autodestroy] [–pass-fds <string>] [–validate]
[–file] <string> file containing an XML domain description
–console attach to console after creation
–paused leave the guest paused after creation
–autodestroy automatically destroy the guest when virsh disconnects
–pass-fds <string> pass file descriptors N,M,… to the guest
–validate validate the XML against the schema
5. 获取域id
[root@localhost ~]# virsh domid debian8
3
6. 获取域uuid
[root@localhost ~]# virsh domuuid debian8
9332c5a4-4abc-4e7f-bec0-faf394950a55
7. 获取域信息
[root@localhost ~]# virsh dominfo debian8
Id: 3
Name: debian8
UUID: 9332c5a4-4abc-4e7f-bec0-faf394950a55
OS Type: hvm
State: running
CPU(s): 2
CPU time: 428.6s
Max memory: 1047552 KiB
Used memory: 1047552 KiB
Persistent: yes
Autostart: disable
Managed save: no
Security model: selinux
Security DOI: 0
Security label: system_u:system_r:svirt_t:s0:c327,c602 (enforcing)
8. 登录虚拟机控制台
[root@localhost ~]# virsh console debian8
Connected to domain debian8
Escape character is ^]
使用ctrl+],退出console
9. 开启域
[root@localhost ~]# virsh start debian8
Domain debian8 started
10. 重启域
reboot
11. 关闭域
destory
shutdown
12. 删除域
undefine
13. 暂停域并保存域状态至某文件中
# virsh save debian8 /tmp/debian_save1 –running
–running 下次恢复,直接启动
14. 从保存文件中恢复域
# virsh restore /tmp/debian_save1
管理域的命令:
15. 改变内存大小
不能超出预设值,只能调小,可以当前生效,也可以下次生效
# virsh setmem debian8 786m –current
[root@localhost ~]# virsh dominfo debian8
Id: 5
Name: debian8
UUID: 9332c5a4-4abc-4e7f-bec0-faf394950a55
OS Type: hvm
State: running
CPU(s): 2
CPU time: 1471.5s
Max memory: 1047552 KiB
Used memory: 804864 KiB #此处为改过的值
Persistent: yes
Autostart: disable
Managed save: no
Security model: selinux
Security DOI: 0
Security label: system_u:system_r:svirt_t:s0:c470,c985 (enforcing)
[root@localhost ~]# free -mh
total used free shared buff/cache available
Mem: 977M 741M 73M 4.2M 162M 64M
Swap: 1.9G 1.1G 827M
16. 设定内存最大内存
运行中的域不能修改最大内存值
[root@localhost ~]# virsh setmaxmem debian8 900m –config
下次启动有效
17. 设定vcpu数量
# virsh setvcpus debian8 1 –config
不能实时改,下次启动有效
18. 获取vcpu信息
[root@localhost ~]# virsh vcpuinfo debian8
VCPU: 0 #vcpu
CPU: 0 #在宿主机cpu位置
State: running
CPU time: 675.5s
CPU Affinity: yyyy
VCPU: 1
CPU: 1
State: running
CPU time: 694.2s
CPU Affinity: yyyy
19. 获取域网络接口信息
[root@localhost ~]# virsh domiflist debian8
Interface Type Source Model MAC
——————————————————-
vnet0 network default virtio 52:54:00:82:53:a2
20. 获取域的接口统计信息
[root@localhost ~]# virsh domifstat debian8 vnet0
vnet0 rx_bytes 197810
vnet0 rx_packets 3755
vnet0 rx_errs 0
vnet0 rx_drop 0
vnet0 tx_bytes 13400
vnet0 tx_packets 111
vnet0 tx_errs 0
vnet0 tx_drop 0
21. 获取域块设备信息
[root@localhost ~]# virsh domblklist debian8
Target Source
————————————————
vda /var/lib/libvirt/images/debian8.qcow2
hda –
22. 获取域块设备(存储)统计信息
[root@localhost ~]# virsh domblkstat debian8
rd_req 21908
rd_bytes 670065746
wr_req 1105
wr_bytes 29772800
flush_operations 229
rd_total_times 97947369758
wr_total_times 60546346501
flush_total_times 1534616225
创建及管理磁盘:
23. 创建磁盘
[root@localhost ~]# qemu-img create -f qcow2 -o preallocation=metadata /tmp/test.qcow2 120G 稀疏格式
Formatting '/tmp/test.qcow2', fmt=qcow2 size=128849018880 encryption=off cluster_size=65536 preallocation='metadata' lazy_refcounts=off
[root@localhost ~]# du -lh /tmp/test.qcow2
19M /tmp/test.qcow2
[root@localhost ~]# ll -lh /tmp/test.qcow2
-rw-r–r–. 1 root root 121G Jan 12 13:53 /tmp/test.qcow2
24. 增加磁盘大小
[root@localhost ~]# qemu-img resize /tmp/test.qcow2 150G
Image resized.
[root@localhost ~]# ll -h /tmp/test.qcow2
-rw-r–r–. 1 root root 121G Jan 12 13:57 /tmp/test.qcow2
[root@localhost ~]# du -lh /tmp/test.qcow2
19M /tmp/test.qcow2
25. 附加磁盘到域
# qemu-img create -f qcow2 -o preallocation=metadata /tmp/mytest.img 20G
[root@localhost ~]# virsh attach-disk debian8 /tmp/mytest.img vdb
Disk attached successfully
26. 拆除磁盘
[root@localhost ~]# virsh detach-disk debian8 vdb
Disk detached successfully
网卡管理
网桥查看命令
[root@localhost ~]# brctl show
bridge name bridge id STP enabled interfaces
br0 8000.000000000000 no
virbr0 8000.525400571a76 yes virbr0-nic
vnet0
27.添加域网卡到宿主机桥上
[root@localhost ~]# virsh attach-interface debian8 bridge virbr0 为宿主机nat网桥
Interface attached successfully
[root@localhost ~]# virsh domiflist debian8
Interface Type Source Model MAC
——————————————————-
vnet0 network default virtio 52:54:00:82:53:a2
vnet1 bridge virbr0 rtl8139 52:54:00:ca:04:d3
vnet2 bridge br0 rtl8139 52:54:00:89:3b:1d
28. 删除域网卡
[root@localhost ~]# virsh detach-interface debian8 bridge –mac 52:54:00:89:3b:1d
Interface detached successfully
使用qemu命令手动创建虚拟机
qemu-kvm为创建工具
kmv 学习笔记 工具的更多相关文章
- PowerDesigner16工具学习笔记-工具介绍
1.初始界面 1.1 .浏览窗口:本地(Local)浏览窗口.知识库(Repository)浏览窗口 Local:用于显示本地模型 Repository:用于显示知识库模型 1.2 .输出窗口:用于显 ...
- 20151212jquery学习笔记--工具函数
工具函数是指直接依附于 jQuery 对象,针对 jQuery 对象本身定义的方法,即全局性 的函数.它的作用主要是提供比如字符串.数组.对象等操作方面的遍历. 一.字符串操作 在 jQuery 中, ...
- vue.js 源代码学习笔记 ----- 工具方法 option
/* @flow */ import Vue from '../instance/index' import config from '../config' import { warn } from ...
- vue.js 源代码学习笔记 ----- 工具方法 env
/* @flow */ /* globals MutationObserver */ import { noop } from 'shared/util' // can we use __proto_ ...
- Cesium学习笔记-工具篇20-PrimitiveTexture自定义渲染-贴图【转】
前几篇博客我们了解了自定义点.线.面绘制,这篇我们接着学习cesium自定义纹理贴图.我们完成点线面的绘制,只是绘制出了对象的框架,没有逼真的外观.逼真外观是需要设置材质来实现:Material . ...
- JMeter学习笔记--工具简单介绍
一.JMeter 介绍 Apache JMeter是纯JAVA桌面应用程序,被设计为用于测试客户端/服务端结构的软件(例如web应用程序).它可以用来测试静态和动态资源的性能,例如:静态文件,Java ...
- angularjs学习笔记—工具方法
angular.bind(self, fn, args) 作用:返回一个新的函数,绑定这个函数的this指向self 参数: self:新函数的上下文对象 fn:需要绑定的函数 args:传递给函数的 ...
- vue.js 源代码学习笔记 ----- 工具方法 props
/* @flow */ import { hasOwn, isObject, isPlainObject, capitalize, hyphenate } from 'shared/util' imp ...
- vue.js 源代码学习笔记 ----- 工具方法 share
/* @flow */ /** * Convert a value to a string that is actually rendered. { .. } [ .. ] 2 => '' */ ...
随机推荐
- flex弹性布局没有生效
display: -webkit-flex; /* 新版本语法: Chrome 21+ */ display: -webkit-box; /* 老版本语法: Safari, iOS, Android ...
- Python之Beautiful Soup 4使用实例
Beautiful Soup 是一个可以从HTML或XML文件中提取数据的Python库,它能够通过你喜欢的转换器实现惯用的文档导航.查找.修改文档的方式.Beautiful Soup 4 官方文档: ...
- Costco
1 会员制,并不是Costco成功的关键原因 Costco最早开始推行会员制的时候,其实遭遇了巨大的失败. 人们当时是不接受,也不理解会员制度的,没有多少人来办会员,Costco差点就死掉了. 那Co ...
- VSCode 如何同步设置
微软新推出的 VSCode 是一款开源.轻量.良心的开发工具,一经问世,迅速受到全球广泛开发者的好评与青睐,威风之下有干掉 Sublime Text 的趋势.然而有不少 VSCode 使用者吐槽其不能 ...
- CodeForces-1257D (贪心+双指针)
题意 https://vjudge.net/problem/CodeForces-1257D 你需要操作m个英雄去打败n只怪物,每个英雄的力量值为pi,可以打败si只怪物:每只怪物的力量值为ai. 当 ...
- 网络流(3)——找到最小st-剪切
在大规模战争中,后勤补给是重中之重,为了尽最大可能满足前线的物资消耗,后勤部队必然要充分利用每条运输网.与此同时,交战双方也想要以最小的代价切断敌军的补给,从而使敌军处于孤立无援的境地.在古今中外的各 ...
- RC4 对称加密
public class RC4 { byte[] s = new byte[256]; byte[] key; byte keylen;// 4 ~ 16 int pi = 0; int pj = ...
- 面向过程编程&面向对象编程
面向过程编程 Procedure Oriented Programming C语言是面向过程编程的,面向过程编程主要使用顺序.条件选择.循环三种基本结构来编写程序. 顺序:按照时间轴顺序完成每个处理: ...
- JS高阶---线程与事件机制(小结)
[大纲] [主体] 注意:先进先出 事件轮询: 事件初始化代码执行完毕后,开始执行事件队列里的待处理事件 .
- CodeForces 984C Finite or not?
http://codeforces.com/problemset/problem/984/C Time limit 1000 msMemory limit 262144 kB 题目 You ...