Linux 虚拟机之--KVM的安装和配置(一)

简介:

系统环境:

     操作系统: RedHat EL6.4(x86_64)


一、前言

     KVM,即Kernel-based Virtual Machine的简称,是一个开源的系统虚拟化模块,自Linux 2.6.20之后集成在Linux的各个主要发行版本中。它使用Linux自身的调度器进行管理,所以相对于Xen,其核心源码很少。KVM目前已成为学术界的主流VMM之一。KVM的虚拟化需要硬件支持(如Intel VT技术或者AMD V技术)。是基于硬件的完全虚拟化。而Xen早期则是基于软件模拟的Para-Virtualization,

       新版本则是基于硬件支持的完全虚拟化。但Xen本身有自己的进程调度器,存储管理模块等,所以代码较为庞大。广为流传的商业系统虚拟化软件VMware ESX系列也是基于软件模拟的Para-Virtualization。

二、配置环境

软件包组:

virtualization            提供虚拟机的环境,主要包含qemu-kvm

virtualization-client      管理和安装虚拟机实例的客户端,主要有python-virtinst,virt-manager,virt-viewer

virtualization-platform    提供访问和控制虚拟客户端的接口,主要有libvirt,libvirt-client

virtualization-tools      管理离线虚拟机镜像的工具,主要有libguestfs

根据需求选择软件包,一般都安装前三个,也可以只安装个别主要的包。

为了减少不必要的麻烦,请关闭防火墙和SELinux

# cat /proc/cpuinfo |grep flags    需要全虚拟化支持为vmx(Inter)或svm(AMD)

三、安装KVM软件包

1、查看主机CPU信息

[root@rh64 ~]# cat /proc/cpuinfo|grep flag
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 syscall nx rdtscp lm constant_tsc up rep_good xtopology nonstop_tsc unfair_spinlock pni pclmulqdq monitor ssse3 cx16 sse4_1 sse4_2 popcnt aes xsave avx hypervisor lahf_lm

2、查看系统内核版本

[root@rh64 ~]# uname -a
Linux rh64 2.6.32-358.el6.x86_64 #1 SMP Tue Jan 29 11:47:41 EST 2013 x86_64 x86_64 x86_64 GNU/Linux

