Oracle11g RAC常用操作 (维护及管理)
1. 查看各資源狀態(nodeapps節點應用程序,ASM實例,數據庫實例等):
[root@rac01 u01]# su - grid??
[grid@rac01 ~]$ crs_stat -t?? (命令兼容10g)
Name?????????? Type?????????? Target??? State???? Host????????
------------------------------------------------------------
ora....ER.lsnr ora....er.type ONLINE??? ONLINE??? rac01???????
ora....N1.lsnr ora....er.type ONLINE??? ONLINE??? rac01???????
ora....VOTE.dg ora....up.type ONLINE??? ONLINE??? rac01???????
ora.ORADATA.dg ora....up.type ONLINE??? ONLINE??? rac01???????
ora....LASH.dg ora....up.type ONLINE??? ONLINE??? rac01???????
ora.asm??????? ora.asm.type?? ONLINE??? ONLINE??? rac01???????
ora.eons?????? ora.eons.type? ONLINE??? ONLINE??? rac01???????
ora.gsd??????? ora.gsd.type?? OFFLINE?? OFFLINE???????????????
ora....network ora....rk.type ONLINE??? ONLINE??? rac01???????
ora.oc4j?????? ora.oc4j.type? OFFLINE?? OFFLINE???????????????
ora.ons??????? ora.ons.type?? ONLINE??? ONLINE??? rac01???????
ora....SM1.asm application??? ONLINE??? ONLINE??? rac01???????
ora....01.lsnr application??? ONLINE??? ONLINE??? rac01???????
ora.rac01.gsd? application??? OFFLINE?? OFFLINE???????????????
ora.rac01.ons? application??? ONLINE??? ONLINE??? rac01???????
ora.rac01.vip? ora....t1.type ONLINE??? ONLINE??? rac01???????
ora....SM2.asm application??? ONLINE??? ONLINE??? rac02???????
ora....02.lsnr application??? ONLINE??? ONLINE??? rac02???????
ora.rac02.gsd? application??? OFFLINE?? OFFLINE???????????????
ora.rac02.ons? application??? ONLINE??? ONLINE??? rac02???????
ora.rac02.vip? ora....t1.type ONLINE??? ONLINE??? rac02???????
ora.racdb.db?? ora....se.type ONLINE??? ONLINE??? rac01???????
ora....ry.acfs ora....fs.type ONLINE??? ONLINE??? rac01???????
ora.scan1.vip? ora....ip.type ONLINE??? ONLINE??? rac01??????
在11g R2中,默認 oc4j和gsd資源是 disable 的;oc4j? 是用于WLM 的一個
資源,?WLM在 11.2.0.2 才可用;gsd 是 CRS 用于跟 9i?RAC?進行通信的一
個模塊,是為了向后兼容才保留的,不影響性能;建議不要刪除, 也不要嘗試開
啟他們,? 忽略即可。???
11g RAC 常用的是下面的命令:crsctl stat? resource -t .
[root@rac01 u01]# su - grid??
[grid@rac01 ~]$ crsctl stat? resource -t
如果后面不帶 -t , 那么可以看到相對詳細的資源信息 。?
[grid@rac01 ~]$ crsctl stat? resource
?
2. 常用開關機命令
注意, 11g RAC 開啟資源相對比較慢(即使命令后面顯示的資源都start succeeded,?
通過crs_stat -t查看都不一定online), 請注意命令操作后觀察crs log變化,以免出
現還沒有開啟就懷疑啟動有異常而采取重復動作 。??
以下命令供參考:?
---------------------------------------------------?
在本地服務器上停止Oracle Clusterware 系統:
[root@rac01 ~]# /u01/grid/11.2.0/bin/crsctl?? stop? cluster?
注:在運行“crsctl stop cluster”命令之后,如果 Oracle Clusterware 管理的
資源中有任何一個還在運行,則整個命令失敗。使用 -f 選項無條件地停止所有資源
并停止 Oracle Clusterware 系統。
[root@rac02 ~]# /u01/grid/11.2.0/bin/crsctl? stop? cluster? -all?
停止所有節點上的clusterware系統。
在本地服務器上啟動oralce clusterware系統:
[root@rac01 ~]# /u01/grid/11.2.0/bin/crsctl start cluster
注:可通過指定 -all 選項在集群中所有服務器上啟動 Oracle Clusterware 系統。
[root@rac02 ~]# /u01/grid/11.2.0/bin/crsctl start cluster –all
還可以通過列出服務器(各服務器之間以空格分隔)在集群中一個或多個指定的服務器上啟動 Oracle Clusterware 系
統:
[root@rac01 ~]# /u01/grid/11.2.0/bin/crsctl start cluster -n rac01 rac02
使用 SRVCTL 啟動/停止所有實例:
[oracle@rac01 ~]# srvctl stop database -d racdb
[oracle@rac01 ~]# srvctl start database -d racdb
參考順序
關機順序: 先關閉Oracle實例(或數據庫),然后關閉ASM實例,最后關閉節點應用
程序(虛擬 IP、GSD、TNS 監聽器和 ONS) .
手工開機順序: 先啟動節點應用程序(虛擬 IP、GSD、TNS 監聽器和 ONS)。當成功
啟動節點應用程序后,啟動 ASM 實例。最后,啟動 Oracle 實例(相關服務)以及
企業管理器數據庫控制臺。
?
例子:
關閉:
在節點1上關閉所有節點的clusterware(如果有資源不能被關閉,使用-f).?
[root@rac01 bin]# /u01/grid/11.2.0/bin/crsctl? stop cluster? -all
節點1,2上都關閉后我們查看
[grid@rac02 rac02]$ crsctl stat resource -t??
CRS-4535: Cannot communicate with Cluster Ready Services
CRS-4000: Command Status failed, or completed with errors.
開啟:?
[root@rac01 bin]# /u01/grid/11.2.0/bin/crsctl? start? cluster? -all
一般來說,開啟上面一個命令就夠用了,但是如果發現有異常,比如db等很長
時間都沒有onine, 我們也可以手工開啟數據庫(任何一個節點執行):
[root@rac02 ~]# /u01/grid/11.2.0/bin/srvctl? start? database? -d? racdb??
備注:?
如果有需要也可以一個一個實例開啟。
[root@rac02 ~]# /u01/grid/11.2.0/bin/srvctl start instance -d racdb -i racdb1
[root@rac02 ~]# /u01/grid/11.2.0/bin/srvctl start instance -d racdb -i racdb2
?
3.? 常用建立表空間及加入數據文件?
參考 :?http://space.itpub.net/?uid-7607759-action-viewspace-itemid-670722??
[root@rac01 bin]# su - oracle???
[oracle@rac01 ~]$ sqlplus / as sysdba??
SQL> create tablespace test? datafile '+oradata/racdb/datafile/test01.dbf'? size 50m ;?
Tablespace created.
[root@rac02 ~]# su - grid
[grid@rac02 ~]$ asmcmd
ASMCMD>?
ASMCMD> pwd
+oradata/racdb/datafile
ASMCMD>?
ASMCMD> ls
SYSAUX.261.739387301
SYSTEM.260.739387283
TEST.340.740166807
UNDOTBS1.262.739387315
UNDOTBS2.264.739387351
USERS.265.739387361
test01.dbf
SQL> alter tablespace test add datafile? '+oradata/racdb/datafile/test02.dbf' size 50m ;??
Tablespace altered.
SQL>
ASMCMD> ls
SYSAUX.261.739387301
SYSTEM.260.739387283
TEST.340.740166807
TEST.341.740166937
UNDOTBS1.262.739387315
UNDOTBS2.264.739387351
USERS.265.739387361
test01.dbf
test02.dbf
ASMCMD>
ASMCMD> ls? -al?
Type????? Redund? Striped? Time???????????? Sys? Name
DATAFILE? UNPROT? COARSE?? JAN 11 17:00:00? Y??? none => SYSAUX.261.739387301
DATAFILE? UNPROT? COARSE?? JAN 11 17:00:00? Y??? none => SYSTEM.260.739387283
DATAFILE? UNPROT? COARSE?? JAN 11 17:00:00? Y??? +ORADATA/RACDB/DATAFILE/test01.dbf =>
TEST.340.740166807
DATAFILE? UNPROT? COARSE?? JAN 11 17:00:00? Y??? +ORADATA/RACDB/DATAFILE/test02.dbf =>
TEST.341.740166937
DATAFILE? UNPROT? COARSE?? JAN 11 17:00:00? Y??? none => UNDOTBS1.262.739387315
DATAFILE? UNPROT? COARSE?? JAN 11 17:00:00? Y??? none => UNDOTBS2.264.739387351
DATAFILE? UNPROT? COARSE?? JAN 11 17:00:00? Y??? none => USERS.265.739387361
??????????????????????????????????????????? N??? test01.dbf =>
+ORADATA/RACDB/DATAFILE/TEST.340.740166807
??????????????????????????????????????????? N??? test02.dbf =>
+ORADATA/RACDB/DATAFILE/TEST.341.740166937
ASMCMD>
?
4. 查看ASM實例及用戶數據庫實例(注意分別是grid及oracle用戶):
查看ASM實例(以grid用戶登入,通過查看初始參數可以看到instance_name=+ASM1):
[grid@rac01 ~]$ id
uid=501(grid) gid=501(oinstall) groups=501(oinstall),504(asmadmin),506(asmdba),507(asmoper)
[grid@rac01 ~]$ sqlplus "/as sysdba"
SQL*Plus: Release 11.2.0.1.0 Production on Tue Jan 4 00:58:52 2011
Copyright (c) 1982, 2009, Oracle.? All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Real Application Clusters and Automatic Storage Management options
SQL> show parameter
NAME???????????????????????????????? TYPE??????? VALUE
------------------------------------ ----------- ------------------------------
asm_diskgroups?????????????????????? string????? ORADATA, ORAFLASH
asm_diskstring?????????????????????? string
asm_power_limit????????????????????? integer???? 1
asm_preferred_read_failure_groups??? string
audit_file_dest????????????????????? string????? /u01/grid/11.2.0/rdbms/audit
.....
?
查看用戶數據庫實例(以oracle用戶登入,查看instance_name=racdb2,顯然是用戶實例):?
[root@rac02 u01]# su - oracle
[oracle@rac02 ~]$?
[oracle@rac02 ~]$ sqlplus "/as sysdba"
SQL*Plus: Release 11.2.0.1.0 Production on Tue Jan 4 01:01:04 2011
Copyright (c) 1982, 2009, Oracle.? All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
SQL> show parameter
NAME???????????????????????????????? TYPE??????? VALUE
------------------------------------ ----------- ------------------------------
O7_DICTIONARY_ACCESSIBILITY????????? boolean???? FALSE
active_instance_count??????????????? integer
aq_tm_processes????????????????????? integer???? 0
archive_lag_target?????????????????? integer???? 0
asm_diskgroups?????????????????????? string
asm_diskstring?????????????????????? string
asm_power_limit????????????????????? integer???? 1
.......
?
5. 查看11g 數據庫實例的alert log及trace :?
[oracle@rac01 trace]$ pwd
/u01/product/oracle/diag/rdbms/racdb/racdb1/trace
[oracle@rac01 trace]$?
[oracle@rac01 trace]$ vi? alert_racdb1.log
?
6. 查看11g RAC Clusterware的log :
[root@rac01 sbin]# su - grid
[grid@rac01 ~]$?
[grid@rac01 rac01]$ pwd
/u01/grid/11.2.0/log/rac01
[grid@rac01 trace]$ pwd
/u01/grid/11.2.0/log/diag/tnslsnr/rac01/listener_scan1/trace
[grid@rac01 trace]$ ls
listener_scan1.log
[grid@rac01 rac01]$ pwd
/u01/grid/11.2.0/log/rac01
[grid@rac01 rac01]$ ls
admin/? alertrac01.log? crsd/? ctssd/??? evmd/?? gnsd/?? mdnsd/? racg/
agent/? client/???????? cssd/? diskmon/? gipcd/? gpnpd/? ohasd/? srvm/
?
7. 常用集群命令
[grid@rac02 ~]$ crs_stat -t?
檢查Oracle Clusterware 是否在線
[grid@rac02 ~]$ crsctl check crs?
CRS-4638: Oracle High Availability Services is online
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
檢查cssd (Cluster Synchronization Services) 是否在線
[grid@rac02 ~]$ crsctl check cssd?
CRS-272: This command remains for backward compatibility only
Cluster Synchronization Services is online
檢查crsd (Cluster Ready Services) 是否在線
[grid@rac02 ~]$ crsctl check crsd???
CRS-272: This command remains for backward compatibility only
Cluster Ready Services is online
檢查evmd (Event Mananger)是否在線
[grid@rac02 ~]$ crsctl check evmd?
CRS-272: This command remains for backward compatibility only
Event Manager is online
在節點間檢查CSS的存活
[grid@rac02 ~]$ crsctl check cluster -n? rac01?
**************************************************************
rac01:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************
[grid@rac02 ~]$ crsctl check cluster -n? rac02?
**************************************************************
rac02:
CRS-4537: Cluster Ready Services is online
CRS-4529: Cluster Synchronization Services is online
CRS-4533: Event Manager is online
**************************************************************
開啟數據庫
[grid@rac02 ~]$ srvctl start database -d racdb
開啟oc4j :
[grid@rac02 ~]$ ./srvctl enable oc4j
[grid@rac02 ~]$ ./srvctl start oc4j
[grid@rac02 ~]$ ./crs_stat -t
?
8.? vote disk 管理?
[grid@rac01 ~]$ ocrcheck?????
Status of Oracle Cluster Registry is as follows :
???????? Version????????????????? :????????? 3
???????? Total space (kbytes)???? :???? 262120
???????? Used space (kbytes)????? :?????? 2720
???????? Available space (kbytes) :???? 259400
???????? ID?????????????????????? :? 132900461
???????? Device/File Name???????? :? +OCR_VOTE
??????????????????????????????????? Device/File integrity check succeeded
??????????????????????????????????? Device/File not configured
??????????????????????????????????? Device/File not configured
??????????????????????????????????? Device/File not configured
??????????????????????????????????? Device/File not configured
???????? Cluster registry integrity check succeeded
???????? Logical corruption check bypassed due to non-privileged user
在Oracle11g R2中,不必備份voting disk, 當任何配置發生改變,voting disk
數據會自動備份在OCR中,并自動恢復到任何加入的voting disk中。 從下面可以看
到OCR和VotingDisk是一個文件。
[grid@rac01 ~]$ crsctl? query css votedisk?
##? STATE??? File Universal Id??????????????? File Name Disk group
--? -----??? -----------------??????????????? --------- ---------
?1. ONLINE?? 095112005ec24f57bf98f6148818cc53 (ORCL:OCR_VOTE01) [OCR_VOTE]
Located 1 voting disk(s).
[grid@rac01 ~]$
[grid@rac01 ~]$ asmcmd
ASMCMD> ls
OCR_VOTE/
ORADATA/
ORAFLASH/
ASMCMD> cd ocr_vote
ASMCMD> cd rac
ASMCMD> ls
ASMPARAMETERFILE/
OCRFILE/
ASMCMD> cd ocrfile
ASMCMD> ls
REGISTRY.255.739337635
OCR 管理
[grid@rac01 ~]$ crsctl query crs activeversion?
Oracle Clusterware active version on the cluster is [11.2.0.1.0]
[grid@rac01 ~]$ ocrcheck?
Status of Oracle Cluster Registry is as follows :
???????? Version????????????????? :????????? 3
???????? Total space (kbytes)???? :???? 262120
???????? Used space (kbytes)????? :?????? 2720
???????? Available space (kbytes) :???? 259400
???????? ID?????????????????????? :? 132900461
???????? Device/File Name???????? :? +OCR_VOTE
??????????????????????????????????? Device/File integrity check succeeded
??????????????????????????????????? Device/File not configured
??????????????????????????????????? Device/File not configured
??????????????????????????????????? Device/File not configured
??????????????????????????????????? Device/File not configured
???????? Cluster registry integrity check succeeded
???????? Logical corruption check bypassed due to non-privileged user
使用下面命令(root登陸)使用 destination_file 或者 +ASM_disk_group取代現在的OCR Location:
# ocrconfig -replace current_OCR_location -replacement new_OCR_location
如果只有一個OCR Location, 那么使用下面的命令:?
# ocrconfig -add? +new_storage_disk_group
# ocrconfig -delete? +current_disk_group
運行下面的命令顯示備份:
[grid@rac01 ~]$ ocrconfig?? -showbackup??
rac01???? 2011/01/08 17:54:51???? /u01/grid/11.2.0/cdata/rac/backup00.ocr
rac01???? 2011/01/08 13:54:49???? /u01/grid/11.2.0/cdata/rac/backup01.ocr
rac02???? 2011/01/08 06:34:46???? /u01/grid/11.2.0/cdata/rac/backup02.ocr
rac01???? 2011/01/07 02:15:37???? /u01/grid/11.2.0/cdata/rac/day.ocr
rac01???? 2011/01/02 07:51:43???? /u01/grid/11.2.0/cdata/rac/week.ocr
PROT-25: Manual backups for the Oracle Cluster Registry are not available
?
當Oracle Clusterware起來的時候,在一個節點上運行ocrconfig -manualbackup命令
[grid@rac01 ~]$ ocrconfig?? -manualbackup?
在 /u01/grid/11.2.0/cdata/rac/day.ocr下生成備份文件 backup_20100112_141900.ocr
然后使用 $ ocrconfig -showbackup 可以查看到備份信息。
運行下面的命令檢驗備份文件內容及完整性。?
$ ocrdump -backupfile backup_file_name ??
http://blog.itpub.net/22548752/viewspace-1164846/
總結
以上是生活随笔為你收集整理的Oracle11g RAC常用操作 (维护及管理)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Object-C学习代码【简单的Car程
- 下一篇: java解析xml文件四种方式介绍、性能