:Xlib: No protocol sp…

我在linux下访问db2cc,出现Xlib: No protocol specified的错误

转自 http://blog.sina.com.cn/s/blog_66719ff30100sdib.html

设置xhost +允许所有的服务器使用当前的X Server,默认情况下,其他服务器是无法访问本机的X Server,这时如果执行需要图形化显示的命令,就会导致上面的Xlib: connection to "172.25.198.226:1.0" refused by server的错误。

root用户下执行#xhost +

看到如下显示: access control disabled, clients can connect from any host

另,我还按照 http://blog.sina.com.cn/s/blog_4d6e44860100lyo2.html 的说法操作了一次,但当时没有成功。
但是确实设置了一下环境变量。不知道这个环境变量是否有影响。关键步骤还是“ root用户下执行#xhost +

出现错误提示:“Xlib: connection to ":1.0" refused by server”

如下处理:

实用技巧:在Linux下设置xhost方法步骤

<wbr><wbr></wbr><wbr><wbr></wbr><wbr><wbr></wbr> 第一步:用root登陆</wbr></wbr></wbr>linux,启动vnc服务;

<wbr><wbr></wbr><wbr><wbr></wbr><wbr><wbr></wbr> 第二步:根据vnc起来的端口,设置export DISPLAY=localhost:1(1表示vnc在第一个tty上启动的),vnc的启动信息如下:</wbr></wbr></wbr>

  1. [root@localhost<wbr><wbr></wbr>~]#<wbr><wbr></wbr>vncserver <wbr><wbr></wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr>
  2. <wbr><wbr></wbr><wbr><wbr></wbr></wbr></wbr>
  3. New<wbr><wbr></wbr></wbr>'localhost:1<wbr><wbr></wbr>(root)'</wbr><wbr><wbr></wbr>desktop<wbr><wbr></wbr>is<wbr><wbr></wbr>localhost:</wbr></wbr></wbr>1<wbr><wbr></wbr><wbr><wbr></wbr></wbr></wbr>
  4. <wbr><wbr></wbr><wbr><wbr></wbr></wbr></wbr>
  5. Starting<wbr><wbr></wbr>applications<wbr><wbr></wbr>specified<wbr><wbr></wbr>in<wbr><wbr></wbr>/root/.vnc/xstartup <wbr><wbr></wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  6. Log<wbr><wbr></wbr>file<wbr><wbr></wbr>is<wbr><wbr></wbr>/root/.vnc/localhost:</wbr></wbr></wbr>1.log <wbr><wbr></wbr><wbr><wbr></wbr></wbr></wbr>
  7. <wbr><wbr></wbr><wbr><wbr></wbr></wbr></wbr>
  8. [root@localhost<wbr><wbr></wbr>~]#<wbr><wbr></wbr>export<wbr><wbr></wbr>DISPLAY=localhost:</wbr></wbr></wbr>1<wbr><wbr></wbr><wbr><wbr></wbr><wbr><wbr></wbr></wbr></wbr></wbr>
  9. [root@localhost<wbr><wbr></wbr>~]#<wbr><wbr></wbr>xhost<wbr><wbr></wbr><wbr><wbr></wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr>
  10. access<wbr><wbr></wbr>control<wbr><wbr></wbr>disabled,<wbr><wbr></wbr>clients<wbr><wbr></wbr>can<wbr><wbr></wbr>connect<wbr><wbr></wbr>from<wbr><wbr></wbr>any<wbr><wbr></wbr>host<wbr><wbr></wbr><wbr><wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr></wbr>
[root@localhost ~]# vncserver

New 'localhost:1 (root)' desktop is localhost:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost:1.log

[root@localhost ~]# export DISPLAY=localhost:1 
[root@localhost ~]# xhost  
access control disabled, clients can connect from any host

<wbr><wbr></wbr><wbr><wbr></wbr></wbr></wbr>

<wbr><wbr></wbr><wbr><wbr></wbr><wbr><wbr></wbr> 第三步:执行xhost ,并且提示“</wbr></wbr></wbr>access control disabled, clients can connect from any host”才正确。<wbr><wbr></wbr></wbr>

<wbr><wbr></wbr></wbr>

<wbr><wbr></wbr>关键在于用xhost管理Xserver的访问权限</wbr>


你可能感兴趣的:(protocol)