Oracle数据库数据恢复、性能优化

找回密码
注册
搜索
热搜: 活动 交友 discuz
发新帖

3

积分

0

好友

0

主题
1#
发表于 2012-3-3 18:38:55 | 查看: 6091| 回复: 2
windows上面如何物理备份crs的ocr与voting disk
2#
发表于 2012-3-3 20:47:36
"windows上面如何物理备份RAC 中 crs的ocr与voting disk?"

ODM Data:
  1. OCR / Vote disk Maintenance Operations: (ADD/REMOVE/REPLACE/MOVE) [ID 428681.1]

  2. Applies to:
  3. Oracle Server - Enterprise Edition - Version: 10.2.0.1 to 11.2.0.3 - Release: 10.2 to 11.2
  4. Information in this document applies to any platform.
  5. Goal
  6. The goal of this note is to provide steps to add, remove, replace or move an Oracle Cluster Repository (OCR) or voting disk in Oracle Clusterware 10gR2, 11gR1 and 11gR2 environment. It will also provide steps to move OCR / voting and ASM devices from raw device to block device.

  7. This article is intended for DBA and Support Engineers who need to modify, or move OCR and voting disks files, customers who have an existing clustered environment deployed on a storage array and might want to migrate to a new storage array with minimal downtime.

  8. Typically, one would simply cp or dd the files once the new storage has been presented to the hosts. In this case, it is a little more difficult because:

  9. 1. The Oracle Clusterware has the OCR and voting disks open and is actively using them. (Both primary and mirrors)
  10. 2. There is an API provided for this function (ocrconfig, and crsctl), which is the appropriate interface than typical cp and/or dd commands.

  11. It is highly recommended to take a backup of the voting disk, and OCR device before making any changes.

  12. Oracle Cluster Registry (OCR) and Voting Disk Additional clarifications

  13. The following steps assume the cluster is setup using Oracle redundancy with 3 voting disks and 2 OCR.


  14. Solution
  15. ADD/REMOVE/REPLACE/MOVE OCR Device
  16. Note: You must be logged in as the root user, because root owns the OCR files. "crsctl -replace" command can only be issued when CRS is running, otherwise "PROT-1: Failed to initialize ocrconfig" will occur.


  17. Make sure there is a recent copy of the OCR file before making any changes:

  18.     ocrconfig -showbackup

  19. If there is not a recent backup copy of the OCR file, an export can be taken for the current OCR file. Use the following command to generate an export of the online OCR file:

  20. In 10.2

  21.     # ocrconfig -export <OCR export_filename> -s online

  22. In 11.1 and 11.2

  23.     # ocrconfig -manualbackup
  24.     node1 2008/08/06 06:11:58 /crs/cdata/crs/backup_20080807_003158.ocr

  25. If you need to recover using this file, the following command can be used:

  26. # ocrconfig -import <OCR export_filename>

  27. From 11.2+, please also refer How to restore ASM based OCR after complete loss of the CRS diskgroup on Linux/Unix systems Document 1062983.1

  28. To see whether OCR is healthy, run an ocrcheck, which should return with like below.

  29.     # ocrcheck
  30.     Status of Oracle Cluster Registry is as follows :
  31.     Version : 2
  32.     Total space (kbytes) : 497928
  33.     Used space (kbytes) : 312
  34.     Available space (kbytes) : 497616
  35.     ID : 576761409
  36.     Device/File Name : /dev/raw/raw1
  37.     Device/File integrity check succeeded
  38.     Device/File Name : /dev/raw/raw2
  39.     Device/File integrity check succeeded

  40.     Cluster registry integrity check succeeded

  41.     For 11.2+, ocrcheck as root user should also show:

  42.     Logical corruption check succeeded

  43. 1. To add an OCRMIRROR device when only OCR device is defined:

  44. To add an OCR mirror device, provide the full path including file name.
  45. 10.2 and 11.1:

  46.     # ocrconfig -replace ocrmirror <filename>

  47. 11.2+: From 11.2 onwards, upto 4 ocrmirrors can be added

  48.     # ocrconfig -add <filename>


  49. 2. To remove an OCR device:

  50. To remove an OCR device:
  51. 10.2 and 11.1:

  52.     # ocrconfig -replace ocr

  53. 11.2+:

  54.     # ocrconfig -delete <filename>


  55.     * Once an OCR device is removed, ocrmirror device automatically changes to be OCR device.
  56.     * It is not allowed to remove OCR device if only 1 OCR device is defined, the command will return PROT-16.


  57. To remove an OCR mirror device:
  58. 10.2 and 11.1:

  59.     # ocrconfig -replace ocrmirror

  60. 11.2+:

  61.     # ocrconfig -delete <ocrmirror filename>


  62. After removal, the old OCR/OCRMIRROR can be deleted if they are on cluster filesystem.


  63. 3. To replace or move the location of an OCR device:

  64. Note. 1. An ocrmirror must be in place before trying to replace the OCR device. The ocrconfig will fail with PROT-16, if there is no ocrmirror.
  65. 2. If an OCR device is replaced with a device of a different size, the size of the new device will not be reflected until the clusterware is restarted.
  66. 3. If OCR is on cluster file system, the new OCR or OCRMIRROR file must be touched first before replace command can be issued. Otherwise PROT-21: Invalid parameter will occur.

  67. 10.2 and 11.1:
  68. To replace the OCR device with <filename>, provide the full path including file name.

  69.     # ocrconfig -replace ocr <filename>

  70. To replace the OCR mirror device with <filename>, provide the full path including file name.

  71.     # ocrconfig -replace ocrmirror <filename>

  72. 11.2:
  73. The command is same for replace either OCR or OCRMIRRORs:

  74. # ocrconfig -replace <current filename> -replacement <new filename>
  75. eg:
  76. # ocrconfig -replace /cluster_file/ocr.dat -replacement +OCRVOTE

  77. Example Moving OCR from Raw Device to Block Device(pre 11.2)

  78. The OCR disk must be owned by root, in the oinstall group, and must have permissions set to 640. Provide at least 100 MB disk space for the OCR.

  79. In this example the OCR files will be on the following devices:

  80.     /dev/raw/raw1
  81.     /dev/raw/raw2

  82. For moving the OCR  from raw device to block device there are two different ways. One, which requires a full cluster outage, and one with no outage. The offline method is recommended for 10.2 and earlier since a cluster outage is required anyways due to an Oracle bug, which prevents online addition and deletion of voting files. This bug is fixed in 11.1, so either online or offline method can be employed in 11.1 onwards.

  83. Method 1 (Online)

  84. If there are additional block devices of same or larger size available, one can perform 'ocrconfig -replace'.

  85. PROS: No cluster outage required. Run 2 commands and changes are reflected across the entire cluster.

  86. CONS: Need temporary additional block devices with 256MB in size. One can reclaim the storage pointed by the raw devices when the operation completes.

  87. On one node as root run:


  88.     # ocrconfig -replace ocr /dev/sdb1
  89.     # ocrconfig -replace ocrmirror /dev/sdc1

  90. For every ocrconfig or ocrcheck command a trace file to $CRS_Home/log/<hostname>/client directory is written. Below an example from the successful ocrconfig -replace ocr command.

  91. Oracle Database 10g CRS Release 10.2.0.4.0 Production Copyright 1996, 2008 Oracle. All rights reserved.
  92. 2008-08-06 07:07:10.424: [ OCRCONF][3086866112]ocrconfig starts...
  93. 2008-08-06 07:07:11.328: [ OCRCONF][3086866112]Successfully replaced OCR and set block 0
  94. 2008-08-06 07:07:11.328: [ OCRCONF][3086866112]Exiting [status=success]...


  95. Now run ocrcheck to verify if the OCR is pointing to the block device and no error is returned.
  96. Status of Oracle Cluster Registry is as follows :


  97.     Version : 2
  98.     Total space (kbytes) : 497776
  99.     Used space (kbytes) : 3844
  100.     Available space (kbytes) : 493932
  101.     ID : 576761409
  102.     Device/File Name : /dev/sdb1
  103.     Device/File integrity check succeeded
  104.     Device/File Name : /dev/sdc2
  105.     Device/File integrity check succeeded

  106.     Cluster registry integrity check succeeded

  107. Method 2 (Offline)

  108. In place method when additional storage is not available, but this requires cluster downtime.

  109. Below the existing mapping from the raw bindings to the block devices, is defined in /etc/sysconfig/rawdevices


  110.     /dev/raw/raw1 /dev/sdb1
  111.     /dev/raw/raw2 /dev/sdc1

  112.     # raw -qa
  113.     /dev/raw/raw1: bound to major 8, minor 17
  114.     /dev/raw/raw2: bound to major 8, minor 33

  115.     # ls /dev/raw/raw*
  116.     crw-r----- 1 root oinstall 162, 1 Jul 24 10:39 /dev/raw/raw1
  117.     crw-r----- 1 root oinstall 162, 2 Jul 24 10:39 /dev/raw/raw2

  118.     # ls -ltra /dev/*
  119.     brw-r----- 1 root oinstall 8, 17 Jul 24 10:39 /dev/sdb1
  120.     brw-r----- 1 root oinstall 8, 33 Jul 24 10:39 /dev/sdc1


  121. 1. Shutdown Oracle Clusterware on all nodes using "crsctl stop crs" as root.

  122. 2. On all nodes run the following commands as root:

  123.     # ocrconfig -repair ocr /dev/sdb1
  124.     # ocrconfig -repair ocrmirror /dev/sdc1

  125. 3. On one node as root run:

  126.     # ocrconfig -overwrite

  127. In the $CRS_Home/log/<hostname>/client directory there is a trace file from "ocrconfig -overwrite" like ocrconfig_<pid>.log which should exit with status=success like below:

  128.     cat /crs/log/node1/client/ocrconfig_20022.log

  129.     Oracle Database 10g CRS Release 10.2.0.4.0 Production Copyright 1996, 2008 Oracle. All rights reserved.
  130.     2008-08-06 06:41:29.736: [ OCRCONF][3086866112]ocrconfig starts...
  131.     2008-08-06 06:41:31.535: [ OCRCONF][3086866112]Successfully overwrote OCR configuration on disk
  132.     2008-08-06 06:41:31.535: [ OCRCONF][3086866112]Exiting [status=success]...

  133. As a verification step run ocrcheck on all nodes and the Device/File Name should reflect the block devices replacing the raw devices:

  134.     # ocrcheck
  135.     Status of Oracle Cluster Registry is as follows :
  136.     Version : 2
  137.     Total space (kbytes) : 497776
  138.     Used space (kbytes) : 3844
  139.     Available space (kbytes) : 493932
  140.     ID : 576761409
  141.     Device/File Name : /dev/sdb1
  142.     Device/File integrity check succeeded
  143.     Device/File Name : /dev/sdc1
  144.     Device/File integrity check succeeded

  145.     Cluster registry integrity check succeeded

  146. Example of adding an OCR device file on raw device (Pre 11.2)

  147. If you have upgraded your environment from a previous version, where you only had one OCR device file, you can use the following step to add an OCRMIRROR file.

  148. Add /dev/raw/raw2 as OCR mirror device

  149.     # ocrconfig -replace ocrmirror /dev/raw/raw2

  150. Example of adding/replacing OCR/OCRMIRROR on cluster file system (per 11.2)

  151. The new OCR/OCRMIRROR file on the cluster filesystem must exist before add/replace can happen. For example, the new OCR and OCRMIRROR will be located under:
  152. /cluster_fs/OCR/newocr.dat
  153. /cluster_fs/OCR/newocrm.dat

  154. As root user:
  155. # touch /cluster_fs/OCR/newocr.dat
  156. # touch /cluster_fs/OCR/newocrm.dat
  157. # chown root:oinstall /cluster_fs/OCR/newocr.dat
  158. # chown root:oinstall /cluster_fs/OCR/newocrm.dat
  159. # chmod 640 /cluster_fs/OCR/newocr.dat
  160. # chmod 640 /cluster_fs/OCR/newocrm.dat

  161. To add OCRMIRROR:
  162. # ocrconfig -replace ocrmirror /cluster_fs/OCR/newocrm.dat

  163. To replace OCR or OCRMIRROR:
  164. # ocrconfig -replace ocr /cluster_fs/OCR/newocr.dat
  165. # ocrconfig -replace ocrmirror /cluster_fs/OCR/newocrm.dat


  166. ADD/DELETE/MOVE Voting Disk
  167. Note: 1. crsctl votedisk commands must be run as root
  168. 2 .If the new voting disk is on cluster file system, then it needs to be touched with proper ownership and permission before they can be added.
  169. 3. If the old voting disk is on cluster file system, it needs to be deleted manually after crsctl delete css votedisk command.
  170. 4. The voting disk must be owned by the oracle user, in the oinstall group, and must have permissions set to 644. In 10g provide at least 20 MB disk space for the voting disk. In 11g provide at least 280 MB disk space for the voting disk.


  171. 10.2

  172. Shutdown the Oracle Clusterware (crsctl stop crs as root) on all nodes before making any modification to the voting disk. Determine the current voting disk location using:
  173. crsctl query css votedisk

  174. 1. To add a Voting Disk, provide the full path including file name:

  175.     # crsctl add css votedisk <VOTEDISK_LOCATION> -force

  176. 2. To delete a Voting Disk, provide the full path including file name:

  177.     # crsctl delete css votedisk <VOTEDISK_LOCATION> -force

  178. 3. To move a Voting Disk, provide the full path including file name:

  179.     # crsctl add css votedisk <NEW_LOCATION> -force
  180.     # crsctl delete css votedisk <OLD_LOCATION> -force

  181. After modifying the voting disk, start the Oracle Clusterware stack on all nodes

  182.     # crsctl start crs

  183. Verify the voting disk location using

  184.     # crsctl query css votedisk


  185. 11.1

  186. Starting with 11.1.0.6, the below commands can be performed online.

  187. 1. To add a Voting Disk, provide the full path including file name:

  188. # crsctl add css votedisk <VOTEDISK_LOCATION>


  189. 2. To delete a Voting Disk, provide the full path including file name:

  190. # crsctl delete css votedisk <VOTEDISK_LOCATION>

  191. 3. To move a Voting Disk, provide the full path including file name:

  192. # crsctl add css votedisk <NEW_LOCATION>
  193. # crsctl delete css votedisk <OLD_LOCATION>

  194. Verify the voting disk location using:
  195. # crsctl query css votedisk

  196. 11.2+:
  197. From 11.2, votedisk can be stored on either ASM diskgroup or cluster file systems. The following commands can only be executed when GI is running either in cluster mode or exclusive mode. As grid user:

  198. 1. To add a Voting Disk
  199. a. When votedisk is on cluster file system:
  200. $ crsctl add css votedisk <VOTEDISK_LOCATION/filename>

  201. b. When votedisk is on ASM diskgroup, no add option available. The number of votedisk is determined by the diskgroup redundancy. If more copy of votedisk is desired, one can move votedisk to a diskgroup with higher redundancy.

  202. 2. To delete a Voting Disk
  203. a. When votedisk is on cluster file system:
  204. $ crsctl delete css votedisk <VOTEDISK_LOCATION/filename>

  205. b. When votedisk is on ASM, no delete option available, one can only replace the existing votedisk group with another ASM diskgroup

  206. 3. To move a Voting Disk
  207. a. When votedisk is on cluster file system:
  208. $ crsctl add css votedisk <NEW VOTEDISK_LOCATION/filename>
  209. $ crsctl delete css votedisk <OLD VOTEDISK_LOCATION/filename>

  210. b. When votedisk is on ASM or moving votedisk between cluster file system and ASM diskgroup

  211. $ crsctl replace votedisk <+diskgroup>|<vdisk>

  212. eg:
  213. move from ASM to cluster file system:
  214. $ crsctl replace votedisk /shared/vote.dat
  215. Now formatting voting disk: /shared/vote.dat.
  216. CRS-4256: Updating the profile
  217. Successful addition of voting disk 32ff90ab38a04f65bf0c428c8fea9721.
  218. Successful deletion of voting disk 3d34623f09b64f9dbfa44fabf455513e.
  219. Successful deletion of voting disk 7043c38000a24f1abf36473ca7e9cd9e.
  220. Successful deletion of voting disk 18de241007df4f9cbf3fbb4193f0ecb4.
  221. CRS-4256: Updating the profile
  222. CRS-4266: Voting file(s) successfully replaced

  223. move from an ASM diskgroup +CRS to ASM diskgroup +OCRVOTE:
  224. $ crsctl replace votedisk +OCRVOTE
  225. CRS-4256: Updating the profile
  226. Successful addition of voting disk 3d34623f09b64f9dbfa44fabf455513e.
  227. Successful addition of voting disk 7043c38000a24f1abf36473ca7e9cd9e.
  228. Successful addition of voting disk 18de241007df4f9cbf3fbb4193f0ecb4.
  229. Successful deletion of voting disk a32c9b158e644fabbfdcc239c76f22a0.
  230. Successfully replaced voting disk group with +CRS.
  231. CRS-4256: Updating the profile
  232. CRS-4266: Voting file(s) successfully replaced


  233. 4. To verify:
  234. $ crsctl query css votedisk


  235. EXAMPLE MOVING VOTING DISK FROM RAW DEVICE to BLOCK DEVICE(Pre 11.2)

  236. In this example the voting disks will be on the following devices:

  237.     /dev/raw/raw4
  238.     /dev/raw/raw5
  239.     /dev/raw/raw6

  240. Backup Voting before starting any modification.

  241. To determine the configured voting devices run "crsctl query css votedisk"


  242.     # crsctl query css votedisk
  243.     0. 0 /dev/raw/raw4
  244.     1. 0 /dev/raw/raw5
  245.     2. 0 /dev/raw/raw6
  246.     located 3 votedisk(s).

  247. Backup Voting

  248. Take a backup of all voting disk:

  249.     $ dd if=voting_disk_name of=backup_file_name

  250. For Windows:

  251.     ocopy \\.\votedsk1 o:\backup\votedsk1.bak


  252. Moving Voting Device from RAW Device to Block Device

  253. 1) Run crsctl query css votedisk to determine the current voting disks:

  254.     # crsctl query css votedisk
  255.     0. 0 /dev/raw/raw4
  256.     1. 0 /dev/raw/raw5
  257.     2. 0 /dev/raw/raw6
  258.     located 3 votedisk(s).

  259. 2) Shutdown Oracle Clusterware on all nodes using "crsctl stop crs" as root.

  260. Note: This step is only required for 10g CRS. For 11.1 this is an online operation and no cluster outage is required.


  261. 3) Perform add new voting disk and delete old voting disk. Please note, it is not allowed to delete the last defined voting disk without adding a new one first. Perform the below commands on one node only:

  262.     # crsctl delete css votedisk /dev/raw/raw4 -force
  263.     # crsctl add css votedisk /dev/vote1 -force
  264.     # crsctl delete css votedisk /dev/raw/raw5 -force
  265.     # crsctl delete css votedisk /dev/raw/raw6 -force
  266.     # crsctl add css votedisk /dev/vote2 -force
  267.     # crsctl add css votedisk /dev/vote3 -force


  268. 4) Verify with crsctl query css votedisk:

  269.     # crsctl query css votedisk
  270.     0. 0 /dev/vote1
  271.     1. 0 /dev/vote2
  272.     2. 0 /dev/vote3
  273.     located 3 votedisk(s).

  274. 5) After this the Oracle Clusterware stack can be restarted with "crsctl start crs" as root. (Only required for 10g CRS)

  275. Monitoring the cluster_alert.log in $CRS_HOME/log/<hostname>/alertnode.log the new configured voting disks should be online:

  276. 2008-08-06 07:41:55.029
  277. [cssd(31750)]CRS-1605:CSSD voting file is online: /dev/vote1. Details in /crs/log/node1/cssd/ocssd.log.
  278. 2008-08-06 07:41:55.038
  279. [cssd(31750)]CRS-1605:CSSD voting file is online: /dev/vote2. Details in /crs/log/node1/cssd/ocssd.log.
  280. 2008-08-06 07:41:55.058
  281. [cssd(31750)]CRS-1605:CSSD voting file is online: /dev/vote3. Details in /crs/log/node1/cssd/ocssd.log.
  282. [cssd(31750)]CRS-1601:CSSD Reconfiguration complete. Active nodes are node1 node2 .


  283. References
  284. NOTE:1062983.1 - How to restore ASM based OCR after complete loss of the CRS diskgroup on Linux/Unix systems
  285. NOTE:390880.1 - OCR Corruption after Adding/Removing voting disk to a cluster when CRS stack is running
  286. NOTE:866102.1 - Renaming OCR Using "ocrconfig -overwrite" Fails
