#打开监听服务
lsnrctl start
#进入oracle数据库,打开实例
sqlplus / as sysdba #或者sqlplus /nolog startup #关闭实例 shutdown immediate
安装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
#给oracle创建监控用户 CREATE USER C##QGS123 IDENTIFIED BY QGS123 DEFAULT TABLESPACE SYSTEM TEMPORARY TABLESPACE TEMP PROFILE DEFAULT ACCOUNT UNLOCK; GRANT CONNECT TO C##QGS123; GRANT RESOURCE TO C##QGS123; GRANT SELECT ANY TABLE TO C##QGS123; GRANT SELECT ANY DICTIONARY TO C##QGS123; GRANT UNLIMITED TABLESPACE TO C##QGS123; GRANT SELECT ANY DICTIONARY TO C##QGS123; GRANT CREATE SESSION TO C##QGS123; #注释 创建用户C##QGS,密码QGS123 默认表空间系统 临表空间温度 配置文件默认值 账户解锁; 允许连接到C##QGS; 向C##QGS授予资源; 允许选择任意表给C##QGS; 允许选择任意字典到C##QGS; 向C##QGS授予无限表空间; 允许选择任意字典到C##QGS; 将创建会话权限授予C##QGS;