3、通过系统安装盘安装kvm软件包
[root@rh64 ~]# mount /dev/sr0 /media
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@rh64 ~]# yum groupinstall "Virtualization" "Virtualization Client" "Virtualzation Platform"

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is  not  registered to Red Hat Subscription Management. You can use subscription-manager to register.
base                                                                                       |  3.9  kB      00 : 00  ... 
Setting up Group Process
base/group_gz                                                                              |  204  kB      00 : 00  ... 
Warning: Group Virtualzation Platform does  not  exist.
Resolving Dependencies
--> Running transaction check
---> Package hypervkvpd.x86_64  0 : 0 -0.9. el6 will be installed
---> Package python-virtinst.noarch  0 : 0.600. 0 -15. el6 will be installed
--> Processing Dependency: libvirt-python >=  0.2. 0  for  package : python-virtinst -0.600. 0 -15. el6.noarch
---> Package qemu-kvm.x86_64  2 : 0.12. 1.2 -2.355. el6 will be installed
base/filelists_db                                                                          |  3.7  MB      00 : 00  ... 
--> Processing Dependency: qemu-img =  2 : 0.12. 1.2 -2.355. el6  for  package 2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64
--> Processing Dependency: seabios >=  0.6. 1.2 -20. el6  for  package 2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64
--> Processing Dependency: vgabios-vmware  for  package 2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64
--> Processing Dependency: vgabios-stdvga  for  package 2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64
--> Processing Dependency: vgabios-qxl  for  package 2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64
--> Processing Dependency: vgabios  for  package 2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64
--> Processing Dependency: libspice-server.so .1 (SPICE_SERVER_0 .8.3 )(64bit)  for  package 2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64
--> Processing Dependency: libspice-server.so .1 (SPICE_SERVER_0 .8.2 )(64bit)  for  package 2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64
--> Processing Dependency: libspice-server.so .1 (SPICE_SERVER_0 .8.1 )(64bit)  for  package 2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64
--> Processing Dependency: libspice-server.so .1 (SPICE_SERVER_0 .6.0 )(64bit)  for  package 2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64
--> Processing Dependency: libspice-server.so .1 (SPICE_SERVER_0 .11.2 )(64bit)  for  package 2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64
--> Processing Dependency: libspice-server.so .1 (SPICE_SERVER_0 .10.4 )(64bit)  for  package 2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64
--> Processing Dependency: /usr/share/sgabios/sgabios.bin  for  package 2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64
--> Processing Dependency: /usr/share/gpxe/virtio-net.rom  for  package 2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64
--> Processing Dependency: /usr/share/gpxe/rtl8139.rom  for  package 2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64
--> Processing Dependency: /usr/share/gpxe/rtl8029.rom  for  package 2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64
--> Processing Dependency: /usr/share/gpxe/pcnet32.rom  for  package 2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64
--> Processing Dependency: /usr/share/gpxe/e1000 -0x100e. rom  for  package 2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64
--> Processing Dependency: libusbredirparser.so .1 ()(64bit)  for  package 2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64
--> Processing Dependency: libspice-server.so .1 ()(64bit)  for  package 2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64
---> Package virt-manager.x86_64  0 : 0.9. 0 -18. el6 will be installed
--> Processing Dependency: gtk-vnc-python >=  0.3. 8  for  package : virt-manager -0.9. 0 -18. el6.x86_64
--> Processing Dependency: gnome-python2-gnomekeyring >=  2.15. 4  for  package : virt-manager -0.9. 0 -18. el6.x86_64
--> Processing Dependency: spice-gtk-python  for  package : virt-manager -0.9. 0 -18. el6.x86_64
---> Package virt-top.x86_64  0 : 1.0. 4 -3.15. el6 will be installed
---> Package virt-viewer.x86_64  0 : 0.5. 2 -18. el6 will be installed
--> Processing Dependency: libspice-client-gtk -2.0. so .4 (SPICEGTK_1)(64bit)  for  package : virt-viewer -0.5. 2 -18. el6.x86_64
--> Processing Dependency: libspice-client-glib -2.0. so .8 (SPICEGTK_1)(64bit)  for  package : virt-viewer -0.5. 2 -18. el6.x86_64
--> Processing Dependency: libspice-controller.so .0 ()(64bit)  for  package : virt-viewer -0.5. 2 -18. el6.x86_64
--> Processing Dependency: libspice-client-gtk -2.0. so .4 ()(64bit)  for  package : virt-viewer -0.5. 2 -18. el6.x86_64
--> Processing Dependency: libspice-client-glib -2.0. so .8 ()(64bit)  for  package : virt-viewer -0.5. 2 -18. el6.x86_64
--> Processing Dependency: libgtk-vnc -1.0. so .0 ()(64bit)  for  package : virt-viewer -0.5. 2 -18. el6.x86_64
--> Running transaction check
---> Package gnome-python2-gnomekeyring.x86_64  0 : 2.28. 0 -4. el6 will be installed
---> Package gpxe-roms-qemu.noarch  0 : 0.9. 7 -6.9. el6 will be installed
---> Package gtk-vnc.x86_64  0 : 0.3. 10 -3. el6 will be installed
---> Package gtk-vnc-python.x86_64  0 : 0.3. 10 -3. el6 will be installed
---> Package libvirt-python.x86_64  0 : 0.10. 2 -18. el6 will be installed
---> Package qemu-img.x86_64  2 : 0.12. 1.2 -2.355. el6 will be installed
---> Package seabios.x86_64  0 : 0.6. 1.2 -26. el6 will be installed
---> Package sgabios-bin.noarch  0 : 0 -0.3. 20110621svn.el6 will be installed
---> Package spice-glib.x86_64  0 : 0.14 -7. el6 will be installed
--> Processing Dependency: libcelt051.so .0 ()(64bit)  for  package : spice-glib -0.14 -7. el6.x86_64
--> Processing Dependency: libcacard.so .0 ()(64bit)  for  package : spice-glib -0.14 -7. el6.x86_64
---> Package spice-gtk.x86_64  0 : 0.14 -7. el6 will be installed
---> Package spice-gtk-python.x86_64  0 : 0.14 -7. el6 will be installed
---> Package spice-server.x86_64  0 : 0.12. 0 -12. el6 will be installed
---> Package usbredir.x86_64  0 : 0.5. 1 -1. el6 will be installed
---> Package vgabios.noarch  0 : 0. 6b -3.7. el6 will be installed
--> Running transaction check
---> Package celt051.x86_64  0 : 0.5. 1.3 -0. el6 will be installed
---> Package libcacard.x86_64  0 : 0.15. 0 -2. el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================
  Package                               Arch              Version                            Repository       Size
