Oracle 11gThe clientLinuxThe configuration process is a little bit difficult, but as long as we configure step by step, there is nothing. This article describes how to configure the Oracle 11g client on Linux.
First download several compressed packages from OTN, for: http://www.oracle.com/technology/software/tech/oci/instantclient/index.html, And then according to your platform, choose a different download, I am installed under rhel5, so I chose linux x86 and downloaded the following two packages:
The instantclient-basic-linux32-11.1.0.7.zip Basic Package provides support for OCI, OCCI and JDBC-OCI applications.
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.
Next we will introduce the configuration process as follows:
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 variables.
If sqlplus is used, the PATH environment variable is also set. 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
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, 2008, Oracle. All rights reserved.
-
- Connected to:
-
- 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 client on Linux is introduced here, hoping to bring you some gains!