咱们可以使用 带 –target-config 参数的办法启动了代理,所有代理都在一个端口(6080)下,并会在指定的目录下(/home/xy/noVNC/websockify)生成一个对应的文件(vnc_token),其将 VNC 服务(主机名:端口)对应起来,具体如下。
vm1: localhost:7900
vm2: localhost:7910
vm3: localhost:7920
vm4: localhost:7930
vm5: localhost:7940
vm6: localhost:7950
vm7: localhost:7960
vm8: localhost:7970
vm9: localhost:7980
vm10: localhost:7990
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
这样一个(启动了 VNC 服务的,启动命令如下)虚拟机生成这样一个token文件,根据该文件内容能识别这个代理对应到哪个主机上的 VNC 服务。
xy@tnode07:~/noVNC/websockify$ ./ --web=./ --target-config /home/xy/noVNC/websockify/vnc_tokens 6080 &
- 1
执行完该命令后,可ps查看下websockify代理的状态:
xy@tnode07:~/novncService$ ps axu|grep python
nsr 7609 0.1 0.0 41804 13528 pts/0 S 15:12 0:00 python /home/xy/novncService/websockify-master/ --web=./ --target-config /home/xy/novncService/websockify-master/vnc_tokens 6080
nsr 7613 0.0 0.0 10488 2172 pts/0 S+ 15:12 0:00 grep --color=auto python
- 1
- 2
- 3
附件:Websockify代理启动shell脚本
#! /bin/bash
count=`ps -ef |grep |grep -v "grep" |wc -l`
if [ $count -eq 0 ]
then
nohup python /home/xy/novncService/websockify-master/ --web=./ --target-config /home/xy/novncService/websockify-master/vnc_tokens 6080 &
fi
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8