天天看點

Xlib: Invalid MIT-MAGIC-COOKIE-1 key 解決方法

使用vnc工具連接配接伺服器,使用圖形界面方式安裝oracle時,grid 使用者執行./runinstaller 後報錯,提示說明缺少/etc/bin/xplayinfo 指令檔案,

但是網上的資料解決問題時,以root身份執行xhost + 時又報如下錯誤:

xlib: connection to ":0.0" refused by server

xlib: invalid mit-magic-cookie-1 key

can't open display named

目前的情況是:目前使用者為root(報上面的錯誤資訊),而且使用者grid以vnc登入了,上面的錯誤的原因是使用者grid不允許打開一個root控制的視窗。如果root 使用者想要讓其他使用者使用視窗,就要執行 xhost +localhost 以便将其他使用者加入通路清單。這裡我的問題是由于 /etc/sysconfig/vncserver 檔案裡面内容為

vncservers="1:root  2:oracle  4:grid"

vncserverargs[1]="-geometry 1024x768"

vncserverargs[2]="-geometry 1024x768"

vncserverargs[4]="-geometry 1024x768"

但是實際上我以grid身份使用vnc連接配接系統時使用的是ip:1 (正确的應該是 ip:4),從配置檔案來看 1 是由root來控制的。是以會報開始的錯誤。

解決辦法是

在grid 使用者下:

關閉vnc 連接配接

grid@rac1:/home/grid>vncserver -kill :1

killing xvnc process id 29019

在root使用者下

root@rac1#/etc/init.d/vncserver stop

再次啟動

root@rac1#vncserver

new 'rac1:1 (root)' desktop is rac1:1

starting applications specified in /root/.vnc/xstartup

log file is /root/.vnc/rac1:1.log  

在grid 使用者下

重新啟動

new 'rac1:2 (grid)' desktop is rac1:2

starting applications specified in /home/grid/.vnc/xstartup

log file is /home/grid/.vnc/rac1:2.log

在oracle 使用者下(以後會使用oracle 安裝oracle資料庫軟體)

oracle@rac1$vncserver

new 'rac1:3 (oracle)' desktop is rac1:3

starting applications specified in /home/oracle/.vnc/xstartup

log file is /home/oracle/.vnc/rac1:3.log  

最後配置/etc/sysconfig/vncserver 檔案裡面内容為

vncservers="1:root 2:grid 3:oracle"

vncserverargs[3]="-geometry 1024x768"

再次連接配接vnc 的方式是:

root使用者     ip:1

grid使用者     ip:2

oracle 使用者  ip:3

至此問題解決了。如果你的問題也出現了xlib: invalid mit-magic-cookie-1 key ,那很可能與我的案例一樣。僅供參考了。