ASM是Oracle10gR2中为了简化Oracle数据库的管理而推出来的一项新功能,这是Oracle自己提供的卷管理器,主要用于替代 *** 作系统所提供的LVM,它不仅支持单实例,同时对RAC的支持也是非常好。ASM可以自动管理磁盘组并提供有效的数据冗余功能。使用ASM(自动存储管理)后,数据库管理员不再需要对ORACLE中成千上万的数据文件进行管理和分类,从而简化了DBA的工作量,可以使得工作效率大大提高。详细步骤:7924376
oracle里似乎没有直接的对应关系。[@more@]
SQL> select name,path from v$asm_disk where name is not null;
NAME PATH
------------------------------ --------------------
VOL1 ORCL:VOL1
VOL2 ORCL:VOL2
VOL3 ORCL:VOL3
SQL>
root@node1 dev]# oracleasm querydisk -d VOL1
Disk "VOL1" is a valid ASM disk on device [8, 17]
先要使用-d选项输出device的主次编号,之后在dev下根据device的主次编号找到对应的设备,看来oracle内部没有直接记录设备的名称。
[root@node1 dev]# cd /dev
[root@node1 dev]# ls sdb1
sdb1
[root@node1 dev]# ls -l sdb1
brw-rw---- 1 root disk 8, 17 Mar 15 23:36 sdb1
[root@node1 dev]#
另外通过oracleasm createdisk创建asm disk之后,在/dev/oracleasm/disks下出现了下面的asm disk:
--=================================
[root@node1 disks]# ls -l
total 0
brw-rw---- 1 oracle dba 8, 17 Mar 15 23:36 VOL1
brw-rw---- 1 oracle dba 8, 33 Mar 15 23:36 VOL2
brw-rw---- 1 oracle dba 8, 49 Mar 15 23:36 VOL3
[root@node1 disks]# pwd
/dev/oracleasm/disks
在文件系统下用dd备份文件头部做测试
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/oradata/upgr/system01dbf
/oradata/upgr/sysaux01dbf
/oradata/upgr/undotbs01dbf
/oradata/upgr/users01dbf
SQL>
SQL> set lines 156 pages 100
SQL> col dd_backup_cmd for a156
SQL> col dd_restore_cmd for a156
SQL> select 'dd if='||name||' of=/backup/'||substr(name,instr(name,'/',-1)+1)||'FH bs='||block_size||' count=2' dd_backup_cmd from v$datafile;
DD_BACKUP_CMD
--------------------------------------------------------------------------------
dd if=/oradata/upgr/system01dbf of=/backup/system01dbfFH bs=8192 count=2
dd if=/oradata/upgr/sysaux01dbf of=/backup/sysaux01dbfFH bs=8192 count=2
dd if=/oradata/upgr/undotbs01dbf of=/backup/undotbs01dbfFH bs=8192 count=2
dd if=/oradata/upgr/users01dbf of=/backup/users01dbfFH bs=8192 count=2
SQL> select 'dd of='||name||' if=/backup/'||substr(name,instr(name,'/',-1)+1)||'FH bs='||block_size||' count=2 conv=notrunc' dd_restore_cmd from v$datafile;
DD_RESTORE_CMD
------------------------------------------------------------------------------------------
dd of=/oradata/upgr/system01dbf if=/backup/system01dbfFH bs=8192 count=2 conv=notrunc
dd of=/oradata/upgr/sysaux01dbf if=/backup/sysaux01dbfFH bs=8192 count=2 conv=notrunc
dd of=/oradata/upgr/undotbs01dbf if=/backup/undotbs01dbfFH bs=8192 count=2 conv=notrunc
dd of=/oradata/upgr/users01dbf if=/backup/users01dbfFH bs=8192 count=2 conv=notrunc
SQL>
[oracle@db1 ~]$ dd if=/oradata/upgr/system01dbf of=/backup/system01dbfFH bs=8192 count=2
2+0 records in
2+0 records out
16384 bytes (16 kB) copied, 0000412654 s, 397 MB/s
破坏数据文件头部
[oracle@db1 ~]$ dd if=/dev/zero of=/oradata/upgr/system01dbf bs=8192 count=2 conv=notrunc
2+0 records in
2+0 records out
16384 bytes (16 kB) copied, 0000434433 s, 377 MB/s
[oracle@db1 ~]$ sqlplus / as sysdba
SQLPlus: Release 112040 Production on Thu Jun 16 15:23:33 2016
Copyright (c) 1982, 2013, Oracle All rights reserved
Connected to an idle instance
SQL> startup
ORACLE instance started
Total System Global Area 313159680 bytes
Fixed Size 2252824 bytes
Variable Size 167776232 bytes
Database Buffers 138412032 bytes
Redo Buffers 4718592 bytes
Database mounted
ORA-01157: cannot identify/lock data file 1 - see DBWR trace file
ORA-01110: data file 1: '/oradata/upgr/system01dbf'
SQL> shutdown abort
ORACLE instance shut down
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 112040 - 64bit Production
With the Partitioning, Data Mining and Real Application Testing options
恢复数据文件头部
[oracle@db1 ~]$ dd of=/oradata/upgr/system01dbf if=/backup/system01dbfFH bs=8192 count=2 conv=notrunc
2+0 records in
2+0 records out
16384 bytes (16 kB) copied, 0000574576 s, 285 MB/s
[oracle@db1 ~]$ sqlplus / as sysdba
SQLPlus: Release 112040 Production on Thu Jun 16 15:24:32 2016
Copyright (c) 1982, 2013, Oracle All rights reserved
Connected to an idle instance
SQL> startup
ORACLE instance started
Total System Global Area 313159680 bytes
Fixed Size 2252824 bytes
Variable Size 167776232 bytes
Database Buffers 138412032 bytes
Redo Buffers 4718592 bytes
Database mounted
Database opened
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 112040 - 64bit Production
With the Partitioning, Data Mining and Real Application Testing options
[oracle@db1 ~]$
在ASM情况下用dd备份文件头部做测试
SQL> select ' dd '||
2 ' if=/backup/'||egroup_kffxp||'_'||edisk_kffxp||'_'||afile_number||'FH'||
3 ' of='||dpath||
4 ' bs='||callocation_unit_size||
5 ' seek='||eau_kffxp||
6 ' count=1 conv=notrunc' dd_restore_cmd
7 from
8 v$asm_alias a,
9 v$asm_file b,
10 v$asm_diskgroup c,
11 v$asm_disk d,
12 x$kffxp e
13 where afile_number=enumber_kffxp
14 and agroup_number=egroup_kffxp
15 and bgroup_number=agroup_number
16 and dgroup_number=cgroup_number
17 and egroup_kffxp=dgroup_number
18 and afile_number=bfile_number
19 and ddisk_number=edisk_kffxp
20 and asystem_created='Y'
21 and btype='DATAFILE'
22 and exnum_kffxp=0
23 order by afile_number
24 /
DD_RESTORE_CMD
--------------------------------------------------------------------------------------------
dd if=/backup/1_3_283FH of=/dev/oracleasm/disks/ASMDISK7 bs=1048576 seek=21 count=1 conv=notrunc
dd if=/backup/1_4_285FH of=/dev/oracleasm/disks/ASMDISK8 bs=1048576 seek=262 count=1 conv=notrunc
dd if=/backup/1_2_287FH of=/dev/oracleasm/disks/ASMDISK6 bs=1048576 seek=266 count=1 conv=notrunc
dd if=/backup/1_1_288FH of=/dev/oracleasm/disks/ASMDISK5 bs=1048576 seek=299 count=1 conv=notrunc
dd if=/backup/1_3_291FH of=/dev/oracleasm/disks/ASMDISK7 bs=1048576 seek=163 count=1 conv=notrunc
SQL>
SQL> select ' dd'||
2 ' if='||dpath||
3 ' of=/backup/'||egroup_kffxp||'_'||edisk_kffxp||'_'||afile_number||'FH'||
4 ' bs='||callocation_unit_size||
5 ' skip='||eau_kffxp||
6 ' count=1' dd_backup_cmd
7 from
8 v$asm_alias a,
9 v$asm_file b,
10 v$asm_diskgroup c,
11 v$asm_disk d,
12 x$kffxp e
13 where afile_number=enumber_kffxp
14 and agroup_number=egroup_kffxp
15 and bgroup_number=agroup_number
16 and dgroup_number=cgroup_number
17 and egroup_kffxp=dgroup_number
18 and afile_number=bfile_number
19 and ddisk_number=edisk_kffxp
20 and asystem_created='Y'
21 and btype='DATAFILE'
22 and exnum_kffxp=0
23 order by afile_number
24 /
DD_BACKUP_CMD
---------------------------------------------------------------------------------------------------------------
dd if=/dev/oracleasm/disks/ASMDISK7 of=/backup/1_3_283FH bs=1048576 skip=21 count=1
dd if=/dev/oracleasm/disks/ASMDISK8 of=/backup/1_4_285FH bs=1048576 skip=262 count=1
dd if=/dev/oracleasm/disks/ASMDISK6 of=/backup/1_2_287FH bs=1048576 skip=266 count=1
dd if=/dev/oracleasm/disks/ASMDISK5 of=/backup/1_1_288FH bs=1048576 skip=299 count=1
dd if=/dev/oracleasm/disks/ASMDISK7 of=/backup/1_3_291FH bs=1048576 skip=163 count=1
SQL>
备份ASM中数据文件头部
[oracle@ohs1 ~]$ dd if=/dev/oracleasm/disks/ASMDISK7 of=/backup/1_3_283FH bs=1048576 skip=21 count=1
1+0 records in
1+0 records out
1048576 bytes (10 MB) copied, 000664794 seconds, 158 MB/s
破坏ASM中数据文件头部
[oracle@ohs1 ~]$ dd if=/dev/zero of=/dev/oracleasm/disks/ASMDISK7 seek=21 count=1 conv=notrunc bs=1M
1+0 records in
1+0 records out
1048576 bytes (10 MB) copied, 0000517497 seconds, 20 GB/s
[oracle@ohs1 ~]$ sqlplus / as sysdba
SQLPlus: Release 112030 Production on Thu Jun 16 14:58:53 2016
Copyright (c) 1982, 2011, Oracle All rights reserved
Connected to an idle instance
SQL> startup
ORACLE instance started
Total System Global Area 318046208 bytes
Fixed Size 1344680 bytes
Variable Size 188746584 bytes
Database Buffers 121634816 bytes
Redo Buffers 6320128 bytes
Database mounted
ORA-01122: database file 1 failed verification check
ORA-01110: data file 1: '+DATA_PGOLD/racdb/system01dbf'
ORA-01210: data file header is media corrupt
SQL> shut abort
ORACLE instance shut down
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 112030 - Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
恢复ASM中数据文件头部
[oracle@ohs1 ~]$ dd if=/backup/1_3_283FH of=/dev/oracleasm/disks/ASMDISK7 bs=1048576 seek=21 count=1 conv=notrunc
1+0 records in
1+0 records out
1048576 bytes (10 MB) copied, 000153561 seconds, 683 MB/s
[oracle@ohs1 ~]$ sqlplus / as sysdba
SQLPlus: Release 112030 Production on Thu Jun 16 15:00:08 2016
Copyright (c) 1982, 2011, Oracle All rights reserved
Connected to an idle instance
SQL> startup
ORACLE instance started
Total System Global Area 318046208 bytes
Fixed Size 1344680 bytes
Variable Size 188746584 bytes
Database Buffers 121634816 bytes
Redo Buffers 6320128 bytes
Database mounted
Database opened
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
SQL>
生成备份数据文件头部所需要的dd脚本(数据库用户)
set lines 156 pages 100
col dd_backup_cmd for a156
col dd_restore_cmd for a156
select 'dd if='||name||' of=/backup/'||substr(name,instr(name,'/',-1)+1)||'FH bs='||block_size||' count=2' dd_backup_cmd from v$datafile;
select 'dd of='||name||' if=/backup/'||substr(name,instr(name,'/',-1)+1)||'FH bs='||block_size||' count=2 conv=notrunc' dd_restore_cmd from v$datafile;
生成备份ASM数据文件头部所需要的dd脚本(在GI用户下ASM实例)
set lines 156 pages 100
col dd_backup_cmd for a156
col dd_restore_cmd for a156
select ' dd'||
' if='||dpath||
' of=/backup/'||egroup_kffxp||'_'||edisk_kffxp||'_'||afile_number||'FH'||
' bs='||callocation_unit_size||
' skip='||eau_kffxp||
' count=1' dd_backup_cmd
from
v$asm_alias a,
v$asm_file b,
v$asm_diskgroup c,
v$asm_disk d,
x$kffxp e
where afile_number=enumber_kffxp
and agroup_number=egroup_kffxp
and bgroup_number=agroup_number
and dgroup_number=cgroup_number
and egroup_kffxp=dgroup_number
and afile_number=bfile_number
and ddisk_number=edisk_kffxp
and asystem_created='Y'
and btype='DATAFILE'
and exnum_kffxp=0
order by afile_number
/
select ' dd '||
' if=/backup/'||egroup_kffxp||'_'||edisk_kffxp||'_'||afile_number||'FH'||
' of='||dpath||
' bs='||callocation_unit_size||
' seek='||eau_kffxp||
' count=1 conv=notrunc' dd_restore_cmd
from
v$asm_alias a,
v$asm_file b,
v$asm_diskgroup c,
v$asm_disk d,
x$kffxp e
where afile_number=enumber_kffxp
and agroup_number=egroup_kffxp
and bgroup_number=agroup_number
and dgroup_number=cgroup_number
and egroup_kffxp=dgroup_number
and afile_number=bfile_number
and ddisk_number=edisk_kffxp
and asystem_created='Y'
and btype='DATAFILE'
and exnum_kffxp=0
order by afile_number
/
生成备份ASM磁盘头部所需要的dd脚本(在GI用户下ASM实例)
set lines 150
set pages 1000
select
'dd if='||path||
' of=/backup/'||substr(path,instr(path,'/',-1)+1)||'_'||group_number||'_'||disk_number||'DH bs=1M count=100'
from v$asm_disk asm_header_backup
where header_status='MEMBER'
order by group_number,disk_number;
select 'dd if=/backup/'||substr(path,instr(path,'/',-1)+1)||'_'||group_number||'_'||disk_number||'DH'||
' of='||path||' bs=1M count=100 conv=notrunc'
from v$asm_disk asm_header_restore
where header_status='MEMBER'
order by group_number,disk_number;
生成asmcmd cp命令(数据库用户下执行)
select 'asmcmd cp '||name||' /backup/'||substr(name,instr(name,'/',-1)+1) asmcmd_cp from v$controlfile
union all
select 'asmcmd cp '||name||' /backup/'||substr(name,instr(name,'/',-1)+1) from v$datafile
union all
select 'asmcmd cp '||member||' /backup/'||thread#||'_'||agroup#||'_'||substr(member,instr(member,'/',-1)+1)
from v$log a, v$logfile b where agroup# = bgroup#;
ASMCMD_CP
--------------------------------------------------------------------------------
asmcmd cp +DATA_PGOLD/racdb/control01ctl /backup/control01ctl
asmcmd cp +DATA_PGOLD/racdb/control02ctl /backup/control02ctl
asmcmd cp +DATA_PGOLD/racdb/system01dbf /backup/system01dbf
asmcmd cp +DATA_PGOLD/racdb/sysaux01dbf /backup/sysaux01dbf
asmcmd cp +DATA_PGOLD/racdb/undotbs01dbf /backup/undotbs01dbf
asmcmd cp +DATA_PGOLD/racdb/users01dbf /backup/users01dbf
asmcmd cp +DATA_PGOLD/racdb/undotbs02dbf /backup/undotbs02dbf
asmcmd cp +DATA_PGOLD/racdb/redo02log /backup/1_2_redo02log
asmcmd cp +DATA_PGOLD/racdb/redo01log /backup/1_1_redo01log
asmcmd cp +DATA_PGOLD/racdb/redo03log /backup/2_3_redo03log
asmcmd cp +DATA_PGOLD/racdb/redo04log /backup/2_4_redo04log
11 rows selected
SQL>
然后执行以上命令即可
生成rman copy命令(数据库用户下执行)
select 'copy current controlfile to ''/tmp/'||substr(name,instr(name,'/',-1)+1)||''';' rman_copy from v$controlfile
union all
select 'copy datafile '||file#||' to ''/backup/'||substr(name,instr(name,'/',-1)+1)||''';' from v$datafile;
RMAN_COPY
--------------------------------------------------------------------------------
copy current controlfile to '/tmp/control01ctl';
copy current controlfile to '/tmp/control02ctl';
copy datafile 1 to '/backup/system01dbf';
copy datafile 2 to '/backup/sysaux01dbf';
copy datafile 3 to '/backup/undotbs01dbf';
copy datafile 4 to '/backup/users01dbf';
copy datafile 5 to '/backup/undotbs02dbf';
7 rows selected
SQL>
然后使用rman这些以上命令
下面是迁移至一个已经存在的ASM数据库的步骤:
1群集中的所有实例shutdown immediate
2修改目标数据库的初始参数:
DB_CREATE_FILE_DEST
DB_CREATE_ONLINE_LOG_DEST[1,2,3,4]
CONTROL_FILES
3使用RMAN连接目标数据库,并启动目标数据库至nomount状态
4将源控制文件移动到第2步指定的位置
5完成第4步之后mount目标数据库
6使用RMAN拷贝数据库到ASM磁盘
7一旦拷贝完成,数据库就可以recovery了。使用RMAN进行数据库恢复 *** 作
8OPEN目标数据库
9注意临时表空间没有迁移,需要自己手工创建的
10下一步是建联机重做日志(在ASM中)
11旧数据文件可以从 *** 作系统删除了——慎重
12如果之前开启了数据块变化跟踪,可以重新开启这个特征
以上就是关于ORACLE 11g单机数据库安装,应该选择文件系统还是ASM,为什么全部的内容,包括:ORACLE 11g单机数据库安装,应该选择文件系统还是ASM,为什么、如何查看ASM磁盘对应的实际的磁盘分区的相关推荐、如何使用dd备份数据文件头部和ASM磁盘头部等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)