SQL server database access data across Oracle DBLink synchronous step on pit Record

  Project requirements: A company called it here for the time being, the company has A personnel management software, staff need to do synchronize information with our software company, A company using a SQL server database, our use of Oracle, the interface will not develop ( ten thousand "fuck you"), it is only to our company provides a SQL server account and password, as well as a view. Later Baidu about it, cross-database can be accessed by DBLink, then do data synchronization.

  During installation, stepped on a lot of the pit, you need to configure a lot of things, QQ group where also ask a lot of people, there are very few people have heard of this stuff, now do data docking, all went to the port, pass JSON string up, answer me, it is very few, ten thousand "fuck you", really pit ah, finally spent a day out of the fiddle, so the whole installation procedure recorded.

  First step: the need to download a transparent network, the equivalent of a middleware (we use Oracle 11g, the database may be different from the version you want to install a different transparent network management)

A friend in need please download my Baidu cloud disk

Link: https: //pan.baidu.com/s/1pLsPI8jw7e5JiTazPJpFwQ
extraction code: m7od  

  Step 2: Install a transparent gateway

1, unpacked the installation package, click on the setup.exe installation

2, the next step ( Note: Be sure to seemingly consistent and Oracle database installation directory, when first installed, and Oracle will be installed in different places, and eventually found Baidu for a long time, and Oracle to install the same location )

3, select the form, select SQL Server

4. Fill in SQL SERVER host name and the database name

 

5, start the installation

 

6, after the installation is complete exit, and then began to configure the listener, here is the key! ! ! !

   The third step: transparent gateway configuration

 Configuration instructions:

Local Oracle installation directory: D: \ Oracle \ product \ 11.2.0 \ dbhome_1

Local DBLink installation directory: D: \ Oracle \ product \ 11.2.0 \ dbhome_1

SQL Server:账号:sa;密码:password;IP地址:127.0.0.1

1、来到:D:\Oracle\product\11.2.0\dbhome_1\dg4msql\admin;打开initdg4msql.ora

1 这个目录下可以看到以下initdg4msql.ora文件,上面在安装透明网关的时候有配置的要链接SQL SERVER数据的地址和数据库名称,在这里都可以体现:

配置文件:initdg4msql.ora

 1 # This is a customized agent init file that contains the HS parameters
 2 # that are needed for the Database Gateway for Microsoft SQL Server
 3 
 4 #
 5 # HS init parameters
 6 #
 7 HS_FDS_CONNECT_INFO=[127.0.0.1]:1433//DEMO   注:连接其他的SQL Server可修改此处
 8 HS_FDS_TRACE_LEVEL=OFF
 9 HS_FDS_RECOVERY_ACCOUNT=RECOVER
10 HS_FDS_RECOVERY_PWD=RECOVER

检查一下HS_FDS_CONNECT_INFO是否是我们想要链接的地址,格式为:目标数据库的IP地址:端口//数据库名。SQL SERVER的默认端口是1433。

配置文件:listener.ora.sample(localhost是监听的IP地址,这里我们连的是本地,127.0.0.1也是可以的)

 1 # This is a sample listener.ora that contains the NET8 parameters that are
 2 # needed to connect to an HS Agent
 3 
 4 LISTENER =
 5  (ADDRESS_LIST=
 6       (ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))
 7  )
 8 
 9 SID_LIST_LISTENER=
10   (SID_LIST=
11       (SID_DESC=
12          (SID_NAME=dg4msql)
13          (ORACLE_HOME=D:\Oracle\product\11.2.0\dbhome_1)
14          (PROGRAM=dg4msql)
15       )
16   )
17 
18 #CONNECT_TIMEOUT_LISTENER = 0 

配置文件:tnsnames.ora.sample

1 # This is a sample tnsnames.ora that contains the NET8 parameters that are
2 # needed to connect to an HS Agent
3 
4 dg4msql  =
5   (DESCRIPTION=
6     (ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))
7     (CONNECT_DATA=(SID=dg4msql))
8     (HS=OK)
9   ) 

 2、配置透明网关的监听,来到:D:\Oracle\product\11.2.0\dbhome_1\NETWORK\ADMIN(开始配置这3个文件)

 

