服务端
先安装 os : centos-6.4-livecd
# yum install qemu-kvm
# yum install virt-manager
打开 virt-manager:(如提示安装libvirtd,点击安装即可 )
先安装一个系统(要先确定virt-manager上的localhost为已连接)。
打开已安装的虚拟系统
在弹出的窗口中,点击一个有 I 图标的按钮
在 显示 那些选择 类型为 spice
在 视频 那项选择 类型为 qxl
添加 virt-manager 的桥接
# cd /etc/sysconfig/network-scripts/
# cat ifcfg-br0
DEVICE=br0
TYPE=Bridge
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.125 #br0's ip
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
NETWORK=192.168.1.1
NM_CONTROLLED=no
# cat ifcfg-eth0
DEVICE=eth0
HWADDR=F0:4D:A2:47:D5:48
NM_CONTROLLED=no
BOOTPROTO=dhcp
ONBOOT=yes
#IPADDR=192.168.1.107
#NETMASK=255.255.255.0
#GATEWAY=192.168.1.1
TYPE=Ethernet
USERCTL=no
BRIDGE=br0
# service network restart
# ifconfig
br0 Link encap:Ethernet HWaddr F0:4D:A2:47:D5:48
inet addr:192.168.1.125 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::f24d:a2ff:fe47:d548/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:54574 errors:0 dropped:0 overruns:0 frame:0
TX packets:175978 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:3042869 (2.9 MiB) TX bytes:54970764 (52.4 MiB)
eth0 Link encap:Ethernet HWaddr F0:4D:A2:47:D5:48
inet6 addr: fe80::f24d:a2ff:fe47:d548/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:89583 errors:0 dropped:0 overruns:0 frame:0
TX packets:200989 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:50533650 (48.1 MiB) TX bytes:56877345 (54.2 MiB)
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:2856 errors:0 dropped:0 overruns:0 frame:0
TX packets:2856 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1341980 (1.2 MiB) TX bytes:1341980 (1.2 MiB)
virbr0 Link encap:Ethernet HWaddr 52:54:00:9E:E5:BE
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)
vnet0 Link encap:Ethernet HWaddr FE:54:00:EB:11:56
inet6 addr: fe80::fc54:ff:feeb:1156/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:25010 errors:0 dropped:0 overruns:0 frame:0
TX packets:34958 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:1906455 (1.8 MiB) TX bytes:46678874 (44.5 MiB)
vi /etc/libvirt/qemu.conf
去掉spice_listen = "0.0.0.0"的注释
然后service libvirtd restart
service iptables stop //关防火墙
service iptables status //查看防火墙状态,显示无则关闭成功
chkconfig iptables off //设置开机不运行
PS: 如服务端为双网卡,最好关闭一个不用的网卡
客户端
# ./spicec -h 192.168.1.125 -p 5901 //192.168.1.125为物理机的ip,如有建立桥接,则为br0 的ip
出现如下错误一般为: 防火墙未关,或spice_listen = "0.0.0.0" 未打开
Warning: failed to connect: Connection refused (111)
PS:spice 编译,参见spice 编译一文
阅读(2703) | 评论(0) | 转发(1) |