OCR磁盘的导出和导入、备份和恢复以及移动(ocrconfig命令的应用)

数据库版本:10.2.0.1

一,使用导出、导入进行备份和恢复

Oracle推荐在对集群做调整时,比如增加、删除节点之前,应该对OCR做一个备份,可以使用export 备份到指定文件。如果做了replace或restore等操作,Oracle建议使用"cluvfy comp ocr -n all" 命令做一次全面检查。

1.首先关闭所有节点的CRS

[[email protected]rac3 ~]$ crs_stat -t
Name           Type           Target    State     Host
------------------------------------------------------------
ora....SM1.asm application    ONLINE    ONLINE    rac3
ora....C3.lsnr application    ONLINE    ONLINE    rac3
ora.rac3.gsd   application    ONLINE    ONLINE    rac3
ora.rac3.ons   application    ONLINE    ONLINE    rac3
ora.rac3.vip   application    ONLINE    ONLINE    rac3
ora....SM2.asm application    ONLINE    ONLINE    rac4
ora....C4.lsnr application    ONLINE    ONLINE    rac4
ora.rac4.gsd   application    ONLINE    ONLINE    rac4
ora.rac4.ons   application    ONLINE    ONLINE    rac4
ora.rac4.vip   application    ONLINE    ONLINE    rac4
ora.racdb.db   application    ONLINE    ONLINE    rac3
ora....b1.inst application    ONLINE    ONLINE    rac3
ora....b2.inst application    ONLINE    ONLINE    rac4
ora....rver.cs application    ONLINE    ONLINE    rac3
ora....db2.srv application    ONLINE    ONLINE    rac3  

[[email protected] bin]# ./crsctl stop crs
Stopping resources.
Successfully stopped CRS resources
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.
[[email protected] ~]$ crs_stat -t
Name           Type           Target    State     Host
------------------------------------------------------------
ora....SM1.asm application    ONLINE    ONLINE    rac3
ora....C3.lsnr application    ONLINE    ONLINE    rac3
ora.rac3.gsd   application    ONLINE    ONLINE    rac3
ora.rac3.ons   application    ONLINE    ONLINE    rac3
ora.rac3.vip   application    ONLINE    ONLINE    rac3
ora....SM2.asm application    ONLINE    ONLINE    rac4
ora....C4.lsnr application    ONLINE    ONLINE    rac4
ora.rac4.gsd   application    ONLINE    ONLINE    rac4
ora.rac4.ons   application    ONLINE    ONLINE    rac4
ora.rac4.vip   application    ONLINE    ONLINE    rac4
ora.racdb.db   application    ONLINE    ONLINE    rac3
ora....b1.inst application    ONLINE    ONLINE    rac3
ora....b2.inst application    ONLINE    ONLINE    rac4
ora....rver.cs application    ONLINE    ONLINE    rac3
ora....db2.srv application    ONLINE    ONLINE    rac3        

[[email protected] bin]# ./crsctl stop crs
Stopping resources.
Successfully stopped CRS resources
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.

2.导出OCR内容(需要root用户导出)

[[email protected] bin]# ./ocrconfig -export /home/oracle/ocr.exp
[[email protected] bin]# ll /home/oracle/ocr.exp
-rw-r--r--  1 root root 98847 Jan 27 11:23 /home/oracle/ocr.exp

3.重新启动CRS

[[email protected] bin]# ./crsctl start crs
Attempting to start CRS stack
The CRS stack will be started shortly

[[email protected] bin]# ./crsctl start crs
Attempting to start CRS stack
The CRS stack will be started shortly

4.检查CRS状态

[[email protected] bin]# ./crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy

[[email protected] bin]# ./crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy

5.破坏ocr内容

