Linux上配置Unix ODBC连接Oracle数据库

Linux上配置Unix ODBC连接Oracle数据库

作者:eygle

出处:http://blog.eygle.com

日期:January 05, 2005


Oracle10g前,Oracle并不提供UNIX/Linux下的ODBC驱动,用的最为广泛的是UnixOdbc,UnixOdbc的配置不算复杂,但是如果不顺利的话也会遇到一些问题。

今天成功安装配置了UnixOdbc把步骤总结一下供参考。
UnixOdbc可以在官方站点上下载。

以下是测试及配置步骤:

首先你需要安装Oracle客户端,并且确认网络可达。

1.使用isql进行测试

[root@magic root]# isql
**********************************************
* unixODBC - isql *
**********************************************
* Syntax *
* *
* isql DSN [UID [PWD]] [options] *
* *
* Options *
* *
* -b batch.(no prompting etc) *
* -dx delimit columns with x *
* -x0xXX delimit columns with XX, where *
* x is in hex, ie 0x09 is tab *
* -w wrap results in an HTML table *
* -c column names on first row. *
* (only used when -d) *
* -mn limit column display width to n *
* -v verbose. *
* -lx set locale to x *
* --version version *
* *
* Notes *
* *
* isql supports redirection and piping *
* for batch processing. *
* *
* Examples *
* *
* cat My.sql | isql WebDB MyID MyPWD -w *
* *
* Each line in My.sql must contain *
* exactly 1 SQL command except for the *
* last line which must be blank. *
* *
* Please visit; *
* *
* http://www.unixodbc.org *
* [email protected] *
* [email protected] *
**********************************************

[root@magic root]# isql --versio
unixODBC 2.2.10
[root@magic root]# which isql
/usr/bin/isql


2./etc/odbc.ini文件配置

[ODBC Data Sources]
test = Oracle ODBC Driver DSN

[default]
Driver = /usr/local/easysoft/oracle/libesoracle.so

[test]
Driver = /usr/local/easysoft/oracle/libesoracle.so

Description = Oracle
server = 172.16.1.21
ServerType = Oracle
Port = 1521
User = username
Password = password
Database = ava
SID = ava
METADATA_ID = 0
ENABLE_USER_CATALOG = 1
ENABLE_SYNONYMS = 1


[default]
Driver = /usr/local/easysoft/oracle/libesoracle.so


3. /etc/odbcinst.ini 文件配置

;
; odbcinst.ini
;

[test]
Description=ODBC for ORACLE
Driver = /usr/local/easysoft/oracle/libesoracle.so

[ODBC]
Trace=1
Debug=1
Pooling=No


4.sqlnet.ora文件配置

NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME)

5.tnsnames.ora文件配置


  
ava =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.18.21)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SID = ava)
    )
  )


6.测试


  
[root@magic admin]# isql test -v
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> 

7.启动LDAP


  

[root@magic admin]# /usr/local/libexec/slapd -d 5 -f /home/eygle/openldap/slapd.conf
@(#) $OpenLDAP: slapd 2.2.17 (Dec 29 2004 20:45:12) $
[email protected]:/home/eygle/openldap/openldap-2.2.17/servers/slapd
daemon_init: <null><br> daemon_init: listen on ldap:///<br> daemon_init: 1 listeners to open...<br> ldap_url_parse_ext(ldap:///)<br> daemon: IPv6 socket() failed errno=97 (Address family not supported by protocol)<br> daemon: initialized ldap:///<br> daemon_init: 2 listeners opened<br> slapd init: initiated server.<br> ==&gt;backsql_initialize()<br> &lt;==backsql_initialize()<br> &gt;&gt;&gt; dnNormalize: <cn><br> =&gt; ldap_bv2dn(cn=Subschema,0)<br> ldap_err2string<br> &lt;= ldap_bv2dn(cn=Subschema)=0 Success<br> =&gt; ldap_dn2bv(272)<br> ldap_err2string<br> ....<br> ==&gt;backsql_open_db_conn()<br> backsql_open_db_conn(): connected, adding to tree<br> &lt;==backsql_open_db_conn()<br> backsql_get_db_conn(): first call -- reading schema map<br> ==&gt;backsql_load_schema_map()<br> ldapinfo.dn_ru field exists in the schema<br> backsql_load_schema_map(): at_query "SELECT name,sel_expr,from_tbls,join_where,add_proc,delete_proc,param_order,<br> expect_return,sel_expr_u FROM ldap_attr_mappings WHERE oc_map_id=?"<br> &lt;==backsql_load_schema_map()<br> &lt;==backsql_get_db_conn()<br> ==&gt;backsql_free_db_conn()<br> backsql_free_db_conn(): closing db connection<br> ==&gt;backsql_close_db_conn()<br> &lt;==backsql_close_db_conn()<br> &lt;==backsql_free_db_conn()<br> &lt;==backsql_db_open(): test succeeded, schema map loaded<br> slapd starting <br></cn></null>

启动成功.

<!-- google_ad_client = "pub-1012037994804294"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_channel =""; //-->

你可能感兴趣的:(oracle,linux,unix,SQL Server,Google)