首先,配置vncservers(注意,rootW为1,普通用户按2,3以此类推)
[root@hadoop1001 hadoop]# vi /etc/sysconfig/vncservers
# VNCSERVERS="2:myusername"
# VNCSERVERARGS[]="-geometry 800x600 -nolisten tcp -localhost"
VNCSERVERS="2:hadoop"
VNCSERVERARGS[]="-geometry 1420x868 -nolisten tcp -localhost"
生成xstartup+设置vncpasswd
[hadoop@hadoop1001 ~]$ vncpasswd
Password:
Verify:
启动vncserver,生成xstartup
[hadoop@hadoop1001 ~]$ vncserver Warning: hadoop1001: is taken because of /tmp/.X1-lock
Remove this file if there is no X server hadoop1001:
xauth: creating new authority file /home/hadoop/.Xauthority New 'hadoop1001:2 (hadoop)' desktop is hadoop1001: Creating default startup script /home/hadoop/.vnc/xstartup
Starting applications specified in /home/hadoop/.vnc/xstartup
Log file is /home/hadoop/.vnc/hadoop1001:.log [hadoop@hadoop1001 ~]$
修改xstartup
[hadoop@hadoop1001 ~]$ vi /home/hadoop/.vnc/xstartup
#xterm -geometry 80x24++ -ls -title "$VNCDESKTOP Desktop" & #注释这两行
#twm &
# 添加下面一行
gnome -session &
配置防火墙,放行VNC端口:
[root@hadoop1001 ~]# vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport : -j ACCEPT
添加vncserver自启动
[root@hadoop1001 ~]# chkconfig vncserver on
启动vncserver
[root@hadoop1001 ~]# /etc/init.d/vncserver restart
Shutting down VNC server: :hadoop [ OK ]
Starting VNC server: :hadoop
New 'hadoop1001:2 (hadoop)' desktop is hadoop1001: Starting applications specified in /home/hadoop/.vnc/xstartup
Log file is /home/hadoop/.vnc/hadoop1001:.log [ OK ]