Detailed steps for configuring the Oracle 11g client on Linux

Source: Internet
Author: User

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:

 
 
  1. #groupadd oinstall  
  2.  
  3. #useradd -g oinstall oracle  
  4.  
  5. #passwd oracle 

2. Create an Oracle basic directory

 
 
  1. #mkdir –p /usr/local/oracle  
  2.  
  3. #chown –R oracle:oinstall /usr/local/oracle  
  4.  
  5. #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:

 
 
  1. Export ORACLE_HOME =/usr/local/oracle
  2.  
  3. # Export ORACLE_SID = hbdb
  4.  
  5. Export SQLPATH =/usr/local/oracle
  6.  
  7. # Search for the tnsnames. ora path
  8.  
  9. Export TNS_ADMIN =/usr/local/oracle
  10.  
  11. Export NLS_LANG = ''american _ america. ZHS16GBK''
  12.  
  13. Export LD_LIBRARY_PATH = $ ORACLE_HOME: $ LD_LIBRARY_PATH
  14.  
  15. Export PATH = $ PATH: $ ORACLE_HOME

4. tnsnames. ora Configuration:

 
 
  1. MYDB =  
  2.  
  3. (DESCRIPTION =  
  4.  
  5. (ADDRESS_LIST =  
  6.  
  7. (ADDRESS = (PROTOCOL = TCP)(HOST = 10.0.0.5)(PORT = 1521))  
  8.  
  9. )  
  10.  
  11. (CONNECT_DATA =  
  12.  
  13. (SID = HBDB)  
  14.  
  15. (SERVER = DEDICATED)  
  16.  
  17. )  
  18.  

5. connect SQL plus to the database:

 
 
  1. Sqlplus user/passwd@10.0.0.5/hbdb or sqlplus user/passwd @ MYDB

If:

 
 
  1. 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:

 
 
  1. [root@localhost ~]# getenforce  
  2.  
  3. Enforcing  
  4.  
  5. [root@localhost ~]# setenforce 0  
  6.  
  7. [root@localhost ~]#  getenforce  
  8.  
  9. Permissive  
  10.  
  11. [oracle@localhost ~]# sqlplus xfdb/xfdb@MYDB  
  12.  
  13. SQL*Plus: Release 11.1.0.7.0 - Production on Wed Jun 17 16:37:06 2009  
  14.  
  15. Copyright (c) 1982, 2008, Oracle.  All rights reserved.  
  16.  
  17. Connected to:  
  18.  
  19. Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - 64bit Production  
  20.  
  21. With the Partitioning, OLAP, Data Mining and Real Application Testing options  
  22.  
  23. SQL> select sysdate from dual;  
  24.  
  25. SYSDATE  
  26.  
  27. ------------  
  28.  
  29. 17-JUN-09  
  30.  
  31. SQL> 

6. Test the database access component dboci of the eams Project (c ++ encapsulation of oci)

First create a libclntsh. so.11.1 link:

 
 
  1. [oracle@localhost oracle]# ln -s libclntsh.so.11.1  libclntsh.so  
  2.  
  3. #include "dboci.h"  
  4.  
  5. #include <iostream> 
  6.  
  7. int main(void)  
  8.  
  9. {  
  10.  
  11. CDbOci oci;  
  12.  
  13. int iret = oci.Open("xfdb", "xfdb", "HBDB");  
  14.  
  15. if (iret < 1)  
  16.  
  17.     return 0;   //  
  18.  
  19. char*** result = NULL;  
  20.  
  21. int num = oci.Query("select sysdate from dual", &result, 1);  
  22.  
  23. if (num > 0)  
  24.  
  25. {     
  26.  
  27.     for (int i=0; i < num; i++)  
  28.  
  29.     {  
  30.  
  31.         std::cout <<result[i][0] <<std::endl;  
  32.  
  33.     }  
  34.  
  35.     oci.FreeExecSqlBuf(&result, num, 1);  
  36.  
  37. }  
  38.  
  39. oci.Close();  
  40.  
  41. return 1;  
  42.  

Scons script:

 
 
  1. env = Environment()  
  2.  
  3. env.Append(CCFLAGS='-g')  
  4.  
  5. src_files = Split('DBconnect.cpp ../dboci/source/dboci.cpp')  
  6.  
  7. include = Split('/usr/local/oracle/sdk/include ../dboci/include')  
  8.  
  9. lib_path = Split('/usr/local/oracle')  
  10.  
  11. lib_files = Split('clntsh nnz11')  
  12.  
  13. env.Program(target='dbconnect',source = src_files, LIBS=lib_files, LIBPATH=lib_path,CPPPATH=include) 

Running result:

 
 
  1. [root@localhost dbconnecttest]# ./dbconnect  
  2.  
  3. 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!

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.