oracle asm磁盘头 备份,11g中asm磁盘组元数据备份及恢复

注意:在11g中asm变化挺大的,用md_backup备份,用md_restore来恢复

1 当前磁盘组相关信息

SQL>  select PATH,b.NAME from v$asm_disk

a,v$asm_diskgroup b where a.GROUP_NUMBER=b.GROUP_NUMBER;

PATH  NAME

--------------- --------------------

ORCL:ASM2  FFFNORMAL

ORCL:ASM3  FFFNORMAL

ORCL:ASM4  FFFNORMAL

ORCL:CRS1  OCRDG

ORCL:CRS2  OCRDG

ORCL:CRS3  OCRDG

6 rows selected.

2  md_backup操作

2.1 md_backup命令介绍

ASMCMD [+] > help md_backup

md_backup

The md_backup command creates a backup file

containing metadata

for one or more disk groups.

Volume and Oracle Automatic Storage Management

Cluster File System

(Oracle ACFS) file system information is not

backed up.

md_backup backup_file [-G diskgroup

[,diskgroup,...]]

The options for the md_backup command are

described below.

backup_file  - Specifies the backup file in which you want

to

store the metadata.

-G diskgroup  - Specifies the disk group name of the disk

group

that must be backed up

By default all the mounted disk groups are

included in the backup file,

which is saved in the current working

directory.

The first example shows the use of the backup

command when you run it

without the disk group option. This example

backs up all of the mounted

disk groups and creates the backup image in the

current working

directory. The second example creates a backup

of disk group DATA and

FRA. The backup that this example creates is

saved in the

/tmp/dgbackup20090716 file.

ASMCMD [+] > md_backup

/tmp/dgbackup20090716

ASMCMD [+] > md_backup /tmp/dgbackup20090716

-G DATA,FRA

Disk group metadata to be backed up: DATA

Disk group metadata to be backed up: FRA

Current alias directory path:

ASM/ASMPARAMETERFILE

Current alias directory path:

ORCL/DATAFILE

Current alias directory path:

ORCL/TEMPFILE

Current alias directory path:

ORCL/CONTROLFILE

Current alias directory path:

ORCL/PARAMETERFILE

Current alias directory path: ASM

Current alias directory path:

ORCL/ONLINELOG

Current alias directory path: ORCL

Current alias directory path:

ORCL/CONTROLFILE

Current alias directory path:

ORCL/ARCHIVELOG/2009_07_13

Current alias directory path:

ORCL/BACKUPSET/2009_07_14

Current alias directory path:

ORCL/ARCHIVELOG/2009_07_14

Current alias directory path: ORCL

Current alias directory path:

ORCL/DATAFILE

Current alias directory path:

ORCL/ARCHIVELOG

Current alias directory path:

ORCL/BACKUPSET

Current alias directory path:

ORCL/ONLINELOG

2.2 备份所有mount磁盘组

ASMCMD [+] > md_backup /home/grid/yaogangdb.md

Disk group metadata to be backed up: FFFNORMAL

Disk group metadata to be backed up: OCRDG

Current alias directory path: smedb-cluster/OCRFILE

Current alias directory path: smedb-cluster

Current alias directory path:

smedb-cluster/ASMPARAMETERFILE

2.3 备份指定磁盘组

ASMCMD [+] > md_backup /home/grid/yaogang_ocrdg.md -G

ocrdg

Disk group metadata to be backed up: OCRDG

Current alias directory path: smedb-cluster/OCRFILE

Current alias directory path: smedb-cluster

Current alias directory path:

smedb-cluster/ASMPARAMETERFILE

3 md_restore操作

3.1 md_restore命令介绍

ASMCMD [+] > help  md_restore

md_restore

This command restores a disk group metadata

backup.

md_restore backup_file

