作业环境
服务器
server01:Red Hat Enterprise Linux Server release 6.1 (Santiago)
IP:10.8.0.124/255.255.0.0
KVM:qemu-kvm-0.12.1.2-2.113.el6.x86_64
server 02:Red Hat Enterprise Linux Server release 6.1 (Santiago)
IP:10.8.0.130/255.255.0.0
KVM:qemu-kvm-0.12.1.2-2.113.el6.x86_64
客户端
Client:Windows 7
IP:10.8.110.28/255.255.0.0
KVM管理工具:Xming 6.9
一、连接远程物理主机VMM的前提条件
1、RHEL6 下SELinux默认状态为enforcing,需将其设置为disabled
[root@server01 ~]# sestatus
SELinux status: enabled
SELinuxfs mount: /selinux
Current mode: enforcing
Mode from config file: enforcing
Policy version: 24
Policy from config file: targeted
[root@server01 ~]# cat /etc/sysconfig/selinux
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
重启主机使设置生效,重启后,状态为:
[root@server01 ~]# sestatus
SELinux status: disabled
2、配置SSH公钥认证
a. server01使用ssh-keygen命令生成私钥和公钥,设置过程中,将密码短语置为空
[root@server01 ~]# ssh-keygen -b 1024 -t dsa
b. 将公钥上传到server02的/root目录下
[root@server01 ~]# scp .ssh/id_dsa.pub root@10.8.0.130:
c. 在server2上配置公钥,使用root登录
[root@server02 ~]# mkdir .ssh
[root@server02 ~]# chmod 700 .ssh
[root@server02 ~]# mv id_dsa.pub .ssh
[root@server02 ~]# cd .ssh
[root@server02 .ssh]# cat id_dsa.pub >> authorized_keys
[root@server02 .ssh]# chmod 600 authorized_keys
[root@server02 .ssh]# rm -rf id_dsa.pub
d. 测试连接:
[root@server01 ~]# ssh root@10.8.0.130
Last login: Sun Oct 3 06:07:13 2011 from 10.8.0.124
[root@server02 ~]# exit
logout
Connection to 10.8.0.130 closed.
显然,不用输密码就可以直接登录了。
二、连接远程物理主机VMM的实际操作
1、在Server01上打开 virt-manager 应用程序(显示界面导出到PC机Client上),连接 localhost 本机虚拟机列表。
[root@server01 ~]# export DISPLAY=10.8.110.28:0
[root@server01 ~]# virt-manager
2、点击 File->Add Connection,弹出添加连接窗口,输入以下各项:
Hypervisor:选择 QEMU/KVM
Connection:连接方式Remote tunnel over SSH
Hostname:输入将要连接的主机名或 IP 地址,这里填写目的主机server02的IP
Autoconnect:可以勾选,表示VMM启动时,是否自动连接远端VMM
添加连接前
添加连接
添加连接后
至此,可以通过server01管理server02上的KVM虚拟机。同样地,如果server03、server04……上都有KVM虚拟机的话,也都可以由server01管理,而不必逐台分散管理。
本文转自Sunshyfangtian 51CTO博客,原文链接:http://blog.51cto.com/sunshyfangtian/798109,如需转载请自行联系原作者