RAC日常維護命令

jackjw發表於2009-11-03
RAC日常維護命令[@more@]

所有例項和服務的狀態

$ srvctl status database -d orcl
Instance orcl1 is running on node linux1
Instance orcl2 is running on node linux2


單個例項的狀態

$ srvctl status instance -d orcl -i orcl2
Instance orcl2 is running on node linux2

在全域性命名服務的狀態

$ srvctl status service -d orcl -s orcltest
Service orcltest is running on instance(s) orcl2, orcl1

特定節點上節點應用程式的狀態

$ srvctl status nodeapps -n linux1
VIP is running on node: linux1
GSD is running on node: linux1
Listener is running on node: linux1
ONS daemon is running on node: linux1

ASM 例項的狀態

$ srvctl status asm -n linux1
ASM instance +ASM1 is running on node linux1.

列出配置的所有資料庫

$ srvctl config database
orcl

顯示 資料庫的配置

$ srvctl config database -d orcl
linux1 orcl1 /u01/app/oracle/product/10.2.0/db_1
linux2 orcl2 /u01/app/oracle/product/10.2.0/db_1

顯示指定叢集資料庫的所有服務

$ srvctl config service -d orcl
orcltest PREF: orcl2 orcl1 AVAIL:

顯示節點應用程式的配置 —(VIP、GSD、ONS、監聽器)

$ srvctl config nodeapps -n linux1 -a -g -s -l
VIP exists.: /linux1-vip/192.168.1.200/255.255.255.0/eth0:eth1
GSD exists.
ONS daemon exists.
Listener exists.

顯示 ASM 例項的配置

$ srvctl config asm -n linux1
+ASM1 /u01/app/oracle/product/10.2.0/db_1

叢集中所有正在執行的例項

SELECT
inst_id
, instance_number inst_no
, instance_name inst_name
, parallel
, status
, database_status db_status
, active_state state
, host_name host
FROM gv$instance
ORDER BY inst_id;

INST_ID INST_NO INST_NAME PAR STATUS DB_STATUS STATE HOST
-------- -------- ---------- --- ------- ------------ --------- -------
1 1 orcl1 YES OPEN ACTIVE NORMAL rac1
2 2 orcl2 YES OPEN ACTIVE NORMAL rac2

位於磁碟組中的所有資料檔案

select name from v$datafile
union
select member from v$logfile
union
select name from v$controlfile
union
select name from v$tempfile;

NAME
-------------------------------------------
+FLASH_RECOVERY_AREA/orcl/controlfile/current.258.570913191
+FLASH_RECOVERY_AREA/orcl/onlinelog/group_1.257.570913201
+FLASH_RECOVERY_AREA/orcl/onlinelog/group_2.256.570913211
+FLASH_RECOVERY_AREA/orcl/onlinelog/group_3.259.570918285
+FLASH_RECOVERY_AREA/orcl/onlinelog/group_4.260.570918295
+ORCL_DATA1/orcl/controlfile/current.259.570913189
+ORCL_DATA1/orcl/datafile/example.257.570913311
+ORCL_DATA1/orcl/datafile/indx.270.570920045
+ORCL_DATA1/orcl/datafile/sysaux.260.570913287
+ORCL_DATA1/orcl/datafile/system.262.570913215
+ORCL_DATA1/orcl/datafile/undotbs1.261.570913263
+ORCL_DATA1/orcl/datafile/undotbs1.271.570920865
+ORCL_DATA1/orcl/datafile/undotbs2.265.570913331
+ORCL_DATA1/orcl/datafile/undotbs2.272.570921065
+ORCL_DATA1/orcl/datafile/users.264.570913355
+ORCL_DATA1/orcl/datafile/users.269.570919829
+ORCL_DATA1/orcl/onlinelog/group_1.256.570913195
+ORCL_DATA1/orcl/onlinelog/group_2.263.570913205
+ORCL_DATA1/orcl/onlinelog/group_3.266.570918279
+ORCL_DATA1/orcl/onlinelog/group_4.267.570918289
+ORCL_DATA1/orcl/tempfile/temp.258.570913303

21 rows selected.

屬於“ORCL_DATA1”磁碟組的所有 ASM 磁碟

SELECT path
FROM v$asm_disk
WHERE group_number IN (select group_number
from v$asm_diskgroup
where name = 'ORCL_DATA1');

PATH
----------------------------------
ORCL:VOL1
ORCL:VOL2

啟動/停止RAC叢集

確保是以 UNIX 使用者登入的。我們將從rac1節點執行所有命令:

# su – oracle

$ hostname

Rac1

停止 Oracle RAC 環境

第一步是停止 Oracle 例項。當此例項(和相關服務)關閉後,關閉 ASM 例項。最後,關閉節點應用程式(虛擬 IP、GSD、TNS 監聽器和 ONS)。

$ export ORACLE_SID=orcl1
$ emctl stop dbconsole
$ srvctl stop instance -d orcl -i orcl1
$ srvctl stop asm -n rac1
$ srvctl stop nodeapps –n rac1

