1
2
3
4
5
6
7
|
[root@taokey ~]
# /etc/init.d/iptables stop
[root@taokey ~]
# chkconfig iptables off
[root@taokey ~]
# chkconfig --list iptables
iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@taokey ~]
# vim /etc/sysconfig/selinux
SELINUX=disabled
[root@taokey ~]
# setenforce 0
|
1
2
|
[root@taokey ~]
# grep "flags" /proc/cpuinfo
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts mmx fxsr sse sse2 ss syscall nx rdtscp lm constant_tsc up arch_perfmon pebs bts xtopology tsc_reliable nonstop_tsc aperfmperf unfair_spinlock pni pclmulqdq vmx ssse3 cx16 pcid sse4_1 sse4_2 x2apic popcnt xsave avx hypervisor lahf_lm arat epb xsaveopt pln pts dts tpr_shadow vnmi ept vpid
|
1
|
[root@taokey ~]
# yum install -y kvm virt-* libvirts bridge-utils qemu-img
|
1
2
3
4
|
[root@taokey ~]
# modprobe kvm-intel
[root@taokey ~]
# lsmod | grep kvm
kvm_intel 54285 0
kvm 333172 1 kvm_intel
|
1
2
3
4
|
[root@taokey ~]
# reboot
[root@taokey ~]
# lsmod | grep kvm
kvm_intel 54285 0
kvm 333172 1 kvm_intel
|
1
2
3
|
[root@taokey ~]
# virsh list
Id Name State
----------------------------------------------------
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
[root@taokey ~]
# more /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:0C:29:33:B3:E5
TYPE=Ethernet
UUID=142284ae-3173-4b0a-80d8-437c26a96719
ONBOOT=
yes
NM_CONTROLLED=
yes
BOOTPROTO=none
BRIDGE=br0
[root@taokey ~]
# more /etc/sysconfig/network-scripts/ifcfg-br0
DEVICE=br0
HWADDR=00:0C:29:33:B3:E5
TYPE=Bridge
UUID=142284ae-3173-4b0a-80d8-437c26a96719
ONBOOT=
yes
NM_CONTROLLED=
yes
BOOTPROTO=static
IPADDR=10.0.1.149
NETMASK=255.255.255.0
GATEWAY=10.0.1.1
[root@taokey ~]
# /etc/init.d/network restart
|
1
2
3
4
|
[root@taokey ~]
# brctl show
bridge name bridge
id
STP enabled interfaces
br0 8000.000c2933b3e5 no eth0
virbr0 8000.525400d969b8
yes
virbr0-nic
|
1
2
|
[root@taokey ~]
# vim /etc/libvirt/qemu.conf
vnc_listen =
"0.0.0.0"
第十二行,把vnc_listen前面的
#号去掉。
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
[root@taokey ~]
# /etc/init.d/libvirtd restart
Stopping libvirtd daemon: [ OK ]
Starting libvirtd daemon: libvirtd: initialization failed [FAILED]
解决办法:
[root@taokey libvirt]
# echo "export LC_ALL=en_US.UTF-8" >> /etc/profile
[root@taokey libvirt]
# source /etc/profile
[root@taokey libvirt]
# /etc/init.d/libvirtd restart
Stopping libvirtd daemon: [FAILED]
Starting libvirtd daemon: 2014-08-15 16:14:18.595+0000: 2429: info : libvirt version: 0.10.2, package: 29.el6_5.11 (CentOS BuildSystem <http:
//bugs
.centos.org>, 2014-07-31-18:52:08, c6b8.bsys.dev.centos.org)
2014-08-15 16:14:18.595+0000: 2429: warning : virGetHostname:2294 : getaddrinfo failed
for
'taokey'
: Name or service not known
[ OK ]
[root@taokey ~]
# /etc/init.d/messagebus restart
Stopping system message bus: [ OK ]
Starting system message bus: [ OK ]
|
-
创建镜像文件目录和虚拟磁盘存放目录
1
2
|
[root@taokey ~]
# mkdir /iso
[root@taokey ~]
# mkdir -p /data/kvmdisk
|
1
2
3
4
|
[root@taokey ~]
# dd if=/dev/cdrom of=/iso/Centos6.iso
8726528+0 records
in
8726528+0 records out
4467982336 bytes (4.5 GB) copied, 298.268 s, 15.0 MB
/s
|
1
2
3
|
[root@taokey ~]
# cd /etc/libvirt/
[root@taokey libvirt]
# qemu-img create -f qcow2 -o preallocation=metadata kvm_mode.img 10G
Formatting
'kvm_mode.img'
,
fmt
=qcow2 size=10737418240 encryption=off cluster_size=65536 preallocation=
'metadata'
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
[root@taokey libvirt]
# virt-install --name=kvm_mode_5566 --ram 1024 --vcpus=1 -f /etc/libvirt/kvm_mode.img --cdrom=/iso/Centos6.iso --graphics vnc,listen=0.0.0.0,port=7788 --force --autostart
Starting
install
...
ERROR internal error Process exited
while
reading console log output: char device redirected to
/dev/pts/2
qemu-kvm: -drive
file
=
/etc/libvirt/kvm_mode
.img,
if
=none,
id
=drive-ide0-0-0,
format
=raw,cache=none: could not
open
disk image
/etc/libvirt/kvm_mode
.img: Permission denied
Domain installation does not appear to have been successful.
If it was, you can restart your domain by running:
virsh --connect qemu:
///system
start kvm_mode_5566
otherwise, please restart your installation.
解决办法:
[root@taokey libvirt]
# chmod -R 777 /etc/libvirt
[root@taokey libvirt]
# virt-install --name=kvm_mode_5566 --ram 1024 --vcpus=1 -f /etc/libvirt/kvm_mode.img --cdrom=/iso/Centos6.iso --graphics vnc,listen=0.0.0.0,port=7788 --force --autostart
Starting
install
...
Creating domain... | 0 B 00:00
Cannot
open
display:
Run
'virt-viewer --help'
to see a full list of available
command
line options
Domain installation still
in
progress. You can reconnect to
the console to complete the installation process.
|
-
用VNC连接,进行创建kvm虚拟机(VNC连上之后,跟安装linux Centos 6.5系统一样,重新装一次)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
[root@taokey ~]
# virsh
Welcome to virsh, the virtualization interactive terminal.
Type:
'help'
for
help with commands
'quit'
to quit
virsh
# list --all
Id Name State
----------------------------------------------------
- kvm_mode_5566 shut off
virsh
# start kvm_mode_5566
Domain kvm_mode_5566 started
|
1
2
3
4
5
6
7
8
9
10
11
12
|
[root@taokey ~]
# virsh
Welcome to virsh, the virtualization interactive terminal.
Type:
'help'
for
help with commands
'quit'
to quit
virsh
# list --all
Id Name State
----------------------------------------------------
1 kvm_mode_5566 running
virsh
#
|