Oracle Linux 7配置vncserver

DBA,在创建Oracle数据库的过程中一般要使用dbca和netca图像化进行建库和创建监听(如果使用脚本建库另说),所以图形化操作工具是必不可少的,在Linux操作系统中个人比较喜欢的图形化操作软件是VNC,今天刚好遇到了Oracle Linux 7的操作环境,就顺手记录一下配置过程。
1.检查系统是否已经安装vncserver软件包

[root@oracle12c ~]# rpm -qa|grep tigervnc
tigervnc-server-minimal-1.2.80-0.30.20130314svn5065.el7.x86_64
tigervnc-license-1.2.80-0.30.20130314svn5065.el7.noarch

没有安装执行以下命令进行安装

[root@oracle12c Packages]# pwd
/run/media/yong/OL-7.0 Server.x86_64/Packages
[root@oracle12c Packages]# yum -y install tigervnc-server-1.2.80-0.30.20130314svn5065.el7.x86_64.rpm
Loaded plugins: langpacks
Examining tigervnc-server-1.2.80-0.30.20130314svn5065.el7.x86_64.rpm: tigervnc-server-1.2.80-0.30.20130314svn5065.el7.x86_64
Marking tigervnc-server-1.2.80-0.30.20130314svn5065.el7.x86_64.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package tigervnc-server.x86_64 0:1.2.80-0.30.20130314svn5065.el7 will be installed
--> Finished Dependency Resolution
http://public-yum.oracle.com/repo/OracleLinux/OL7/UEKR3/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: public-yum.oracle.com; Unknown error"
Trying other mirror.
http://public-yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: public-yum.oracle.com; Unknown error"
Trying other mirror.

Dependencies Resolved

=======================================================================================================================================================================
 Package                     Arch               Version                                      Repository                                                           Size
=======================================================================================================================================================================
Installing:
 tigervnc-server             x86_64             1.2.80-0.30.20130314svn5065.el7              /tigervnc-server-1.2.80-0.30.20130314svn5065.el7.x86_64             488 k

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

Total size: 488 k
Installed size: 488 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : tigervnc-server-1.2.80-0.30.20130314svn5065.el7.x86_64                                                                                              1/1
  Verifying  : tigervnc-server-1.2.80-0.30.20130314svn5065.el7.x86_64                                                                                              1/1

Installed:
  tigervnc-server.x86_64 0:1.2.80-0.30.20130314svn5065.el7

Complete!

2.配置vncserver,之前的版本,如果安装vnc一般都需要使用vncserver命令来设置口令,然后配置/etc/sysconfig/vncservers文件。在Oracle Linux7中,虽然然还存在这个文件,不过其内容只有如下一行:

[root@oracle12c /]# cat /etc/sysconfig/vncservers
# THIS FILE HAS BEEN REPLACED BY /lib/systemd/system/vncserver@.service

先来看一下该文件/lib/systemd/system/vncserver@.service的内容

[root@oracle12c system]# cat /lib/systemd/system/vncserver@.service
# The vncserver service unit file
#
# Quick HowTo:
# 1. Copy this file to /etc/systemd/system/vncserver@:.service
# 2. Edit  and vncserver parameters appropriately
#   ("runuser -l <USER> -c /usr/bin/vncserver %i -arg1 -arg2")
# 3. Run `systemctl daemon-reload`
# 4. Run `systemctl enable vncserver@:.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=/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
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

从上面的可以看到如下信息,这给出了操作步骤。1:是将该文件复制一份到/etc/systemd/system目录下并命名为vncserver@:.service;2:是将<USER>替换成你要开启vncserver的用户名;3:是执行systemctl daemon-reload;4:是执行systemctl enable vncserver@:.service来启动vncserver服务。

# 1. Copy this file to /etc/systemd/system/vncserver@:.service
# 2. Edit  and vncserver parameters appropriately
#   ("runuser -l <USER> -c /usr/bin/vncserver %i -arg1 -arg2")
# 3. Run `systemctl daemon-reload`
# 4. Run `systemctl enable vncserver@:.service`

首先复制文件:

[root@oracle12c system]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service

[root@oracle12c /]# cd /etc/systemd/system
[root@oracle12c system]# ls -lrt vnc*
-rw-r--r--. 1 root root 1744 Mar 28 10:47 vncserver@:1.service

编辑vncserver@:1.service文件将文件中的用root替换
修改前的内容如下:

[root@oracle12c system]# cat /lib/systemd/system/vncserver@.service
# The vncserver service unit file
#
# Quick HowTo:
# 1. Copy this file to /etc/systemd/system/vncserver@:.service
# 2. Edit  and vncserver parameters appropriately
#   ("runuser -l <USER> -c /usr/bin/vncserver %i -arg1 -arg2")
# 3. Run `systemctl daemon-reload`
# 4. Run `systemctl enable vncserver@:.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=/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
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

修改后的内容如下:

