安装VNC

一、安装VNC相关包

 

[plain] view plain copy
 
在CODE上查看代码片派生到我的代码片
  1. yum -y install tigervnc tigervnc-server tigervnc-server-module  

二、复制配置模板文件为vncserver@:1.service

 

 

[plain] view plain copy
 
在CODE上查看代码片派生到我的代码片
  1. cp /lib/systemd/system/vncserver@.service /lib/systemd/system/vncserver@:1.service  

三、修改/lib/systemd/system/vncserver@:1.service配置文件

 

 

[plain] view plain copy
 
在CODE上查看代码片派生到我的代码片
  1. [root@kvm01 ~]# cat /lib/systemd/system/vncserver\@\:1.service | grep -v ^# | grep -v ^$  
  2. [Unit]  
  3. Description=Remote desktop service (VNC)  
  4. After=syslog.target network.target  
  5. [Service]  
  6. Type=forking  
  7. ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'  
  8. ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i"  
  9. PIDFile=/root/.vnc/%H%i.pid  
  10. ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'  
  11. [Install]  
  12. WantedBy=multi-user.target  

四、设置VNC用户密码

 

 

[plain] view plain copy
 
在CODE上查看代码片派生到我的代码片
  1. vncpasswd  
输入两次密码,完成密码设置

五、重新载入system配置

 

[plain] view plain copy
 
在CODE上查看代码片派生到我的代码片
  1. systemctl daemon-reload  

六、启动vncserver@:1.service服务,并设置开机自启

 

[plain] view plain copy
 
在CODE上查看代码片派生到我的代码片
  1. systemctl start vncserver@:1.service && systemctl enable vncserver@:1.service  
注:若系统无法正常关机,则再次启动,此服务无法启动,解决办法参照步骤七

 

 

七、问题解决

1.报错:Job for vncserver@:1.service failed because the control process exited with error code. See "systemctl status vncserver@:1.service" and "journalctl -xe" for details.

处理方法:

 

[plain] view plain copy
 
在CODE上查看代码片派生到我的代码片
    1. rm -rf /tmp/.X11-unix/*  
查看错误
systemctl status vncserver@:1.service

开启防火墙
$ sudo firewall-cmd --permanent --add-service vnc-server
$ sudo systemctl restart firewalld.service
posted @ 2017-02-16 20:22  littlewrong  阅读(243)  评论(0编辑  收藏  举报