[[email protected] bin]# dd if=/dev/zero of=/dev/raw/raw1 bs=1M count=120
dd: writing `/dev/raw/raw1‘: No space left on device
102+0 records in
101+0 records out

6.现在检查ocr一致性

[[email protected] bin]# ./ocrcheck
PROT-601: Failed to initialize ocrcheck

[[email protected] bin]# ./ocrcheck
PROT-601: Failed to initialize ocrcheck

7.使用cluvfy工具检查一致性

[[email protected] cluvfy]# pwd
/opt/clusterware/cluvfy
[[email protected] cluvfy]# ./runcluvfy.sh  comp ocr -n all

Verifying OCR integrity
Unable to retrieve nodelist from Oracle clusterware.

Verification cannot proceed.

同样是检查失败

8.现在查看集群状态

[[email protected] ~]$ crs_stat -t    --ocr被破坏,集群已经宕掉
CRS-0184: Cannot communicate with the CRS daemon.

[[email protected] ~]$ crs_stat -t
CRS-0184: Cannot communicate with the CRS daemon.

9.使用import恢复OCR内容

[[email protected] bin]# ./ocrconfig -import /home/oracle/ocr.exp
[[email protected] bin]#

10.再次检查OCR

[[email protected] bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     104344
         Used space (kbytes)      :       4340
         Available space (kbytes) :     100004
         ID                       :  945144556
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded

                                    Device/File not configured

         Cluster registry integrity check succeeded
[[email protected] bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     104344
         Used space (kbytes)      :       4340
         Available space (kbytes) :     100004
         ID                       :  945144556
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded

                                    Device/File not configured

         Cluster registry integrity check succeeded

11.检查通过,用cluvfy工具检查

[[email protected] cluvfy]$ ./runcluvfy.sh  comp ocr -n all

Verifying OCR integrity 

Checking OCR integrity...

Checking the absence of a non-clustered configuration...
All nodes free of non-clustered, local-only configurations.

Uniqueness check for OCR device passed.

Checking the version of OCR...
OCR of correct Version "2" exists.

Checking data integrity of OCR...
Data integrity check for OCR passed.

OCR integrity check passed.

Verification of OCR integrity was successful. 

12.启动CRS

[[email protected] bin]# ./crsctl start crs
Attempting to start CRS stack
The CRS stack will be started shortly

[[email protected] bin]# ./crsctl start crs
Attempting to start CRS stack
The CRS stack will be started shortly
[[email protected] ~]$ crs_stat -t
Name           Type           Target    State     Host
------------------------------------------------------------
ora....SM1.asm application    ONLINE    OFFLINE
ora....C3.lsnr application    ONLINE    OFFLINE
ora.rac3.gsd   application    ONLINE    OFFLINE
ora.rac3.ons   application    ONLINE    OFFLINE
ora.rac3.vip   application    ONLINE    OFFLINE
ora....SM2.asm application    ONLINE    OFFLINE
ora....C4.lsnr application    ONLINE    OFFLINE
ora.rac4.gsd   application    ONLINE    OFFLINE
ora.rac4.ons   application    ONLINE    OFFLINE
ora.rac4.vip   application    ONLINE    OFFLINE
ora.racdb.db   application    ONLINE    OFFLINE
ora....b1.inst application    ONLINE    OFFLINE
ora....b2.inst application    ONLINE    OFFLINE
ora....rver.cs application    ONLINE    OFFLINE
ora....db2.srv application    ONLINE    OFFLINE 

13.最后检查CRS的状态

[[email protected] bin]# ./crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy

[[email protected] bin]# ./crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy

二,移动OCR文件的位置

以下示例将演示如何把OCR从/dev/raw/raw1移动到/dev/raw/raw8上

1.首先查看是否有最近的OCR备份

[[email protected] bin]# ./ocrconfig -showbackup

rac4     2015/01/23 17:54:53     /opt/ora10g/product/10.2.0/crs_1/cdata/crs

rac3     2014/10/10 16:51:14     /opt/ora10g/product/10.2.0/crs_1/cdata/crs

rac3     2014/10/10 12:51:11     /opt/ora10g/product/10.2.0/crs_1/cdata/crs

rac4     2015/01/23 17:54:53     /opt/ora10g/product/10.2.0/crs_1/cdata/crs

rac4     2015/01/23 17:54:53     /opt/ora10g/product/10.2.0/crs_1/cdata/crs

更改备份位置 ocrconfig -backuploc /oracle/backup/ocr

如果没有备份,可以立即执行一次导出作为备份

[[email protected] bin]# ./ocrconfig -export /home/oracle/ocr.bak2 -s online

[[email protected] bin]#

2.查看当前ocr配置

[[email protected] bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     104344
         Used space (kbytes)      :       4340
         Available space (kbytes) :     100004
         ID                       :  945144556
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded

                                    Device/File not configured

         Cluster registry integrity check succeeded

输出显示当前只有一个Primary OCR,位于 /dev/raw/raw1,没有Mirror OCR

3.因为现在只有一个OCR文件,位于/dev/raw/raw1,所以不能直接改变这个OCR的位置,
必须先添加镜像后再修改,否则会出现错误:

[[email protected] bin]# ./ocrconfig -replace ocr /dev/raw/raw8
PROT-16: Internal Error

4.添加一个Mirror OCR

[[email protected] bin]# ./ocrconfig -replace ocrmirror /dev/raw/raw7
[[email protected] bin]# 

5.确认添加成功

[[email protected] bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     104344
         Used space (kbytes)      :       4340
         Available space (kbytes) :     100004
         ID                       :  945144556
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded
         Device/File Name         : /dev/raw/raw7    --新添加的Mirror OCR
                                    Device/File integrity check succeeded

         Cluster registry integrity check succeeded

现在有两个OCR了,可以修改原来的Primary OCR了

6.修改Primary OCR为/dev/raw/raw8

[[email protected] bin]# ./ocrconfig -replace ocr /dev/raw/raw8
[[email protected] bin]# 

7.确认修改成功

[[email protected] bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :    2096364
         Used space (kbytes)      :       4340
         Available space (kbytes) :    2092024
         ID                       :  945144556
         Device/File Name         : /dev/raw/raw8   --Primary OCR改变了
                                    Device/File integrity check succeeded
         Device/File Name         : /dev/raw/raw7
                                    Device/File integrity check succeeded

         Cluster registry integrity check succeeded

8.确认修改被同步到了其他节点

--在另一节点也能看到更新的信息

[[email protected] bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :    2096364
         Used space (kbytes)      :       4340
         Available space (kbytes) :    2092024
         ID                       :  945144556
         Device/File Name         : /dev/raw/raw8
                                    Device/File integrity check succeeded
         Device/File Name         : /dev/raw/raw7
                                    Device/File integrity check succeeded

         Cluster registry integrity check succeeded

9.使用ocrconfig -replace命令后,所有节点上的/etc/oracle/ocr.loc文件内容也都自动同步了,
如果有点节点没有同步,也可以手工修改使其同步:

[[email protected] bin]# more /etc/oracle/ocr.loc
#Device/file /dev/raw/raw1 getting replaced by device /dev/raw/raw8
ocrconfig_loc=/dev/raw/raw8
ocrmirrorconfig_loc=/dev/raw/raw7
local_only=false

三,解决PROT-22: Storage too small错误

现在我想改回原来的Primary OCR

[[email protected] bin]# ./ocrconfig -replace ocr /dev/raw/raw1
PROT-22: Storage too small

查询metalink发现,这是一个10.2.0.1上的bug,要求ocrmirror设备的大小要比原始ocr设备大128M,详细描述可以参考:ID 317628.1。

那如何更改过来????  可参考 http://blog.itpub.net/14284241/viewspace-442842/
尝试直接修改/etc/oracle/orc.loc文件

1.查看目前的OCR配置

[[email protected] bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :    2096364
         Used space (kbytes)      :       4340
         Available space (kbytes) :    2092024
         ID                       :  945144556
         Device/File Name         : /dev/raw/raw8
                                    Device/File integrity check succeeded
         Device/File Name         : /dev/raw/raw7
                                    Device/File integrity check succeeded

         Cluster registry integrity check succeeded

2.对目前的OCR备份

[[email protected] bin]# ./ocrconfig -export /home/oracle/ocr.bak3 -s online
[[email protected] bin]# 

3.停掉所有节点的CRS

[[email protected] bin]# ./crsctl stop crs
Stopping resources.
Successfully stopped CRS resources
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.

[[email protected] bin]# ./crsctl stop crs
Stopping resources.
Error while stopping resources. Possible cause: CRSD is down.
Stopping CSSD.
Shutting down CSS daemon.
Shutdown request successfully issued.

4.手动修改所有节点的/etc/oracle/ocr.loc文件

[[email protected] bin]# more /etc/oracle/ocr.loc
#Device/file /dev/raw/raw1 getting replaced by device /dev/raw/raw8
ocrconfig_loc=/dev/raw/raw8
ocrmirrorconfig_loc=/dev/raw/raw7
local_only=false
[[email protected] bin]# vi /etc/oracle/ocr.loc
[[email protected] bin]# more /etc/oracle/ocr.loc
#Device/file /dev/raw/raw1 getting replaced by device /dev/raw/raw8
ocrconfig_loc=/dev/raw/raw1
#ocrmirrorconfig_loc=/dev/raw/raw7
local_only=false

[[email protected] bin]# more /etc/oracle/ocr.loc
#Device/file /dev/raw/raw1 getting replaced by device /dev/raw/raw8
ocrconfig_loc=/dev/raw/raw8
ocrmirrorconfig_loc=/dev/raw/raw7
local_only=false
[[email protected] bin]# vi /etc/oracle/ocr.loc
[[email protected] bin]# more /etc/oracle/ocr.loc
#Device/file /dev/raw/raw1 getting replaced by device /dev/raw/raw8
ocrconfig_loc=/dev/raw/raw1
#ocrmirrorconfig_loc=/dev/raw/raw7
local_only=false

5.检查一下ocr

--可以看到ocr现在检查报错

[[email protected] bin]# ./ocrcheck
PROT-601: Failed to initialize ocrcheck

6.导入之前备份的OCR数据

[[email protected] bin]# ./ocrconfig -import /home/oracle/ocr.bak3

7.现在检查ocr

--两个节点检查正常,且ocr盘实现已经改过来了

[[email protected] bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     104344
         Used space (kbytes)      :       4340
         Available space (kbytes) :     100004
         ID                       : 1887132889
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded

                                    Device/File not configured

         Cluster registry integrity check succeeded

[[email protected] bin]# ./ocrcheck
Status of Oracle Cluster Registry is as follows :
         Version                  :          2
         Total space (kbytes)     :     104344
         Used space (kbytes)      :       4340
         Available space (kbytes) :     100004
         ID                       : 1887132889
         Device/File Name         : /dev/raw/raw1
                                    Device/File integrity check succeeded

                                    Device/File not configured

         Cluster registry integrity check succeeded

8.启动crs

[[email protected] bin]# ./crsctl start crs
Attempting to start CRS stack
The CRS stack will be started shortly

[[email protected] bin]# ./crsctl start crs
Attempting to start CRS stack
The CRS stack will be started shortly
[[email protected] ~]$ crs_stat -t
Name           Type           Target    State     Host
------------------------------------------------------------
ora....SM1.asm application    ONLINE    ONLINE    rac3
ora....C3.lsnr application    ONLINE    ONLINE    rac3
ora.rac3.gsd   application    ONLINE    ONLINE    rac3
ora.rac3.ons   application    ONLINE    ONLINE    rac3
ora.rac3.vip   application    ONLINE    ONLINE    rac3
ora....SM2.asm application    ONLINE    ONLINE    rac4
ora....C4.lsnr application    ONLINE    ONLINE    rac4
ora.rac4.gsd   application    ONLINE    ONLINE    rac4
ora.rac4.ons   application    ONLINE    ONLINE    rac4
ora.rac4.vip   application    ONLINE    ONLINE    rac4
ora.racdb.db   application    ONLINE    ONLINE    rac4
ora....b1.inst application    ONLINE    ONLINE    rac3
ora....b2.inst application    ONLINE    ONLINE    rac4
ora....rver.cs application    ONLINE    ONLINE    rac3
ora....db2.srv application    ONLINE    ONLINE    rac4

9.检查crs状态

[[email protected] bin]# ./crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy

[[email protected] bin]# ./crsctl check crs
CSS appears healthy
CRS appears healthy
EVM appears healthy

至此我么把ocr盘通过手动的方式更改过来了,RAC正常。

--本文章 部分参考张晓明<<大话Oracle RAC>>及其他

时间: 2024-08-06 11:51:28

OCR磁盘的导出和导入、备份和恢复以及移动(ocrconfig命令的应用)的相关文章

第五章.事物,视图,索引,备份,恢复

★.存储过程 语法: delimiter $$ create procedure usp_list() begin select * from student;  end$$ delimiter ; 1.事务 概念: 就是一堆操作的集合.要么都执行成功,要么都执行失败基本要素: 1.原子性:事务是一个完整的操作.事物的各元素是不可分的. 2.一致性:事务完成时,数据必须处于一致状态. 3.隔离性:事务是独立的,它不应以任何方式依赖于或影响其他事务. 4.持久性:事务的处理结果是永久的. 执行事物

索引,视图,导入导出,备份,恢复

一.实验介绍 1.1 实验内容 本节实验中我们将学习并实践数据库的其他基本操作:索引.视图,导入和导出,备份和恢复等. 这些概念对于数据库管理员而言都非常重要,请仔细理解并完成所有实验操作. 1.2 实验知识点 索引 视图 导入和导出 备份和恢复 1.3 实验环境 课程使用的实验环境为 Ubuntu Linux 14.04 64 位版本.实验中会用到程序: Mysql 5.5.50 Xfce终端 二.开发准备 注:如果你是从上一节直接进入本节进行学习的,请先删除上一节建立的数据库mysql_sh

Oracle简单的备份和恢复-导出和导入(2)

ylbtech-Oracle:Oracle简单的备份和恢复-导出和导入(2) 简单的备份和恢复-导出和导入(2) 1. 用户导入导出文件中的一张表(emp)返回顶部 0.1, 我们在sql plus中删除掉一张表emp,把dept表的记录删空. drop table emp; delete from dept; 之后我们先利用刚才导出的mytable.dmp导入emp表.具体导入步骤如下: 1.在命令行下输入imp命令. 2.系统首先提示我们输入用户名和密码,在这里我们可以用scott/tige

Oracle简单的备份和恢复-导入和导出

ylbtech-Oracle:Oracle简单的备份和恢复-导入和导出  Oracle安全运行离不开良好的备份和恢复机制,因为我们不是DBA.所以我们也就不过多的讲解DBA的备份和恢复.作为程序员开发者来说,必须了解的是数据的导入和导出,利用这个方法我们可以搬迁数据库和数据. 1. 导出(exp)返回顶部 1.1, Oracle简单的备份和恢复-导出(exp) 1.2, 1.3, 2. 导入(imp)返回顶部 2.1, Oracle简单的备份和恢复-导入(imp) 2.2, 2.3, 3. 导入

MongoDB 备份(mongodump)恢复(mongorerstore) 导出 (Mongoexport) 导入( Mongoimport)

MongoDB 备份(mongodump) 在Mongodb中我们使用mongodump命令来备份MongoDB数据.该命令可以导出所有数据到指定目录中. mongodump命令可以通过参数指定导出的数据量级转存的服务器. 语法 mongodump命令脚本语法如下: mongodump -h dbhost -d dbname -o dbdirectory -h: MongDB所在服务器地址,例如:127.0.0.1,当然也可以指定端口号:127.0.0.1:27017 -d: 需要备份的数据库实

MongoDB导入、导出、备份、恢复、用户授权(四)

五:MongoDB导入.导出.备份.恢复.用户授权 一:数据导出,数据导入 作为DBA(管理员),经常会碰到导入导出数据的需求,下面介绍实用工具(自带的): 1:数据导入 mongoexport 导出csv格式的文件 ./mongoexport -d Test -c user1 -o /tmp/user1.out     --指定导出文件位置及文件名 数据库       集合(表) ./mongoexport -d my_mongodbTest -c user --csv -f uid,name

Mysql 导入导出,备份和恢复

导入/出,备份/恢复 导入/导出 备份/恢复 数据备份和恢复 参考:http://www.mysqltutorial.org/mysql-copy-database/ 参考:http://www.mysqltutorial.org/how-to-backup-database-using-mysqldump.aspx  mysqldump命令的详细介绍,包括参数的使用. 备份 mysqldump -u root -p 数据库名 > 路径/xxx.sql ??>代表export 恢复 连接mys

【Oracle】导出全库备份,导入指定的schema并替换现有的表

需求:开发环境,每天晚上做了全库导出备份.由于误操作,现在要恢复指定的schema下的所有表,操作思路如下: 1.全库导出备份的语句 expdp system/oracle full=y dumpfile=arp103.$version.dmp logfile=arp103.$version.log directory=dmppath compression=ALL compression=ALL 是压缩备份的意思,节省空间. 2.导入备份语句: impdp system/oracle dump

如何导出和导入mysql数据(数据迁移)

本文转自 如何导出和导入mysql数据(数据迁移) 这是其中一种方法,非常简单 1. 导出数据库数据 mysqldump -uroot -p dp_db > dumpout.sql 其中 root是账户名 dp_db是需要导出的数据库名称 dumpout.sql存储导出的数据 2. 将导出的数据dumpout.sql放到你的目标机器上(如果是远程目标机器的话,直接将dunmpout.sql copy到目标机器就行).这里假设cp到主目录下~/ 3. 在目标机器的数据库里建立新数据库,这里建立名为