對於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
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視頻教程請關注:http://u.youku.com/user_video/id_UMzAzMjkxMjE2.html