VNCwwwtl111888comKVM13094391112VNC

使用VNC连接KVM虚拟机安装系统
Centos 7.4安装VNC
1、安装图形界面,已安装的就跳过

yum groupinstall "X Window System"

yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts

unlink /etc/systemd/system/default.target

ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target

reboot

2、yum 安装vnc包

yum install tigervnc-server -y

3、修改配置信息

cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service

vim /etc/systemd/system/vncserver@:1.service

修改前:

ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"

PIDFile=/home/<USER>/.vnc/%H%i.pid

修改后:

ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i"

PIDFile=/root/.vnc/%H%i.pid

注:将<USER>换成系统账号,最好使用root账号,否则可能有其他错误。

4、重新加载systemd

systemctl daemon-reload

5、为vnc设定密码

vncpasswd

6、设置开机自动和启动服务

systemctl start vncserver@:1.service

systemctl enable vncserver@:1.service

7、报错及处理方式

如果启动时候报错:

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.

处理方法1:

rm -rf /tmp/.X11-unix/*(该方法不成功)

处理方法2:

把 vncserver@:1.service 中的 Type 参数必为: simple (本人验证成功)

Failed to issue method call: File exists

此错误一般发生在systemctl enable创建系统连接到/etc/systemd/system/的时候。一般是在切换显示管理器(例如从 GDM 到 KDM)时出现,这时/etc/systemd/system/vncserver@:1.service 已经存在。 要解决此问题,使用 systemctl -f enable 覆盖原有链接,或者删除已经存在的链接。

猜你喜欢

转载自blog.51cto.com/14254839/2367889
VNC