对于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:Usersrobinson.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:Usersrobinson.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)
)
)