配置文件:listener.ora

 1 # This is a sample listener.ora that contains the NET8 parameters that are
 2 # needed to connect to an HS Agent
 3 SID_LIST_LISTENER =
 4   (SID_LIST =
 5     (SID_DESC =
 6       (SID_NAME = CLRExtProc)
 7       (ORACLE_HOME = D:\Oracle\product\11.2.0\dbhome_1)
 8       (PROGRAM = extproc)
 9       (ENVS = "EXTPROC_DLLS=ONLY:D:\Oracle\product\11.2.0\dbhome_1\bin\oraclr11.dll")
10     )
11     (SID_DESC=
12          (SID_NAME=dg4msql)
13          (ORACLE_HOME=D:\Oracle\product\11.2.0\dbhome_1)
14          (PROGRAM=dg4msql)
15     )
16   )
17 
18 LISTENER =
19   (DESCRIPTION_LIST =
20     (DESCRIPTION =
21       (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
22       (ADDRESS = (PROTOCOL = TCP)(HOST = YRDLG5GS4G3ODYI)(PORT = 1521))
23       (ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521))
24     )
25   )
26 
27 ADR_BASE_LISTENER = D:\Oracle
28 
29 #CONNECT_TIMEOUT_LISTENER = 0 
1 这里需要注意的主要是一下几点:
2 PROGRAM为dg4msql:因为实例的配置文件在dg4msql目录下,就是上面的initdg4msql.ora文件所在的目录
3 SID_NAME为dg4msql:这个sid就是上面的文件名中的sid,initdg4msql.ora的sid为dg4msql
4 ORACLE_HOME就是我们透明网关的安装目录
5 ORACLE的监听端口是1521,我的oracle和透明网关是安装在同一台机器上的,所以透明网关的监听端口设置为1522。
6 一个initSID.ora文件就对应一个SID_DESC,可以根据想要链接的数据库来配置。

配置文件:sqlnet.ora

 1 # sqlnet.ora Network Configuration File: D:\Oracle\product\11.2.0\dbhome_1\network\admin\sqlnet.ora
 2 # Generated by Oracle configuration tools.
 3 
 4 # This file is actually generated by netca. But if customers choose to 
 5 # install "Software Only", this file wont exist and without the native 
 6 # authentication, they will not be able to connect to the database on NT.
 7 
 8 SQLNET.AUTHENTICATION_SERVICES= (NONE)
 9 
10 NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

配置文件:tnsnames.ora

 1 # This is a sample tnsnames.ora that contains the NET8 parameters that are
 2 # needed to connect to an HS Agent
 3 ORCL =
 4   (DESCRIPTION =
 5     (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
 6     (CONNECT_DATA =
 7       (SERVER = DEDICATED)
 8       (SERVICE_NAME = orcl)
 9     )
10   )
11 
12 dg4msql  =
13   (DESCRIPTION=
14     (ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521))
15     (CONNECT_DATA=(SID=dg4msql))
16     (HS=OK)
17   ) 

配置完之后,一定不要忘记重启监听!!!!!!一定不要忘记重启监听!!!!!!一定不要忘记重启监听!!!!!!

1 命令:lsnrctl reload

查看监听状态:

  第四步:Oracle配置DBLink

 1、先查看哪些用户可以使用DBLink,没有则创建权限

 

赋权限配置命令

1 如:grant create public database link to system ;
2 格式:grant create public database link to 用户名 ;

2、建立DBLink(用户要一定要权限才可以继续往下执行哦!没有的往上看,给用户配置权限)

 1 create database link DBTEST1
 2   connect to SA identified by "password"
 3   using 'dg4msql';
 4 
 5 
 6 
 7 格式:
 8 create database link DBLink名称
 9   connect to SQL Server账户 identified by "SQL Server密码"
10   using 'SID';

搞定!!!!

 下面这个报错信息,QQ群问一个遍,很少人知道DBLink这玩意,百度上资料也很少,捣鼓一下午,终于搞定了

出现这个问题是因为这6个文件导致的!!!!!!

 捣鼓一下午,问题找到是因为这6个文件配置出问题了,这次就不再叙述了,修改那个配置文件了,配置文件因人而异,剩下的自己百度去查吧~~~~好了,捣鼓一天了,洗洗睡了,拜~~

 

Guess you like

Origin www.cnblogs.com/chenyanbin/p/11291752.html