虚拟化容器,大数据,DBA,中间件,监控。

非XenCenter方式连接到XenServer各个VM的VNC本地界面

14 10月
作者:admin|分类:容器虚拟化

通过非XenCenter方式连接到XenServer各个VM的VNC本地界面


下面,就是我们在线上所使用的脚本,只需要你本地安装有一个VNC客户端就可以了。

获取本地VM列表
# ./getvnc

1Usage: ./getvnc vm_name
2VMs found:
3idc2-server1                    
4idc2-server2

获取指定VM的VNC端口号
# ./getvnc idc2-server2

1run this on laptop and connect via vnc to localhost:5903
2--> ssh -L 5903:localhost:5903 root@10.100.1.30

接下来,直接在本地运行"ssh -L 5903:localhost:5903 root@10.100.1.30";
再通过VNC客户端连接"localhost:5903"就可以了。

脚本代码:

 
#!/bin/bash

vm=$1
if [ -z ${vm} ]; then
  echo "Usage: $0 vm_name"
  echo "VMs found:"
  xl list-vm | awk '{print $3}' | grep -vw name
  exit 1
fi

xe vm-list params=name-label name-label=${vm} | grep ${vm} > /dev/null
if [ $? -gt 0 ]; then
  echo "Error: invalid VM name"
  exit 1
fi

host=$(xe vm-list params=resident-on name-label=${vm} | grep resident-on | awk '{print $NF}')
dom=$(xe vm-list params=dom-id name-label=${vm} | grep dom-id | awk '{print $NF}')
port=$(xenstore-read /local/domain/${dom}/console/vnc-port)
ip=$(xe pif-list management=true params=IP host-uuid=${host} | awk '{print $NF}')

echo "run this on laptop and connect via vnc to localhost:${port}"
echo "--> ssh -L ${port}:localhost:${port} root@${ip}"

 
浏览2015 评论0
返回
目录
返回
首页
XEN: "x0" re-spawning too fast message/ agetty[8511]: /dev/xvc0: No such file or directory SSH/OpenSSH/PortForwarding/channel_setup_fwd_listener/Could not request local forwarding