===================================================================================================
Installing:
  hypervkvpd                            x86_64             0 -0.9. el6                          base              17  k
  python-virtinst                       noarch             0.600. 0 -15. el6                     base             490  k
  qemu-kvm                              x86_64             2 : 0.12. 1.2 -2.355. el6               base             1.3  M
  virt-manager                          x86_64             0.9. 0 -18. el6                       base             1.0  M
  virt-top                              x86_64             1.0. 4 -3.15. el6                     base             368  k
  virt-viewer                           x86_64             0.5. 2 -18. el6                       base             200  k
Installing  for  dependencies:
  celt051                               x86_64             0.5. 1.3 -0. el6                      base              50  k
  gnome-python2-gnomekeyring            x86_64             2.28. 0 -4. el6                       base              24  k
  gpxe-roms-qemu                        noarch             0.9. 7 -6.9. el6                      base             219  k
  gtk-vnc                               x86_64             0.3. 10 -3. el6                       base              95  k
  gtk-vnc-python                        x86_64             0.3. 10 -3. el6                       base              17  k
  libcacard                             x86_64             0.15. 0 -2. el6                       base              41  k
  libvirt-python                        x86_64             0.10. 2 -18. el6                      base             457  k
  qemu-img                              x86_64             2 : 0.12. 1.2 -2.355. el6               base             469  k
  seabios                               x86_64             0.6. 1.2 -26. el6                     base              91  k
  sgabios-bin                           noarch             0 -0.3. 20110621svn.el6              base             6.6  k
  spice-glib                            x86_64             0.14 -7. el6                         base             291  k
  spice-gtk                             x86_64             0.14 -7. el6                         base              54  k
  spice-gtk-python                      x86_64             0.14 -7. el6                         base              22  k
  spice-server                          x86_64             0.12. 0 -12. el6                      base             326  k
  usbredir                              x86_64             0.5. 1 -1. el6                        base              40  k
  vgabios                               noarch             0. 6b -3.7. el6                       base              42  k
