1.下载安装包
下载链接
https://www.oracle.com/technetwork/database/database-technologies/instant-client/downloads/index.html
instantclient-basic-linux.x64-12.2.0.1.0.zipinstantclient-jdbc-linux.x64-12.2.0.1.0.zipinstantclient-odbc-linux.x64-12.2.0.1.0-2.zipinstantclient-sdk-linux.x64-12.2.0.1.0.zipinstantclient-sqlplus-linux.x64-12.2.0.1.0.zipinstantclient-tools-linux.x64-12.2.0.1.0.zip
2.安装
在当前目录下解压缩zip包得到:
instantclient_12_23.创建数据库连接文件(可选)
[root@localhost oracle]# cd instantclient_12_2[root@localhost instantclient_12_2]# mkdir -p network/admin
并在 admin 目录下创建 tnsnames.ora 文件:
ORCL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )
4.配置环境变量
这里配置 root 用户环境变量: ~/.bashrc
export ORACLE_HOME=/opt/oracle/instantclient_12_2export PATH=$ORACLE_HOME:$PATHexport TNS_ADMIN=$ORACLE_HOME/network/adminexport LD_LIBRARY_PATH=$ORACLE_HOME:$LD_LIBRARY_PATHexport NLS_LANG='american_america.AL32UTF8'
配置完毕后,进行刷新环境变量,进行生效
source ~/.bashrc
5.测试
[root@localhost instantclient_12_2]# sqlplus /nolog6SQL*Plus: Release 12.2.0.1.0 Production on Fri Nov 9 15:45:04 2018Copyright (c) 1982, 2016, Oracle. All rights reserved.SQL>
出现上面的结果说明测试成功。
6.数据库导入导出
exp username/password@//host:1521/orclpdb1 file=/opt/oracle/daochu.dmp owner=usernameimp username/password@//host:1521/orclpdb1 file=/opt/oracle/daochu.dmp