Oracle 通过透明网关访问mysql配置步骤

http://blog.itpub.net/21601207/viewspace-709366

Oracle 通过透明网关访问mysql配置步骤

一、当前环境

1.  OS

more /etc/redhat-release

Red Hat Enterprise Linux Server release 5.1 (Tikanga)

2.  Oracle

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

3.  Mysql

5.1.46-community-log MySQL Community Server

4.  IP

 

机器名

IP

数据库

A

s1.db.sns.mdc.139.com

192.168.2.235

Oracle

B

backup.139.com

192.168.2.23

mysql

 

 

二、所需的包

mysql-connector-odbc-5.1.8-1.rhel5.x86_64.rpm

unixODBC-2.2.11-7.1.x86_64.rpm

unixODBC-2.2.11-7.1.i386.rpm

 

三、配置过程

1.  在机器A上安装相关包

rpm –ivh mysql-connector-odbc-5.1.8-1.rhel5.x86_64.rpm

yum install unixODBC

 

2.  在机器B上创建mysql用户并授权

grant select on user_global.* to my23_3322@192.168.2.235  identified by 'my23_3322';

 

3.  配置机器A上的 /etc/odbc.ini文件,添加如下内容

[my23_3322]

Driver          = /usr/lib64/libmyodbc5.so

Server   = 192.168.2.23

User = my23_3322

Password = my23_3322

Port = 3322

database = user_global

 

其中,my23_3322 为服务名,后面将会用到

/usr/lib64/libmyodbc5.so 为odbc 驱动

192.168.2.23 为要访问mysql 所在IP

my23_3322 登陆mysql 服务器用户名

3322 为mysql 数据库端口

 

4.  在机器A使用isql 命令进行测试

isql my23_3322

+---------------------------------------+

| Connected!                            |

|                                       |

| sql-statement                         |

| help [tablename]                      |

| quit                                  |

|                                       |

+---------------------------------------+

能够连接上表示ODBC配置成功

 

下面进行oracle 方面的配置,如无特殊说明均在机器A上配置

 

5.  在/opt/oracle/11.2/db_1/hs/admin/目录下,配置init my23_3322.ora文件,   init my23_3322.ora命名方式为init+服务名+.ora。添加如下内容

 

# HS init parameters

#

HS_FDS_CONNECT_INFO = my23_3322

HS_FDS_TRACE_LEVEL = debug

HS_FDS_SHAREABLE_NAME = /usr/lib64/libmyodbc5.so

HS_LANGUAGE=AMERICAN_AMERICA.WE8ISO8859P1


HS_FDS_SQLLEN_INTERPRETATION=32

HS_LONG_PIECE_TRANSFER_SIZE=1258291


# ODBC specific environment variables

#

#set DBCINI=<full path name of the odbc initilization file>

set DBCINI=/etc/odbc.ini

 

HS_FDS_CONNECT_INFO为服务名,与前面保持一致

HS_FDS_TRACE_LEVEL 为日志跟踪级别,不使用时可以设为OFF

HS_FDS_SHAREABLE_NAME 为ODBC驱动

HS_LANGUAGE 为 Provides Heterogeneous Services with character set, language, and territory information of the non-Oracle data source. The value must use the following format:language[_territory.character_set] 。为异构服务器的字符集,语言

HS_FDS_SQLLEN_INTERPRETATION 允许64bit 驱动可以使用32bit 标准,具体解释可以参考oracle 文档ID 554409.1

 

6.  修改tnsnames.ora 文件,添加如下内容

my23_3322 =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = s1.db.sns.mdc.139.com)(PORT = 1521))

    (CONNECT_DATA =

     (SID = my23_3322)

      )

    (hs=ok)

  )

其中SID为前面定义的服务名

HOST为本机的机器名或者IP

PORT为本机的数据库监听器端口

 

7.  修改listener.ora 文件,添加如下内容

   (SID_DESC =

        (SID_NAME = my23_3322)

        (ORACLE_HOME = /opt/oracle/11.2/db_1)

        (PROGRAM = dg4odbc)

        (ENVS=LD_LIBRARY_PATH=/opt/oracle/11.2/db_1/lib:/opt/oracle/11.2/db_1/odbc/lib)

   )

SID_NAME为服务名

PROGRAM 为使用dg4odbc 驱动

8.  重新启动listener ,基本内容如下:

lsnrctl status

Service "my23_3322" has 1 instance(s).

  Instance "my23_3322", status UNKNOWN, has 1 handler(s) for this service...

如果看到my23_3322 这个服务,则表示listener.ora 配置成功

 

9.  创建oracle 中创建数据库链接

sqlplus scott/tiger

create  database link ln_my23_3322 connect to "my23_3322" identified by "my23_3322" using 'my23_3322';

 

10.              测试

 

SQL> select count(1) from tmp_reg_ip@ln_my23_3322;


  COUNT(1)

----------

      3812


Elapsed: 00:00:00.07

SQL> select * from dual@ln_my23_3322;


D

-

X

 

四、安装过程中遇到的问题

1.  配置完成后,执行SQL报如下错误

SQL> select * from dual@ln_my23_3322;

select * from dual@ln_my23_3322

                   *

ERROR at line 1:

ORA-28511: lost RPC connection to heterogeneous remote agent using

SID=ORA-28511: lost RPC connection to heterogeneous remote agent using

SID=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=s1.db.sns.mdc.139.com)(PORT=1521))

(CONNECT_DATA=(SID=my23_3322)))

ORA-02063: preceding line from LN_MY23_3322

Process ID: 18585

Session ID: 96 Serial number: 207

在initmy23_3322.ora文件中添加如下参数

HS_LANGUAGE=AMERICAN_AMERICA.WE8ISO8859P1

参考Oracle ID 555355.1

 

2.  从异种数据库拷贝大数据量时,报错如下

insert into auth_user select * from auth_user@ln_my23_3322

*

ERROR at line 1:

ORA-03113: end-of-file on communication channel

Process ID: 19180

Session ID: 96 Serial number: 227

 

Alert 文件有如下报错:

ORA-07445: exception encountered: core dump [npixfc()+243] [SIGSEGV] [ADDR:0x7FFF086B7C08] [PC:0x59BAB0D] [Address not mapped to object] []

ORA-28511: lost RPC connection to heterogeneous remote agent using SID=ORA-28511: lost RPC connection to heterogeneous remote agent using SID=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=s1.db.sns.mdc.139.com)(PORT=1521))(CONNECT_DATA=(SID=my23_3322)))

ORA-02063: preceding line from LN_MY23_3322

Incident details in: /opt/oracle/diag/rdbms/ora11g/ora11g/incident/incdir_13360/ora11g_ora_17512_i13360.trc

 

现象为服务器内存(4G)被吃光,数据库分配2G内存。机器内存有限无法再提供更多的内存,这可能是个BUG,暂没有找到解决办法,郁闷。。。。。。

 

五、透明网关有如下限制

1.  BLOB and CLOB data cannot be read by pass-through queries

2.  Updates or deletes that include unsupported functions within a WHERE clause are not allowed

3.  Does not support stored procedures

4.  Cannot participate in distributed transactions; they support single-site transactions only

5.  Does not support multithreaded agents

6.  Does not support updating LONG columns with bind variables

7.  Does not support rowids

8.  COMMIT or ROLLBACK in PL/SQL Cursor Loops Closes Open Cursors

9.  UPDATE and DELETE statements with the WHERE CURRENT OF clause are not  supported by the gateway because they rely on the Oracle   implementation.

10.              The gateway does not support the CONNECT BY clause in a SELECT statement.

11.              The Oracle ROWID implementation is not supported.

12.              EXPLAIN PLAN Statement

13.              The gateway does not support the  START WITH condition and NOWAIT in a SELECT statement.

 

六、参考文档

Support.oracle.com

Database Gateway Installation and Configuration Guide for AIX 5L Based Systems (64-Bit), HP-UX Itanium, Solaris Operating System (SPARC 64-Bit), Linux x86, and Linux x86-64

Oracle Database Gateway for ODBC User’s Guide


  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安装 Oracle Linux 透明网关需要进行以下步骤: 1. 安装 Oracle Linux 系统,并确保系统已经更新到最新版本。 2. 安装透明网关软件包: ```sudo yum install oracle-ocn-config``` 3. 配置网络接口: 透明网关需要两个网络接口,一个用于内部网络,一个用于外部网络。您需要将两个接口配置为静态 IP 地址或 DHCP 客户端。您可以使用以下命令查看网络接口的当前配置: ```ip addr show``` 您可以使用以下命令编辑网络接口配置文件: ```sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0``` ```sudo vi /etc/sysconfig/network-scripts/ifcfg-eth1``` 您需要根据您的网络配置更改以下参数: ``` DEVICE=eth0 或 DEVICE=eth1 BOOTPROTO=none 或 BOOTPROTO=dhcp ONBOOT=yes TYPE=Ethernet USERCTL=no ``` 4. 配置透明网关: 您可以使用以下命令编辑透明网关配置文件: ```sudo vi /etc/sysconfig/network-scripts/ifcfg-ocn``` 将以下参数添加到配置文件中: ``` DEVICE=ocn ONBOOT=yes TYPE=Ethernet USERCTL=no BOOTPROTO=none ``` 5. 配置防火墙规则: 透明网关需要允许流量通过,您需要配置防火墙规则以允许所有进出流量通过。 您可以使用以下命令编辑防火墙规则文件: ```sudo vi /etc/sysconfig/iptables``` 在文件中添加以下规则: ``` *filter :INPUT ACCEPT [0:0] :FORWARD ACCEPT [0:0] :OUTPUT ACCEPT [0:0] -A INPUT -j ACCEPT -A FORWARD -j ACCEPT -A OUTPUT -j ACCEPT COMMIT ``` 然后,重新启动 iptables 服务: ```sudo service iptables restart``` 6. 启用透明网关: 使用以下命令启用透明网关: ```sudo systemctl enable ocn``` 然后,重新启动网络服务: ```sudo systemctl restart network``` 7. 配置客户端: 您需要将客户端的网关配置透明网关的 IP 地址。您可以在客户端上使用以下命令更改网关配置: ```sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0``` 更改以下参数: ``` BOOTPROTO=none 或 BOOTPROTO=dhcp ONBOOT=yes TYPE=Ethernet USERCTL=no GATEWAY=<透明网关的 IP 地址> ``` 然后,重新启动网络服务: ```sudo systemctl restart network``` 完成以上步骤后,您的 Oracle Linux 透明网关将已经安装和配置完成,可以开始使用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值