ubuntu14.0安装 oracle instant client(oracle 12c)
安装环境
本文介绍在ubuntu14.04系统(X64)上安装Oracle Instant Client,安装版本为11.2.0.4.0(读者需要按照自己安装版本修改相应的版本号)
安装RPM文件
-
在Oracle官网地址 http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html 下载以下RPM文件:
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
-
使用alien转换PRM文件到DEB文件并安装(
sudo apt-get install alien
) -
安装alien后,执行下面的命令安装Oracle客户端:
sudo alien -i oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
sudo alien -i oracle-instantclient11.2-devel-11.2.0.4.0-1.x86_64.rpm
sudo alien -i oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm
配置Oracle环境
-
安装以下步骤新增tnsnames.ora文件:
cd /usr/lib/oracle/11.2/client64
sudo mkdir -p network/admin
sudo vi tnsnames.ora
-
填写如下内容,或者直接从oracle服务器端将相同目录下的这个文件拷贝过来。
# tnsnames.ora Network Configuration File
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.100.126.174)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orclpdb)
)
)
-
链接Oracle的库文件到Oracle目录:
sudo ln -s /usr/include/oracle/11.2/client64 /usr/lib/oracle/11.2/client64/include
配置环境变量
在登录用户的profile中增加以下内容:
export ORACLE_HOME=/usr/lib/oracle/11.2/client64
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
export TNS_ADMIN=$ORACLE_HOME/network/admin
export PATH=$PATH:$ORACLE_HOME/bin
export NLS_LANG="AMERICAN_AMERICA.UTF8"
上面的内容是从https://blog.csdn.net/hanzengyi/article/details/70849091 复制过来的,需要注意的是ORCL
是登录时@后面的名字,而orclpdb是在oracle服务端上通过
select name,pdb from v$services; 查到的pdb对应的name,切记。
下面是我查出来的结果,找到ORCLPDB 对应的NAME,即orclpdb,这个就相当于zbudcdb_stdby
。
NAME PDB -------------------- -------------------- orclXDB CDB$ROOT orcl CDB$ROOT SYS$BACKGROUND CDB$ROOT SYS$USERS CDB$ROOT orclpdb ORCLPDB
注意:查看服务端的监听状态会有以下信息:
[oracle@localhost admin]$ lsnrctl status LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 19-APR-2018 03:56:10 Copyright (c) 1991, 2016, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production Start Date 19-APR-2018 02:42:15 Uptime 0 days 1 hr. 13 min. 55 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /orcl/app/oracle/product/12.1.0/db_1/network/admin/listener.ora Listener Log File /orcl/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=localhost)(PORT=5500))(Security=(my_wallet_directory=/orcl/app/oracle/admin/orcl/xdb_wallet))(Presentation=HTTP)(Session=RAW)) Services Summary... Service "6a02d18fca293032e055000000000001" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... Service "orclXDB" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... Service "orclpdb" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... The command completed successfully
有:Service "orclpdb" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service...,证明监听启动正常。
另外附上远程登录用户的创建过程。
一 先将容器切换成pdb,详见https://blog.csdn.net/hanzengyi/article/details/70849091
1 查看系统中的容器: select con_id,dbid,NAME,OPEN_MODE from v$pdbs; 2 先打开pdb容器: alter pluggable database orclpdb open; 3再查看容器,pdb应该是READ,WRITE: select con_id,dbid,NAME,OPEN_MODE from v$pdbs; 4切换容器: alter session set container=orclpdb; 5查看当前使用的容器 select sys_context ('USERENV', 'CON_NAME') from dual;
二 创建表空间
create tablespace test_space datafile '/usr/local/yrm/oracle_data/test_space.dbf' size 50M autoextend on next 50m maxsize 2048m extent management local; create temporary tablespace test_space_temp tempfile '/usr/local/yrm/oracle_data/test_space_temp.dbf' size 32m autoextend on next 32m maxsize 1024m extent management local;
三 创建用于远程登陆的用户
create user test_user identified by 123456 default tablespace test_space temporary tablespace test_space_temp; grant connect,resource to test_user; grant dba to test_user; alter user test_user account unlock identified by 123456;
四 在oracle主机上启动监听及服务
#su - oracle #切换到 oracle 用户且切换到它的环境 $lsnrctl status #查看监听及数据库状态 $lsnrctl start #启动监听 $sqlplus / as sysdba #以 DBA 身份进入 sqlplus #登陆之后启动服务:startup,shutdown为停止服务。
五 测试远程登陆 sqlplus test_user/123456@ORCl。
成功!
oracle的安装与远程登陆太瘠薄难呢,濒临崩溃~ ,欢迎留言探讨。
.