复制代码

回复 只看该作者 道具 举报

3#
发表于 2012-3-3 20:58:49
1.

默认每4个小时 ocr会自动备份, 可以通过如下命令找出 备份文件

[grid@vrh2 ~]$ ocrconfig -showbackup

vrh2     2012/03/03 22:02:45     /g01/11.2.0/grid/cdata/vrh-cluster/backup00.ocr

vrh2     2012/03/03 18:02:45     /g01/11.2.0/grid/cdata/vrh-cluster/backup01.ocr

vrh2     2012/03/03 14:02:44     /g01/11.2.0/grid/cdata/vrh-cluster/backup02.ocr

vrh2     2012/03/02 03:09:35     /g01/11.2.0/grid/cdata/vrh-cluster/day.ocr

vrh2     2012/02/24 03:09:04     /g01/11.2.0/grid/cdata/vrh-cluster/week.ocr
PROT-25: Manual backups for the Oracle Cluster Registry are not available


还可以利用  ocrconfig  -export 导出ocr到文件


[grid@vrh2 ~]$ su - root
Password:

[root@vrh2 ~]# ocrconfig  -export new.ocr
[root@vrh2 ~]# file new.ocr
new.ocr: data


2. 在Unix/Linux上可以使用dd 备份votedisk

而在Windows上有 ocopy

C:\Users\Maclean.Liu>ocopy
OCOPY v2.0 - Copyright 1989-1993 Oracle Corp.  All rights reserved.
Usage:
    ocopy from_file [to_file [a | size_1 [size_n]]]
    ocopy -b from_file to_drive
    ocopy -r from_drive to_dir


How do I restore OCR from a backup? On Windows, can I use ocopy?
The only recommended way to restore an OCR from a backup is "ocrconfig -restore ". The ocopy command will not be able to perform the restore action for OCR.


    ocopy \\.\votedsk1 o:\backup\votedsk1.bak

回复 只看该作者 道具 举报

您需要登录后才可以回帖 登录 | 注册

QQ|手机版|Archiver|Oracle数据库数据恢复、性能优化

GMT+8, 2024-12-24 00:15 , Processed in 0.047064 second(s), 21 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部
TEL/電話+86 13764045638
Email service@parnassusdata.com
QQ 47079569