[root@oracle12c system]# vi vncserver@:1.service
# The vncserver service unit file
#
# Quick HowTo:
# 1. Copy this file to /etc/systemd/system/vncserver@:.service
# 2. Edit  and vncserver parameters appropriately
#   ("runuser -l <USER> -c /usr/bin/vncserver %i -arg1 -arg2")
# 3. Run `systemctl daemon-reload`
# 4. Run `systemctl enable vncserver@:.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=simple
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill :1 > /dev/null 2>&1 || :'
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver :1"
PIDFile=/root/.vnc/%H:1.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill :1 > /dev/null 2>&1 || :'

[Install]
WantedBy=multi-user.target

这里重点要注意的是Type的值要修改为simple,不能用原来的forking,否则会在执行systemctl start vncserver@:1.service时出现问题,故障信息如下:

[root@oracle12c system]# systemctl start vncserver@:1.service
Job for vncserver@:1.service failed. See 'systemctl status vncserver@:1.service' and 'journalctl -xn' for details.
[root@oracle12c system]# systemctl status vncserver@:1.service
vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled)
   Active: failed (Result: resources) since Mon 2016-03-28 10:57:03 CST; 26s ago
  Process: 11898 ExecStart=/sbin/runuser -l root -c /usr/bin/vncserver %i (code=exited, status=0/SUCCESS)
  Process: 11895 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)

3.设置远程登陆的密码
操作系统登陆,执行vncpasswd,注意这个密码不一定与操作系统登陆的密码一致,需要远程桌面的所有的账号,都需要设置一次。

[root@oracle12c /]# vncpasswd root
Password:
Verify:

4.设置vncserver 为自启动

[root@oracle12c system]# systemctl daemon-reload
[root@oracle12c system]# systemctl enable vncserver@:1.service
[root@oracle12c system]# systemctl start vncserver@:1.service
[root@oracle12c system]# systemctl status vncserver@:1.service
vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled)
   Active: active (running) since Mon 2016-03-28 13:14:47 CST; 14min ago
  Process: 7237 ExecStop=/bin/sh -c /usr/bin/vncserver -kill :1 > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
  Process: 9030 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill :1 > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
 Main PID: 9080 (Xvnc)
   CGroup: /system.slice/system-vncserver.slice/vncserver@:1.service
           鈥9080 /usr/bin/Xvnc :1 -desktop oracle12c:1 (root) -auth /root/.Xauthority -geometry 1024x768 -rfbwait 30000 -rfbauth /root/.vnc/passwd -rfbport 5901 -f...

Mar 28 13:14:47 oracle12c systemd[1]: Started Remote desktop service (VNC).

[root@oracle12c system]# systemctl stop vncserver@:1.service
[root@oracle12c system]# systemctl status vncserver@:1.service
vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled)
   Active: inactive (dead) since Mon 2016-03-28 13:31:08 CST; 12s ago
  Process: 10703 ExecStop=/bin/sh -c /usr/bin/vncserver -kill :1 > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
  Process: 9080 ExecStart=/sbin/runuser -l root -c /usr/bin/vncserver :1 (code=exited, status=0/SUCCESS)
  Process: 9030 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill :1 > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
 Main PID: 9080 (code=exited, status=0/SUCCESS)

Mar 28 13:14:47 oracle12c systemd[1]: Started Remote desktop service (VNC).
Mar 28 13:31:08 oracle12c systemd[1]: Stopping Remote desktop service (VNC)...
Mar 28 13:31:08 oracle12c systemd[1]: Stopped Remote desktop service (VNC).
[root@oracle12c system]# systemctl start vncserver@:1.service
[root@oracle12c system]# systemctl status vncserver@:1.service
vncserver@:1.service - Remote desktop service (VNC)
   Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled)
   Active: active (running) since Mon 2016-03-28 13:31:29 CST; 7s ago
  Process: 10703 ExecStop=/bin/sh -c /usr/bin/vncserver -kill :1 > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
  Process: 10733 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill :1 > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
 Main PID: 10783 (Xvnc)
   CGroup: /system.slice/system-vncserver.slice/vncserver@:1.service
           鈥10783 /usr/bin/Xvnc :1 -desktop oracle12c:1 (root) -auth /root/.Xauthority -geometry 1024x768 -rfbwait 30000 -rfbauth /root/.vnc/passwd -rfbport 5901 -...

Mar 28 13:31:29 oracle12c systemd[1]: Starting Remote desktop service (VNC)...
Mar 28 13:31:29 oracle12c systemd[1]: Started Remote desktop service (VNC).

5.关闭Oracle Linux的防火墙
root用户执行操作
查看防火墙状态。

[root@oracle12c tmp]# systemctl status firewalld
firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled)
   Active: active (running) since Mon 2016-03-28 14:51:40 CST; 6s ago
 Main PID: 14827 (firewalld)
   CGroup: /system.slice/firewalld.service
           14827 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

临时关闭防火墙命令。重启电脑后,防火墙自动起来。
[root@oracle12c tmp]# systemctl stop firewalld

永久关闭防火墙命令。重启后,防火墙不会自动启动。
[root@oracle12c tmp]# systemctl disable firewalld
rm '/etc/systemd/system/basic.target.wants/firewalld.service'
rm '/etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service'

6.使用vnc viewer进行远程连接

时间: 2024-11-02 15:15:25

Oracle Linux 7配置vncserver的相关文章

