Linux 通过安装vncserver,客户端远程连接展示图形化界面
Step 1: 安装vncserver和其依赖的软件
# 修改yum为国内镜像 cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup-linux && \ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo && \ yum clean all && \ yum makecache # 安装依赖软件 yum install -y compat-libstdc++* && \ yum install -y binutils* && \ yum install -y compat-libstdc* && \ yum install -y elfutils-libelf* && \ yum install -y gcc* && \ yum install -y glibc* && \ yum install -y ksh* && \ yum install -y libaio* && \ yum install -y libgcc* && \ yum install -y libstdc* && \ yum install -y make* && \ yum install -y sysstat* && \ yum install -y libXp* && \ yum install -y glibc-kernheaders # yum rpm -q --queryformat %-{name}-%{version}-%{release}-%{arch}"\n" \ compat-libstdc++-33 glibc-kernheaders glibc-headers libaio libgcc glibc-devel xorg-x11-deprecated-libs # 输出无法下载和安装的软件,清单如下: # package compat-libstdc++-33 is not installed # package glibc-kernheaders is not installed # package glibc-headers is not installed # libaio-0.3.109-13.el7-x86_64 # libgcc-4.8.5-16.el7-x86_64 # package glibc-devel is not installed # package xorg-x11-deprecated-libs is not installed # 遇到部分无法在aliyun下载的软件,则需要重新替换yum.repo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup-aliyun && \ cp /etc/yum.repos.d/CentOS-Base.repo.backup-linux /etc/yum.repos.d/CentOS-Base.repo && \ yum clean all && \ yum makecache && \ yum install -y compat-libstdc++* && \ # 安装包找不到 yum install -y glibc-kernheaders* && \ yum install -y glibc-headers* && \ yum install -y libaio* && \ yum install -y libgcc* && \ yum install -y glibc-devel* && \ # 安装包找不到 yum install -y xorg-x11-deprecated-libs* && \ # 查看VNC启动失败的日志, cat ./.vnc/CNT7XORACLED01:1.log # xrdb: No such file or directory # xrdb: can't open file '/root/.Xresources' # xterm: cannot load font '-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1' # 根据日志错误信息,安装插件或创建目录 touch ~/.Xresources && \ yum install -y xterm && \ yum install -y gnome-session # 如果日志提示错误:xterm: cannot load font '-misc-fixed-medium-r-semicondensed--13-120-75-75-c-60-iso10646-1' # 则编辑文件,添加如下两行内容 vi ~/.Xresources xterm*faceName:AR PL Uming CN xterm*faceSize:12 # 然后,重新启动vncserver # 关闭vncserver , vncserver这里是"Xvnc :1",见下面查询结果所得:1 # 详情使用ps -ef | grep vncserver查看 # [root@CNT7XORACLED01 ~]# ps -ef | grep vnc # root 1608 1 0 10:20 pts/1 00:00:00 /usr/bin/Xvnc :1 -auth /root/.Xauthority -desktop CNT7XORACLED01:1 (root) -fp catalogue:/etc/X11/fontpath.d -geometry 1024x768 -pn -rfbauth /root/.vnc/passwd -rfbport 5901 -rfbwait 30000 # 关闭vncserver vncserver -kill :1 vncserver :1 # 然后,执行如下命令 export DISPLAY=localhost:1 xhost + # 出现如下输出,才是成功启动了Linux的远程连接的图形化界面
Step 2:客户端连接linux服务器
创建vnc客户端连接如下:{linux_ip}:{vncserver进程的参数 Xvnc :1}
执行链接,弹出窗口如下: