Centos7下安装Sql*Plus并连接远程Oralce服务器
1.下载oracle sqlplus,选择下载 .rpm文件(以12.2版本为例)
https://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html
2. 下载两个 .rpm文件
oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm
oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86_64.rpm
3. 安装 rpm
rpm -ivh oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm
rpm -ivh oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86_64.rpm
4. 编辑sqlplus配置文件
成功安装rpm包后,oracle客户端的默认路径为: /usr/lib/oracle/12.2/client64
编辑配置文件ld.so.conf
$ sudo vim /etc/ld.so.conf
#在文件尾部添加--根据自己实际情况
/usr/lib/oracle/12.2/client64/lib
5. 配置oracle环境变量
编辑配置文件.bashrc, .bashrc文件在 ~ 路径下,在文件末尾加上:
#sqlplus remote configure
export ORACLE_HOME=/usr/lib/oracle/12.2/client64
export TNS_ADMIN=$ORACLE_HOME
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/loacl/lib:$LD_LIBRARY_PATH
#export SQLPATH=$ORACLE_HOME
#export NLS_LANG=AMERICAN_CHINA.ZHS16GBK
export PATH=$PATH:$ORACLE_HOME/bin
保存,使生效: source .bashrc
6. 配置oracle连接文件tnsnames.ora
在 /usr/lib/oracle/12.2/client64/路径下新建文件夹 network/admin/,再新建文件 tnsnames.ora
编辑 tnsnames.ora
# tnsnames.ora Network Configuration File: /opt/oracle/12c/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.122.133)(PORT = 1521))
转接名 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.122.133)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = serviceName)
)
)
7. 测试
sqlplus username/userpwd@转接名
查询当前用户下的表
select table_name from user_tables;