技术分享
10g RAC环境下的备份与恢复
2021-06-08
本节中将演示下rac环境下的数据的备份和完全恢复,rac的备份和恢复同单实例数据库对比,只是在处理归档日志上有些扩展,一般来讲,可以将归档日志存储在ASM磁盘组中,或者存储在集群文件系统上,NFS以及本地文件系统上,当归档日志存储在ASM,集群文件系统或者NFS上的时候,rac备份和恢复和单实例下的操作基本一致,下面的场景归档日志存储在ASM上!
一:查看rac归档的设置
[oracle@rac1 ~]$ sqlplus /nolog SQL> conn /as sysdba SQL> conn sys/123456@racdb2 as sysdba |
二:查看ASM磁盘组中的归档日志
[oracle@rac1 ~]$ export ORACLE_SID=+ASM1 [oracle@rac1 ~]$ asmcmd ASMCMD> cd FRA ASMCMD> ls RACDB/ ASMCMD> cd racdb ASMCMD> ls ARCHIVELOG/ BACKUPSET/ CONTROLFILE/ ONLINELOG/ ASMCMD> ls archivelog 2011_12_12/ ASMCMD> ls archivelog/2011_12_12/ thread_1_seq_39.261.769724057 thread_2_seq_15.265.769695387 |
三:使用rman备份数据库
[oracle@rac1 ~]$ rman target / RMAN> run { RMAN> list backup of database summary; List of Backups |
四:创建基础数据
[oracle@rac1 ~]$ sqlplus /nolog SQL> create user test identified by hr account unlock SQL> grant connect,resource to test; SQL> conn test/hr@racdb2 SQL> create table t1 (a number); SQL> insert into t1 values (1); SQL> commit; SQL> conn /as sysdba FILE_NAME |
五:删除users表空间数据文件
[oracle@rac2 ~]$ export ORACLE_SID=+ASM2 [oracle@rac2 ~]$ srvctl stop database -d racdb |
六:进行恢复
在接下来的启动数据库操作将会失败,日志里面明显的告诉我们4号数据文件不存在
[oracle@rac2 ~]$ srvctl start database -d racdb [oracle@rac1 ~]$ tail -f /u01/app/oracle/admin/racdb/bdump/alert_racdb1.log Shutting down instance (abort) 将数据库启动到mount状态,利用rman进行还原和恢复 [oracle@rac1 ~]$ rman target / RMAN> restore datafile 4; channel ORA_DISK_1: starting datafile backupset restore RMAN> recover datafile 4; starting media recovery archive log thread 1 sequence 42 is already on disk as file +FRA/racdb/archivelog/2011_12_12/thread_1_seq_42.265.769726867 |
七:验证
[oracle@rac2 ~]$ srvctl stop database -d racdb -o immediate [oracle@rac2 ~]$ srvctl status database -d racdb [oracle@rac2 ~]$ sqlplus sys/123456@racdb2 as sysdba Connected to: SQL> select * from test.t1; A |
八:表决盘和ocr的备份
[oracle@rac1 ~]$ crsctl query css votedisk located 3 votedisk(s). [oracle@rac1 ~]$ dd if=/dev/raw/raw7 of=vote.dbf [oracle@rac1 ~]$ ocrcheck Cluster registry integrity check succeeded 导出ocr,需要使用root用户 |
- 标签:
-
云计算