VNC常⽤操作及常见问题解决办法汇总
VNC登录⽤户缺省是root,但在安装oracle时必须⽤oracle⽤户的⾝份登录,下⾯我们就以oracle为例说明如何配置VNC,从⽽可以使⽤不同的⽤户登录到主机。
步骤描述如下:
步骤⼀:修改/etc/sysconfig/vncservers,添加oracle⽤户,修改后内容如下:
VNCSERVERS="1:root 2:root 3:oracle"
VNCSERVERARGS[1]="-geometry 1024x768"
VNCSERVERARGS[2]="-geometry 1024x768"
VNCSERVERARGS[3]="-geometry 1024x768"
步骤⼆:在系统中新建oracle⽤户静态变量和局部变量的区别
useradd oracle
passwd oracle
步骤三:将root⽤户下的路径复制到oracle⽤户的home路径下,并修改路径所属⽤户及组:
cp -r /root/.vnc ~oracle/.vnc
chown oracle ~oracle/.vnc/
chown oracle.oinstall -R ~oracle/.vnc/
chown oracle ~oracle/.vnc/*
chown oracle.oinstall -R ~oracle/.vnc/*竖版ppt模板下载 免费
步骤四:重启VNC,观察id为3的端⼝是否启动
service vncserver restart
netstat -anlpt | grep 5903
linux修改口令的命令
vnc的端⼝从5901开始,每增加⼀个⽤户,端⼝号就在5901上加1。如果要单独关闭指定id的端⼝,可以使⽤命令:
vncserver -kill :id
如:
vncserver -kill :1
vncserver -kill :2
就将关闭5901和5902两个VNC端⼝
1、安装
yum install vnc*
2、启动
/etc/init.d/vncserver start
Starting VNC server: no displays configured                [  OK  ]
3、配置⽤户名
CODE:[root@localhost ~]#  vi /etc/sysconfig/vncservers
# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the line below to start a VNC server on display :1
# as my 'myusername' (adjust this to your own).  You will also
# need to set a VNC password; run 'man vncpasswd' to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted!  For a secure way of using VNC, see
electric的一系列单词# URL:
# VNCSERVERS="1:myusername"
VNCSERVERS="1:root" (注意:root是CentOS⽤户名)
如果建2个,可以⽤VNCSERVERS="1:root 2:linglong"来配置
3.⽤vncpasswd创建⼀个vnc的⼝令
注意这将同时在你的home⽬录下,创建⼀个隐藏的⽬录.vnc,其中有⼀个⽂件passwd保存着你的vnc⼝令. CODE:
[root@localhost ~]# vncpasswd
Password:
Verify:
[root@localhost ~]# ls -d .vnc
.vnc
[root@localhost ~]# ls .vnc
passwd
4.启动vnc服务.
CODE:[root@localhost ~]#  /sbin/service vncserver restart
Shutting down VNC server: 1:root                          [ OK ]
Starting VNC server: 1:root perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "zh_EN.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log
[ OK ]
察看⼀下.vnc这个⽬录的内容,应该类似于下⾯的东西.
注:在这⾥我刚开始出现“Warning: *****  is taken because of /tmp/.X1-lock”
在⽹上了好多⽅法,终于到解决办法了!
我直接将: /tmp/.X1-lock 删除就可以 了 ,命令式: rm /tmp/.X1-lock
如果还出现其他的⽂件错误 也可照样操作!
CODE:[root@localhost ~]# cd .vnc
[******************]#ls
localhost.localdomain:1.log localhost.localdomain:2.log passwd
localhost.localdomain:1.pid localhost.localdomain:2.pid xstartup
[******************]#
编辑这个名为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 80x24+10+10 -ls -title "$VNCDESKTOP Desktop"
twm
因为我们已经修改了启动脚本,现在来重新启动vncserver.
CODE:[******************]#/sbin/servicevncserverrestart
Shutting down VNC server: 1:root                          [ OK ]
Starting VNC server: 1:root perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "zh_EN.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain:1
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log
[ OK ]
[******************]#
5.防⽕墙端⼝设置
在使⽤防⽕墙的情况下来连接到⼀个远程系统,需要打开端⼝5901.
加⼊以下红⾊的部分,然后重启iptables服务。
[root@localhost ~]#  /sbin/service iptables restart
Flushing firewall rules:                              [  OK  ]
Setting chains to policy ACCEPT: filter                    [  OK  ]
Unloading iptables modules:                                [  OK  ]
Applying iptables firewall rules:                          [  OK  ]
[root@localhost ~]#
vim      /root/.vnc/xstartup  oracle⽤户 (/home/oracle/.vnc/xstartup)
twm &(默认⽂本类型桌⾯)修改为gnome-session(GNOME风格的桌⾯环境) startkde & (KDE风格桌⾯) Redhat下VNC SERVER的配置
1、启动VNC SERVER
输⼊vncserver,第⼀次启动会要求输⼊验证密码,完成后,VNC SERVER就启动了    [root@localhost ~]# vncserver
You will require a password to access your desktops.
Password:            //输⼊密码
Verify:                  //再次输⼊密码
xauth:  creating new authority file /root/.Xauthority
New ‘localhost.localdomain:1 (root)’ desktop is localhost.localdomain:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log
[root@localhost ~]#
2、编辑.vnc/xstartup
使⽤VI打开xstartup⽂件,如下:
[root@localhost /]# cd /root/.vnc
[******************]#vixstartup
删除全部内容,然后添加如下内容:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
3、重启动VNC SERVER
[root@localhost ~]# vncserver -kill :1
Killing Xvnc process ID 21198
[root@localhost ~]# vncserver
New ‘localhost.localdomain:1 (root)’ desktop is localhost.localdomain:1
网页导航栏代码怎么写Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log
[root@localhost ~]#
4、查看VNC的监听端⼝
如下,VNC⽤到了三个端⼝:5801、5901、6001。
[root@localhost /]# netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address              Foreign Address            State
tcp        0      0 127.0.0.1:2208              0.0.0.0:*                  LISTEN
tcp        0      0 0.0.0.0:5801                0.0.0.0:*                  LISTEN
tcp        0      0 0.0.0.0:5901                0.0.0.0:*                  LISTEN
tcp        0      0 0.0.0.0:111                0.0.0.0:*                  LISTEN
tcp        0      0 0.0.0.0:6001                0.0.0.0:*                  LISTEN
tcp        0      0 0.0.0.0:724                0.0.0.0:*                  LISTEN
tcp        0      0 127.0.0.1:631              0.0.0.0:*                  LISTEN
tcp        0      0 127.0.0.1:2207              0.0.0.0:*                  LISTEN
tcp        0      0 172.200.102.3:5901          181.181.181.51:1669        ESTABLISHED
tcp        0      0 :::6001                    :::*                        LISTEN
tcp        0      0 :::22                      :::*                        LISTEN
tcp        0  1364 ::ffff:172.200.102.3:22    ::ffff:181.181.181.51:1599  ESTABLISHED
[root@localhost /]#
5、在防⽕墙上打开VNC⽤到的上⾯三个端⼝
[root@localhost /]# cd /etc/sysconfig
[root@localhost sysconfig]# vi iptables
添加如下三⾏:
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 5801 -j ACCEPT
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 5901 -j ACCEPT
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 6001 -j ACCEPT
重记动IPTABLES
[root@localhost sysconfig]# /etc/rc.d/init.d/iptables restart
Flushing firewall rules: [  OK  ]
Setting chains to policy ACCEPT: filter [  OK  ]
Unloading iptables modules: [  OK  ]
Applying iptables firewall rules: [  OK  ]
Loading additional iptables modules: ip_conntrack_netbios_ns ip_conntrack_ftp [  OK  ]
配置多个桌⾯
Linux下VNC配置多个桌⾯和修改密码可以使⽤如下的⽅法启动多个桌⾯的VNC    vncserver :1   vncserver :2   vncserver :3   ……   但是这种⼿⼯启动的⽅法在服务器重新启动之后将失效,因此,下⾯介绍如何让系统⾃动管理多个桌⾯的VNC,⽅法是将需要⾃动管理的信息添加
到/etc/sysconfig/vncservers配置⽂件中,先以桌⾯1为root⽤户桌⾯2为oracle⽤户为例进⾏配置如下:  格式为:VNCSERVERS="桌⾯号:使⽤的⽤户名桌⾯号:使⽤的⽤户名"    [root@testdb ~]# vi /etc/sysconfig/vncservers    VNCSERVERS="1:root 2:oracle"    VNCSERVERARGS[1]="-geometry 1024x768"    VNCSERVERARGS[2]="-geometry 1024x768"   修改VNC访问的密码  使⽤命令vncpasswd对不同⽤户的VNC的密码进⾏修改,⼀定

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。