windows连接远程Oracle数据库

Posted 自由の翼

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了windows连接远程Oracle数据库相关的知识,希望对你有一定的参考价值。

一、在windows安装Oracle客户端:

下载地址:https://www.oracle.com/database/technologies/112010-win64soft.html
** 选择第二项管理员安装**

  • 问题1:版本错误
    解决:
    修改安装文件:\\client\\stage\\cvu
    编辑该目录下的两个xml文件:oracle.client_InstantClient.xml和cvu_prereq.xml
    按规律添加以下内容:
<OPERATING_SYSTEM RELEASE="6.2">
    <VERSION VALUE="3"/>
    <ARCHITECTURE VALUE="64-bit"/>
    <NAME VALUE="Windows 10"/>
    <ENV_VAR_LIST>
        <ENV_VAR NAME="PATH" MAX_LENGTH="5119" />
    </ENV_VAR_LIST>
</OPERATING_SYSTEM>
  • 问题二:安装目录重复
    重新选择安装目录!

二、安装PL/SQL Developer

下载地址:https://www.allroundautomations.com/try-it-free/

三、登录连接Orcle

  • 问题一:没有监听
    修改服务端Oracle的文件:
    一定得备份!!!
    解决办法简述:
  • 1.修改/home/tools/oracle11g/product/11.2.0/dbhome_1/network/admin/listener.ora中的localhost改为192.168.8.13【服务器IP】;
  • 2.修改/home/tools/oracle11g/product/11.2.0/dbhome_1/network/admin/tnsnames.ora中的localhost改为192.168.8.13【服务器IP】;
  • 3.修改后,重启oracle,监听,并注册,主win10上的plsql就可以远程连接虚拟机上的数据库了。

具体操作步骤如下:

  • 1、修改数据库服务器中listener.ora文件内容
    原始内容:
# listener.ora Network Configuration File:/home/tools/oracle11g/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
    )
  )
ADR_BASE_LISTENER = /home/tools/oracle11g

修改后的内容如下:

# listener.ora Network Configuration File: /home/tools/oracle11g/product/11.2.0/dbhome_1/network/admin/listener.ora# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
    (SID_LIST =
        (SID_DESC =
            (GLOBAL_DBNAME = orcl)
            (ORACLE_HOME = /home/tools/oracle11g/product/11.2.0/dbhome_1/)
            (SID_NAME = orcl)
        )
    )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.8.13)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = /home/tools/oracle11g
  • 2、修改数据库服务器中tnsnames.ora文件内容
    原始内容:
# tnsnames.ora Network Configuration File: /home/tools/oracle11g/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

修改后的内容:

# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

LISTENER_ORCL =
  (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.183.129)(PORT = 1521))

orcl =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.183.129)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

  • 添加服务器
    管理员权限运行Net Mananger
    按步骤添加:

    然后按内容添加:

  • 修改windows客户端文件
    使用管理员权限修改:
    D:\\Oracle11g_Client\\product\\11.2.0\\client_1\\network\\admin
    修改内容为:【核对一下,一般不用修改】

# tnsnames.ora Network Configuration File: D:\\Oracle11g_Client\\product\\11.2.0\\client_1\\NETWORK\\ADMIN\\tnsnames.ora
# Generated by Oracle configuration tools.

ORCL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.183.129)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = orcl)
    )
  )

三、在数据库服务器中启动监听并更新注册

  • 最后重启一下监听与数据库并更新注册
$ lsnrctl stop        #先关闭监听服务
$ lsnrctl start        #开启监听服务
$ sqlplus / as sysdba      #登入
SQL> shutdown immediate    #立即关闭数据库服务
SQL> startup        #开启数据库服务
命令:SQL> alter system register;  #注册
System altered.
SQL>
SQL> quit #登出
输出:
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

四、登录plsql

以上是关于windows连接远程Oracle数据库的主要内容,如果未能解决你的问题,请参考以下文章

PLSQL连接远程Oracle数据库教程(Windows11最新详细教程)

PHP7在windows上配置远程连接Oracle数据库的方法

windows环境下安装连接远程oracle工具PL/SQL Developer 11.0

windows环境下安装连接远程oracle工具PL/SQL Developer 11.0

oracle远程连接报ORA-12541:TNS:无监听程序

NaviCat Primium远程连接Oracle 11g数据库操作方法