安裝軟件包
[root@clust2 ~]# rpm -qa | grep vnc-server
[root@clust2 ~]# yum install vnc-server -y
2. 設置用戶密碼
[root@clust2 ~]# vncpassword
-- 設置用戶密碼之後會在 /root 目錄下新建一個 .vnc 的隱藏目錄
3. 編輯服務配置文件
[root@clust2 ~]# vim /etc/sysconfig/vncservers
VNCSERVERS="2:root"
VNCSERVERARGS[2]="-geometry 800x600"
4. 創建 xstartup 腳本
[root@clust2 ~]# service vncserver start [root@clust2 ~]# service vncserver stop [root@clust2 ~]# ll .vnc/ 總計 16 -rw-r--r-- 1 root root 2024 06-01 11:14 clust2:2.log -rw-r--r-- 1 root root 5 06-01 11:13 clust2:2.pid -rw------- 1 root root 8 06-01 10:55 passwd -rwxr-xr-x 1 root root 330 06-01 10:58 xstartup |
5. 編輯 xstartup 文件
(只需把紅色字部分的註釋去掉即可)
#!/bin/sh # Uncomment the following two lines for normal desktop: unset SESSION_MANAGER exec /etc/X11/xinit/xinitrc |
報錯:
Starting VNC server: 2:root xauth: (stdin):2: bad display name "clust2:2" in "add" command