Oracle利器:AMDU抽取ASM数据文件测试

Oracle利器:AMDU抽取ASM数据文件测试

在异常情况下RAC集群无法启动,asm实例无法打开,此时asm磁盘组文件也无法使用asmcmd拷贝到文件目录,我们可以使用Oracle自带的工具amdu,在asm实例无法启动或者磁盘组无法mount的情况下对数据进行抽取。
本次通过odu以及amdu,将rac环境下的数据库,在异机单实例下进行恢复。
备注:本次通过odu的试用版,仅仅是获取asm目录结构,抽取文件的动作是由amdu完成。
1、关闭RAC集群

[root@rac1 ~]# crsctl stop cluster -all

asmcmd已无法查看磁盘组

[grid@rac2:/home/grid]$asmcmd
Connected to an idle instance.
ASMCMD> ls
ASMCMD-8102: no connection to Oracle ASM; command requires Oracle ASM to run

2、查看ASM磁盘组对应磁盘

[grid@rac1:/home/grid/odu]$kfod di=all group=diskgroup ds=true
--------------------------------------------------------------------------------
 Disk          Size Path                                     Disk Group   User     Group   
================================================================================
   1:       5120 Mb /dev/asmdisk1                            CRS          grid     asmadmin
   2:      10240 Mb /dev/asmdisk2                            DATA         grid     asmadmin
   3:       6144 Mb /dev/asmdisk3                            ARCH         grid     asmadmin
KFOD returned no data

3、解压odu
链接:https://pan.baidu.com/s/1QIf9ykw-A9yxM5MUAXtO9Q 密码:gmrp

[root@rac1 opt]# tar -zxvf odu_trial_413_linux_x86.tar.gz 
odu/
odu/asmdisk.txt
odu/config.txt
odu/control.txt
odu/data/
odu/odu
[root@rac1 opt]# cd odu/
[root@rac1 odu]# ll
total 2544
-rwxrwxrwx 1 root   root          90 Mar 22  2011 asmdisk.txt
-rwxrwxrwx 1 root   root         558 Mar 22  2011 config.txt
-rwxrwxrwx 1 root   root         118 Mar 22  2011 control.txt
drwxr-xr-x 2 oracle oinstall    4096 May 15  2009 data
-rwxrwxrwx 1 root   root     2588361 Feb  2  2012 odu

4、编辑odu对应asm磁盘文件
odu会根据此文件查找asm磁盘组

[root@rac1 odu]# vi asmdisk.txt 
# disk_no  disk_path       group_name meta_block_size  ausize disk_size header_offset
1 /dev/asmdisk1
2 /dev/asmdisk2
3 /dev/asmdisk3

5、启动odu

[root@rac1 odu]# ./odu 

Oracle Data Unloader trial version 4.1.3

Copyright © 2008,2009,2010,2011 XiongJun. All rights reserved.

Web: http://www.oracleodu.com
Email: magic007cn@gmail.com

loading default config.......

byte_order little
block_size  8192
block_buffers 1024
error at line 3.
db_timezone -7
Invalid db timezone:-7
client_timezone 8
Invalid client timezone:8
asmfile_extract_path   /asmfile
data_path   data
lob_path    /odu/data/lob
charset_name US7ASII
charset name 'US7ASII' not found,will use default charset ZHS16GBK
ncharset_name AL16UTF16
output_format text
lob_storage infile
clob_byte_order big
trace_level 1
delimiter |
unload_deleted no
file_header_offset 0
is_tru64 no
record_row_addr no
convert_clob_charset yes
use_scanned_lob  yes
trim_scanned_blob yes
lob_switch_dir_rows 20000
db_block_checksum yes
db_block_checking yes
rdba_file_bits 10
compatible 10
load config file 'config.txt' successful
loading default asm disk file ......


grp# dsk# bsize ausize disksize diskname        groupname       path
---- ---- ----- ------ -------- --------------- --------------- --------------------------------------------
   1    0  4096  1024K     5120 CRS_0000        CRS             /dev/asmdisk1
   2    0  4096  4096K     2560 DATA_0000       DATA            /dev/asmdisk2
   3    0  4096  4096K     1536 ARCH_0000       ARCH            /dev/asmdisk3

load asm disk file 'asmdisk.txt' successful
-->ODU已成功扫描asm磁盘组
loading default control file ......


 ts#   fn  rfn bsize   blocks bf offset filename
---- ---- ---- ----- -------- -- ------ --------------------------------------------
load control file 'control.txt' successful
loading dictionary data......done

loading scanned data......done