Transaction Summary
===================================================================================================
Install       22  Package(s)
Total download size:  5.6  M
Installed size:  19  M
Is  this  ok [y/N]: 
Downloading Packages:
------------------------------------------------------------------------------------------------------------------
Total                                                                               10  MB/s |  5.6  MB      00 : 00     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Warning: RPMDB altered outside of yum.
** Found  1  pre-existing rpmdb problem(s),  'yum check'  output follows:
openssl -1.0. 1e-42. el6.x86_64 is a duplicate  with  openssl -1.0. 0 -27. el6.x86_64
   Installing : usbredir -0.5. 1 -1. el6.x86_64                                                                    1 / 22 
   Installing : celt051 -0.5. 1.3 -0. el6.x86_64                                                                   2 / 22 
   Installing : libcacard -0.15. 0 -2. el6.x86_64                                                                  3 / 22 
   Installing : spice-glib -0.14 -7. el6.x86_64                                                                   4 / 22 
   Installing : spice-gtk -0.14 -7. el6.x86_64                                                                    5 / 22 
   Installing : gtk-vnc -0.3. 10 -3. el6.x86_64                                                                    6 / 22 
   Installing : libvirt-python -0.10. 2 -18. el6.x86_64                                                            7 / 22 
   Installing : python-virtinst -0.600. 0 -15. el6.noarch                                                          8 / 22 
   Installing : gtk-vnc-python -0.3. 10 -3. el6.x86_64                                                             9 / 22 
   Installing : spice-gtk-python -0.14 -7. el6.x86_64                                                            10 / 22 
   Installing : spice-server -0.12. 0 -12. el6.x86_64                                                             11 / 22 
   Installing :  2 :qemu-img -0.12. 1.2 -2.355. el6.x86_64                                                          12 / 22 
   Installing : seabios -0.6. 1.2 -26. el6.x86_64                                                                 13 / 22 
   Installing : gpxe-roms-qemu -0.9. 7 -6.9. el6.noarch                                                           14 / 22 
   Installing : sgabios-bin -0 -0.3. 20110621svn.el6.noarch                                                      15 / 22 
   Installing : vgabios -0. 6b -3.7. el6.noarch                                                                   16 / 22 
   Installing : gnome-python2-gnomekeyring -2.28. 0 -4. el6.x86_64                                                17 / 22 
   Installing : virt-manager -0.9. 0 -18. el6.x86_64                                                              18 / 22 
   Installing :  2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64                                                          19 / 22 
   Installing : virt-viewer -0.5. 2 -18. el6.x86_64                                                               20 / 22 
   Installing : hypervkvpd -0 -0.9. el6.x86_64                                                                   21 / 22 
   Installing : virt-top -1.0. 4 -3.15. el6.x86_64                                                                22 / 22 
   Verifying  : gnome-python2-gnomekeyring -2.28. 0 -4. el6.x86_64                                                 1 / 22 
   Verifying  : spice-glib -0.14 -7. el6.x86_64                                                                   2 / 22 
   Verifying  : virt-top -1.0. 4 -3.15. el6.x86_64                                                                 3 / 22 
   Verifying  : vgabios -0. 6b -3.7. el6.noarch                                                                    4 / 22 
   Verifying  :  2 :qemu-img -0.12. 1.2 -2.355. el6.x86_64                                                           5 / 22 
   Verifying  : sgabios-bin -0 -0.3. 20110621svn.el6.noarch                                                       6 / 22 
   Verifying  : spice-gtk -0.14 -7. el6.x86_64                                                                    7 / 22 
   Verifying  : celt051 -0.5. 1.3 -0. el6.x86_64                                                                   8 / 22 
   Verifying  : usbredir -0.5. 1 -1. el6.x86_64                                                                    9 / 22 
   Verifying  : hypervkvpd -0 -0.9. el6.x86_64                                                                   10 / 22 
   Verifying  : gpxe-roms-qemu -0.9. 7 -6.9. el6.noarch                                                           11 / 22 
   Verifying  : libvirt-python -0.10. 2 -18. el6.x86_64                                                           12 / 22 
   Verifying  : spice-server -0.12. 0 -12. el6.x86_64                                                             13 / 22 
   Verifying  : virt-viewer -0.5. 2 -18. el6.x86_64                                                               14 / 22 
   Verifying  : virt-manager -0.9. 0 -18. el6.x86_64                                                              15 / 22 
   Verifying  : libcacard -0.15. 0 -2. el6.x86_64                                                                 16 / 22 
   Verifying  : python-virtinst -0.600. 0 -15. el6.noarch                                                         17 / 22 
   Verifying  : seabios -0.6. 1.2 -26. el6.x86_64                                                                 18 / 22 
   Verifying  : gtk-vnc-python -0.3. 10 -3. el6.x86_64                                                            19 / 22 
   Verifying  : gtk-vnc -0.3. 10 -3. el6.x86_64                                                                   20 / 22 
   Verifying  :  2 :qemu-kvm -0.12. 1.2 -2.355. el6.x86_64                                                          21 / 22 
   Verifying  : spice-gtk-python -0.14 -7. el6.x86_64                                                            22 / 22 
Installed:
   hypervkvpd.x86_64  0 : 0 -0.9. el6      python-virtinst.noarch  0 : 0.600. 0 -15. el6 qemu-kvm.x86_64  2 : 0.12. 1.2 -2.355. el6
   virt-manager.x86_64  0 : 0.9. 0 -18. el6 virt-top.x86_64  0 : 1.0. 4 -3.15. el6        virt-viewer.x86_64  0 : 0.5. 2 -18. el6   
