数据库运维
记录DBA学习成长历程

Centos7安装配置VNC

文章目录

VNC需要系统安装的有桌面,如果是生产环境服务器,安装时使用的最小化安装,那么进行下面操作安装GNOME 桌面。

我使用的下列镜像进行创建虚拟机

把镜像文件挂载到/mnt

[root@test ~]# mount /dev/sr0 /mnt
mount: /dev/sr0 is write-protected, mounting read-only
[root@test ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 48G 1.5G 47G 3% /
devtmpfs               2.0G 0 2.0G 0% /dev
tmpfs                  2.0G 0 2.0G 0% /dev/shm
tmpfs                  2.0G 12M 2.0G 1% /run
tmpfs                  2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/sda1              1014M 130M 885M 13% /boot
tmpfs                  394M 0 394M 0% /run/user/0
/dev/sr0               4.2G 4.2G 0 100% /mnt

将/etc/yum.repos.d内的文件进行备份

[root@test ~]# cd /etc/yum.repos.d/

[root@test yum.repos.d]# ll
total 32
-rw-r--r--. 1 root root 1664 Apr 29 2018 CentOS-Base.repo
-rw-r--r--. 1 root root 1309 Apr 29 2018 CentOS-CR.repo
-rw-r--r--. 1 root root 649 Apr 29 2018 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root 314 Apr 29 2018 CentOS-fasttrack.repo
-rw-r--r--. 1 root root 630 Apr 29 2018 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 Apr 29 2018 CentOS-Sources.repo
-rw-r--r--. 1 root root 4768 Apr 29 2018 CentOS-Vault.repo
[root@test yum.repos.d]# mkdir bak
[root@test yum.repos.d]# mv *.repo bak/
[root@test yum.repos.d]# ls
bak

编辑文件使下载走镜像

[root@test yum.repos.d]# vi CentOS-local.repo

[base-local]
name=base-local
baseurl=file:///mnt
enabled=1
gpgcheck=0

[root@test yum.repos.d]# cat CentOS-local.repo 
[base-local]
name=base-local
baseurl=file:///mnt
enabled=1
gpgcheck=0

清理yum缓存
[root@test yum.repos.d]# yum clean all
Loaded plugins: fastestmirror
Cleaning repos: base-local
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos

把服务器的包信息下载到本地电脑缓存起来,makecache建立一个缓存,以后用install时就在缓存中搜索,提高了速度。
[root@test yum.repos.d]# yum makecache
Loaded plugins: fastestmirror
Determining fastest mirrors
base-local                                                                                                                                           | 3.6 kB  00:00:00     
(1/4): base-local/group_gz                                                                                       | 166 kB  00:00:00     
(2/4): base-local/filelists_db                                                                                   | 3.1 MB  00:00:00     
(3/4): base-local/primary_db                                                                                     | 3.1 MB  00:00:00     
(4/4): base-local/other_db                                                                                       | 1.3 MB  00:00:00     
Metadata Cache Created

安装GNOME 桌面

[root@test ~]# yum -y groups install "GNOME Desktop"
。。。。。。。。省略
Complete!

安装VNCserver

[root@test ~]# yum install tigervnc-server nvc -y
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
No package nvc available.
Resolving Dependencies
--> Running transaction check
---> Package tigervnc-server.x86_64 0:1.8.0-5.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================
 Package                                      Arch                                Version                                     Repository                               Size
============================================================================================================================================================================
Installing:
 tigervnc-server                              x86_64                              1.8.0-5.el7                                 base-local                              214 k

Transaction Summary
============================================================================================================================================================================
Install  1 Package

Total download size: 214 k
Installed size: 508 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : tigervnc-server-1.8.0-5.el7.x86_64                                                                                                                       1/1 
  Verifying  : tigervnc-server-1.8.0-5.el7.x86_64                                                                                                                       1/1 

Installed:
  tigervnc-server.x86_64 0:1.8.0-5.el7                                                                                                                                      

Complete!

改变运行级别并重启

[root@test ~]# systemctl set-default graphical.target
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.
[root@test ~]# systemctl get-default
graphical.target
[root@test ~]# reboot

第一次启动图形化进行简单设置

配置VNC

[root@test ~]# vncserver

You will require a password to access your desktops.

Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used

New 'test:1 (root)' desktop is test:1

Creating default startup script /root/.vnc/xstartup
Creating default config /root/.vnc/config
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/test:1.log

赞(3)
MySQL学习笔记 » Centos7安装配置VNC