oracle database 远程连接
2018-10-07 本文已影响0人
e43ef8a56980
- download the latest JDBC driver for dbeaver ojdbc8.jar
you must login in to download for the very first time.
for example, if you downloaded ojdbc7.jar, to install this into your maven repository use this
mvn install:install-file -Dfile=ojdbc7.jar -DgroupId=com.oracle -DartifactId=ojdbc7 -Dversion=12.1.0.1 -Dpackaging=jar
the output will be like
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---
[INFO] Installing /home/yz/.dbeaver-drivers/ojdbc7.jar to /home/yz/.m2/repository/com/oracle/ojdbc7/12.1.0.1/ojdbc7-12.1.0.1.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.491 s
[INFO] Finished at: 2018-10-08T22:59:05+08:00
[INFO] Final Memory: 6M/178M
[INFO] ------------------------------------------------------------------------
- open the port on your server.
or make sure firewall is not running on your server. my centos case
firewall-cmd --state
- sample working tnsnames.ora file on client side
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
- sample working listener.ora file on the server side ( just copy the sample file offered by the installation )
LISTENER =
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))
(ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)))
change listener.ora HOST=0.0.0.0
to accept all the connections
- start the listener process
lsnrctl stat
- connect
sqlplus hr/xxxxxxx@localhost/orcl
orcl : database
hr: username
xxxx : password
localhost : server address
change according your need
-
test from my local fedora to remote tecent cloud server centos 7.4
image.png