对于Oracle 网络配置,我们通常通过negmgr或者netca来完成客户端连接到数据库实例。而对于连接到ASM实例,同样可以实现从客户端来进行连接。不过Oracle并未为我们提供工具来完成配置,我们可以通过手动配置监听以及客户端tnsnames来实现。本文对此给出描述与示例。
1、服务器端、客户端的环境 #服务器端环境,host信息 oracle@bo2dbp:~> cat /etc/hosts |grep vip 192.168.7.61 bo2dbp-vip.2gotrade.com bo2dbp-vip 192.168.7.62 bo2dbs-vip.2gotrade.com bo2dbs-vip #操作系统及Oracle版本 oracle@bo2dbp:~> cat /etc/issue Welcome to SUSE Linux Enterprise Server 10 SP3 (x86_64) - Kernel \r (\l). oracle@bo2dbp:~> sqlplus -v SQL*Plus: Release 10.2.0.3.0 - Production #服务器端环境,集群信息 oracle@bo2dbp:~> ./crs_stat.sh Resource name Target State -------------- ------ ----- ora.GOBO4.GOBO4A.inst ONLINE ONLINE on bo2dbp ora.GOBO4.GOBO4B.inst ONLINE ONLINE on bo2dbs ora.GOBO4.db ONLINE ONLINE on bo2dbp ora.bo2dbp.ASM1.asm ONLINE ONLINE on bo2dbp ora.bo2dbp.LISTENER_BO2DBP.lsnr ONLINE ONLINE on bo2dbp ora.bo2dbp.gsd ONLINE ONLINE on bo2dbp ora.bo2dbp.ons ONLINE ONLINE on bo2dbp ora.bo2dbp.vip ONLINE ONLINE on bo2dbp ora.bo2dbs.ASM2.asm ONLINE ONLINE on bo2dbs ora.bo2dbs.LISTENER_BO2DBS.lsnr ONLINE ONLINE on bo2dbs ora.bo2dbs.gsd ONLINE ONLINE on bo2dbs ora.bo2dbs.ons ONLINE ONLINE on bo2dbs ora.bo2dbs.vip ONLINE ONLINE on bo2dbs #客户端信息 C:\Users\robinson.cheng>systeminfo Host Name: PC39 OS Name: Microsoft Windows 7 Professional OS Version: 6.1.7600 N/A Build 7600 OS Manufacturer: Microsoft Corporation System Type: x64-based PC C:\Users\robinson.cheng>sqlplus -v SQL*Plus: Release 10.2.0.3.0 - Production 2、监听器的状态 oracle@bo2dbs:~> lsnrctl status LISTENER_BO2DBS | grep ASM Service "+ASM" has 1 instance(s). #可以看到ASM实例处于BLOCKED状态 Instance "+ASM2", status BLOCKED, has 1 handler(s) for this service... Service "+ASM_XPT" has 1 instance(s). Instance "+ASM2", status BLOCKED, has 1 handler(s) for this service... 3、分配ASM SID #使用下面的ASM配置信息来修改监听器配置文件 Item Node1 Node2 ------ -------- ----------- hostname bo2dbp bo2dbs Oracle SID GOBO4A GOBO4B ASM SID +ASM1 +ASM2 ASM Global DB Name (service name) +ASM +ASM 4、修改监听配置文件listener.ora #对于监听器的配置,仅仅是增加子项SID_DESC #下面是增加之后所看到的内容 oracle@bo2dbp:~> more $ORACLE_HOME/network/admin/listener.ora # listener.ora.bo2dbp Network Configuration File: /u01/oracle/db/network/admin/listener.ora.bo2dbp # Generated by Oracle configuration tools. LISTENER_BO2DBP = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = bo2dbp-vip.2gotrade.com)(PORT = 1521)(IP = FIRST)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.51)(PORT = 1521)(IP = FIRST)) ) ) SID_LIST_LISTENER_BO2DBP = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /u01/oracle/db) (PROGRAM = extproc) (SID_DESC = #这整个SID_DESC项即为ASM1实例新增的条目 (SID_NAME = +ASM1) (GLOBAL_DBNAME = +ASM) (ORACLE_HOME = /u01/oracle/db) ) ) oracle@bo2dbs:~> more $ORACLE_HOME/network/admin/listener.ora # listener.ora.bo2dbs Network Configuration File: /u01/oracle/db/network/admin/listener.ora.bo2dbs # Generated by Oracle configuration tools. LISTENER_BO2DBS = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = bo2dbs-vip.2gotrade.com)(PORT = 1521)(IP = FIRST)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.52)(PORT = 1521)(IP = FIRST)) ) ) SID_LIST_LISTENER_BO2DBS = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (ORACLE_HOME = /u01/oracle/db) (PROGRAM = extproc) ) (SID_DESC = #这整个SID_DESC项即为ASM2实例新增的条目 (SID_NAME = +ASM2) (GLOBAL_DBNAME = +ASM) (ORACLE_HOME = /u01/oracle/db) ) ) 5、重启监听器 oracle@bo2dbp:~> srvctl stop listener -n bo2dbp oracle@bo2dbp:~> srvctl start listener -n bo2dbp oracle@bo2dbp:~> srvctl stop listener -n bo2dbs oracle@bo2dbp:~> srvctl start listener -n bo2dbs #查看监听器的状态 oracle@bo2dbp:~> lsnrctl status LISTENER_BO2DBP | grep ASM Service "+ASM" has 2 instance(s). #可以看到多处了一个为UNKNOWN状态,表明使用了静态方式注册 Instance "+ASM1", status UNKNOWN, has 1 handler(s) for this service... Instance "+ASM1", status BLOCKED, has 1 handler(s) for this service... Service "+ASM_XPT" has 1 instance(s). Instance "+ASM1", status BLOCKED, has 1 handler(s) for this service... oracle@bo2dbs:~> lsnrctl status LISTENER_BO2DBS | grep ASM Service "+ASM" has 2 instance(s). #示例2上监听器状态也多出了一个为UNKNOWN状态的+ASM2实例 Instance "+ASM2", status UNKNOWN, has 1 handler(s) for this service... Instance "+ASM2", status BLOCKED, has 1 handler(s) for this service... Service "+ASM_XPT" has 1 instance(s). Instance "+ASM2", status BLOCKED, has 1 handler(s) for this service... #Author : Robinson #Blog : http://blog.csdn.net/robinson_0612 6、配置客户端tnsnames #Windons 客户端tnsnames.ora添加如下配置条目 GOBO4_ASM1 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.61)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = +ASM) ) ) GOBO4_ASM2 = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.7.62)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = +ASM) ) ) 7、测试连接到ASM实例 C:\Users\robinson.cheng>sqlplus -S sys/oracle@GOBO4_ASM1 as sysdba @inst INSTANCE_NAME HOST_NAME STATUS ---------------- ------------------------------ ------------ +ASM1 bo2dbp STARTED C:\Users\robinson.cheng>sqlplus -S sys/oracle@GOBO4_ASM2 as sysdba @inst INSTANCE_NAME HOST_NAME STATUS ---------------- ------------------------------ ------------ +ASM2 bo2dbs STARTED
更多参考
有关Oracle RAC请参考
使用crs_setperm修改RAC资源的所有者及权限
使用crs_profile管理RAC资源配置文件
RAC 数据库的启动与关闭
再说 Oracle RAC services
Services in Oracle Database 10g
Migrate datbase from single instance to Oracle RAC
Oracle RAC 连接到指定实例
Oracle RAC 负载均衡测试(结合服务器端与客户端)
Oracle RAC 服务器端连接负载均衡(Load Balance)
Oracle RAC 客户端连接负载均衡(Load Balance)
ORACLE RAC 下非缺省端口监听配置(listener.ora tnsnames.ora)
ORACLE RAC 监听配置 (listener.ora tnsnames.ora)
配置 RAC 负载均衡与故障转移
CRS-1006 , CRS-0215 故障一例
基于Linux (RHEL 5.5) 安装Oracle 10g RAC
使用 runcluvfy 校验Oracle RAC安装环境
有关Oracle 网络配置相关基础以及概念性的问题请参考:
配置非默认端口的动态服务注册
配置sqlnet.ora限制IP访问Oracle
Oracle 监听器日志配置与管理
设置 Oracle 监听器密码(LISTENER)
配置ORACLE 客户端连接到数据库
有关基于用户管理的备份和备份恢复的概念请参考
Oracle 冷备份
Oracle 热备份
Oracle 备份恢复概念
Oracle 实例恢复
Oracle 基于用户管理恢复的处理
SYSTEM 表空间管理及备份恢复
SYSAUX表空间管理及恢复
Oracle 基于备份控制文件的恢复(unsing backup controlfile)
有关RMAN的备份恢复与管理请参考
RMAN 概述及其体系结构
RMAN 配置、监控与管理
RMAN 备份详解
RMAN 还原与恢复
RMAN catalog 的创建和使用
基于catalog 创建RMAN存储脚本
基于catalog 的RMAN 备份与恢复
RMAN 备份路径困惑
使用RMAN实现异机备份恢复(WIN平台)
使用RMAN迁移文件系统数据库到ASM
linux 下RMAN备份shell脚本
使用RMAN迁移数据库到异机
有关ORACLE体系结构请参考
Oracle 表空间与数据文件
Oracle 密码文件
Oracle 参数文件
Oracle 联机重做日志文件(ONLINE LOG FILE)
Oracle 控制文件(CONTROLFILE)
Oracle 归档日志
Oracle 回滚(ROLLBACK)和撤销(UNDO)
Oracle 数据库实例启动关闭过程
Oracle 10g SGA 的自动化管理
Oracle 实例和Oracle数据库(Oracle体系结构)