Oracle 11g client Configuration
First download several compressed packages from OTN
For: http://www.oracle.com/technology/software/tech/oci/instantclient/index.html
Then select different downloads based on your platform. I installed them in rhel5, so I chose Linux x86 and downloaded the following two packages:
Instantclient-basic-linux32-11.1.0.7.zip basic package that provides OCI, occi and JDBC-OCI applicationsProgram.
Instantclient-sdk-linux32-11.1.0.7.zip appended header files and makefile files, part of the template needs to be compiled, such as compiling PHP oci8, and Python cx_oracle. (Here we only use its provided OCI header files)
Instantclient-sqlplus-linux32-11.1.0.7.zip optional installation, sqlplus... sometimes testing, managing what is very convenient.
1. Create oracle users and groups:
# Groupadd oinstall
# Useradd-G oinstall Oracle
# Passwd Oracle
2. Create an oracle basic directory
# Mkdir-P/usr/local/Oracle
# Chown-r ORACLE: oinstall/usr/local/Oracle
# Chmod-r 775/usr/local/Oracle
Decompress the tar.gz or zip package and copy it to the/usr/local/Oracle directory.
3. Set the ORACLE_HOME and LD_LIBRARY_PATH environment variables, and configure the tns_admin variable (directory where tnsname. ora is placed). If sqlplus is used, set the PATH environment variable. Modify. bash_profile in the Oracle user directory and add the following statement.
Export ORACLE_HOME =/usr/local/Oracle
# Export oracle_sid = hbdb
Export sqlpath =/usr/local/Oracle
# Search for the tnsnames. ora path
Export tns_admin =/usr/local/Oracle
Export nls_lang = ''american _ America. zhs16gbk''
Export LD_LIBRARY_PATH = $ ORACLE_HOME: $ LD_LIBRARY_PATH
Export Path = $ path: $ ORACLE_HOME
4. tnsnames. ora Configuration:
Mydb =
(Description =
(Address_list =
(Address = (Protocol = TCP) (host = 10.0.0.5) (Port = 1521 ))
)
(CONNECT_DATA =
(SID = hbdb)
(Server = dedicated)
)
)
5. connect SQL plus to the database:
Sqlplus user/passwd@10.0.0.5/hbdb or sqlplus user/passwd @ mydb
If: sqlplus: Error while loading shared libraries:/usr/local/Oracle/libnnz11.so: cannot restore segment prot after reloc: Permission denied appears
The simplest solution is to set the permissive status of the SELinux bit:
[Root @ localhost ~] # Getenforce
Enforcing
[Root @ localhost ~] # Setenforce 0
[Root @ localhost ~] # Getenforce
Permissive
[Oracle @ localhost ~] # Sqlplus xfdb/xfdb @ mydb
SQL * Plus: Release 11.1.0.7.0-production on Wed JUN 17 16:37:06 2009
Copyright (c) 1982,200 8, Oracle. All rights reserved.
Connected:
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0-64bit Production
With the partitioning, OLAP, data mining and real application testing options
SQL> select sysdate from dual;
Sysdate
------------
17-jun-09
SQL>
6. Test the database access component dboci of the eams Project (C ++ encapsulation of OCI)
First create a libclntsh. so.11.1 link:
[Oracle @ localhost Oracle] # ln-s libclntsh. so.11.1 libclntsh. So
# Include "dboci. H"
# Include <iostream>
Int main (void)
{
Cdboci OCI;
Int iret = OCI. Open ("xfdb", "xfdb", "hbdb ");
If (iret <1)
Return 0 ;//
Char *** result = NULL;
Int num = OCI. Query ("select sysdate from dual", & result, 1 );
If (Num> 0)
{
For (INT I = 0; I <num; I ++)
{
STD: cout <result [I] [0] <STD: Endl;
}
OCI. freeexecsqlbuf (& result, num, 1 );
}
OCI. Close ();
Return 1;
}
Scons script:
ENV = environment ()
Env. append (ccflags = '-G ')
Src_files = Split ('dbconnect. cpp ../dboci/source/dboci. cpp ')
Include = Split ('/usr/local/Oracle/SDK/include ../dboci/include ')
Lib_path = Split ('/usr/local/Oracle ')
Lib_files = Split ('clntsh nnz11 ')
Env. Program (target = 'dbconnect ', source = src_files, Libs = lib_files, libpath = lib_path, cpppath = include)
Running result:
[Root @ localhost dbconnecttest] #./dbconnect
17-jun-09
So far, the development and deployment of database access for the eams project have passed the test!
The configuration of the Oracle 11g real-time client in Windows
1. Extract the compressed file to the root directory of drive D;
2. edit the environment, add D: \ instantclient_11_1 to path (before other Oracle Directories), add the system environment variable tns_admin to D: \ instantclient_11_1, and set ORACLE_HOME to D: \ instantclient_11_1; nls_lang is ''american _ America. zhs16gbk''
For example, on Windows 2000, choose Start> Settings> Control Panel> system> advanced> environment variables ", edit the path in the system Variable list. Set the system environment variable tns_admin to D: \ instantclient_11_1, the system environment variable ORACLE_HOME to D: \ instantclient_11_1, and the system environment variable nls_lang to american_america.zhs16gb
3. Edit the D: \ instantclient_11_1 \ tnsnames. ora file:
Mydb =
(Description =
(Address_list =
(Address = (Protocol = TCP) (host = 10.0.0.5) (Port = 1521 ))
)
(CONNECT_DATA =
(SID = hbdb)
(Server = dedicated)
)
)
Here: mydb: database instance name
10.0.0.5 database server address
Hbdb: the SID of the database;