RAC中通過設定服務名實現業務分割
說明:通過在RAC中新增四個監聽服務,來實現通過不同服務名連線到不同的例項。
注意:不配置DNS而使用SCAN IP時,通過客戶機連線RAC伺服器時,需要在客戶機的hosts檔案中配置一下SCAN IP以及VIP的條目。
如果只配置SCAN IP未配置VIP的條目,會報錯:ORA-12545: Connect failed because target host or object does not exist
客戶機通過SCAN連線RAC資料庫的步驟是:SCAN IP LISTENER接收到連線請求時,會根據 LBA 演算法將該客戶端的連線請求,轉發給對應的instance上的VIP LISTENER。
client -> scan listener -> local listener<VIPLISTENER > -> local instance
SCAN IP的介紹,詳見:http://blog.csdn.net/q947817003/article/details/11558709
1.檢視並使用srvctl來增加服務名
[oracle@bysrac1 ~]$ crs_stat -t-bash: crs_stat: command not found
[oracle@bysrac1 ~]$ su - grid
Password:
[grid@bysrac1 ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 24-OCT-2013 09:41:36
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 24-OCT-2013 09:24:34
Uptime 0 days 0 hr. 17 min. 2 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /g01/app/11.2.0/grid/network/admin/listener.ora
Listener Log File /g01/app/grid/diag/tnslsnr/bysrac1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.221)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.226)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "bysrac" has 1 instance(s).
Instance "bysrac1", status READY, has 1 handler(s) for this service...
The command completed successfully
使用srvctl向監聽中增加 jiaoyi ,fengkong,caiwu,jiesuan四個服務--要用ORACLE使用者
[grid@bysrac1 ~]$ srvctl add service -d bysrac -s jiaoyi -r "bysrac1"PRCD-1026 : Failed to create service jiaoyi for database bysrac
PRKH-1014 : Current user grid is not the same as oracle owner oracle of oracle home /u01/app/oracle/product/11.2.0/dbhome_1.
[grid@bysrac1 ~]$ exit
logout
[oracle@bysrac1 ~]$ srvctl add service -d bysrac -s jiaoyi -r "bysrac1"
[oracle@bysrac1 ~]$ srvctl add service -d bysrac -s fengkong -r "bysrac2"
[oracle@bysrac1 ~]$ srvctl add service -d bysrac -s caiwu -r "bysrac1"
[oracle@bysrac1 ~]$ srvctl add service -d bysrac -s jiesuan -r "bysrac2"
[oracle@bysrac1 ~]$ su - grid
Password:
[grid@bysrac1 ~]$ crs_stat -t 可以看到新增的四個服務已經存在,但還是OFFLINE狀態。
Name Type Target State Host
------------------------------------------------------------
ora....MBAK.dg ora....up.type OFFLINE OFFLINE
ora....DATA.dg ora....up.type ONLINE ONLINE bysrac1
ora....SMDG.dg ora....up.type ONLINE ONLINE bysrac1
ora....ER.lsnr ora....er.type ONLINE ONLINE bysrac1
ora....N1.lsnr ora....er.type ONLINE ONLINE bysrac2
ora.asm ora.asm.type ONLINE ONLINE bysrac1
ora....iwu.svc ora....ce.type OFFLINE OFFLINE
ora.bysrac.db ora....se.type ONLINE ONLINE bysrac1
ora....ong.svc ora....ce.type OFFLINE OFFLINE
ora....oyi.svc ora....ce.type OFFLINE OFFLINE
ora....uan.svc ora....ce.type OFFLINE OFFLINE
ora....SM1.asm application ONLINE ONLINE bysrac1
ora....C1.lsnr application ONLINE ONLINE bysrac1
ora....ac1.gsd application OFFLINE OFFLINE
ora....ac1.ons application ONLINE ONLINE bysrac1
ora....ac1.vip ora....t1.type ONLINE ONLINE bysrac1
ora....SM2.asm application ONLINE ONLINE bysrac2
ora....C2.lsnr application ONLINE ONLINE bysrac2
ora....ac2.gsd application OFFLINE OFFLINE
ora....ac2.ons application ONLINE ONLINE bysrac2
ora....ac2.vip ora....t1.type ONLINE ONLINE bysrac2
ora.eons ora.eons.type ONLINE ONLINE bysrac1
ora.gsd ora.gsd.type OFFLINE OFFLINE
ora....network ora....rk.type ONLINE ONLINE bysrac1
ora.oc4j ora.oc4j.type OFFLINE OFFLINE
ora.ons ora.ons.type ONLINE ONLINE bysrac1
ora.scan1.vip ora....ip.type ONLINE ONLINE bysrac2
啟動新增的四個監聽的服務
[grid@bysrac1 ~]$ crs_start ora.bysrac.jiaoyi.svc
Attempting to start `ora.bysrac.jiaoyi.svc` on member `bysrac1`
Start of `ora.bysrac.jiaoyi.svc` on member `bysrac1` succeeded.
[grid@bysrac1 ~]$ crs_start ora.bysrac.fengkong.svc
Attempting to stop `ora.bysrac.db` on member `bysrac2`
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux Error: 2: No such file or directory
Process ID: 0
Session ID: 0 Serial number: 0
Stop of `ora.bysrac.db` on member `bysrac2` succeeded.
Attempting to start `ora.bysrac.db` on member `bysrac2`
Start of `ora.bysrac.db` on member `bysrac2` succeeded.
Attempting to start `ora.bysrac.jiesuan.svc` on member `bysrac2`
Start of `ora.bysrac.jiesuan.svc` on member `bysrac2` succeeded.
Attempting to start `ora.bysrac.fengkong.svc` on member `bysrac2`
Start of `ora.bysrac.fengkong.svc` on member `bysrac2` succeeded.
[grid@bysrac1 ~]$ crs_start ora.bysrac.caiwu.svc
Attempting to start `ora.bysrac.caiwu.svc` on member `bysrac1`
Start of `ora.bysrac.caiwu.svc` on member `bysrac1` succeeded.
[grid@bysrac1 ~]$ crs_start ora.bysrac.jiesuan.svc
CRS-5702: Resource 'ora.bysrac.jiesuan.svc' is already running on 'bysrac2'
CRS-0223: Resource 'ora.bysrac.jiesuan.svc' has placement error.
再來查詢各資源和服務狀態
[grid@bysrac1 ~]$ crs_stat -tName Type Target State Host
------------------------------------------------------------
ora....MBAK.dg ora....up.type OFFLINE OFFLINE
ora....DATA.dg ora....up.type ONLINE ONLINE bysrac1
ora....SMDG.dg ora....up.type ONLINE ONLINE bysrac1
ora....ER.lsnr ora....er.type ONLINE ONLINE bysrac1
ora....N1.lsnr ora....er.type ONLINE ONLINE bysrac2
ora.asm ora.asm.type ONLINE ONLINE bysrac1
ora....iwu.svc ora....ce.type ONLINE ONLINE bysrac1
ora.bysrac.db ora....se.type ONLINE ONLINE bysrac1
ora....ong.svc ora....ce.type ONLINE ONLINE bysrac2
ora....oyi.svc ora....ce.type ONLINE ONLINE bysrac1
ora....uan.svc ora....ce.type ONLINE ONLINE bysrac2
ora....SM1.asm application ONLINE ONLINE bysrac1
ora....C1.lsnr application ONLINE ONLINE bysrac1
ora....ac1.gsd application OFFLINE OFFLINE
ora....ac1.ons application ONLINE ONLINE bysrac1
ora....ac1.vip ora....t1.type ONLINE ONLINE bysrac1
ora....SM2.asm application ONLINE ONLINE bysrac2
ora....C2.lsnr application ONLINE ONLINE bysrac2
ora....ac2.gsd application OFFLINE OFFLINE
ora....ac2.ons application ONLINE ONLINE bysrac2
ora....ac2.vip ora....t1.type ONLINE ONLINE bysrac2
ora.eons ora.eons.type ONLINE ONLINE bysrac1
ora.gsd ora.gsd.type OFFLINE OFFLINE
ora....network ora....rk.type ONLINE ONLINE bysrac1
ora.oc4j ora.oc4j.type OFFLINE OFFLINE
ora.ons ora.ons.type ONLINE ONLINE bysrac1
ora.scan1.vip ora....ip.type ONLINE ONLINE bysrac2
至此在RAC配置服務並啟動的操作完成。
2.下面需要在tnsnames.ora檔案中進行配置
[oracle@bysrac1 ~]$ cd $ORACLE_HOME/network/[oracle@bysrac1 network]$ ls
admin doc install jlib lib log mesg tools trace
[oracle@bysrac1 network]$ cd admin/
[oracle@bysrac1 admin]$ ls
samples shrept.lst tnsnames.ora
[oracle@bysrac1 admin]$ vi tnsnames.ora
編輯結果如下:--主要增加了新增的四個服務的連線串
藉助RAC的SCAN,可以只指定服務名而不顯式指定例項,由SCAN來根據配置的服務名指定的例項,最終通過監聽的服務名定位到具體的例項。
BYSRAC =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = bysrac-cluster-scan)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = bysrac)
)
)
caiwu =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = bysrac-cluster-scan)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = caiwu)
)
)
jiaoyi =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = bysrac-cluster-scan)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = jiaoyi)
)
)
fengkong =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = bysrac-cluster-scan)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = fengkong)
)
)
jiesuan =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = bysrac-cluster-scan)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = jiesuan)
)
)
"tnsnames.ora" 53L, 1266C written
這裡未在RAC的另一節點上修改,可以直接把此tnsnames.ora檔案SSH傳送過去即可。
3.登陸測試,可以實現通過不同服務登陸不同例項
[oracle@bysrac1 admin]$ sqlplus bys/bys@caiwuBYS@ caiwu>select instance_name from v$instance;
INSTANCE_NAME
----------------
bysrac1
###############################################
[oracle@bysrac1 admin]$ sqlplus bys/bys@jiaoyi
BYS@ jiaoyi>select instance_name from v$instance;
INSTANCE_NAME
----------------
bysrac1
############################################
[oracle@bysrac1 admin]$ sqlplus bys/bys@jiesuan
BYS@ jiesuan>select instance_name from v$instance;
INSTANCE_NAME
----------------
bysrac2
##############################################
[oracle@bysrac1 admin]$ sqlplus bys/bys@fengkong
BYS@ fengkong>select instance_name from v$instance;
INSTANCE_NAME
----------------
bysrac2
相關文章
- 通過Eureka中已經註冊的服務名,呼叫服務
- 通過C#實現OPC-UA服務端(二)C#服務端
- Go實戰 22 | 網路程式設計:通過 RPC 實現跨平臺服務Go程式設計RPC
- C#通過rabbitmq實現定時任務(延時佇列)C#MQ佇列
- Windos NTP 服務設定
- 如何通過全面質量管理 (TQM) 實現業務增長?
- 通過Nacos讓Nginx擁有服務發現能力Nginx
- [翻譯]微服務設計模式 - 5. 服務發現 - 服務端服務發現微服務設計模式服務端
- NodeJs服務註冊與服務發現實現NodeJS
- Dubbo服務降級設定
- Linux中如何實現定時任務Linux
- Angular父子元件通過服務傳參Angular元件
- linux中透過systemctl建立服務並實現開機啟動Linux
- Linux下Apache服務的基本設定(企業級)LinuxApache
- 如何管理企業通訊服務?
- 通過事件風暴發現業務流程 - Sarah Denayer事件
- 隗華:OceanBase 企業服務助力客戶實現業務無憂
- Docker實現服務發現Docker
- etcd實現服務發現
- 如何設定iis服務更安全
- [記]SAF 中快取服務的實現快取
- 微服務的服務間通訊與服務治理微服務
- 通過express快速搭建一個node服務Express
- 通過MapReduce降低服務響應時間
- 實現客戶端與服務端的HTTP通訊客戶端服務端HTTP
- mybatis實現變數定義,實現sql業務程式碼MyBatis變數SQL
- 在騰訊雲容器服務 TKE 中利用 HPA 實現業務的彈性伸縮
- 定時任務crond服務
- 業務名詞
- Windows 服務設定工具 WinSW 使用教程Windows
- SpringBoot Windows 自啟動 - 透過 Windows Service 服務實現Spring BootWindows
- 通過 Samba 服務,建立 Linux 開發環境SambaLinux開發環境
- 使用 grpcurl 通過命令列訪問 gRPC 服務RPC命令列
- 實現SSR服務端渲染服務端
- PHP實現代理服務功能PHP
- Keepalived實現服務高可用
- 製造企業如何實現“一碼通”的業務管理?
- 微服務架構中的服務發現策略微服務架構
- 資料服務在新媒體業務體系中的實踐