[RAC]ORACLE Database 10g RAC for Administrators學習筆記(四)
7. Services
Traditional Workload Dispatching
傳統模式下,每個應用被永久性地分配到一部分相對獨立的資源,這些分配到的資源必須分別滿足每個應用的峰值需求。由於應用的峰值時段一般只持續幾小時,因此在絕大多數時間中,大量資源處於浪費狀態。
Grid Workload Dispatching
在網格計算環境下,由一個全域性的資源池同時對多個應用提供使用,在不同的應用間計算單元可被動態地分配和調整。
What Is a Service?
• Is a means of grouping sessions that are doing the same kind of work
可將完成同一種工作的會話分組
• Provides a single-system image instead of a multipleinstances image
提供一種單一系統的映像(可以跨多個例項)
• Is a part of the regular administration tasks that provide dynamic service-to-instance allocation
可動態增加或減少支援該service的instance
• Is the base for High Availability of connections
高可用性連線的基礎元素
• Provides a new performance-tuning dimension
提供一種新的效能調優角度
High Availability of Services in RAC
• Preferred instances:
– Set the initial cardinality for the service – 設定支援service的instance的初始基數
– Are the first to start the service – 在啟動service時即啟動
• Available instances are used in response to preferredinstance failures.
相關的HA配置資訊儲存在OCR中
Possible Service Configuration with RAC
• Active/spare – N+M,M個空閒例項為多個service提供failover功能
• Active/symmetric – 各service在所有節點上均勻分佈
• Active/asymmetric – 根據負載將各service在所有節點上作不對等的分佈
Service Attributes
• Global unique name
• Network name
• Load Balancing Advisory goal*
• Distributed transactions flag*
• Advance queuing notification characteristics for OCI and ODP.NET clients*
• Failover characteristics*
• Connection load-balancing algorithm*
• Threshold
• Priority
• High-availability configuration*
clb_goal: 確認使用connection數或者使用LBA來進行負載均衡(short or long)
LBA goal: LBA使用的負載均衡策略
Service Types
• Application services – 上限為100,服務名長度不能超過64個字元
• Internal services:
– SYS$BACKGROUND
– SYS$USERS
– Cannot be deleted or changed
Service Goodness – 評價service執行情況的效能指標,由MMNL進行根據service metrics進行計算。使用的metrics由不同的service goal決定。
Create Services with the DBCA
使用DBCA,可新增、刪除服務,配置prefer和available例項以及TAF。DBCA配置CRS resource,也配置net service服務名。
實驗:在動態註冊的情況下,啟動一個服務,會在例項的service_names變數中新增這個服務名,在關閉例項的時候再去掉這個例項名。
Create Services with Enterprise Manager
使用EM新增、刪除服務及配置服務屬性。但不再tnsnames.ora檔案中新增網路服務名。
Create Services with SRVCTL
使用srvctl add/remove service命令新增/刪除服務。可配置prefer和available instance及TAF。(經實驗,一定要使用oracle使用者來建立服務,否則服務可能無法正常啟動)
Modify Services with the DBMS_SERVICE Package
使用dbms_service包修改service的一些屬性(dbca或EM無法修改),但由於未和clusterware進行整合,因此無法設定prefer或available的instance。可用於非rac環境建立和刪除例項。還可將連線到某個例項及某個服務的所有會話斷開。
Everything Switches to Services
• Data dictionary maintains services. – service相關的統計資訊
• The AWR measures the performance of services.
• The Database Resource Manager uses services in place of users for priorities.
• Job scheduler, Parallel Query (PQ), and Streams queues run under services.
• RAC keeps services available within a site.
• Data Guard Broker with RAC keeps primary services available across sites.
Use Services with Client Applications
透過在tns設定中將connect_data配置為service,即可連線到特定的service。
Use Services with the Resource Manager
使用service來進行consumer group的對映。當連線建立時,根據會話連線的service自動分配consumer group。可用於管理service間的優先順序和資源使用限制。
Use Services with the Scheduler
當建立一個job class時,為其指定service。則該class中的所有作業都執行在該service下。這樣設定便於進行一些工作負載管理以及效能調優。同時,把一個job class與service關聯起來而不是與一個特定的instance關聯起來,有助於提升高可用性以及更好地進行負載均衡。
instance_stickiness – job的屬性。設定為true傾向於採用負載均衡的策略選擇job執行的例項。
Use Services with Parallel Operations
在並行查詢或並行DML中,slave可在一個不支援coordinator所屬service的例項上執行,當並行操作執行完成後,該slave自動恢復為預設service。
Use Services with Metric Thresholds
Two service-level thresholds
– ELAPSED_TIME_PER_CALL
– CPU_TIME_PER_CALL
React on generated alerts
– Change priority.
– Relocate services.
– Add instances for services.
如使用dbms_server_alert來設定metric thresholds,則每個intance都需要設定thresholds。
Service Aggregation and Tracing
• Statistics can be aggregated at finer levels: - service一級的統計資訊預設收集
– MODULE
– ACTION
– Combination of SERVICE_NAME, MODULE, ACTION
• Tracing can be done at various levels:
– SERVICE_NAMES
– MODULE
– ACTION
– Combination of SERVICE_NAME, MODULE, ACTION
在shared server模式下,service/module/action一級的資訊收集對問題分析有較大用處。
Service_name - 登陸時設定;MODULE&ACTION – 使用dbms_application_info包或OCI呼叫在應用中設定。可使用DBMS_MONITOR包配置統計資訊收集和trace。統計資訊收集為資料庫一級的操作,例項重啟後設定仍然生效。Trace收集預設收集所有instance,但也可指定特定的instance。
Trcsess Utility – 可透過session ID、client ID、service name、action name、module name等對trace檔案進行篩選,可將多個檔案合併成單個trace檔案,使用tkprof工具閱讀。
Manage Services
• Use EM or SRVCTL to manage services:
Start/stop/enable/disable/relocate/modify/get status info/add/remove
• Use the DBCA :
Add/remove/modify(prefer/available/TAF)
服務必須enable後才能啟動。Disable服務可避免不必要的自動重啟。
Relocate – 臨時將服務從一個節點移到另一個節點。這個操作會強制中斷原節點所有與該服務相連的會話。
Using Distributed Transactions with RAC
在RAC環境下支援分散式事務時,如同一事務的兩部分被分配到不同例項執行,可能會產生資料不一致、死鎖等問題。解決方法為將service的 DTP屬性置為true。支援分散式事務的service只能有一個prefer的節點。
Restricted Session and Services
當一個節點起到restricted session模式時,(1) 有restricted session許可權的使用者也只能從本地連線例項;(2) 如為動態註冊,listener把該節點排除在負載均衡策略之外。如為靜態註冊,無法將其排除在負載均衡之外,可能會造成該例項成為cluster中最為空閒的例項,大量連線被髮送到該例項後又被拒絕,造成應用堵塞。
8. High Availability of Connections
Types of Workload Distribution
Connection balancing is rendered possible by configuring multiple listeners on multiple nodes:
– Client-side connect-time load balancing
– Client-side connect-time failover
– Server-side connect-time load balancing
Run-time connection load balancing is rendered possible by using connection pools
Client-Side Connect-Time Load Balancing
客戶端發起連線時隨機選擇一個地址
ERP =
(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE=ON)
(ADDRESS=(PROTOCOL=TCP)(HOST=node1vip)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=node2vip)(PORT=1521))
)
(CONNECT_DATA=(SERVICE_NAME=ERP)))
Client-Side Connect-Time Failover
客戶端連線一個地址失敗後嘗試其他地址。配置vip後,可避免等待TCP/IP超時。
ERP =
(DESCRIPTION =
(ADDRESS_LIST =
(LOAD_BALANCE=ON)
(FAILOVER=ON)
(ADDRESS=(PROTOCOL=TCP)(HOST=node1vip)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=node2vip)(PORT=1521))
)
(CONNECT_DATA=(SERVICE_NAME=ERP)))
靜態註冊global dbname(在listener.ora檔案中設定GLOBLE_DBNAME)會使connect_time failover disable掉。
Server-Side Connect-Time Load Balancing
Spfile:
*.REMOTE_LISTENER=RACDB_LISTENERS
Server-Side tnsnames.ora:
RACDB_LISTENERS=
(DESCRIPTION=
(ADDRESS=(PROTOCOL=tcp)(HOST=node1vip)(PORT=1521))
(ADDRESS=(PROTOCOL=tcp)(HOST=node2vip)(PORT=1521)))
使用動態服務註冊允許PMON程式將service的執行情況提供給listener,以便進行負載均衡。
remote_listener – 列出了配置中所有的listener
local_listener – 設定後使得動態註冊可以註冊到非1521埠的監聽
Fast Application Notification: Overview
使用FAN event在failure發生時對應用進行快速提醒。已被整合到多種客戶端中。
Fast Application Notification: Benefits
• No need for connections to rely on connection timeouts
• Used by Load Balancing Advisory to propagate load information
• Designed for enterprise application and management console integration
• Reliable distributed system that:
– Detects high-availability event occurrences in a timely manner
– Pushes notification directly to your applications
• Tightly integrated with:
– Oracle JDBC applications using connection pools
– Enterprise Manager
– Data Guard Broker
FAN-Supported Event Types
SERVICE
SRV_PRECONNECT
SERVICEMEMBER
DATABASE
INSTANCE
ASM
NODE
SERVICE_METRICS
FAN Event Status
Up/down/preconn_up/preconn_down/nodedown/not_restarting/restart_failed/Unknown
FAN Event Reasons
User/failure/dependency/unknown/autostart/Boot
FAN Event Format
VERSION=
[service=
[database=
[host=
status=
reason=
[card=
timestamp=
Load Balancing Advisory: FAN Event
Event type為SERVICE_METRICS,計算應該分配給每個instance的request百分比。
Server-Side Callouts Implementation
• Writing callouts involves:
1. Parsing callout arguments: The event payload
2. Filtering incoming FAN events
3. Executing event-handling programs
Configuring the Server-Side ONS
ONS配置檔案路徑:
三個引數:localport/remoteport/nodes
如使用ocr的配置,則在檔案中設定useocr=on。透過racgons命令配置。
Optionally Configure the Client-Side ONS
在client端,10.1版本需要安裝ons並起daemon。10.2版本只需呼叫API即可。
JDBC Fast Connection Failover: Overview
FCF與JDBC ICC共同使用,用於對中斷的連線進行快速自動恢復。當某個節點的服務down時,event handler自動清理無用當的連線。當新的節點啟動服務時,event handler回收部分未使用的連線並重新建立連線。由於listener的負載均衡機制達到連線在多個節點上的均勻分佈。
使用本地或遠端ONS接收FAN event可支援JDBC thin以及OCI drivers
使用AQ釋出FAN event可支援ODP.NET或OCI
Using Oracle Streams Advanced Queuing for FAN
使用dbms_service.modify_service開啟設定
exec DBMS_SERVICE.MODIFY_SERVICE (
service_name => 'SELF-SERVICE', aq_ha_notification => TRUE);
透過DBA_OUTSTANDING_ALERTS檢視檢視FAN events。
JDBC/ODP.NET FCF Benefits
自動負載均衡connections和requests(使用哪個連線進行工作)、連線預先建立、失敗的連線可被立刻檢測和清除。
Load Balancing Advisory
LBA – 一個advisory,可用於各種傳遞連線請求的客戶端。對如何在各節點間均衡分配工作任務給出建議。
The Load Balancing Advisory is deployed with Oracle’s key clients, such as Connection Load Balancing, JDBC Implicit Connection Cache, OCI Session Pool, Oracle Data Provider (ODP) Connection Pool for .NET, and is open for third-party subscription via ONS.
JDBC/ODP.NET Runtime Connection Load Balancing: Overview
透過使用LBA,可根據各節點間服務執行情況來分配工作(在連線池中將工作分配給已建立的連線),實時進行負載均衡。
Connection Load Balancing in RAC
根據不同的clb_goal,使用不同的metrics作為connection load balancing的依據。
• Session count by instance - clb_goal=LONG
• Run queue length of the node - clb_goal=SHORT & goal= DBMS_SERVICE.GOAL_NONE
• Goodness by service – clb_goal=SHORT
Load Balancing Advisory: Summary
• Uses DBMS_SERVICE.GOAL
– Service time: weighted moving average of elapsed time
– Throughput: weighted moving average of throughput
• AWR
– Calculates goodness locally (MMNL), forwards to master MMON
– Master MMON builds advisory for distribution of work across RAC, and posts load balancing advice to AQ
– IMON retrieves advice and send it to ONS
– EMON retrieves advice and send it to OCI
– Local MMNL post goodness to PMON
• Listeners use DBMS_SERVICE.CLB_GOAL=SHORT
– Use goodness from PMON to distribute connections.
• Load Balancing Advisory users (inside the pools)
– Use percentages and flags to send work.
Monitor LBA FAN Events
SQL> SELECT TO_CHAR(enq_time, 'HH:MI:SS') Enq_time, user_data
2 FROM sys.sys$service_metrics_tab
3 ORDER BY 1 ;
Transparent Application Failover: Overview
TAF提供一種功能,使得應用在初始連線中斷後自動重連。活動事務被回滾,但查詢可以繼續執行(可選)。
TAF提供兩種failover的方式:
Basic: 在failover時建立連線
Preconnect: 為初始連線維護一個shadow connection,在failover時使用這個提前建立的連線。
TAF Basic Configuration Without FAN: Example
$ srvctl add service -d RACDB -s AP -r I1,I2 -P BASIC
$ srvctl start service -d RACDB -s AP
AP =
(DESCRIPTION =(FAILOVER=ON)(LOAD_BALANCE=ON)
(ADDRESS=(PROTOCOL=TCP)(HOST=N1VIP)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=N2VIP)(PORT=1521))
(CONNECT_DATA =
(SERVICE_NAME = AP)
(FAILOVER_MODE =
(TYPE=SESSION)
(METHOD=BASIC)
(RETRIES=180)
(DELAY=5))))
TYPE - SESSION/SELECT
TAF Basic Configuration with FAN: Example
10.2版本中提供,可使用dbms_service包在server端配置TAF,客戶端連線串無須配置failover_mode。
TAF Preconnect Configuration: Example
$ srvctl add service -d RACDB -s ERP -r I1 –a I2 -P PRECONNECT
$ srvctl start service -d RACDB -s ERP
ERP =
(DESCRIPTION =(FAILOVER=ON)(LOAD_BALANCE=ON)
(ADDRESS=(PROTOCOL=TCP)(HOST=N1VIP)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=N2VIP)(PORT=1521))
(CONNECT_DATA = (SERVICE_NAME = ERP)
(FAILOVER_MODE = (BACKUP=ERP_PRECONNECT)
(TYPE=SESSION)(METHOD=PRECONNECT))))
ERP_PRECONNECT =
(DESCRIPTION =(FAILOVER=ON)(LOAD_BALANCE=ON)
(ADDRESS=(PROTOCOL=TCP)(HOST=N1VIP)(PORT=1521))
(ADDRESS=(PROTOCOL=TCP)(HOST=N2VIP)(PORT=1521))
(CONNECT_DATA = (SERVICE_NAME = ERP_PRECONNECT)))
Shadow service自動命名為
TAF Verification
SELECT machine, failover_method, failover_type, failed_over, service_name, COUNT(*)
FROM v$session
GROUP BY machine, failover_method, failover_type, failed_over, service_name;
FAN Connection Pools and TAF Considerations
• Both techniques are integrated with services and provide service connection load balancing.
• Do not use FCF when working with TAF, and vice versa. - 兩者無法同時使用
• Connection pools that use FAN are always preconnected.
• TAF may rely on operating system (OS) timeouts to detect failures.
• FAN never relies on OS timeouts to detect failures.
[@more@]來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/8558093/viewspace-1016290/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 10g RAC故障處理Oracle 10g
- RAC學習筆記-Day_01筆記
- Solaris 10下遷移10G RAC (四)
- 10g RAC on AIXAI
- Linux下Oracle 11.2.0.1 RAC安裝筆記LinuxOracle筆記
- Oracle 10g RAC 資料儲存更換Oracle 10g
- Disable Database Audit In Oracle 19c RAC-20220111DatabaseOracle
- Oracle 11.2 DataGuard RAC To RAC搭建Oracle
- AIX 5.3 Install Oracle 10g RAC 錯誤集錦AIOracle 10g
- oracle RACOracle
- Oracle RAC Cache Fusion 系列十七:Oracle RAC DRMOracle
- Oracle 19c Concepts(18):Concepts for Database AdministratorsOracleDatabase
- Oracle RAC CacheFusion 系列十五:Oracle RAC CRServer Part TwoOracleServer
- Oracle Database 19c(19.9) RAC On RedHat 8.3 Using VirtualBox and MacBookOracleDatabaseRedhatMac
- ORACLE RAC clusterwareOracle
- 【RAC】Oracle RAC如何修改心跳網路Oracle
- oracle 10g flashback databaseOracle 10gDatabase
- Oracle RAC Cache Fusion系列十八:Oracle RAC Statisticsand Wait EventsOracleAI
- 【TUNE_ORACLE】Oracle 19c RAC搭建番外篇之RAC引數配置參考(四)Oracle
- Oracle 19c Concepts(17):Topics for Database Administrators and DevelopersOracleDatabaseDeveloper
- 【RAC】Oracle rac 如何修改公網及vipOracle
- Oracle RAC Cache Fusion 系列十四:Oracle RAC CR Server Part OneOracleServer
- Oracle RAC Cache Fusion 系列十:Oracle RAC Enqueues And Lock Part 1OracleENQ
- Oracle RAC Wait EventsOracleAI
- oracle rac 增加磁碟Oracle
- Scheduler in Oracle Database 10g(轉)OracleDatabase
- 10g NewFeatures學習筆記(轉)筆記
- Oracle RAC Cache Fusion 系列九:Oracle RAC 分散式資源管理(二)Oracle分散式
- Oracle RAC Cache Fusion 系列八:Oracle RAC 分散式資源管理(一)Oracle分散式
- Oracle RAC一鍵部署004(RAC引數校驗)Oracle
- 【RAC】Oracle RAC上線測試場景介紹Oracle
- Solaris 10下遷移10G RAC (六)
- Solaris 10下遷移10G RAC (八)
- Solaris 10下遷移10G RAC (二)
- Solaris 10下遷移10G RAC (七)
- Solaris 10下遷移10G RAC (三)
- Solaris 10下遷移10G RAC (一)
- Solaris 10下遷移10G RAC (五)
- Oracle RAC+DG搭建Oracle