Linux下Oracle client(sqlplus)安装和配置
分类专栏: Linux 数据库 文章标签: Linux Oracle Client sqlplus 方向键
版权
1、下载rpm包
http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
[root@node1 ~]# ls
oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm
...
1
2
3
4
5
2、安装
[root@node1 ~]# rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:oracle-instantclient11.2-basic-11################################# [100%]
[root@node1 ~]# rpm -ivh oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:oracle-instantclient11.2-sqlplus-################################# [100%]
[root@node1 ~]# rpm -ivh oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:oracle-instantclient11.2-devel-11################################# [100%]
[root@node1 ~]#
1
2
3
4
5
6
7
8
9
10
11
12
13
3、配置
[root@node1 ~]# mkdir -p /usr/lib/oracle/11.2/client64/network/admin
1
[root@node1 ~]# vim /usr/lib/oracle/11.2/client64/network/admin/tnsnames.ora
1
[root@node1 ~]# cat /usr/lib/oracle/11.2/client64/network/admin/tnsnames.ora
TPADCTEST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.81)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = TPADC)
)
)
[root@node1 ~]#
[root@node1 ~]# vi ~/.bashrc
1
增加几行
export ORACLE_HOME=/usr/lib/oracle/11.2/client64
export TNS_ADMIN=$ORACLE_HOME/network/admin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
1
2
3
4
5
[root@node1 ~]# source ~/.bashrc
1
4、运行SQLPlus
[root@node1 ~]# sqlplus
SQL*Plus: Release 11.2.0.4.0 Production on Tue May 22 14:45:50 2018
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Enter user-name:
1
2
3
4
5
6
7
[root@node1 ~]# sqlplus test/test@//192.168.1.81:1521/TPADC
SQL*Plus: Release 11.2.0.4.0 Production on Tue May 22 14:46:21 2018
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
1
2
3
4
5
6
7
8
9
10
11
12
5、Linux环境下Oracle SqlPlus中方向键问题的解决方法
(1)问题
SQL> ^[[A^[[A^[[B
1
(2)安装readline-devel
[root@node1 ~]# yum install readline-devel
1
(3)下载rlwrap
http://rpm.pbone.net/index.php3/stat/4/idpl/30448081/dir/centos_7/com/rlwrap-0.42-1.1.x86_64.rpm.html
[root@node1 ~]# rpm -ivh rlwrap-0.42-1.1.x86_64.rpm
warning: rlwrap-0.42-1.1.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID 93680782: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:rlwrap-0.42-1.1 ################################# [100%]
[root@node1 ~]#
1
2
3
4
5
6
(4)运行sqlplus
[root@node1 ~]# rlwrap sqlplus test/test@//192.168.1.81:1521/TPADC
SQL*Plus: Release 11.2.0.4.0 Production on Tue May 22 15:00:18 2018
Copyright (c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
1
2
3
4
5
6
7
8
9
10
11
12
(5)别名
alias sqlplus=’rlwrap sqlplus’
alias rman=’rlwrap rman