我尝试按照以下步骤在centos 7服务器上安装vnc-server:
1)我们安装了vnc-server
sudo yum install tigervnc-server
安装完程序后,以要运行VNC程序的用户身份登录,并在终端中发出以下命令,以便为VNC服务器配置密码。
su - your_user # If you want to configure VNC server to run under this user directly from CLI without switching users from GUI
$ vncpasswd
通过放置在systemd目录树中的守护程序配置文件为您的用户添加VNC服务配置文件。为了复制VNC模板文件,您需要以root特权运行以下命令。
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
下一步,请从/ etc / systemd / system /目录编辑复制的VNC模板配置文件,并替换值以反映您的用户,如下所示
vi /etc/systemd/system/vncserver@\:1.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=forking
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser -l my_user -c "/usr/bin/vncserver %i -geometry 1280x720"
PIDFile=/home/my_user/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
对VNC服务文件进行适当更改后,重新加载systemd系统初始化程序以获取新的vnc配置文件并启动TigerVNC服务器。
systemctl daemon-reload
# systemctl start vncserver@:1
# systemctl status vncserver@:1
# systemctl enable vncserver@:1
出现以下错误
systemctl daemon-reload
[root@ns363691 ~]# systemctl start vncserver@:1
Job for vncserver@:1.service failed because a configured resource limit was exceeded. See "systemctl status vncserver@:1.service" and "journalctl -xe" for details.
[root@ns363691 ~]# systemctl status vncserver@:1
● vncserver@:1.service - Remote desktop service (VNC)
Loaded: loaded (/etc/systemd/system/vncserver@:1.service; disabled; vendor preset: disabled)
Active: failed (Result: resources) since mié 2019-11-13 02:09:07 CET; 14s ago
Process: 7605 ExecStart=/usr/sbin/runuser -l root -c /usr/bin/vncserver %i -geometry 1280x720 (code=exited, status=0/SUCCESS)
Process: 7593 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
nov 13 02:09:04 ns363691 systemd[1]: Starting Remote desktop service (VNC)...
nov 13 02:09:07 ns363691 systemd[1]: Can't open PID file /home/root/.vnc/ns363691:1.pid (yet?) after start: No such file or directory
nov 13 02:09:07 ns363691 systemd[1]: Failed to start Remote desktop service (VNC).
nov 13 02:09:07 ns363691 systemd[1]: Unit vncserver@:1.service entered failed state.
nov 13 02:09:07 ns363691 systemd[1]: vncserver@:1.service failed.
任何想法为什么服务无法启动,这是怎么回事? :(