[--silent][--full|--nodg|--newdg -o 'old_diskgroup:new_diskgroup

[,...]'][-S sql_script_file] [-G 'diskgroup [,diskgroup...]']

The options for the md_restore command are

described below.

backup_file  - Reads the metadata

information from

backup_file.

--silent  - Ignore

errors. Normally, if md_restore

encounters an error, it will

stop.

Specifying this flag ignores

any errors.

--full  - Specifies to create a disk group and

restore

metadata.

--nodg  - Specifies to restore metadata only.

--newdg -o old_diskgroup:new_diskgroup

- Specifies to create a

disk

group with a different name

when restoring

metadata. The -o option is

required

with --newdg.

-S sql_script_file  - Write SQL commands to the

specified SQL

script file instead of

executing the commands.

-G diskgroup  - Select the disk groups to be

restored.

If no disk groups are

defined, then all

disk groups will be

restored.

The first example restores the disk group DATA

from the backup script

and creates a copy. The second example takes an

existing disk group

DATA and restores its metadata. The third

example restores disk group

DATA completely but the new disk group that is

created is called DATA2.

The fourth example restores from the backup file

after applying the

overrides defined in the override.sql script

file

ASMCMD [+] > md_restore --full -G data

--silent /tmp/dgbackup20090714

ASMCMD [+] > md_restore --nodg -G data

--silent /tmp/dgbackup20090714

ASMCMD [+] > md_restore --newdg -o

'data:data2' --silent /tmp/dgbackup20090714

ASMCMD [+] > md_restore -S override.sql

--silent /tmp/dgbackup20090714

3.2 生产sql文件(未执行)

ASMCMD [+] > md_restore -S

/tmp/get_ocrdg_sql -G ocrdg

/home/grid/yaogang_ocrdg.md

Current Diskgroup metadata being restored: OCRDG

3.3 显示生产sql文本内容

[grid@db1 ~]$ cat /tmp/get_ocrdg_sql

create diskgroup OCRDG EXTERNAL redundancy

disk 'ORCL:CRS2' name CRS2 size 1908M

disk 'ORCL:CRS3' name CRS3 size 1908M

disk 'ORCL:CRS1' name CRS1 size 1907M attribute

'compatible.asm' = '11.2.0.0.0', 'compatible.rdbms' =

'10.1.0.0.0';

alter diskgroup OCRDG set attribute '_._DIRVERSION' =

'11.2.0.0.0';

alter diskgroup OCRDG alter template "ARCHIVELOG" attributes

(UNPROTECTED COARSE);

alter diskgroup OCRDG alter template "BACKUPSET" attributes

(UNPROTECTED COARSE);

alter diskgroup OCRDG alter template "FLASHBACK" attributes

(UNPROTECTED COARSE);

alter diskgroup OCRDG alter template "OCRFILE" attributes

(UNPROTECTED COARSE);

alter diskgroup OCRDG alter template "PARAMETERFILE"

attributes (UNPROTECTED COARSE);

alter diskgroup OCRDG alter template "DATAGUARDCONFIG"

attributes (UNPROTECTED COARSE);

alter diskgroup OCRDG alter template "CONTROLFILE" attributes

(UNPROTECTED FINE);

alter diskgroup OCRDG alter template "XTRANSPORT BACKUPSET"

attributes (UNPROTECTED COARSE);

alter diskgroup OCRDG alter template "CHANGETRACKING"

attributes (UNPROTECTED COARSE);

alter diskgroup OCRDG alter template "DATAFILE" attributes

(UNPROTECTED COARSE);

alter diskgroup OCRDG alter template "FLASHFILE" attributes

(UNPROTECTED COARSE);

alter diskgroup OCRDG alter template "ASMPARAMETERFILE"

attributes (UNPROTECTED COARSE);

alter diskgroup OCRDG alter template "DUMPSET" attributes

(UNPROTECTED COARSE);

alter diskgroup OCRDG alter template "TEMPFILE" attributes

(UNPROTECTED COARSE);

alter diskgroup OCRDG alter template "XTRANSPORT" attributes

(UNPROTECTED COARSE);

alter diskgroup OCRDG alter template "ONLINELOG" attributes

(UNPROTECTED COARSE);

alter diskgroup OCRDG alter template "AUTOBACKUP" attributes

(UNPROTECTED COARSE);

alter diskgroup OCRDG add directory '+OCRDG/db-cluster';

alter diskgroup OCRDG add directory

'+OCRDG/db-cluster/OCRFILE';

alter diskgroup OCRDG add directory

'+OCRDG/db-cluster/ASMPARAMETERFILE';

3.4模拟破坏现场

破坏OCRDG磁盘组中的其中一个asm disk(/dev/oracleasm/disks/ASM2)

知道asm2设备找到真正物理设备方法

[root@db1 ~]# oracleasm querydisk -d asm2

Disk "ASM2" is a valid ASM disk on device [8,49]

[root@db1 ~]# ll /dev/ | grep 8 | grep 49

brw-r----- 1 root disk  8,  49 Oct 22 16:35 sdd1

[root@db1 ~]#  dd if=/dev/zero of=/dev/sdd1

bs=4096 count=1

1+0 records in

1+0 records out

4096 bytes (4.1 kB) copied, 4.8629e-05 seconds, 84.2

MB/s

3.5 尝试还原磁盘组(操作单位是磁盘组)

ASMCMD [+] > md_restore --full -G ocrdg

/home/grid/yaogang_ocrdg.md

Current Diskgroup metadata being restored: OCRDG

ASMCMD-9352: CREATE DISKGROUP failed

ORA-15018: diskgroup cannot be created

ORA-15030: diskgroup name "OCRDG" is in use by another

diskgroup (DBD ERROR: OCIStmtExecute)

以下是在DROP了OCRDG之后,执行恢复的全过程,恢复完成以后,磁盘组被创建,模板信息被还原:

drop diskgroup  OCRDG

including contents; ---这个命令在磁盘设备挂载上才能使用

drop diskgroup  OCRDG force

including contents;

---在11g中force选项磁盘不挂载也能删除掉磁盘组

ASMCMD [+] > md_restore --full -G ocrdg  /home/grid/yaogang_ocrdg.md

Current Diskgroup metadata being restored: ocrdg

Diskgroup ocrdg created!

System template DATAFILE modified!

System template AUTOBACKUP modified!

System template OCRFILE modified!

System template ASMPARAMETERFILE modified!

System template PARAMETERFILE modified!

System template DUMPSET modified!

System template ARCHIVELOG modified!

System template XTRANSPORT modified!

System template DATAGUARDCONFIG modified!

System template BACKUPSET modified!

System template ONLINELOG modified!

System template CONTROLFILE modified!

System template FLASHFILE modified!

System template XTRANSPORT BACKUPSET modified!

System template FLASHBACK modified!

System template TEMPFILE modified!

System template CHANGETRACKING modified!

4 11g中asm新增命令如下

ASMCMD [+] > help

asmcmd

[-V] [-v ] [--privilege ] [-p] [command]

asmcmd_no_conn_str

Starts asmcmd (if no parameters) or executes the

command with given parameters

asmcmd [-V] [-v ] [--privilege ] [-p]

[command]

Specify the connect string after the -c option

to use the listener to

connect.  By default, ASMCMD

asks for a password in a non-echoing

prompt, unless the password is specified as part

of the connect string.

The connect identifier is in the form of

"host:port:sid", with the

host and the port being option.

Host defaults to "localhost" and port

to 1521.  If the sid is not

specified as a part of the connect

identifier, then it is read from the environment

variable ORACLE_SID.

If no connect string is used, then environment

variables

ORACLE_HOME and ORACLE_SID determine the

instance to which the program

connects, and asmcmd establishes a bequeath

connection to the it, in

the same manner as a SQLPLUS / AS SYSASM.

The user must be a member

of the SYSDBA group to exercise this

option.

Specifying the -V option prints the asmcmd

version number and

exits immediately.

Specifying the -v option prints extra

information that can help

advanced users diagnose problems.

Specify the --privilege option to choose the

type of connection. There are

only two possibilities: connecting as SYSASM or

as SYSDBA.

The default value if this option is unspecified

is SYSASM:

Specifying the -p option allows the current

directory to be displayed

in the command prompt, like so:

ASMCMD [+DATA/ORCL/CONTROLFILE] >

The parameter command specifies one of the

following commands, along

with its parameters.

Type "help [command]" to get help on a specific

ASMCMD command.

commands:

--------

md_backup, md_restore

lsattr, setattr

cd, cp, du, find, help, ls, lsct, lsdg, lsof,

mkalias

mkdir, pwd, rm, rmalias

chdg, chkdg, dropdg, iostat, lsdsk, lsod, mkdg,

mount

offline, online, rebal, remap, umount

dsget, dsset, lsop, shutdown, spbackup, spcopy,

spget

spmove, spset, startup

chtmpl, lstmpl, mktmpl, rmtmpl

chgrp, chmod, chown, groups, grpmod, lsgrp,

lspwusr, lsusr

mkgrp, mkusr, orapwusr, passwd, rmgrp,

rmusr

volcreate, voldelete, voldisable, volenable,

volinfo

volresize, volset, volstat

总结说明

md_backup和md_restore是磁盘组级别的备份和还原,如果一个磁盘组的某个asm

disk出现问题,使用这对命令解决起来还是很麻烦,甚至根本不可行(因为代价太大:要删除该磁盘组其他asm disk

header,然后要重新还原所有数据文件),这样的情景下dd或者kfed的备份还是非常有必要。

你可能感兴趣的:(oracle,asm磁盘头,备份)