CentOS 7.1安裝GNOME,開啟VNC Server
阿新 • • 發佈:2018-11-19
A.準備:
1.安裝GNOME D
esktop
[[email protected] ~]#yum groupinstall 'GNOME Desktop'
2.確認GNOME Desktop 安裝 [ [email protected] ~]# rpm -qa |grep gnome-desktop gnome-desktop3-3.8.4-4.el7.x86_64
3.預設啟動圖形介面 [ [email protected] ~]#
unlink /etc/systemd/system/default.target
[[email protected] ~]#
ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target
4.檢視CentOS 版本 ~]# cat /etc/redhat-release
~]# yum -y install
tigervnc-server
2. [ [email protected] ~]# cp /lib/systemd/system/ [email protected] /lib/systemd/system/[email protected]:1.service
3.[[email protected] ~]# vim /lib/syste md/system/[email protected]:1.service 將配置檔案中<USER>改為使用者名稱,如root [Service] Type=forking # Clean any existing files in /tmp/.X11-unix environment ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i" PIDFile=/ root/.vnc/%H%i.pid ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' 注意預設的PIDFile後面有/home,當配置使用者為root是要刪除
4.重新載入系統配置 [[email protected] ~]#systemctl daemon-reload
5.關閉防火牆,或者增加VNCSERVER 配置,二選一 a.關閉 [ [email protected] ~]#systemctl stop firewalld.service
6.設定使用者VNC密碼: [ [email protected] ~]#vncpasswd root Password: Verify: 注意:若不是用root賬戶,而是用hadoop使用者,設定vncpasswd要到hadoop使用者下面即先執行: [ [email protected] ~]#su hadoop [ [email protected] ~]$vncpasswd hadoop Password: Verify: 在root下執行vncpasswd hadoop 不行,原因未知
7.服務配置 開啟服務 [[email protected] ~]# systemctl start [email protected]:1.service 關閉服務: [[email protected] ~]# systemctl stop [email protected]:1.service 重啟服務: [[email protected] ~]# systemctl restart [email protected]:1.service 自動啟動 [ [email protected] ~]# systemctl enable [email protected]:1.service ln -s '/usr/lib/systemd/system/[email protected]:1.service' '/etc/systemd/system/multi-user.target.wants/[email protected]:1.service' 查詢狀態 [ [email protected] ~]# systemctl status [email protected]:1.service [email protected]:1.service - Remote desktop service (VNC) Loaded: loaded (/usr/lib/systemd/system/[email protected]:1.service; enabled) Active: active (running) since 一 2015-12-14 18:41:29 CST; 16s ago Main PID: 5335 (Xvnc) CGroup: /system.slice/system-vncserver.slice/[email protected]:1.service ‣ 5335 /usr/bin/Xvnc :1 -desktop p161:1 (root) -auth /root/.Xauthority -geometry 1024x768 -rfbwait 30000 -rfbauth /root/.vnc/passw...
12月 14 18:41:25 p161 systemd[1]: Starting Remote desktop service (VNC)... 12月 14 18:41:29 p161 systemd[1]: Started Remote desktop service (VNC).
8.在vnc viewer中連線地址裡寫上: 192.168.1.161:1 表示連線第一個桌面
2.確認GNOME Desktop 安裝 [ [email protected] ~]# rpm -qa |grep gnome-desktop gnome-desktop3-3.8.4-4.el7.x86_64
3.預設啟動圖形介面 [
4.檢視CentOS 版本
CentOS Linux release 7.1.1503 (Core)
5.由於是第一次使用圖形介面,需要在本機用root或要配置的賬戶登入一次才能進行VNC設定
2. [ [email protected] ~]# cp /lib/systemd/system/ [email protected] /lib/systemd/system/[email protected]:1.service
3.[[email protected] ~]# vim /lib/syste md/system/[email protected]:1.service 將配置檔案中<USER>改為使用者名稱,如root [Service] Type=forking # Clean any existing files in /tmp/.X11-unix environment ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i" PIDFile=/ root/.vnc/%H%i.pid ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' 注意預設的PIDFile後面有/home,當配置使用者為root是要刪除
4.重新載入系統配置 [[email protected] ~]#systemctl daemon-reload
5.關閉防火牆,或者增加VNCSERVER 配置,二選一 a.關閉 [ [email protected] ~]#systemctl stop firewalld.service
[[email protected] ~]#systemctl disable firewalld.service
b.或者增加vnc-server通過: [ [email protected] ~]# firewall-cmd --permanent --add-service vnc-server success [ [email protected] ~]# systemctl restart firewalld.service6.設定使用者VNC密碼: [ [email protected] ~]#vncpasswd root Password: Verify: 注意:若不是用root賬戶,而是用hadoop使用者,設定vncpasswd要到hadoop使用者下面即先執行: [ [email protected] ~]#su hadoop [ [email protected] ~]$vncpasswd hadoop Password: Verify: 在root下執行vncpasswd hadoop 不行,原因未知
7.服務配置 開啟服務 [[email protected] ~]# systemctl start [email protected]:1.service 關閉服務: [[email protected] ~]# systemctl stop [email protected]:1.service 重啟服務: [[email protected] ~]# systemctl restart [email protected]:1.service 自動啟動 [ [email protected] ~]# systemctl enable [email protected]:1.service ln -s '/usr/lib/systemd/system/[email protected]:1.service' '/etc/systemd/system/multi-user.target.wants/[email protected]:1.service' 查詢狀態 [ [email protected] ~]# systemctl status [email protected]:1.service [email protected]:1.service - Remote desktop service (VNC) Loaded: loaded (/usr/lib/systemd/system/[email protected]:1.service; enabled) Active: active (running) since 一 2015-12-14 18:41:29 CST; 16s ago Main PID: 5335 (Xvnc) CGroup: /system.slice/system-vncserver.slice/[email protected]:1.service ‣ 5335 /usr/bin/Xvnc :1 -desktop p161:1 (root) -auth /root/.Xauthority -geometry 1024x768 -rfbwait 30000 -rfbauth /root/.vnc/passw...
12月 14 18:41:25 p161 systemd[1]: Starting Remote desktop service (VNC)... 12月 14 18:41:29 p161 systemd[1]: Started Remote desktop service (VNC).
8.在vnc viewer中連線地址裡寫上: 192.168.1.161:1 表示連線第一個桌面