Dependency Installed:
   celt051.x86_64  0 : 0.5. 1.3 -0. el6                     gnome-python2-gnomekeyring.x86_64  0 : 2.28. 0 -4. el6             
   gpxe-roms-qemu.noarch  0 : 0.9. 7 -6.9. el6              gtk-vnc.x86_64  0 : 0.3. 10 -3. el6                                
   gtk-vnc-python.x86_64  0 : 0.3. 10 -3. el6               libcacard.x86_64  0 : 0.15. 0 -2. el6                              
   libvirt-python.x86_64  0 : 0.10. 2 -18. el6              qemu-img.x86_64  2 : 0.12. 1.2 -2.355. el6                         
   seabios.x86_64  0 : 0.6. 1.2 -26. el6                    sgabios-bin.noarch  0 : 0 -0.3. 20110621svn.el6                   
   spice-glib.x86_64  0 : 0.14 -7. el6                     spice-gtk.x86_64  0 : 0.14 -7. el6                                
   spice-gtk-python.x86_64  0 : 0.14 -7. el6               spice-server.x86_64  0 : 0.12. 0 -12. el6                          
   usbredir.x86_64  0 : 0.5. 1 -1. el6                      vgabios.noarch  0 : 0. 6b -3.7. el6        
                        
Complete!


四、配置KVM建立虚拟机

[root@rh64 u02]# mkdir /u02/data               //建立虚拟机存储空间

通过VNC连接主机,进行配置:

1、vnc连接


2、配置KVM


2、KVM安装包


4、提示启动“libvirt service”


[root@rh64 ~]# service libvirtd restart
Stopping libvirtd daemon: [FAILED]
Starting libvirtd daemon: [  OK  ]

5、KVM虚拟机summary




6、建立虚拟机


7、选择虚拟机的操作系统和安装ISO


8、配置虚拟机Memory和CPU


9、设置虚拟机的Storage


10、虚拟机配置信息汇总


[root@rh64 ~]# service libvirtd status
libvirtd (pid  3163) is running...
查看建立的虚拟机的存储信息:
[root@rh64 ~]# cd /u02/data
[root@rh64 data]# ls
rh6.img
[root@rh64 data]# pwd
/u02/data
[root@rh64 data]# ls -l
total 8396812
-rwxr-xr-x 1 qemu qemu 8589934592 Nov 24 13:08 rh6.img
五、KVM基本的管理命令
[root@rh64 ~]# virsh
Welcome to virsh, the virtualization interactive terminal.
Type:  'help' for help with commands
       'quit' to quit
