在安装虚拟化环境的时候,首先查看下该服务器的硬件配置和环境,具体操作如下:
(一)检查硬件的相关情况:
1,查看cpu型号,物理cpu颗数,
[root@KVM ~]# cat /proc/cpuinfo | grep name | cut -d: -f2 | uniq -c 2 Intel(R) Core(TM) i3-4150 CPU @ 3.50GHz [root@KVM ~]# cat /proc/cpuinfo | grep physical | sort -n | uniq -c 2 address sizes : 42 bits physical, 48 bits virtual 16 physical id : 0 ###说明有一颗cpu,颗数是从0开始的
2,查看内存
[root@KVM ~]# dmidecode|grep -A5 "Memory Device"|grep Size | cut -d: -f2 | sort -n | uniq -c 63 No Module Installed 63 1 kB 1 8 GB 1 8192 MB ###接了一根内存,每根内存的大小为8G
3,查看其它的相关参数:
[root@KVM ~]# dmidecode | grep -A16 "Memory Device" | grep Speed | sort -n | uniq -c 64 Speed: Unknown [root@KVM ~]# dmidecode|grep ‘Maximum Capacity‘ Maximum Capacity: 1 TB [root@KVM ~]#
(二)安装kvm
1,查看服务器是否支持虚拟化
[root@KVM ~]# grep -E -o ‘vmx|svm‘ /proc/cpuinfo
vmx
2,安装kvm软件包
[root@KVM ~]# yum -y install kvm python-virtinst libvirt tunctl bridge-utils virt-manager qemu-kvm-tools virt-viewer virt-v2v
3,安装kvm虚拟化管理工具包
[root@KVM ~]# yum install libguestfs-tools -y
4,查看虚拟机的相关环境
[root@KVM ~]# /etc/init.d/libvirtd restart Stopping libvirtd daemon: [ OK ] Starting libvirtd daemon: [ OK ] [root@KVM ~]# virsh -c qemu:///system list Id Name State ---------------------------------------------------- 1 hadoop4 running [root@KVM ~]# virsh --version ###查看虚拟机的版本 0.10.2 [root@KVM ~]# virt-install --version ###查看虚拟机工具的版本 0.600.0 [root@KVM ~]# ln -s /usr/libexec/qemu-kvm /usr/bin/qemu-kvm [root@KVM ~]# qemu-kvm -version QEMU PC emulator version 0.12.1 (qemu-kvm-0.12.1.2-2.479.el6_7.3), Copyright (c) 2003-2008 Fabrice Bellard [root@KVM ~]#
5,手动创建虚拟网桥:
a,首先NetworkManager服务:
[root@KVM network-scripts]# /etc/init.d/NetworkManager status
NetworkManager (pid 1132) is running...
[root@KVM network-scripts]# /etc/init.d/NetworkManager stop
Stopping NetworkManager daemon: [ OK ]
[root@KVM network-scripts]# /etc/init.d/NetworkManager status
NetworkManager is stopped
[root@KVM network-scripts]# chkconfig NetworkManager off
b,创建br0网桥:
[root@KVM network-scripts]# cp ifcfg-eth0 ifcfg-br0 [root@KVM network-scripts]# vi ifcfg-eth0 DEVICE=eth0 HWADDR=00:0C:29:75:92:CF TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=no BOOTPROTO=static BRIDGE=br0 DEFROUTE=yes NAME=Systemeth0 IPADDR=10.1.156.200 NETMASK=255.255.255.0 GATEWAY=10.1.156.1 DNS1=10.1.156.1
[root@KVM network-scripts]# vi ifcfg-br0 UUID=c12c5da8-e4dd-43e0-a5cb-2c5491d68aff DEVICE=br0 ###修改为:br0 HWADDR=00:0C:29:75:92:CF ###不变 TYPE=Bridge ###把Ethernet变成Bridge ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=static IPADDR=10.1.156.201 ###修改下ip NETMASK=255.255.255.0 GATEWAY=10.1.156.1 DNS1=10.1.156.1
c,关闭了networkmanager服务之后,才能通过service networkrestart管理网络
本文出自 “清风明月” 博客,请务必保留此出处http://liqingbiao.blog.51cto.com/3044896/1740516
原文:http://liqingbiao.blog.51cto.com/3044896/1740516