KVM虚拟机安装笔记

来源:互联网 发布:广西电子政务云计算 编辑:程序博客网 时间:2024/06/05 16:39
KVM虚拟机安装笔记


1、安装图形界面
yum  install  X11
yum groupinstall "X Window System"
yum groupinstall "GNOME Desktop Environment"


2、安装vncserver服务端和客户端端
#su - root
yum -y install vnc-server tigervnc fontforge
echo 'VNCSERVERS="2:root"' >>/etc/sysconfig/vncservers
echo 'VNCSERVERARGS[2]="-geometry 1024x768 -nolisten tcp"' >>/etc/sysconfig/vncservers
su - jkwadmin
mkdir -p /root/.vnc
#vncpasswd
#输入密码
exit
service vncserver start
#vi /root/.vnc/xstartup
sed -i "s@twm@#twm@"  /root/.vnc/xstartup
sed -i "s@xterm@#xterm@" /root/.vnc/xstartup
echo 'gnome-session &`' >>/root/.vnc/xstartup
service vncserver restart


3、安装KVM
grep -E 'vmx|svm' /proc/cpuinfo
查看CPU是否支持虚拟化,如果是intel的cpu且支持KVM虚拟化的,会有vmx标记,AMD的CPU则有svm标记
yum clean all
yum install kvm //安装kvm模块
yum intallqemu-kvm-tools //安装kvm调试工具
yum install bridge-utils  //安装网卡桥接工具
yum install  virt-manager libvirt libvirt-python python-virtinst
reboot重启服务器加载kvm内核
lsmod |grep kvm //查看KVM模块是否正常加载
4、启动KVM虚拟系统管理器
service messagebus start
service haldaemon start
service libvirtd start
chkconfig messagebus on
chkconfig haldaemon on
chkconfig libvirtd on


通过VNC控制虚拟机
virsh vncdisplay vm01
virt-viewer 127.0.0.1:0


配置网卡桥接
cd /etc/sysconfig/network-scripts
  cp ifcfg-eth0 ifcfg-br0  //复制后修改
  修改 ifcfg-eth0为如下内容
DEVICE=eth0
HWADDR=00:E0:81:D2:7A:F1   //视具体情况定
ONBOOT=yes
BRIDGE=br0
 修改ifcfg-br0为如下内容
 DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
IPADDR=192.168.1.220
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
ONBOOT=yes
重启网络服务  service network restart
原创粉丝点击