啟動 Oracle RAC 10g 環境

第一步是啟動節點應用程式(虛擬 IP、GSD、TNS 監聽器和 ONS)。當成功啟動節點應用程式後,啟動 ASM 例項。最後,啟動 Oracle 例項(和相關服務)以及器資料庫控制檯。

$ export ORACLE_SID=orcl1
$ srvctl start nodeapps -n rac1
$ srvctl start asm -n rac1
$ srvctl start instance -d orcl -i orcl1
$ emctl start dbconsole

使用 SRVCTL 啟動/停止所有例項

啟動/停止所有例項及其啟用的服務。我只是覺得有意思就把此步驟作為關閉所有例項的一種方法加進來了!

$ srvctl start database -d orcl
$ srvctl stop database -d orcl

啟停止監聽
hostb$lsnrctl start listener_hostb
hostb$lsnrctl stop listener_hostb備份votning diskdd if=voting_disk_name f=backup_file_name
dd if=/dev/rdsk/c4t600C0FF000000000098ADE240330A000d0s4 f=votingdisk.bak# dd if=/dev/zero f=/dev/rdsk/c4t600C0FF000000000098ADE240330A000d0s4 bs=512 count=261120

# dd if=/dev/rdsk/c4t600C0FF000000000098ADE240330A000d0s4 f=/data/backup/rac/vd_backup0420.bak
261120+0 記錄進入
261120+0 記錄調出
# cd /data/backup/rac
# ls
ocr0420.bak ocrdisk vd_backup0420.bak votingdisk.bak votingdisk0420.bak
# dd if=/data/backup/rac/vd_backup0420.bak f=/dev/rdsk/c4t600C0FF000000000098ADE240330A000d0s4
261120+0 記錄進入
261120+0 記錄調出備份OCR磁碟
檢視
$ocrconfig -showbackup
備份
/data/oracle/crs/bin/ocrconfig -export /data/backup/rac/ocrdisk.bak
還原 需要停掉所有的節點,Stop the Oracle Clusterware software on all of the nodes
/data/oracle/crs/bin/ocrconfig -import file_name
自動備份的還原# /data/oracle/crs/bin/ocrconfig -showbackup
# /data/oracle/crs/bin/ocrconfig -restore /data/oracle/crs/cdata/db168crs/backup00.ocrhosta$cluvfy comp ocr -n all //檢驗
ocr 檢查
#ocrcheck配置路徑在
/var/opt/oracle/ocrconfig_loc檔案裡面 如果需要更改OCR磁碟的路徑配置。
OCR磁碟空間檢查
# /data/oracle/crs/bin/ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 2
Total space (kbytes) : 399752
Used space (kbytes) : 3784
Available space (kbytes) : 395968
ID : 148562961
Device/File Name : /dev/rdsk/c4t600C0FF000000000098ADE240330A000d0s5
Device/File integrity check succeeded Device/File not configured Cluster registry integrity check succeeded#


ASM 例項的狀態
hosta$srvctl status asm -n hosta
ASM 例項 +ASM1 正在節點 hosta 上執行。
hosta$特定節點上節點應用程式的狀態
hosta$srvctl status nodeapps -n hosta
VIP 正在執行的節點: hosta
GSD 正在執行的節點: hosta
監聽程式未在節點上執行: hosta
ONS 守護程式正在節點上執行:hosta
hosta$所有例項和服務的狀態
hosta$srvctl status database -d cole
例項 cole1 正在節點 hosta 上執行
例項 cole2 正在節點 hostb 上執行
hosta$列出配置的所有資料庫
hosta$srvctl config database
cole
hosta$
顯示 RAC 資料庫的配置hosta$srvctl config database -d cole
hosta cole1 /data/oracle/OracleHome
hostb cole2 /data/oracle/OracleHome
hosta$顯示 ASM 例項的配置
hosta$srvctl config asm -n hosta
+ASM1 /data/oracle/OracleHome顯示節點應用程式的配置 -(VIP、GSD、ONS、監聽器)
hosta$srvctl config nodeapps -n hosta -a -g -s -l
VIP 已存在。: /a1-vip/10.1.1.9/255.255.0.0/ce0
GSD 已存在。
ONS 守護程式已存在。
監聽程式已存在。
hosta$
叢集中所有正在執行的例項
SELECT
inst_id
, instance_number inst_no
, instance_name inst_name
, parallel
, status
, database_status db_status
, active_state state
, host_name host
FROM gv$instance
ORDER BY inst_id; INST_ID INST_NO INST_NAME PAR STATUS DB_STATUS STATE HOST
---------- ---------- ---------------- --- ------------ -------------------------- -
1 1 cole1 YES OPEN ACTIVE NORMAL hosta 2 2 cole2 YES OPEN ACTIVE NORMAL hostb

位於磁碟組中的所有資料檔案
SQL> select name from v$datafile
union
select member from v$logfile
union
select name from v$controlfile
union
select name from v$tempfile;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/3907/viewspace-1028398/,如需轉載,請註明出處,否則將追究法律責任。

相關文章