在linux中配置vncserver的教程

1,安装vncserver包. rpm -qa |grep vnc 若无,则下载,或用linux安装光盘package目录下安装rpm -iv vncserver-* 2,在system/prefefence/remote desktop下面,选上"allow other users to view your desktop",此面板其它选项可不勾选. --这个其实是vino-server的配置,和vncserver是不一样的.如果使用vncserver则不用使用这个. 3,设置vnc

安装Oracle 11g RAC R2 之Linux DNS 配置

    Oracle 11g RAC 集群中引入了SCAN(Single Client Access Name)的概念,也就是指集群的单客户端访问名称.SCAN 这个特性为客户端提供了单一的主机名,用于访问集群中运行的 Oracle 数据库.如果您在集群中添加或删除节点,使用 SCAN 的客户端无需更改自己的 TNS 配置.无论集群包含哪些节点,SCAN 资源及其关联的 IP 地址提供了一个稳定的名称供客户端进行连接使用.在Oracle 11g grid 安装时即要求为该特性配置DNS解析方式或

linux中Ubuntu Server安装和配置VNCServer介绍

Ubuntu下包含2种远程桌面的方式:VINO-Server以及VNC Server. 其中Vino-Server是Ubuntu自带的远程桌面服务器,也就是在系统(System) -> 首选项(Preferences) -> 远程桌面(Remote Desktop)下,可以很容易开启,然后就可以使用VNC Viewer进行远程桌面连接.具体开通办法,可以参见<Ubuntu下开启远程桌面的方法>.不过,这种自带的Vino-Server方式有一个最显著的缺点:那就是当你重启机器之后,必

Oracle Dataguard如何配置物理standby

尽管网上有很多Oracle Dataguard的配置教程,但不难发现,很多采用的是rman duplicate这种方法,尽管此种方法较为简便.但在某种程度上,却也误导了初学者,虽说也能配置成功,但只知其然不知其所以然,Dataguard的本质没有吃透,也不利于其维护和调优. 本配置文档基于Oracle官方文档,目的在于加深大家对于Dataguard的了解. 本配置的结果是最大性能模式下的异步传输 ,因此在参数文件中,只涉及基本的主备参数,没有考虑switchover和最大性能模式下的real t

Oracle Linux 6桥接网卡

  Oracle Linux 6桥接网卡 最近把公司一台老掉牙的旧HP格式化了进行Linux虚拟化,安装一些测试服务器.操作系统使用的是Oracle Linux 6.4,虚拟机使用了KVM. 前面安装都非常顺利,但是到了设置网卡桥接的时候却出现了问题,像以前5.x一样设置的br0配置文件根本就没用,只要一桥接就会出错,网卡和桥接的虚拟网卡都报错. 1 eth0: Connection activation failed: Master connection not found or invali

Oracle Linux 6.3下安装Oracle 11g R2(11.2.0.3)

    本文主要描述了在Oracle Linux 6.3下安装Oracle 11gR2(11.2.0.3).从Oracle 11g开始,Oracle官方网站不再提供其Patch的下载链接,需要使用Meatlink账户才可以进行下载.童鞋们不要着急,没有Metalink账户的也可以自己百度一下,网上有很多下载链接,迅雷就可以搞定了.Oracle 11.2.0.3整合为7个zip压缩包,如果仅仅是安装Oracle Database,下载1至2.zip包即可.下面是其安装步骤.   一.准备安装环境1

Oracle 监听器日志配置与管理

--========================-- Oracle 监听器日志配置与管理--========================    Oracle 监听器是一个服务器端程序,用于监听所有来自客户端的请求,并为其提供数据库服务.因此对监听器的管理与维护相当重要. 本文主要描述对Oracle监听器日志文件的配置与管理.有关监听器的描述请参考     配置 ORACLE 客户端连接到数据库     配置非默认端口的动态服务注册    一.监听器日志特性 1.  监听器日志是一个纯文本

如何在 CentOS Linux 中配置 MariaDB 复制

如何在 CentOS Linux 中配置 MariaDB 复制 这是一个创建数据库重复版本的过程.复制过程不仅仅是复制一个数据库,同时也包括从主节点到一个从节点的更改同步.但这并不意味着从数据库就是和主数据库完全相同的副本,因为复制可以配置为只复制表结构.行或者列,这叫做局部复制.复制保证了特定的配置对象在不同的数据库之间保持一致. Mariadb 复制概念 备份 :复制可以用来进行数据库备份.例如,当你做了主->从复制.如果主节点数据丢失(比如硬盘损坏),你可以从从节点中恢复你的数据库. 扩展

php+apache+linux的配置

问题描述 php+apache+linux的配置 我已经下载好php和apache .gz的包 解压后不知道怎么配置 看一些教程配玩后不是出错,就是不能用 求大神教教 解决方案 在linux下的话,新手我建议使用xampp套件好一点 解决方案二: 具体出啥错了才能回答啊,你这个问题要详细说够出本书了 解决方案三: 那要看具体出什么错 对症下药 解决方案四: http://jingyan.baidu.com/article/6079ad0e5b32c428ff86dba1.html 解决方案五: