- 论坛徽章:
- 0
|
最近闲来无事,试着摆弄了一下Sybase ECDA(Enterprise Connect Data Access),它是Sybase ASE数据库用以访问异构数据库的组件。我试着用ECDA访问了一个SQL Server2005,下面是一些步骤,各位大虾轻点拍:
1. 操作系统信息
[root@RHAS4 etc]# lsb_release -a
LSB Version: :core-3.0-ia32:core-3.0-noarch:graphics-3.0-ia32:graphics-3.0-noarch
Distributor ID: RedHatEnterpriseAS
Description: Red Hat Enterprise Linux AS release 4 (Nahant Update 4)
Release: 4
Codename: NahantUpdate4
[root@RHAS4 etc]# rpm -qa |grep gcc
gcc-g77-3.4.6-3
libgcc-3.4.6-3
gcc-c++-3.4.6-3
gcc-java-3.4.6-3
compat-libgcc-296-2.96-132.7.2
compat-gcc-32-c++-3.2.3-47.3
gcc-3.4.6-3
gcc-objc-3.4.6-3
compat-gcc-32-3.2.3-47.3
2. 安装的软件
ECDA
1> select @@version
2> go
Version
---------------------------------------------------------------------------------------------------------
DirectConnect for DCANY/15.0/P/INTEL i686/Linux Red Hat 2.4.21-27.0.2.ELsmp/012
/OPT/Jul 28 2007 18:23:02
ASE1502ESD#5
With ODBC driver
unixODBC
unixODBC貌似不用安装,ECDA自带了unixODBC的lib库。
安装文件:unixODBC-2.2.14.tar.gz
命令:(使用root账号)
./configure (可能会提示没有qt,按照提示加入一个参数即可)
make
make install
默认安装路径:
/usr/local/
odbcinst.ini位于
/usr/local/etc
FreeTDS
FreeTDS是访问SQL Server的ODBC驱动。
安装文件: freetds-stable.tgz
命令:(使用root账号)
./configure
make
make install
3. 配置ECDA连接SQL Server
1. 使用ecda登录
2. cd $SYBASE
3. ln –s ../odbc.ini odbc.ini
ECDA连接目标库时,需要到$SYBASE目录下寻找odbc.ini,所以这里做了个连接,指向了$SYBASE/../odbc.ini。也可以新建一个odbc.ini文件。
4. 在odbc.ini中增加一个名为test2sqlserver的DSN:
[test2sqlserver]
Driver = /usr/local/lib/libtdsodbc.so
Description = My Second Test DSN
Trace = No
Server = SQLServerIP
Database = master
Port = 44173
TDS_Version = 8.0
5. 增加一个名字为tosqlserver端口为2345的ECDA Server:
AddServer tosqlserver 2345
6. 修改
$SYBASE/../servers/tosqlserver/cfg/dcany.cfg
增加一个名为SQLSERVER2005的 Service,如下所示:
[Service Library]
{Logging}
LogSvcLibStatistics=0
{Client Interaction}
ODBCDriverManager=libodbc.so.1.0.0
SvclibDescription=Access Service Library for ODBC.
[SQLSERVER2005]
{ACS Required}
ConnectionSpec1=test2sqlserver
{Client Interaction}
EnableAtStartup=yes
{Target Interaction}
其中的ConnectionSpec1指向了刚才建立的那个SQL Server DSN:test2sqlserver。
EnableAtStartup置为yes,意为启动ECDA server时自动启动SQLSERVER2005服务。
7. 为了使用iqsl能够访问ECDA目标库,还需要修改$SYBASE/interfaces如下:
tosqlserver
master tcp ether localhostip 2345
query tcp ether localhostip 2345
SQLSERVER2005
query tcp ether localhostip 2345
8. 启动tosqlserver:
DCStart –Stosqlserver
9. 使用isql登录SQLSERVER2005:
isql –Usa –Ppasswd –SSQLSERVER2005
不出意外,你应该可以访问目标库了。
4. ASE通过ECDA访问SQL Server
1. 在SQLSERVER中创建一个源表:
1> use master
2> go
1> create table t3 (c1 int,c2 int,c3 int,c4 int)
2> go
在ASE端:
2. 修改interfaces文件,增加:
SQLSERVER2005
master tcp ether ECDAIP 2345
query tcp ether ECDAIP 2345
SQLSERVER2005一定要与ECDA配置的service名字一致。
3. 增加server:
sp_addserver mssql, direct_connect, SQLSERVER2005
4. 增加extern login:
use master
go
sp_addexternlogin mssql, sa, sa, remote_login_passwd
go
5. 创建代理表:
1> use testdb
2> go
1> create proxy_table myt3proxy at 'mssql.master..t3'
2> go
源表一定要存在于ecda odbc.ini中指定的数据库中。ECDA配置的是msater,因此此处t3一定要是master中的表。例如,如果t4存在于SQLServer的testdb中,就会报一个错:
1> create proxy_table myt4proxy at 'mssql.testdb..t4'
2> go
Msg 30291, Level 19, State 0:
Server 'mssql', Line 1:
[[Message Iteration=1|Data Source Name=OpenClient|SQLState=42000|Native
Error=15250|Message=[FreeTDS][SQL Server]The database name component of the
object qualifier must be the name of the current database.]
查询代理表:
1> select * from myt3proxy
2> go
c1 c2 c3 c4
----------- ----------- ----------- -----------
1 1 1 1
(1 row affected) |
|