6、进入asm磁盘组目录

ODU> asmcmd

Entering asmcmd module.

ASMCMD> ls

Current directory: <root>

Disk Group
------------------------------------
CRS
DATA
ARCH

7、找出所有数据库相关的数据文件

ASMCMD> cd +data

Current directory: +DATA

ASMCMD> ls

Current directory: +DATA

Name                                    
----------------------------------------
ORCL                                      <DIR>
system01.dbf                               => +DATA.263.1006945245
sysaux01.dbf                               => +DATA.265.1006945281
undotbs01.dbf                              => +DATA.270.1006945305
users01.dbf                                => +DATA.256.1006945307
admin_5.dbf                                => +DATA.269.1006945307
tbs_6.dbf                                  => +DATA.274.1006945443
tbs_index_7.dbf                            => +DATA.264.1006945445
redo01.log                                 => +DATA.266.1006945479
redo02.log                                 => +DATA.271.1006945479
redo03.log                                 => +DATA.272.1006945481
temp01.dbf                                 => +DATA.267.1006945481
spfileorcl.ora                             => +DATA.259.1006946053
undotbs02.dbf                              => +DATA.258.1006950347
epointwebbuilder4_4.dbf                    => +DATA.281.1010051161
epointwebbuilder4_4_01.dbf                 => +DATA.282.1010052881

ASMCMD> cd ORCL

Current directory: +DATA/ORCL

ASMCMD> ls

Current directory: +DATA/ORCL

Name                                    
----------------------------------------
CONTROLFILE                               <DIR>
DATAFILE                                  <DIR>
ONLINELOG                                 <DIR>
TEMPFILE                                  <DIR>
PARAMETERFILE                             <DIR>
spfileorcldb.ora                           => +DATA.273.1006606953

8、查找控制文件、日志文件

ASMCMD> cd CONTROLFILE

Current directory: +DATA/ORCL/CONTROLFILE

ASMCMD> ls

Current directory: +DATA/ORCL/CONTROLFILE

Name                                    
----------------------------------------
current.268.1006945239                  
control1.ctl                               => +DATA.268.1006945239
Current.268.1006604463                  
group_2.261.965769115                   
group_3.268.965771071                   
group_4.269.965771071                   

9、抽取数据文件、控制文件、日志文件
将asm磁盘对应文件拷贝到文件系统

[root@rac1 ~]# su - grid

根据上述获取的asm文件内部数字编号,抽取数据,格式为
“amdu -diskstring '/dev/磁盘路径' -extract 'ASM磁盘组名称.数字编号'”

amdu -diskstring '/dev/asm*' -extract 'DATA.263'
amdu -diskstring '/dev/asm*' -extract 'DATA.265'
amdu -diskstring '/dev/asm*' -extract 'DATA.270'
amdu -diskstring '/dev/asm*' -extract 'DATA.256'
amdu -diskstring '/dev/asm*' -extract 'DATA.269'
amdu -diskstring '/dev/asm*' -extract 'DATA.274'
amdu -diskstring '/dev/asm*' -extract 'DATA.264'
amdu -diskstring '/dev/asm*' -extract 'DATA.266'
amdu -diskstring '/dev/asm*' -extract 'DATA.271'
amdu -diskstring '/dev/asm*' -extract 'DATA.272'
amdu -diskstring '/dev/asm*' -extract 'DATA.267'
amdu -diskstring '/dev/asm*' -extract 'DATA.259'
amdu -diskstring '/dev/asm*' -extract 'DATA.258'
amdu -diskstring '/dev/asm*' -extract 'DATA.281'
amdu -diskstring '/dev/asm*' -extract 'DATA.282'

amdu -diskstring '/dev/asm*' -extract 'DATA.268'
amdu -diskstring '/dev/asm*' -extract 'DATA.260'
amdu -diskstring '/dev/asm*' -extract 'DATA.261'
amdu -diskstring '/dev/asm*' -extract 'DATA.262'

10、异机环境编辑参数文件

[oracle@gs ~]$ vi /u01/app/oracle/product/11.2.0/db_1/dbs/initorcl.ora 
audit_trail=none
sga_target=4g
pga_aggregate_target=1g
control_files='/u01/app/oracle/oradata/orcl/control1.ctl'
db_name='orcl'
db_domain=''
processes=1000
compatible=11.2.0.4.0
undo_tablespace='UNDOTBS1'

11、启动数据库mount

SQL> startup mount;
ORACLE instance started.

