#打开监听服务
lsnrctl start
#进入oracle数据库,打开实例
sqlplus / as sysdba
startup
安装oracle客户端
#创建oracle目录,进入oracle目录
mkdir -p oracle
cd oracle
#安装wget命令
yum -y install wget
#下载oracle客户端
wget https://download.oracle.com/otn_software/linux/instantclient/199000/oracle-instantclient19.9-basic-19.9.0.0.0-1.x86_64.rpm
wget https://download.oracle.com/otn_software/linux/instantclient/199000/oracle-instantclient19.9-sqlplus-19.9.0.0.0-1.x86_64.rpm
wget https://download.oracle.com/otn_software/linux/instantclient/199000/oracle-instantclient19.9-devel-19.9.0.0.0-1.x86_64.rpm
wget https://download.oracle.com/otn_software/linux/instantclient/199000/oracle-instantclient19.9-odbc-19.9.0.0.0-1.x86_64.rpm
#通过下面的命令安装 oracle-instantclient
yum -y install unixODBC unixODBC-devel
yum localinstall oracle-instantclient19.9-*
#oracle-instantclient的安装位置如下
/usr/lib/oracle/19.9/client64
/usr/share/oracle/19.9/client64
/usr/include/oracle/19.9/client64
保证好监听和实例是运行状态
#打开监听
lsnrctl start
实例名和服务名很重要,后面都会用到
su - oracle
sqlplus / as sysdba
select instance_name from v$instance;
select global_name from global_name;
exit
配置SQLPlus连接
需要在/usr/lib/oracle/19.9/client64下创建 network/admin 文件夹,用来配置 tnsnames.ora
#配置SQLPLUS连接扩展
mkdir -p /usr/lib/oracle/19.9/client64/network/admin
vi /usr/lib/oracle/19.9/client64/network/admin/tnsnames.ora
#添加如下内容
test_oracle=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = IP)(PORT = PORT))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = 数据库SID服务名)
)
)
#配置环境变量
vi /etc/profile
添加内容如下
export ORACLE_HOME=/usr/lib/oracle/19.9/client64
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib64:$LD_LIBRARY_PATH
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$PATH:$ORACLE_HOME/bin:$HOME/binsource /etc/profile
chmod +x /usr/lib/oracle/19.9/client64/lib/libsqora.so.19.1
cd /usr/lib64/
ln -s libodbcinst.so.2.0.0 libodbcinst.so.1
#添加Oracle驱动
vi /etc/odbcinst.ini
#添加如下内容
[oracle]
Description = Oracle ODBC driver for Oracle 12c
Driver = /usr/lib/oracle/19.9/client64/lib/libsqora.so.19.1
#添加oracle数据源,IP,数据库服务名,用户,密码,自行添加
vi /etc/odbc.ini
#添加如下内容
[test]
Driver = Oracle
ServerName = IP:1521/数据库SID
UserID =
Password =
进行ISQL测试
#验证是否配置成功
sql -v test
sqlplus 用户名/密码@IP/oracle数据库服务名 #如sqlplus system/xxxx@IP:1521/cdb1