aix环境文件系统迁移到asm存储 系统环境: 操作系统:aix5.3-08 oracle: oracle 10gr2 一、构建asm 存储环境 http://tiany.blog.51cto.com/513694/1418564 oracle database单实例使用asm案例(4)--aix系统oracle 10g应用 二、迁移文件系统到asm 1、查看asm i
aix环境文件系统迁移到asm存储
系统环境:
操作系统:aix5.3-08
oracle: oracle 10gr2
一、构建asm 存储环境
http://tiany.blog.51cto.com/513694/1418564
oracle database单实例使用asm案例(4)--aix系统oracle 10g应用
二、迁移文件系统到asm
1、查看asm instance
[oracle@aix211 ~]$export oracle_sid=+asm
[oracle@aix211 ~]$!sql
sqlplus '/as sysdba'
sql*plus: release 10.2.0.1.0 - production on thu may 29 17:23:24 2014
copyright (c) 1982, 2005, oracle. all rights reserved.
connected to an idle instance.
sql> startup
asm instance started
total system global area 130023424 bytes
fixed size 2019136 bytes
variable size 102838464 bytes
asm cache 25165824 bytes
asm diskgroups mounted
sql> select name ,state from v$asm_diskgroup;
name state
------------------------------ -----------
dg1 mounted
rcy1 mounted
sql>
2、修改实例参数
sql> alter system set db_create_file_dest ='+dg1' scope=spfile;
system altered.
sql> show parameter control
name type value
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string /u01/app/oracle/oradata/prod/c
ontrol01.ctl, /dsk1/oradata/pr
od/control02.ctl
sql> alter system set control_files='+dg1' scope=spfile;
system altered.
3、转储控制文件到控制文件
rman> shutdown immediate;
database closed
database dismounted
oracle instance shut down
rman> startup nomount;
connected to target database (not started)
oracle instance started
total system global area 1258291200 bytes
fixed size 2020552 bytes
variable size 318769976 bytes
database buffers 922746880 bytes
redo buffers 14753792 bytes
rman> restore controlfile from '/u01/app/oracle/oradata/prod/control01.ctl';
starting restore at 29-may-14
allocated channel: ora_disk_1
channel ora_disk_1: sid=156 devtype=disk
channel ora_disk_1: copied control file copy
output filename=+dg1/prod/controlfile/backup.256.848857069
finished restore at 29-may-14
4、转储数据文件到asm磁盘组
rman> alter database mount;
database mounted
released channel: ora_disk_1
rman> backup as copy database format '+dg1';
starting backup at 29-may-14
allocated channel: ora_disk_1
channel ora_disk_1: sid=156 devtype=disk
channel ora_disk_1: starting datafile copy
input datafile fno=00001 name=/u01/app/oracle/oradata/prod/system01.dbf
output filename=+dg1/prod/datafile/system.257.848857161 tag=tag20140529t173920 recid=12 stamp=848857281
channel ora_disk_1: datafile copy complete, elapsed time: 00:02:05
channel ora_disk_1: starting datafile copy
input datafile fno=00003 name=/u01/app/oracle/oradata/prod/sysaux01.dbf
output filename=+dg1/prod/datafile/sysaux.258.848857287 tag=tag20140529t173920 recid=13 stamp=848857355
channel ora_disk_1: datafile copy complete, elapsed time: 00:01:15
channel ora_disk_1: starting datafile copy
input datafile fno=00005 name=/u01/app/oracle/oradata/prod/example01.dbf
output filename=+dg1/prod/datafile/example.259.848857363 tag=tag20140529t173920 recid=14 stamp=848857404
channel ora_disk_1: datafile copy complete, elapsed time: 00:00:45
channel ora_disk_1: starting datafile copy
input datafile fno=00002 name=/u01/app/oracle/oradata/prod/undotbs01.dbf
output filename=+dg1/prod/datafile/undotbs1.260.848857407 tag=tag20140529t173920 recid=15 stamp=848857434
channel ora_disk_1: datafile copy complete, elapsed time: 00:00:35
channel ora_disk_1: starting datafile copy
input datafile fno=00004 name=/u01/app/oracle/oradata/prod/users01.dbf
output filename=+dg1/prod/datafile/users.261.848857443 tag=tag20140529t173920 recid=16 stamp=848857457
channel ora_disk_1: datafile copy complete, elapsed time: 00:00:25
finished backup at 29-may-14
starting control file and spfile autobackup at 29-may-14
piece handle=/backup/c-259825570-20140529-01 comment=none
finished control file and spfile autobackup at 29-may-14
rman> switch database to copy;
datafile 1 switched to datafile copy +dg1/prod/datafile/system.257.848857161
datafile 2 switched to datafile copy +dg1/prod/datafile/undotbs1.260.848857407
datafile 3 switched to datafile copy +dg1/prod/datafile/sysaux.258.848857287
datafile 4 switched to datafile copy +dg1/prod/datafile/users.261.848857443
datafile 5 switched to datafile copy +dg1/prod/datafile/example.259.848857363
5、恢复数据库
rman> recover database;
starting recover at 29-may-14
using channel ora_disk_1
starting media recovery
media recovery complete, elapsed time: 00:00:00
finished recover at 29-may-14
rman> alter database open;
database opened
6、迁移临时表空间
sql> select name from v$datafile;
name
--------------------------------------------------------------------------------
+dg1/prod/datafile/system.257.848857161
+dg1/prod/datafile/undotbs1.260.848857407
+dg1/prod/datafile/sysaux.258.848857287
+dg1/prod/datafile/users.261.848857443
+dg1/prod/datafile/example.259.848857363
sql> select name from v$tempfile;
name
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/prod/temp01.dbf
sql> alter tablespace temp add tempfile '+dg1';
tablespace altered.
sql> select name from v$tempfile;
name
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/prod/temp01.dbf
+dg1/prod/tempfile/temp.262.848858041
sql> alter tablespace temp drop tempfile '/u01/app/oracle/oradata/prod/temp01.dbf';
tablespace altered.
sql> select name from v$tempfile;
name
--------------------------------------------------------------------------------
+dg1/prod/tempfile/temp.262.848858041
7、迁移redo日志组
sql> set linesize 120
sql> select * from v$log
group# thread# sequence# bytes members arc status first_change# first_tim
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 114 52428800 2 yes inactive 989355 29-may-14
2 1 115 52428800 2 yes inactive 989368 29-may-14
3 1 113 52428800 2 yes inactive 988986 29-may-14
4 1 116 52428800 2 no current 989387 29-may-14
sql> col member for a50
sql> select group#,member from v$logfile;
group# member
---------- --------------------------------------------------
3 /dsk1/oradata/prod/redo03a.log
2 /dsk1/oradata/prod/redo02a.log
1 /dsk1/oradata/prod/redo01a.log
1 /dsk2/oradata/prod/redo01b.log
2 /dsk2/oradata/prod/redo02b.log
3 /dsk2/oradata/prod/redo03b.log
4 /dsk1/oradata/prod/redo04a.log
4 /dsk2/oradata/prod/redo04b.log
8 rows selected.
添加新的日志组到asm diskgroup:
sql> alter database add logfile
2 ('+dg1','+rcy1') size 10m;
sql> alter database add logfile
2 ('+dg1','+rcy1') size 10m;
sql> select * from v$log;
group# thread# sequence# bytes members arc status first_change# first_tim
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 114 52428800 2 yes inactive 989355 29-may-14
2 1 115 52428800 2 yes inactive 989368 29-may-14
3 1 113 52428800 2 yes inactive 988986 29-may-14
4 1 116 52428800 2 no current 989387 29-may-14
5 1 0 10485760 2 yes unused 0
6 1 0 10485760 2 yes unused 0
6 rows selected.
sql> select group#,member from v$logfile order by 1;
group# member
---------- --------------------------------------------------
1 /dsk1/oradata/prod/redo01a.log
1 /dsk2/oradata/prod/redo01b.log
2 /dsk1/oradata/prod/redo02a.log
2 /dsk2/oradata/prod/redo02b.log
3 /dsk1/oradata/prod/redo03a.log
3 /dsk2/oradata/prod/redo03b.log
4 /dsk1/oradata/prod/redo04a.log
4 /dsk2/oradata/prod/redo04b.log
5 +rcy1/prod/onlinelog/group_5.256.848858217
5 +dg1/prod/onlinelog/group_5.263.848858213
6 +rcy1/prod/onlinelog/group_6.257.848858259
group# member
---------- --------------------------------------------------
6 +dg1/prod/onlinelog/group_6.264.848858253
12 rows selected.
sql> select * from v$log;
group# thread# sequence# bytes members arc status first_change# first_tim
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
1 1 114 52428800 2 yes inactive 989355 29-may-14
2 1 115 52428800 2 yes inactive 989368 29-may-14
3 1 113 52428800 2 yes inactive 988986 29-may-14
4 1 116 52428800 2 yes active 989387 29-may-14
5 1 117 10485760 2 yes active 990481 29-may-14
6 1 118 10485760 2 no current 990483 29-may-14
6 rows selected.
删除旧的日志组:
sql> alter database drop logfile group 1;
database altered.
sql> alter database drop logfile group 2;
database altered.
sql> alter database drop logfile group 3;
database altered.
sql> alter system checkpoint;
system altered.
sql> select * from v$log;
group# thread# sequence# bytes members arc status first_change# first_tim
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
4 1 119 52428800 2 yes active 990548 29-may-14
5 1 120 10485760 2 no current 990566 29-may-14
6 1 118 10485760 2 yes inactive 990483 29-may-14
sql> alter system switch logfile;
system altered.
sql> select * from v$log;
group# thread# sequence# bytes members arc status first_change# first_tim
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
4 1 119 52428800 2 yes inactive 990548 29-may-14
5 1 120 10485760 2 no active 990566 29-may-14
6 1 121 10485760 2 no current 991692 29-may-14
sql> alter database drop logfile group 4;
database altered.
sql> select * from v$log;
group# thread# sequence# bytes members arc status first_change# first_tim
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------
5 1 122 10485760 2 no current 991711 29-may-14
6 1 121 10485760 2 yes inactive 991692 29-may-14
sql> select group#,member from v$logfile order by 1;
group# member
---------- --------------------------------------------------
5 +dg1/prod/onlinelog/group_5.263.848858213
5 +rcy1/prod/onlinelog/group_5.256.848858217
6 +dg1/prod/onlinelog/group_6.264.848858253
6 +rcy1/prod/onlinelog/group_6.257.848858259
调整recover area参数:
sql> show parameter recover
name type value
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string
db_recovery_file_dest_size big integer 0
recovery_parallelism integer 0
sql> alter system set db_recovery_file_dest='+rcy1' scope=spfile;
system altered.
sql> alter system set db_recovery_file_dest_size=2g scope=spfile;
system altered.
8、删除文件系统下的原数据文件
[oracle@aix211 ~]$cd /u01/app/oracle/oradata/prod/
[oracle@aix211 prod]$ls
control01.ctl example01.dbf sysaux01.dbf system01.dbf undotbs01.dbf users01.dbf
[oracle@aix211 prod]$rm *
[oracle@aix211 prod]$ls
[oracle@aix211 prod]$
对于spfile参数可以存储在文件系统或asm磁盘组上:
sql> show parameter pfile;
name type value
------------------------------------ ----------- ------------------------------
spfile string /u01/app/oracle/product/10.2.0
/db_1/dbs/spfileprod.ora
@至此,在aix下迁移文件系统到asm磁盘组工作完成,通过asm存储,数据库读写性能得到了一定的提升。
附注:
oracle官方文档提供的redo日志组迁移脚本:
example 8-1 migrating the online redo logs
set serveroutput on;
declare
cursor rlc is
select group# grp, thread# thr, bytes, 'no' srl
from v$log
union
select group# grp, thread# thr, bytes, 'yes' srl
from v$standby_log
order by 1;
stmt varchar2(2048);
begin
for rlcrec in rlc loop
if (rlcrec.srl = 'yes') then
stmt := 'alter database add standby logfile thread ' ||
rlcrec.thr || ' size ' || rlcrec.bytes;
execute immediate stmt;
stmt := 'alter database drop standby logfile group ' || rlcrec.grp;
execute immediate stmt;
else
stmt := 'alter database add logfile thread ' ||
rlcrec.thr || ' size ' || rlcrec.bytes;
execute immediate stmt;
begin
stmt := 'alter database drop logfile group ' || rlcrec.grp;
dbms_output.put_line(stmt);
execute immediate stmt;
exception
when others then
execute immediate 'alter system switch logfile';
execute immediate 'alter system checkpoint global';
execute immediate stmt;
end;
end if;
end loop;
end;
/