CentOS 安装 oracle 11g 客户端
又是折腾的一天,同事又不会搞..又让我来搞....
1.官网下载oracle 客户端(需登录)
https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html
下载:
instantclient-basic-linux.x64-11.2.0.4.0.zip
或者oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
instantclient-sqlplus-linux.x64-11.2.0.4.0.zip
或者oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm
我这边下载的是rpm包直接暴利快速安装~
2.安装软件包
注:默认安装位置为 /usr/lib/oracle/11.2
rpm -ivh oracle-instantclient11.2-basic-11.2.0.4.0-1.x86_64.rpm
rpm -ivh oracle-instantclient11.2-sqlplus-11.2.0.4.0-1.x86_64.rpm
3.配置环境变量
vim ~/.bash_profile
export ORACLE_HOME=/usr/lib/oracle/11.2
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export TNS_ADMIN=$ORACLE_HOME/network/admin
刷新环境变量:source ~/.bash_profile
4.配置tnsnames.ora
反正这个可以从其他机器复制过来
/usr/lib/oracle/11.2/network/admin
vi tnsnames.ora
---->
SENSOR1 =
(DESCRIPTION =
(ENABLE = BROKEN)
(FAILOVER = YES)
(ADDRESS = (PROTOCOL = TCP)(HOST = ip2)(PORT = 1525))
(ADDRESS = (PROTOCOL = TCP)(HOST = ip1)(PORT = 1525))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = sensor)
(FAILOVER_MODE =
(TYPE = select)
(METHOD = BASIC)
(RETRIES = 30)
(DELAY = 10)
)
)
)
SENSOR2 =
(DESCRIPTION =
(ENABLE = BROKEN)
(FAILOVER = YES)
(ADDRESS = (PROTOCOL = TCP)(HOST = ip1)(PORT = 1525))
(ADDRESS = (PROTOCOL = TCP)(HOST = ip2)(PORT = 1525))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = sensor)
(FAILOVER_MODE =
(TYPE = select)
(METHOD = BASIC)
(RETRIES = 30)
(DELAY = 10)
)
)
)
<----
5.访问远程 oracle
#登录命令为用户名、密码、数据库名
sqlplus username/passwd@sensor2
期间也有很多出现的错误,比如机器名不对也会啥的..既来之则安之吧...