ASM元数据备份与恢复

1.创建一个表空间
SQL> create tablespace asmtbs datafile '+dg1';
Tablespace created.
没有指定大小,默认创建100m.
SQL> select * from v$dbfile;
     FILE# NAME
---------- ------------------------------------------------------------
         4 /u01/app/oracle/oradata/test/users01.dbf
         3 /u01/app/oracle/oradata/test/sysaux01.dbf
         2 /u01/app/oracle/oradata/test/undotbs01.dbf
         1 /u01/app/oracle/oradata/test/system01.dbf
         5 /u01/app/oracle/oradata/test/test01.dbf
         6 /u01/app/oracle/oradata/test/mgmt.dbf
         7 /u01/app/oracle/oradata/test/mgmt_ecm_depot1.dbf
         8 +DG1/test/datafile/asmtbs.256.891217415
8 rows selected.
2.在表空间创建一张表
SQL> create table t (id number,name varchar2(10)) tablespace asmtbs;
Table created.
SQL> select segment_name,tablespace_name from user_segments where segment_name='T';
SEGMENT_NA TABLESPACE_NAME
---------- ------------------------------
T          ASMTBS
3.备份ASM元数据
[oracle@ocp ~]$ dd if=/dev/oracleasm/disks/VOL1 of=/home/oracle/vol1.bak bs=4096 count=1
1+0 records in
1+0 records out
4.破坏ASM元数据
[oracle@ocp ~]$ dd if=/dev/zero of=/dev/oracleasm/disks/VOL1 bs=4096 count=1
1+0 records in
1+0 records out
[oracle@ocp ~]$ kfed read /dev/oracleasm/disks/VOL1  --元数据被破坏
kfbh.endian:                          0 ; 0x000: 0x00
kfbh.hard:                            0 ; 0x001: 0x00
kfbh.type:                            0 ; 0x002: KFBTYP_INVALID
kfbh.datfmt:                          0 ; 0x003: 0x00
kfbh.block.blk:                       0 ; 0x004: T=0 NUMB=0x0
kfbh.block.obj:                       0 ; 0x008: TYPE=0x0 NUMB=0x0
kfbh.check:                           0 ; 0x00c: 0x00000000
kfbh.fcn.base:                        0 ; 0x010: 0x00000000
kfbh.fcn.wrap:                        0 ; 0x014: 0x00000000
kfbh.spare1:                          0 ; 0x018: 0x00000000
kfbh.spare2:                          0 ; 0x01c: 0x00000000
5.插入数据
SQL> select * from t;
no rows selected

SQL> insert into t values(1,'a');  
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t;
        ID NAME
---------- ------------------------------------------------------------
         1 a
6.关闭数据库实例和ASM实例
SQL> select status from v$instance;
STATUS
------------
OPEN
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> select status from v$instance;
STATUS
------------
STARTED
SQL> shutdown immediate;   --关闭ASM实例
ASM diskgroups dismounted
ASM instance shutdown
SQL> startup  --启动ASM实例
ASM instance started

Total System Global Area   83886080 bytes
Fixed Size                  1217836 bytes
Variable Size              57502420 bytes
ASM Cache                  25165824 bytes
ORA-15110: no diskgroups mounted
SQL> alter diskgroup dg1 mount;  --挂载磁盘组
alter diskgroup dg1 mount
*
ERROR at line 1:
ORA-15032: not all alterations performed
ORA-15063: ASM discovered an insufficient number of disks for diskgroup "DG1"

7.恢复
[oracle@ocp ~]$ dd if=/home/oracle/vol1.bak of=/dev/oracleasm/disks/VOL1 bs=4096 count=1
1+0 records in
1+0 records out
SQL> alter diskgroup dg1 mount;   --磁盘组mount成功
Diskgroup altered.
SQL> startup 
ORACLE instance started.

Total System Global Area  285212672 bytes
Fixed Size                  1218992 bytes
Variable Size             117442128 bytes
Database Buffers          163577856 bytes
Redo Buffers                2973696 bytes
Database mounted.
Database opened.
数据库也能正常启动

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26937943/viewspace-1813431/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/26937943/viewspace-1813431/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值