支持linux桌面需求

背景

业务方有一个python爬虫项目,在线上使用需要有图形化界面的linux来帮助他的程序调用chrome浏览器进行爬取数据。还需要能本地登录去执行程序。

支持计划

需求:

  1. 需要有界面:
    安装linux图形界面:
    yum groupinstall -y "GNOME Desktop"
    出现问题解决:
    file /boot/efi/EFI/centos from install of fwupdate-efi-12-5.el7.centos.x86_64 conflicts with file from package grub2-common-1:2.02-0.65.el7.centos.2.noarch yum remove grub2-common-1:2.02-0.65.el7.centos.2.noarch -y 然后重新再安装
  2. 需要本地登录:
    搭建vnc-server:
    安装
    yum install tigervnc-server -y
    配置
cp /usr/lib/systemd/system/[email protected] /etc/systemd/system/[email protected]
vim /etc/systemd/system/[email protected]
# The vncserver service unit file
#
# Quick HowTo:
# 1. Copy this file to /etc/systemd/system/[email protected]
# 2. Replace <USER> with the actual user name and edit vncserver
#    parameters appropriately
#    (ExecStart=/usr/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
#     PIDFile=/home/<USER>/.vnc/%H%i.pid)
# 3. Run `systemctl daemon-reload`
# 4. Run `systemctl enable vncserver@:<display>.service`
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted!  For a secure way of using VNC, you should
# limit connections to the local host and then tunnel from
# the machine you want to view VNC on (host A) to the machine
# whose VNC output you want to view (host B)
#
# [user@hostA ~]$ ssh -v -C -L 590N:localhost:590M hostB
#
# this will open a connection on port 590N of your hostA to hostB's port 590M
# (in fact, it ssh-connects to hostB and then connects to localhost (on hostB).
# See the ssh man page for details on port forwarding)
#
# You can then point a VNC client on hostA at vncdisplay N of localhost and with
# the help of ssh, you end up seeing what hostB makes available on port 590M
#
# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.
#
# Use "-localhost" to prevent remote VNC clients connecting except when
# doing so through a secure tunnel.  See the "-via" option in the
# `man vncviewer' manual page.


[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target

[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 || :'
ExecStart=/usr/sbin/runuser -l vncserver -c "/usr/bin/vncserver %i" # 需要注意这里的vncserver就是用户登录机器的用户
PIDFile=/home/<USER>/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]
WantedBy=multi-user.target

加载systemd配置
systemctl daemon-reload
添加用户
useradd vncserver
配置vnc用户密码
# su vncserver $ vncpasswd Password: Verify: Would you like to enter a view-only password (y/n)?
退回到root权限:
systemctl start vncserver@:1

注意
服务的文件

  1. /etc/systemd/system/[email protected]没有 :1
  2. :1 使当参数启动服务器,表示启动第一个界面

测试客户端使用vncserver能登录了,这个是beta的机器能和办公网互通,线上机器不通需要使用guacamole登录
vnc搭建参考博客:CentOS 7 配置 VNC Server - Zhanming's blog

猜你喜欢

转载自www.cnblogs.com/yanghehe/p/11057733.html
今日推荐