Total System Global Area 4275781632 bytes
Fixed Size                  2260088 bytes
Variable Size             838861704 bytes
Database Buffers         3422552064 bytes
Redo Buffers               12107776 bytes
Database mounted.
SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+DATA/system01.dbf
+DATA/sysaux01.dbf
+DATA/undotbs01.dbf
+DATA/users01.dbf
+DATA/admin_5.dbf
+DATA/tbs_6.dbf
+DATA/tbs_index_7.dbf
+DATA/undotbs02.dbf
+DATA/epointwebbuilder4_4.dbf
+DATA/epointwebbuilder4_4_01.dbf

10 rows selected.

12、修改控制文件中数据文件、日志文件路径

使用脚本批量修改name
select 'alter database rename file '''||name||''' to '''||replace(name,'+DATA/orcl/datafile','/u01/app/oracle/oradata/orcl')||''' ;' from v$datafile;
                                            
select 'alter database rename file '''||member||''' to '''||replace(member,'+DATA/orcl/datafile','/u01/app/oracle/oradata/orcl')||''' ;' from v$logfile;
alter database rename file '+DATA/system01.dbf'               to '/u01/app/oracle/oradata/orcl/DATA_263.f';
alter database rename file '+DATA/sysaux01.dbf'               to '/u01/app/oracle/oradata/orcl/DATA_265.f';
alter database rename file '+DATA/undotbs01.dbf'              to '/u01/app/oracle/oradata/orcl/DATA_270.f';
alter database rename file '+DATA/users01.dbf'                to '/u01/app/oracle/oradata/orcl/DATA_256.f';
alter database rename file '+DATA/admin_5.dbf'                to '/u01/app/oracle/oradata/orcl/DATA_269.f';
alter database rename file '+DATA/tbs_6.dbf'                  to '/u01/app/oracle/oradata/orcl/DATA_274.f';
alter database rename file '+DATA/tbs_index_7.dbf'            to '/u01/app/oracle/oradata/orcl/DATA_264.f';
alter database rename file '+DATA/undotbs02.dbf'              to '/u01/app/oracle/oradata/orcl/DATA_258.f';
alter database rename file '+DATA/epointwebbuilder4_4.dbf'    to '/u01/app/oracle/oradata/orcl/DATA_281.f';
alter database rename file '+DATA/epointwebbuilder4_4_01.dbf' to '/u01/app/oracle/oradata/orcl/DATA_282.f';


alter database rename file '+DATA/redo01.log'  to '/u01/app/oracle/oradata/orcl/DATA_266.f';
alter database rename file '+DATA/redo02.log'  to '/u01/app/oracle/oradata/orcl/DATA_271.f';
alter database rename file '+DATA/redo03.log'  to '/u01/app/oracle/oradata/orcl/DATA_272.f';
alter database rename file '+DATA/orcl/onlinelog/group_4.260.1006950467' to '/u01/app/oracle/oradata/orcl/DATA_260.f';
alter database rename file '+DATA/orcl/onlinelog/group_5.261.1006950467' to '/u01/app/oracle/oradata/orcl/DATA_261.f';
alter database rename file '+DATA/orcl/onlinelog/group_6.262.1006950467' to '/u01/app/oracle/oradata/orcl/DATA_262.f';

13、打开数据库

SQL> recover database;  
Media recovery complete.
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/arch
Oldest online log sequence     96
Next log sequence to archive   98
Current log sequence           98
SQL> alter database open;

Database altered.

rac环境的数据文件在单实例下open完毕

备注:
如果不使用ODU工具,可以通过抽取的控制文件,再获取数据文件各个目录,最主要的是获取数据文件在asm中的内部编号。

[grid@rac1:/home/grid]$strings DATA_268.f  | grep DATA |sort | uniq 

+DATA/orcl/onlinelog/group_10.276.1007243997
+DATA/orcl/onlinelog/group_11.277.1007243997
+DATA/orcl/onlinelog/group_12.278.1007243999
+DATA/orcl/onlinelog/group_13.279.1007244115
+DATA/orcl/onlinelog/group_14.280.1007244119
+DATA/orcl/onlinelog/group_4.260.1006950467
+DATA/orcl/onlinelog/group_5.261.1006950467
+DATA/orcl/onlinelog/group_6.262.1006950467
+DATA/orcl/onlinelog/group_7.257.1007243993
+DATA/orcl/onlinelog/group_8.273.1007243995
+DATA/orcl/onlinelog/group_9.275.1007243995
···

参考:

MOS ASM tools used by Support : KFOD, KFED, AMDU (文档 ID 1485597.1)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值