CentOS 7.1安装GNOME,开启VNC Server

A.准备:
1.安装GNOME Desktop

yum groupinstall 'GNOME Desktop'


2.确认GNOME Desktop 安装
[root@p161 ~]# rpm -qa |grep gnome-desktop
 systemd/system/ systemd/system/graphical.target /etc/[root@p161 ~]# cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core) 


5.由于是第一次使用图形界面,需要在本机用root或要配置的账户登录一次才能进行VNC设置


---------------------------------------------------------------------------------------

tigervnc-server
cp /lib/systemd/system/vncserver@.service /lib/systemd/system/vncserver@:1.service
/lib/systemd/system/vncserver@: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 || :'
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.重新加载系统配置
[root@p161 ~]#systemctl daemon-reload 

5.关闭防火墙,或者增加VNCSERVER 配置,二选一
a.关闭
[root@p161 ~]#systemctl stop firewalld.service
[root@p161 ~]#systemctl disable firewalld.service
firewall-cmd --permanent --add-service vnc-server
systemctl restart firewalld.service

6.设置用户VNC密码:

[root@p161 ~]#vncpasswd root

Password:
Verify:
注意:若不是用root账户,而是用hadoop用户,设置vncpasswd要到hadoop用户下面即先执行:
[root@p161 ~]#su hadoop
[hadoop@p161 ~]$vncpasswd hadoop
Password:
Verify:
在root下执行vncpasswd hadoop 不行,原因未知

7.服务配置
开启服务
 
[root@p161 ~]# systemctl start vncserver@:1.service
 
关闭服务:
[root@p161 ~]# systemctl stop vncserver@:1.service
重启服务:
[root@p161 ~]# systemctl restart vncserver@:1.service
自动启动
[root@p161 ~]# systemctl enable vncserver@:1.service
ln -s '/usr/lib/systemd/system/vncserver@:1.service' '/etc/systemd/system/multi-user.target.wants/vncserver@:1.service'
查询状态
[root@p161 ~]# systemctl status vncserver@:1.service
vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/usr/lib/systemd/system/vncserver@: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/vncserver@: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
表示连接第一个桌面
 
原文地址:https://www.cnblogs.com/seasonzone/p/6640879.html