instantclient在linux下的安装配置过程
1.新建oracle用户,使用root用户
useradd oracle
passwd oracle
2.安装oracle-instantclient
yum localinstall -y oracle-instantclient12.1-basic-12.1.0.1.0-1.x86_64.rpm oracle-instantclient12.1-sqlplus-12.1.0.1.0-1.x86_64.rpm
安装结算后,在 /usr/lib/文件夹下会出现一个新的文件夹oracle
3.修改/usr/lib/oracle文件夹的所有权
cd /usr/lib
chown -R oracle:oracle oracle
4.修改oracle用户的 .bash_profile文件,添加相应环境变量,使用oracle用户
$ vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export ORACLE_HOME=/usr/lib/oracle/12.1/client64
export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$PATH:$ORACLE_HOME/bin
5. .bash_profile文件生效
$ . ./.bash_profile
6.生成tnsnames.ora文件
$ vi /usr/lib/oracle/12.1/client64/network/admin/tnsnames.ora
CACTESTDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.109.10)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = cactestdb)
)
)
7.测试
$ sqlplus /nolog
SQL*Plus: Release 12.1.0.1.0 Production on Sat Jan 4 05:27:00 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
SQL> conn scott/tiger@CACTESTDB
ERROR:
ORA-28000: the account is locked
SQL> conn system/manager@CACTESTDB
Connected.
SQL> select * from scott.emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7369 SMITH CLERK 7902 17-DEC-80 800
20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300
30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500
30
EMPNO ENAME JOB MGR HIREDATE SAL COMM
---------- ---------- --------- ---------- --------- ---------- ----------
DEPTNO
----------
7566 JONES MANAGER 7839 02-APR-81 2975
20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400
30