首页 > 代码库 > KVM+SVN 虚拟机远程管理

KVM+SVN 虚拟机远程管理

1.安装kvm

grep -E -o ‘vmx|svm‘ /proc/cpuinfo  #检查服务器是否支持虚拟化(vmx为interl平台、svm是AMD平台)#安装KVM所需软件包:yum groupinstall kvm或yum install kvm kmod-kvm qemu kvm-qemu-img virt-viewer virt-manager libvirt libvirt-python python-virtinst bridge-utils    lsmod |grep kvm  #检查是否安装成功

2.安装vnc

rpm -qa | grep vnc-server  #检查系统是否安装vncserveryum install tigervnc-server fontforge -y    #安装tigervnc-server和字体编译器(防止远程出现乱码)yum groupinstall Desktop -y   #安装桌面环境vncpasswd  #配置vncserver 密码  ,有时不配服务器起不来vi  ./vnc/xstartup   #改成自己安装的桌面环境,twm & 注释掉    # twm &    gnome-session &vi /etc/sysconfig/vncserver    #更改默认登陆用户和远程分辨率    VNCSERVERS="1:root"    VNCSERVERARGS[2]="-geometry 1024X768 -nolisten tcp -localhost"注: 1.关闭selinux       2.iptables 放行5901端口

3.配置桥口(主要用于KVM虚拟机中安装虚拟机,可以和真是机互通并可出外网)

brctl addbr br0         #添加网桥br0brctl addif br0 eth0  #添加eth0 到br0中brctl addif br0 eth1  #添加eth1 到br0中                  cp /etc/sysconfig/network-script/ifcfg-eth0 /etc/sysconfig/network-script/ifcfg-br0      #创建桥口br0vi /etc/sysconfig/network-script/ifcfg-br0vi /etc/sysconfig/network-script/ifcfg-eth0vi /etc/sysconfig/network-script/ifcfg-eth1                 DEVICE="br0"BOOTPROTO="static"#HWADDR="………………"   #前面加井号注释掉mac地址,因为是eth0上拷贝的ONBOOT="yes"TYPE="Bridge"IPADDR=115.236.81.249NETMASK=255.255.255.240GATEWAY=115.236.81.241vi /etc/sysconfig/network-script/ifcfg-eth0DEVICE="eth0"BOOTPROTO="static"HWADDR="………………"    #默认ONBOOT="yes"TYPE="Ethernet"IPADDR=X.X.X.XNETMASK=X.X.X.XGATEWAY=X.X.X.XBRIDGE="br0"vi /etc/sysconfig/network-script/ifcfg-eth1DEVICE="eth1BOOTPROTO="static"HWADDR="………………"  #默认ONBOOT="yes"TYPE="Ethernet"IPADDR=X.X.X.XNETMASK=X.X.X.XBRIDGE="br0"                 关闭NetworkManager service network restart