ITPub博客

首页 > 数据库 > Oracle > ASM元数据备份与恢复

ASM元数据备份与恢复

原创 Oracle 作者:sky850623 时间:2015-10-07 16:00:31 0 删除 编辑
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/,如需转载,请注明出处,否则将追究法律责任。

下一篇: snmp安装
请登录后发表评论 登录
全部评论

注册时间:2013-05-30

  • 博文量
    154
  • 访问量
    468691