您好,登錄后才能下訂單哦!
AIX環(huán)境文件系統(tǒng)遷移到ASM存儲(chǔ)
系統(tǒng)環(huán)境:
操作系統(tǒng):AIX5.3-08
Oracle: Oracle 10gR2
一、構(gòu)建ASM 存儲(chǔ)環(huán)境
http://tiany.blog.51cto.com/513694/1418564
Oracle DataBase單實(shí)例使用ASM案例(4)--AIX系統(tǒng)Oracle 10g應(yīng)用
二、遷移文件系統(tǒng)到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、修改實(shí)例參數(shù)
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、轉(zhuǎn)儲(chǔ)控制文件到控制文件
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、轉(zhuǎn)儲(chǔ)數(shù)據(jù)文件到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、恢復(fù)數(shù)據(jù)庫(kù)
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、遷移臨時(shí)表空間
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
調(diào)整recover area參數(shù):
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、刪除文件系統(tǒng)下的原數(shù)據(jù)文件
[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]$
對(duì)于spfile參數(shù)可以存儲(chǔ)在文件系統(tǒng)或ASM磁盤組上:
SQL> show parameter pfile;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string /u01/app/oracle/product/10.2.0
/db_1/dbs/spfileprod.ora
@至此,在AIX下遷移文件系統(tǒng)到ASM磁盤組工作完成,通過ASM存儲(chǔ),數(shù)據(jù)庫(kù)讀寫性能得到了一定的提升。
附注:
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;
/
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。