CentOS 6 安装 kvm 过程

CentOS 6 安装kvm


[root@localhost ~]# yum -y install qemu-kvm libvirt python-virtinst bridge-utils


查看安装的模块

[root@localhost ~]# lsmod | grep kvm

kvm_intel              55356  0

kvm                   372521  1 kvm_intel



[root@localhost ~]# reboot


[root@localhost ~]# ifconfig

---------------------------------------------------------------------------------------

eth0      Link encap:Ethernet  HWaddr E0:69:95:FB:7C:D2  

         inet addr:10.6.0.27  Bcast:10.6.0.255  Mask:255.255.255.0

         inet6 addr: fe80::e269:95ff:fefb:7cd2/64 Scope:Link

         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

         RX packets:1383673 errors:0 dropped:616 overruns:0 frame:0

         TX packets:124788 errors:0 dropped:0 overruns:0 carrier:0

         collisions:0 txqueuelen:1000

         RX bytes:328564108 (313.3 MiB)  TX bytes:15140325 (14.4 MiB)

         Interrupt:20 Memory:fe500000-fe520000


lo        Link encap:Local Loopback  

         inet addr:127.0.0.1  Mask:255.0.0.0

         inet6 addr: ::1/128 Scope:Host

         UP LOOPBACK RUNNING  MTU:16436  Metric:1

         RX packets:580 errors:0 dropped:0 overruns:0 frame:0

         TX packets:580 errors:0 dropped:0 overruns:0 carrier:0

         collisions:0 txqueuelen:0

         RX bytes:49436 (48.2 KiB)  TX bytes:49436 (48.2 KiB)


virbr0    Link encap:Ethernet  HWaddr 52:54:00:72:7D:E1  

         inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0

         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

         RX packets:0 errors:0 dropped:0 overruns:0 frame:0

         TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

         collisions:0 txqueuelen:0

         RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

---------------------------------------------------------------------------------------


[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

HWADDR=E0:69:95:FB:7C:D2

TYPE=Ethernet

UUID=46ba3249-6460-48b8-8f47-71c302ce2dd0

ONBOOT=yes

NM_CONTROLLED=yes

BOOTPROTO=static

IPADDR=10.6.0.27

NETMASK=255.255.255.0

GATEWAY=10.6.0.1


[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

HWADDR=E0:69:95:FB:7C:D2

TYPE=Ethernet

#UUID=46ba3249-6460-48b8-8f47-71c302ce2dd0

ONBOOT=yes

NM_CONTROLLED=yes

#BOOTPROTO=static

#IPADDR=10.6.0.27

#NETMASK=255.255.255.0

#GATEWAY=10.6.0.1

BRIDGE=br0



[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-br0

DEVICE=br0

HWADDR=E0:69:95:FB:7C:D2

TYPE=Bridge

UUID=46ba3249-6460-48b8-8f47-71c302ce2dd0

ONBOOT=yes

NM_CONTROLLED=yes

BOOTPROTO=static

IPADDR=10.6.0.27

NETMASK=255.255.255.0

GATEWAY=10.6.0.1

ARPCHECK=no


[root@localhost ~]# service network restart



出现  ( 弹出界面 br0: Determining if ip address 10.6.0.27 is already in use for device br0...)

请在 br0 里面加上 ARPCHECK=no 选项



[root@localhost ~]# ifconfig

br0       Link encap:Ethernet  HWaddr E0:69:95:FB:7C:D2  

         inet addr:10.6.0.27  Bcast:10.6.0.255  Mask:255.255.255.0

         inet6 addr: fe80::e269:95ff:fefb:7cd2/64 Scope:Link

         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

         RX packets:345 errors:0 dropped:0 overruns:0 frame:0

         TX packets:55 errors:0 dropped:0 overruns:0 carrier:0

         collisions:0 txqueuelen:0

         RX bytes:43982 (42.9 KiB)  TX bytes:6656 (6.5 KiB)


eth0      Link encap:Ethernet  HWaddr E0:69:95:FB:7C:D2  

         inet6 addr: fe80::e269:95ff:fefb:7cd2/64 Scope:Link

         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

         RX packets:396 errors:0 dropped:0 overruns:0 frame:0

         TX packets:53 errors:0 dropped:0 overruns:0 carrier:0

         collisions:0 txqueuelen:1000

         RX bytes:70198 (68.5 KiB)  TX bytes:6560 (6.4 KiB)

         Interrupt:20 Memory:fe500000-fe520000


lo        Link encap:Local Loopback  

         inet addr:127.0.0.1  Mask:255.0.0.0

         inet6 addr: ::1/128 Scope:Host

         UP LOOPBACK RUNNING  MTU:16436  Metric:1

         RX packets:0 errors:0 dropped:0 overruns:0 frame:0

         TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

         collisions:0 txqueuelen:0

         RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)


virbr0    Link encap:Ethernet  HWaddr 52:54:00:72:7D:E1  

         inet addr:192.168.122.1  Bcast:192.168.122.255  Mask:255.255.255.0

         UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

         RX packets:0 errors:0 dropped:0 overruns:0 frame:0

         TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

         collisions:0 txqueuelen:0

         RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)


[root@localhost ~]# brctl show

bridge name     bridge id               STP enabled     interfaces

br0             8000.e06995fb7cd2       no              eth0

virbr0          8000.525400727de1       yes             virbr0-nic




创建镜像存放目录

[root@localhost ~]# mkdir -p /opt/kvm/ios



创建虚拟机目录  

[root@localhost ~]# mkdir -p /opt/kvm/images



创建一个50G qcow2格式的磁盘文件,虚拟机的image放在 /opt/kvm/images 目录下

[root@localhost ~]# qemu-img create -f qcow2 -o preallocation=metadata /opt/kvm/images/linux6.qcow2 50G

Formatting '/opt/kvm/images/linux6.qcow2', fmt=qcow2 size=53687091200 encryption=off cluster_size=65536 preallocation='metadata'



创建虚拟机 我们使用管理工具virt-install


virt-install --name=oracle6.5 --ram 2048 --vcpus=1 -f /opt/kvm/images/linux6.qcow2 --cdrom /opt/kvm/ios/oracle-linux-6.5.ios --network bridge=br0 --force  --autostart


[root@localhost ~]# virt-install --name=oracle6.5 --ram 2048 --vcpus=1 -f /opt/kvm/images/linux6.qcow2 --cdrom /opt/kvm/ios/oracle-linux-6.5.ios --network bridge=br0 --force  --autostart  


开始安装......

创建域......                                                                                                                                           |    0 B     00:00    

连接到域 oracle6.5

Escape character is ^]





你可能感兴趣的:(centos,操作系统,kvm)