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 => '' */ ...
随机推荐
- 【深度学习】K-L 散度,JS散度,Wasserstein距离
度量两个分布之间的差异 (一)K-L 散度 K-L 散度在信息系统中称为相对熵,可以用来量化两种概率分布 P 和 Q 之间的差异,它是非对称性的度量.在概率学和统计学上,我们经常会使用一种更简单的.近 ...
- Python线程与进程 I/O多路复用
SSHClient Paramiko模块 远程执行命令 #用户名密码方式: import paramiko ssh = paramiko.SSHClient() ssh.set_missing_hos ...
- Linux帮助——常用命令
Linux帮助——常用命令 摘要:本文主要学习了Linux系统中常用的一些命令. uname命令 uname命令可以显示电脑以及操作系统的相关信息. 基本语法 uname [选项] 选项说明 -a:显 ...
- Runtime 类初探
Runtime类 认识 Runtime类 在每一个JVM进程中都会存在一个Runtime类,这个类的主要功能是取得一些与运行时有关的环境属性或创建进程等操作. 在Runtime类定义的时候,它的构造方 ...
- GitHub 总是打不开,网再好也米有用,怎么办?
所用方法:修改host文件 一.键入网址:http://github.global.ssl.fastly.net.ipaddress.com/#ipinfo 拿到github.global.ssl.f ...
- Microsoft.Extensions.DependencyInjection 阅读笔记
一. 关于IServiceCollection接口的设计 public interface IServiceCollection : IList<ServiceDescriptor> { ...
- 1、mongoDB服务器的搭建与连接
下载----编译----安装之后: 1.首先,创建一个mongodb_simple的目录,进入到目录中. 2.创建文件夹:data,用来存储数据库的数据文件. 3.创建文件夹:log,用来存储数据库的 ...
- hbase相关操作
hbase安装 下载 wget http://apache.gree.com/apache/hbase/hbase-1.2.11/hbase-1.2.11-bin.tar.gz tar -zxvf b ...
- TeamyinyinFish->鱼嘤嘤小分队软件工程beta迭代作业
Github项目的链接 github工作组链接 github后台部分项目代码,issue提交在这个项目 github小程序前端部分项目代码链接 scrum会议时间 链接 第十一周 十一周博客 第十二周 ...
- windows 10 下安装VMware Workstation Pro 15.0(亲测可用!)
参考链接:https://blog.csdn.net/qq_39016934/article/details/90285915 VMware Workstation Pro 15.0的下载官网:htt ...