By dblink oracle want to visit sqlserver database, this time you need an oracle software, Transparent Gateway ( Transparent Gateway )
The following is the transparent gateway download address of oracle12c.
Link: https://pan.baidu.com/s/1s8xKDI6SapDSbndn8_Greg
Extraction code: If epvu fails or cannot open the link, you can either send
me a private message or leave a message in the comment area.
The environment I tested is sqlserver2008 and oracle12c , all of which are operated under windows .
First of all: install geteway, the gateways folder will be generated after decompression
Double-click to enter the gateways folder, and then double-click setup.exe to install
Then enter the installation interface,
It is recommended to choose an existing windows user, preferably the same user used during oracle installation.
The installation path here is best to be consistent with the installation path of ORACLE_HOME, which is also convenient for subsequent operations.
Here, because you want to create a dblink of sqlserver, check sqlserver.
Then fill in the connection information of the sqlserver database here, you can leave it alone now, and it will be mentioned in the configuration later.
You can install it afterwards. At the end of the installation, you will be reminded to create a new monitor. You can choose not to create it. The configuration will continue to be mentioned later.
After the gateway installation is over, start to configure,
First enter the ORACLE_HOME path, which is the oracle installation path (E:\app\oracle12c\product\12.2.0\dbhome_1)
There will be a dg4msql folder, which is the configuration file of the gateway.
After entering the dg4msql/admin/ folder, start writing configuration files,
First modify the initdg4msql.ora file, this file contains the connection information of the sqlserver database, which is where the sqlserver database connection information is configured above
The file is named init sid .ora, so sid_name is dg4msql.
Only need to modify the following sentence: the following information corresponds to ip: port // instance name / database name
HS_FDS_CONNECT_INFO=IP address: 143//MSSQLSERVER/QZGX_QX_2018
Then save and exit.
Next modify listener.ora.sample
Just configure it as shown in the figure above, and the only thing that needs to be modified is the path information of oracle_home.
LISTENER =
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))
)
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(SID_NAME=dg4msql)
(ORACLE_HOME=E:\app\oracle12c\product\12.2.0\dbhome_1)
(PROGRAM=dg4msql)
)
)
After that is the tnsnames.ora.sample file.
dg4msql =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))
(CONNECT_DATA=(SID=dg4msql))
(HS=OK)
)
Just write as shown in the figure above.
Key points: The modification of the above two files has no substantive effect, just for the convenience of subsequent configuration file modification.
The next step is also the most critical step.
Modify the original oracle's listener.ora and tnsnames.ora files
Enter the oracle_home/network/admin folder (E:\app\oracle12c\product\12.2.0\dbhome_1\network\admin)
Just add the information framed in the picture above
(SID_DESC=
(SID_NAME = dg4msql)
(ORACLE_HOME = E:\app\oracle12c\product\12.2.0\dbhome_1)
(PROGRAM = dg4msql)
)
And this piece of information comes from the listener.ora.sample information in the previously edited gateway.
Then add in tnsnames.ora
dg4msql =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))
(CONNECT_DATA=(SID=dg4msql))
(HS=OK)
)
This piece of information also comes from tnsnames.ora.sample.
At this point, all configuration files have been modified.
然后 win+r -> cmd ->lsnrctl stop -> lsnrctl start -> lsnrctl status
At this time you will see a monitoring instance of dg4msql
Then you can use the command to create a dblink
create PUBLIC database link TOQZGX_QX_2018 connect to "sa" identified by "Aa111111" using 'dg4msql' ;
dblink created successfully
Then you can access the sqlserver database through the following command
SELECT * FROM gs_etps_info@TOQZGX_QX_2018;
So far, the dblink from oracle to sqlserver has been created.