1.此贴主要演示如何管理rac中的ocr。ocr主要维护各种集群资源,在rac中重要性不言而喻,这里演示如何备份恢复ocr和olr。注意,ocr记录全局资源信息,olr记录本地资源信息。
2.添加ocr直接到asm外部磁盘中:
[root@maclean1 ~]# ocrconfig -add /dev/asm-diskq
[root@maclean1 ~]# ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 2856
Available space (kbytes) : 259264
ID : 1511736497
Device/File Name : +SYSTEMDG
Device/File integrity check succeeded
Device/File Name : /dev/asm-diskq
Device/File integrity check succeeded
Device/File not configured
Device/File not configured
Device/File not configured
Cluster registry integrity check succeeded
Logical corruption check succeeded
[grid@maclean1 ~]$ ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 2856
Available space (kbytes) : 259264
ID : 1511736497
Device/File Name : /dev/asm-diskq
Device/File integrity check succeeded
Device/File Name : +DATA
Device/File integrity check succeeded
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执行ocrcheck比grid执行ocrcheck速度快点,因为root还会检查逻辑坏块,grid不检查。
SQL> select group_number,disk_number,mount_status,header_status,state,redundancy,name,path,total_mb,free_mb from v$asm_disk;
GROUP_NUMBER DISK_NUMBER MOUNT_S HEADER_STATU STATE REDUNDA NAME PATH TOTAL_MB FREE_MB
------------ ----------- ------- ------------ -------- ------- --------------- -------------------- ---------- ----------
0 5 CLOSED FOREIGN NORMAL UNKNOWN /dev/asm-diskq 0 0
0 8 CLOSED CANDIDATE NORMAL UNKNOWN /dev/asm-diskn 0 0
0 11 CLOSED CANDIDATE NORMAL UNKNOWN /dev/asm-diskj 0 0
3 2 CACHED MEMBER NORMAL UNKNOWN SYSTEMDG_0002 /dev/asm-disku 1024 660
1 2 CACHED MEMBER NORMAL UNKNOWN BACKUPDG_0002 /dev/asm-diskv 1024 641
1 1 CACHED MEMBER NORMAL UNKNOWN BACKUPDG_0001 /dev/asm-diskt 1024 642
3 1 CACHED MEMBER NORMAL UNKNOWN SYSTEMDG_0001 /dev/asm-disks 1024 660
2 2 CACHED MEMBER NORMAL UNKNOWN DATA_0002 /dev/asm-diskr 1024 483
2 3 CACHED MEMBER NORMAL UNKNOWN DATA_0003 /dev/asm-diskp 1024 483
2 4 CACHED MEMBER NORMAL UNKNOWN DATA_0004 /dev/asm-disko 1024 484
3 3 CACHED MEMBER NORMAL UNKNOWN SYSTEMDG_0003 /dev/asm-diskm 1024 660
2 0 CACHED MEMBER NORMAL UNKNOWN DATA_0000 /dev/asm-diskl 1024 455
这时候HEADER_STATU状态显示FOREIGN。
3.将ocr添加到某个磁盘中:
[root@maclean1 mail]# ocrconfig -add +DATA
添加后显示:
[root@maclean1 mail]# ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 2856
Available space (kbytes) : 259264
ID : 1511736497
Device/File Name : +SYSTEMDG
Device/File integrity check succeeded
Device/File Name : /dev/asm-diskq
Device/File integrity check succeeded
Device/File Name : +DATA
Device/File integrity check succeeded
Device/File not configured
Device/File not configured
Cluster registry integrity check succeeded
Logical corruption check succeeded
查看/etc/oracle/ocr.loc目录:
[root@maclean1 ~]# cat /etc/oracle/ocr.loc
#Device/file getting replaced by device +DATA
ocrconfig_loc=+SYSTEMDG
ocrmirrorconfig_loc=/dev/asm-diskq
ocrconfig_loc3=+DATA
local_only=false
4.从磁盘组中删除ocr(至少要有两个可用的ocr的情况才可以删除):
[root@maclean1 ~]# ocrconfig -delete +SYSTEMDG
5.ocr的替换(至少要有两个可用的ocr的情况才可以替换):
语法:
# ocrconfig -replace current_OCR_location -replacement new_OCR_location
事例:
[root@maclean1 ~]# ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 2856
Available space (kbytes) : 259264
ID : 1511736497
Device/File Name : /dev/asm-diskq
Device/File integrity check succeeded
Device/File Name : +DATA
Device/File integrity check succeeded
Device/File Name : +systemdg
Device/File integrity check succeeded
Device/File not configured
Device/File not configured
Cluster registry integrity check succeeded
Logical corruption check succeeded
[root@maclean1 ~]# ocrconfig -replace +data -replacement +backupdg
[root@maclean1 ~]# ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 2856
Available space (kbytes) : 259264
ID : 1511736497
Device/File Name : /dev/asm-diskq
Device/File integrity check succeeded
Device/File Name : +backupdg
Device/File integrity check succeeded
Device/File Name : +systemdg
Device/File integrity check succeeded
Device/File not configured
Device/File not configured
Cluster registry integrity check succeeded
Logical corruption check succeeded
[root@maclean1 ~]#
只有一个可用的ocr的时候无法替换到新位置:
[root@maclean1 ~]# ocrcheck
Status of Oracle Cluster Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 2856
Available space (kbytes) : 259264
ID : 1511736497
Device/File Name : +systemdg
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 succeeded
[root@maclean1 ~]# ocrconfig -replace +systemdg -replacement /dev/asm-diskq
PROT-28: Cannot delete or replace the only configured Oracle Cluster Registry location
6.ocr的备份(自动和手动):
oracle每隔4个小时会自动备份一次ocr,并且系统会保留最近三次,前一天和前一周的一次备份。因此自动备份会保留5份。
查看自动备份的位置(其中00是最新的备份):
[grid@maclean1 crs]$ ocrconfig -showbackup
maclean2 2014/03/05 11:56:35 /g01/grid/app/11.2.0/grid/cdata/maclean-cluster/backup00.ocr
maclean1 2014/02/16 07:18:02 /g01/grid/app/11.2.0/grid/cdata/maclean-cluster/backup01.ocr
maclean1 2014/02/16 03:17:47 /g01/grid/app/11.2.0/grid/cdata/maclean-cluster/backup02.ocr
maclean2 2014/03/05 11:56:35 /g01/grid/app/11.2.0/grid/cdata/maclean-cluster/day.ocr
maclean2 2014/03/05 11:56:35 /g01/grid/app/11.2.0/grid/cdata/maclean-cluster/week.ocr
PROT-25: Manual backups for the Oracle Cluster Registry are not available
自动备份的目录在:
$CRS_HOME/cdata/<cluster_name>
可以通过ocrconfig -backuploc <directory_name>命令修改自动备份的位置。
只查看自动备份:
[grid@maclean1 maclean1]$ ocrconfig -showbackup auto
只查看手动备份:
[grid@maclean1 maclean1]$ ocrconfig -showbackup manual
进行手动备份(做大的操作,比如加减节点前都要进行手动备份):
[root@maclean1 ~]# ocrconfig -manualbackup
maclean1 2014/10/04 01:17:04 /g01/grid/app/11.2.0/grid/cdata/maclean-cluster/backup_20141004_011704.ocr
[root@maclean1 ~]# ocrconfig -showbackup manual
maclean1 2014/10/04 01:17:04 /g01/grid/app/11.2.0/grid/cdata/maclean-cluster/backup_20141004_011704.ocr
root用户才有权限进行手动备份。
dump ocr文件查看其完整性:
[root@maclean1 ~]# ocrdump -backupfile /g01/grid/app/11.2.0/grid/cdata/maclean-cluster/backup_20141004_011704.ocr
[root@maclean1 ~]# ls
anaconda-ks.cfg Desktop install.log install.log.syslog OCRDUMPFILE
以上方法dump出的ocr文件查看不方便。可以以xml格式dump出来。
[root@maclean1 ~]# ocrdump -backupfile /g01/grid/app/11.2.0/grid/cdata/maclean-cluster/backup_20141004_011704.ocr -xml
7.ocr的恢复:
a.查看集群中所有节点:
[root@maclean1 ~]# olsnodes -n
maclean1 1
maclean2 2
b.root用户停止所有节点,如果crs坏了导致无法正常停止集群,可加参数强制停止集群:
crsctl stop crs -f
正常情况不要-f停止集群,有可能会导致无法启动。
c.查看ocr文件(root用户,grid用户可能查看不到):
ocrconfig -showbackup
d.在一个节点(一般选节点1)独占模式启动asm实例但是不启动crs:
crsctl start crs -excel -nocrs
e.然后用root用户执行还原:
ocrconfig -restore /g01/grid/app/11.2.0/grid/cdata/maclean-cluster/backup_20141004_011704.ocr
f.验证:
ocrcheck
g.停止crs:
crsctl stop crs -f
h.正常模式启动crs:
crsctl start crs
8.ocr的导入导出(不推荐使用了,oracle推荐使用backup):
[root@maclean1 ~]# ocrconfig -export /home/grid/ocr_20141004.exp
使用export、import进行恢复:
a.停止所有节点(如果无法正常停止就强制停止)
b.在其中一个节点-excl模式启动
crsctl start crs -excel -nocrs
c.查看crs状态
d.导入ocr文件
ocrconfig -import /home/grid/ocr_20141004.exp
e.验证
ocrcheck
f.停止之前exclusive 模式的Cluster
crsctl stop crs -f
g.在所有节点正常启动crs
9.OLR(Oracle Local Registry)的管理:
查看olr:
[root@maclean1 ~]# ocrcheck -local
Status of Oracle Local Registry is as follows :
Version : 3
Total space (kbytes) : 262120
Used space (kbytes) : 2548
Available space (kbytes) : 259572
ID : 869410121
Device/File Name : /g01/grid/app/11.2.0/grid/cdata/maclean1.olr
Device/File integrity check succeeded
Local registry integrity check succeeded
Logical corruption check succeeded
使用ocrdump查看OLR的内容显示到终端:
ocrdump -local -stdout
导出OLR文件:
ocrconfig -local -export file_name
从OLR备份中dump内容:
ocrdump -local -backupfile olr_backup_file_name
改变OLR的备份位置:
ocrconfig -local -backuploc new_olr_backup_path
---------------------------------------后加的-------------------------------------------------------------------
1.以下可实现裸设备上ocr的迁移:
添加ocr:
ocrconfig -replace ocrmirror /dev/raw/raw4
删除ocr:
ocrconfig -replace ocr
2.voting disk的迁移:
crsctl stop crs
crsctl add css votedisk /dev/raw/raw5 -force
crsctl query css votedisk
crsctl delete css votedisk /dev/raw/raw2 -force
crsctl query css votedisk
crsctl start crs
3.ocr恢复:
ocrconfig -restore <backup_file_name>
该贴由system转至本版2014-11-19 9:34:59