本文共 2585 字,大约阅读时间需要 8 分钟。
转载地址:
centos7.2部署vnc服务记录不做过多介绍了,下面直接记录下centos7系统下安装配置vncserver的操作记录
1)关闭防火墙
centos的防火墙是firewalld,关闭防火墙的命令[root@localhost ~]# systemctl stop firewalld.service #停止firewall[root@localhost ~]# systemctl disable firewalld.service #禁止firewall开机启动[root@localhost ~]# setenforce 0
[root@localhost ~]# getenforce[root@localhost ~]# cat /etc/sysconfig/selinuxSELINUX=disabledSELINUXTYPE=targeted2)安装软件:
[root@localhost ~]# yum update[root@localhost ~]# yum groupinstall "GNOME Desktop" "X Window System" "Desktop"[root@localhost ~]# yum install tigervnc-server tigervnc vnc vnc-server3)配置vnc连接
[root@localhost ~]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service这里直接用root 用户登录,所以我替换成
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"PIDFile=/root/.vnc/%H%i.pid如果是其他用户的话比如john替换如下
ExecStart=/sbin/runuser -l john -c "/usr/bin/vncserver %i"PIDFile=/home/john/.vnc/%H%i.pid由于直接root用户登录,所以配置如下:
[root@localhost ~]# cat /etc/systemd/system/vncserver@:1.service.........[Unit]Description=Remote desktop service (VNC)After=syslog.target network.target[Service]
Type=forkingExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/sbin/runuser -l root -c "/usr/bin/vncserver %i"PIDFile=/root/.vnc/%H%i.pidExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'[Install]
WantedBy=multi-user.target为VNC设密码
[root@localhost ~]# vncpasswd123456[root@localhost ~]# vim /etc/libvirt/qemu.conf
vnc_password = "123456"vnc_listen = "0.0.0.0"重加载 systemd
[root@localhost ~]# systemctl daemon-reload启动vnc
[root@localhost ~]# systemctl enable vncserver@:1.service[root@localhost ~]# systemctl start vncserver@:1.service注意,此处关闭了防火墙
如果防火墙开了,需要开通一下规则:[root@localhost ~]# firewall-cmd --permanent --add-service vnc-server[root@localhost ~]# systemctl restart firewalld.service如果是iptable,则需要在/etc/sysconfig/iptables里添加:-A INPUT -m state --state NEW -m tcp -p tcp --dport 5900:5903 -j ACCEPT关闭vnc连接
[root@localhost ~]# /usr/bin/vncserver -kill :1测试vnc连接:
[root@localhost ~]# novnc_server --vnc 192.168.1.8:5901 --listen 6081Warning: could not find self.pemStarting webserver and WebSockets proxy on port 6081WebSocket server settings:Navigate to this URL:
#http访问方式
Press Ctrl-C to exit
由于kvm-server的主机名对于ip是112.112.113.56,所以在浏览器里输入:
转载于:https://blog.51cto.com/ucode/2063692