virsh # help

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
Grouped commands:
  Domain Management (help keyword  'domain' ):
     attach-device                  attach device  from  an XML file
     attach-disk                    attach disk device
     attach-interface               attach network interface
     autostart                      autostart a domain
     blkdeviotune                   Set  or  query a block device I/O tuning parameters.
     blkiotune                      Get  or  set blkio parameters
     blockcommit                    Start a block commit operation.
     blockcopy                      Start a block copy operation.
     blockjob                       Manage active block operations
     blockpull                      Populate a disk  from  its backing image.
     blockresize                    Resize block device of domain.
     change-media                   Change media of CD  or  floppy drive
     console                        connect to the guest console
     cpu-baseline                   compute baseline CPU
     cpu-compare                    compare host CPU  with  a CPU described by an XML file
     cpu-stats                      show domain cpu statistics
     create                         create a domain  from  an XML file
     define                         define (but don't start) a domain  from  an XML file
     desc                           show  or  set domain's description  or  title
     destroy                        destroy (stop) a domain
     detach-device                  detach device  from  an XML file
     detach-disk                    detach disk device
     detach-interface               detach network interface
     domdisplay                     domain display connection URI
     domhostname                    print the domain's hostname
     domid                          convert a domain name  or  UUID to domain id
     domif-setlink                  set link state of a virtual interface
     domiftune                      get/set parameters of a virtual interface
     domjobabort                    abort active domain job
     domjobinfo                     domain job information
     domname                        convert a domain id  or  UUID to domain name
     dompmsuspend                   suspend a domain gracefully using power management functions
     dompmwakeup                    wakeup a domain  from  pmsuspended state
     domuuid                        convert a domain name  or  id to domain UUID
     domxml- from -native             Convert native config to domain XML
     domxml-to-native               Convert domain XML to native config
     dump                           dump the core of a domain to a file  for  analysis
     dumpxml                        domain information  in  XML
     edit                           edit XML configuration  for  a domain
     inject-nmi                     Inject NMI to the guest
     send-key                       Send keycodes to the guest
     managedsave                    managed save of a domain state
     managedsave-remove             Remove managed save of a domain
     maxvcpus                       connection vcpu maximum
     memtune                        Get  or  set memory parameters
     migrate                        migrate domain to another host
     migrate-setmaxdowntime         set maximum tolerable downtime
     migrate-setspeed               Set the maximum migration bandwidth
     migrate-getspeed               Get the maximum migration bandwidth
     numatune                       Get  or  set numa parameters
     reboot                         reboot a domain
     reset                          reset a domain
     restore                        restore a domain  from  a saved state  in  a file
     resume                         resume a domain
     save                           save a domain state to a file
     save-image-define              redefine the XML  for  a domain's saved state file
     save-image-dumpxml             saved state domain information  in  XML
     save-image-edit                edit XML  for  a domain's saved state file
     schedinfo                      show/set scheduler parameters
     screenshot                     take a screenshot of a current domain console  and  store it  into  a file
     setmaxmem                      change maximum memory limit
     setmem                         change memory allocation
     setvcpus                       change number of virtual CPUs
     shutdown                       gracefully shutdown a domain
     start                          start a (previously defined) inactive domain
     suspend                        suspend a domain
     ttyconsole                     tty console
     undefine                       undefine a domain
     update-device                  update device  from  an XML file
     vcpucount                      domain vcpu counts
     vcpuinfo                       detailed domain vcpu information
     vcpupin                        control  or  query domain vcpu affinity
     emulatorpin                    control  or  query domain emulator affinity
     vncdisplay                     vnc display
  Domain Monitoring (help keyword  'monitor' ):
     domblkerror                    Show errors  on  block devices
     domblkinfo                     domain block device size information
     domblklist                     list all domain blocks
     domblkstat                     get device block stats  for  a domain
     domcontrol                     domain control interface state
     domif-getlink                  get link state of a virtual interface
     domiflist                      list all domain virtual interfaces
     domifstat                      get network interface stats  for  a domain
     dominfo                        domain information
     dommemstat                     get memory statistics  for  a domain
     domstate                       domain state
     list                           list domains
  Host  and  Hypervisor (help keyword  'host' ):
     capabilities                   capabilities
     connect                        (re)connect to hypervisor
     freecell                       NUMA free memory
     hostname                       print the hypervisor hostname
     node-memory-tune               Get  or  set node memory parameters
     nodecpustats                   Prints cpu stats of the node.
     nodeinfo                       node information
     nodememstats                   Prints memory stats of the node.
     nodesuspend                    suspend the host node  for  a given time duration
     qemu-attach                    QEMU Attach
     qemu-monitor-command           QEMU Monitor Command
     qemu-agent-command             QEMU Guest Agent Command
     sysinfo                        print the hypervisor sysinfo
     uri                            print the hypervisor canonical URI
     version                        show version
  Interface (help keyword  'interface' ):
     iface-begin                    create a snapshot of current interfaces settings, which can be later committed (iface-commit)  or  restored (iface-rollback)
     iface-bridge                   create a bridge device  and  attach an existing network device to it
     iface-commit                   commit changes made since iface-begin  and  free restore point
     iface-define                   define (but don't start) a physical host interface  from  an XML file
     iface-destroy                  destroy a physical host interface (disable it /  "if-down" )
     iface-dumpxml                  interface information  in  XML
     iface-edit                     edit XML configuration  for  a physical host interface
     iface-list                     list physical host interfaces
     iface-mac                      convert an interface name to interface MAC address
     iface-name                     convert an interface MAC address to interface name
     iface-rollback                 rollback to previous saved configuration created via iface-begin
     iface-start                    start a physical host interface (enable it /  "if-up" )
     iface-unbridge                 undefine a bridge device  after  detaching its slave device
     iface-undefine                 undefine a physical host interface (remove it  from  configuration)
  Network Filter (help keyword  'filter' ):
     nwfilter-define                define  or  update a network filter  from  an XML file
     nwfilter-dumpxml               network filter information  in  XML
     nwfilter-edit                  edit XML configuration  for  a network filter
     nwfilter-list                  list network filters
     nwfilter-undefine              undefine a network filter
  Networking (help keyword  'network' ):
     net-autostart                  autostart a network
     net-create                     create a network  from  an XML file
     net-define                     define (but don't start) a network  from  an XML file
     net-destroy                    destroy (stop) a network
     net-dumpxml                    network information  in  XML
     net-edit                       edit XML configuration  for  a network
     net-info                       network information
     net-list                       list networks
     net-name                       convert a network UUID to network name
     net-start                      start a (previously defined) inactive network
     net-undefine                   undefine an inactive network
     net-update                     update parts of an existing network's configuration
     net-uuid                       convert a network name to network UUID
  Node Device (help keyword  'nodedev' ):
     nodedev-create                 create a device defined by an XML file  on  the node
     nodedev-destroy                destroy (stop) a device  on  the node
     nodedev-detach                 detach node device  from  its device driver
     nodedev-dumpxml                node device details  in  XML
     nodedev-list                   enumerate devices  on  this  host
     nodedev-reattach               reattach node device to its device driver
     nodedev-reset                  reset node device
  Secret (help keyword  'secret' ):
     secret-define                  define  or  modify a secret  from  an XML file
     secret-dumpxml                 secret attributes  in  XML
     secret-get-value               Output a secret value
     secret-list                    list secrets
     secret-set-value               set a secret value
     secret-undefine                undefine a secret
  Snapshot (help keyword  'snapshot' ):
     snapshot-create                Create a snapshot  from  XML
     snapshot-create- as              Create a snapshot  from  a set of args
     snapshot-current               Get  or  set the current snapshot
     snapshot- delete                 Delete a domain snapshot
     snapshot-dumpxml               Dump XML  for  a domain snapshot
     snapshot-edit                  edit XML  for  a snapshot
     snapshot-info                  snapshot information
     snapshot-list                  List snapshots  for  a domain
     snapshot-parent                Get the name of the parent of a snapshot
     snapshot-revert                Revert a domain to a snapshot
  Storage Pool (help keyword  'pool' ):
     find-storage-pool-sources- as    find potential storage pool sources
     find-storage-pool-sources      discover potential storage pool sources
     pool-autostart                 autostart a pool
     pool-build                     build a pool
     pool-create- as                  create a pool  from  a set of args
     pool-create                    create a pool  from  an XML file
     pool-define- as                  define a pool  from  a set of args
     pool-define                    define (but don't start) a pool  from  an XML file
     pool- delete                     delete  a pool
     pool-destroy                   destroy (stop) a pool
     pool-dumpxml                   pool information  in  XML
     pool-edit                      edit XML configuration  for  a storage pool
     pool-info                      storage pool information
     pool-list                      list pools
     pool-name                      convert a pool UUID to pool name
     pool-refresh                   refresh a pool
     pool-start                     start a (previously defined) inactive pool
     pool-undefine                  undefine an inactive pool
     pool-uuid                      convert a pool name to pool UUID
  Storage Volume (help keyword  'volume' ):
     vol-clone                      clone a volume.
     vol-create- as                   create a volume  from  a set of args
     vol-create                     create a vol  from  an XML file
     vol-create- from                 create a vol, using another volume  as  input
     vol- delete                      delete  a vol
     vol-download                   Download a volume to a file
     vol-dumpxml                    vol information  in  XML
     vol-info                       storage vol information
     vol-key                        returns the volume key  for  a given volume name  or  path
     vol-list                       list vols
     vol-name                       returns the volume name  for  a given volume key  or  path
     vol-path                       returns the volume path  for  a given volume name  or  key
     vol-pool                       returns the storage pool  for  a given volume key  or  path
     vol-resize                     resize a vol
     vol-upload                     upload a file  into  a volume
     vol-wipe                       wipe a vol
  Virsh itself (help keyword  'virsh' ):
     cd                             change the current directory
     echo                           echo arguments
     exit                           quit  this  interactive terminal
     help                           print help
     pwd                            print the current directory
     quit                           quit  this  interactive terminal

virsh # start rh6
Domain rh6 started
virsh # list
 Id    Name                           State
----------------------------------------------------
 1     rh6                            running
virsh # console
error: command 'console' requires <domain> option
virsh # console rh6
Connected to domain rh6
Escape character is ^]










本文转自 客居天涯 51CTO博客,原文链接:http://blog.51cto.com/tiany/1716631,如需转载请自行联系原作者
目录
相关文章
|
1天前
|
Linux Python
Linux 安装python3.7.6
本教程介绍在Linux系统上安装Python 3.7.6的步骤。首先使用`yum`安装依赖环境,包括zlib、openssl等开发库。接着通过`wget`下载Python 3.7.6源码包并解压。创建目标文件夹`/usr/local/python3`后,进入解压目录执行配置、编译和安装命令。最后设置软链接,使`python3`和`pip3`命令生效。
|
4天前
|
Ubuntu Linux
Linux 各发行版安装 ping 命令指南
如何在不同 Linux 发行版(Ubuntu/Debian、CentOS/RHEL/Fedora、Arch Linux、openSUSE、Alpine Linux)上安装 `ping` 命令,详细列出各发行版的安装步骤和验证方法,帮助系统管理员和网络工程师快速排查网络问题。
57 20
|
4天前
|
Unix Linux 编译器
UNIX/Linux 上的安装
UNIX/Linux 上的安装。
20 2
|
23天前
|
数据库连接 Linux Shell
Linux下ODBC与 南大通用GBase 8s数据库的无缝连接配置指南
本文详细介绍在Linux系统下配置GBase 8s数据库ODBC的过程,涵盖环境变量设置、ODBC配置文件编辑及连接测试等步骤。首先配置数据库环境变量如GBASEDBTDIR、PATH等,接着修改odbcinst.ini和odbc.ini文件,指定驱动路径、数据库名称等信息,最后通过catalog.c工具或isql命令验证ODBC连接是否成功。
|
1月前
|
NoSQL Linux PHP
如何在不同操作系统上安装 Redis 服务器,包括 Linux 和 Windows 的具体步骤
本文介绍了如何在不同操作系统上安装 Redis 服务器,包括 Linux 和 Windows 的具体步骤。接着,对比了两种常用的 PHP Redis 客户端扩展:PhpRedis 和 Predis,详细说明了它们的安装方法及优缺点。最后,提供了使用 PhpRedis 和 Predis 在 PHP 中连接 Redis 服务器及进行字符串、列表、集合和哈希等数据类型的基本操作示例。
57 4
|
1月前
|
缓存 资源调度 安全
深入探索Linux操作系统的心脏——内核配置与优化####
本文作为一篇技术性深度解析文章,旨在引领读者踏上一场揭秘Linux内核配置与优化的奇妙之旅。不同于传统的摘要概述,本文将以实战为导向,直接跳入核心内容,探讨如何通过精细调整内核参数来提升系统性能、增强安全性及实现资源高效利用。从基础概念到高级技巧,逐步揭示那些隐藏在命令行背后的强大功能,为系统管理员和高级用户打开一扇通往极致性能与定制化体验的大门。 --- ###
65 9
|
1月前
|
存储 安全 数据管理
如何在 Rocky Linux 8 上安装和配置 Elasticsearch
本文详细介绍了在 Rocky Linux 8 上安装和配置 Elasticsearch 的步骤,包括添加仓库、安装 Elasticsearch、配置文件修改、设置内存和文件描述符、启动和验证 Elasticsearch,以及常见问题的解决方法。通过这些步骤,你可以快速搭建起这个强大的分布式搜索和分析引擎。
43 5
|
1月前
|
消息中间件 Linux RocketMQ
在Red Hat Enterprise Linux 9上使用Docker快速安装并部署
通过以上步骤,你可以在Red Hat Enterprise Linux 9上使用Docker快速安装并部署RocketMQ。这种方法不仅简化了安装过程,还提供了一个灵活的环境来管理和扩展消息队列系统。RocketMQ作为一款高性能的分布式消息系统,通过Docker可以实现快速部署和高效管理。
70 2
|
1月前
|
消息中间件 Linux RocketMQ
在Red Hat Enterprise Linux 9上使用Docker快速安装并部署
通过以上步骤,你可以在Red Hat Enterprise Linux 9上使用Docker快速安装并部署RocketMQ。这种方法不仅简化了安装过程,还提供了一个灵活的环境来管理和扩展消息队列系统。RocketMQ作为一款高性能的分布式消息系统,通过Docker可以实现快速部署和高效管理。
44 3
|
1月前
|
存储 缓存 Linux
【Linux】另一种基于rpm安装yum的方式
通过本文的方法,您可以在离线环境中使用RPM包安装YUM并进行必要的配置。这种方法适用于无法直接访问互联网的服务器或需要严格控制软件源的环境。通过配置本地YUM仓库,确保了软件包的安装和更新可以顺利进行。希望本文能够为您在特定环境中部署YUM提供实用的指导。
164 0
下一篇
DataWorks