vnc 有点类似 windows 的远程桌面,在实际工作中使用还是很方便的。
1,安装vncserver服务
# yum install tigervnc-server
# service vncserver status
Xvnc is stopped
2,查看vncserver状态,启动vncserver 输入初始化密码
# service vncserver status
Xvnc is stopped
# vncserver
You will require a password to access your desktops.
Password:
Verify:
xauth: (stdin):1: bad display name “oradb:1” in “add” command
New ‘oradb:1 (root)’ desktop is oradb:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/oradb:1.log
# ps -ef|grep -i vnc
root 4700 1 0 00:13 pts/0 00:00:00 /usr/bin/Xvnc :1 -desktop oradb:1 (root) -auth /root/.Xauthority -geometry 1024×768 -rfbwait 30000 -rfbauth /root/.vnc/passwd -rfbport 5901 -fp catalogue:/etc/X11/fontpath.d -pn
root 4706 4705 0 00:13 pts/0 00:00:00 vncconfig -iconic
root 4840 2562 0 00:14 pts/0 00:00:00 grep -i vnc
# service vncserver status
Xvnc (pid 4700) is running…
# netstat -anp|grep -i 4700
tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 4700/Xvnc
tcp 0 0 0.0.0.0:6001 0.0.0.0:* LISTEN 4700/Xvnc
tcp 0 0 :::6001 :::* LISTEN 4700/Xvnc
unix 2 [ ACC ] STREAM LISTENING 140192 4700/Xvnc @/tmp/.X11-unix/X1
unix 2 [ ACC ] STREAM LISTENING 140193 4700/Xvnc /tmp/.X11-unix/X1
unix 3 [ ] STREAM CONNECTED 147009 5262/dbus-daemon @/tmp/dbus-APo0GCGAxg
unix 3 [ ] STREAM CONNECTED 147008 5578/gvfsd-metadata
unix 3 [ ] STREAM CONNECTED 141237 4700/Xvnc @/tmp/.X11-unix/X1
unix 3 [ ] STREAM CONNECTED 141232 4700/Xvnc @/tmp/.X11-unix/X1
unix 3 [ ] STREAM CONNECTED 141227 4700/Xvnc @/tmp/.X11-unix/X1
unix 3 [ ] STREAM CONNECTED 141011 4700/Xvnc @/tmp/.X11-unix/X1
unix 3 [ ] STREAM CONNECTED 141006 4700/Xvnc @/tmp/.X11-unix/X1
unix 3 [ ] STREAM CONNECTED 140905 4700/Xvnc @/tmp/.X11-unix/X1
unix 3 [ ] STREAM CONNECTED 140816 4700/Xvnc @/tmp/.X11-unix/X1
unix 3 [ ] STREAM CONNECTED 140770 4700/Xvnc @/tmp/.X11-unix/X1
unix 3 [ ] STREAM CONNECTED 140622 4700/Xvnc @/tmp/.X11-unix/X1
unix 3 [ ] STREAM CONNECTED 140392 4700/Xvnc @/tmp/.X11-unix/X1
unix 3 [ ] STREAM CONNECTED 140253 4700/Xvnc @/tmp/.X11-unix/X1
unix 3 [ ] STREAM CONNECTED 140223 4700/Xvnc @/tmp/.X11-unix/X1
unix 3 [ ] STREAM CONNECTED 140210 4700/Xvnc @/tmp/.X11-unix/X1
3,如果使用 VNC-Viewer 时期望出现图形化界面(6.x 默认就是图形化界面,不用调整),就需要作如下调整(添加两行)。
# vi /etc/sysconfig/vncservers
# VNCSERVERS=”2:myusername”
# VNCSERVERARGS[2]=”-geometry 800×600 -nolisten tcp -nohttpd -localhost”
VNCSERVERS=”2:root”
VNCSERVERARGS[2]=”-geometry 1024×768″
简单解释下着两行密码
VNCSERVERS=”2:root” 表示 5802 端口号对应的是root账号
VNCSERVERARGS[2]=”-geometry 1000×720″ 表示 分辨率
4,修改 x11 的配置文件,红色注释去掉(5.x是默认注销的,6.x是默认开启的)
# vi /root/.vnc/xstartup
#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &
twm &
5,重新启动vncserver服务
# service vncserver restart
6,不建议vncserver随OS自启动,如果确有需要可以使用 chkconfig 配置
# chkconfig –level 35 vncserver on
7,使用 VNC-Viewer 连接vncserver,通常用的client是 VNC-Viewer,可以从这个网站下载 https://www.realvnc.com/download/viewer/
8,重新修改vnc的登录密码
# vncpasswd
新建vncserver的会话
# vncserver :3
杀掉vncserver的会话
# vncserver -kill :3
查看当前的vncserver会话
# vncserver -list
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/1752.html