您好,登錄后才能下訂單哦!
小編給大家分享一下如何修改ASM磁盤冗余度,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
翻了一下官方文檔:
Automatic Storage Management Administrator's Guide -〉
4 Administering Oracle ASM Disk Groups -〉
Using the CREATE DISKGROUP SQL Statement -〉 Specify the redundancy level of the disk group.
After a disk group is created, you cannot alter the redundancy level of the disk group. To change the redundancy level, you must create another disk group with the appropriate redundancy and then move the files to the new disk group.
一個ASM磁盤組創建后,不能修改該磁盤組的冗余級別。如果想要修改磁盤組的冗余級別,你必須創建另一個適當冗余級別的磁盤組,然后把數據移動到新的磁盤組。
官方文檔鏈接:http://docs.oracle.com/cd/E11882_01/server.112/e18951/asmdiskgrps.htm#CHDBDAGI
###############################################################
于是有了下面的實驗:
由于之前的虛擬機環境為10gASM(下次用11g測下,步驟應當差不多),并且數據庫存放在+DATA磁盤上,+DATA磁盤設定的冗余度為常規冗余,故本實驗將由常規冗余改為外部冗余。
外部冗余改為常規冗余和該實驗步驟基本一致。
###############################################################
遷移步驟:
先創建一個新ASM磁盤組。
先將控制文件遷移至磁盤組,再遷移數據文件、日志文件等。
###############################################################
一、創建一個新的磁盤組
10g用dbca,11g用asmca,或者直接用指令也可以,這里我用dbca:
查看一下磁盤組:
點擊(此處)折疊或打開
[root@oracle4 ~]# su - oracle
[oracle@oracle4 ~]$ export ORACLE_SID=+ASM
[oracle@oracle4 ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Aug 19 01:17:26 2015
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select state,name,type from v$asm_diskgroup;
STATE NAME TYPE
----------- ------------------------------ ------
MOUNTED DATA NORMAL
MOUNTED RECOVER EXTERN
MOUNTED NEWDG EXTERN
----這里,我們創建了一個新的ASM磁盤組,名為NEWDG,外部冗余。
環境:舊控制文件放在+data磁盤組上,新的放在+newdg磁盤組上
遷移方法:先在+newdg上增加一個控制文件,再刪除+data磁盤上舊的控制文件
遷移步驟:如下:
----1.將參數文件中,控制文件的參數由+DATA磁盤上的一個路徑改為兩個路徑,
SQL> alter system set control_files='+DATA/asmdb/controlfile/current.260.886430449','+newdg' scope=spfile;
----2. 改為兩個路徑以后,由于第二個文件并不存在,會報錯。
----這時重啟數據庫至nomount模式,使用rman從第一個控制文件恢復第二個控制文件
SQL> startup force nomount;
ORACLE instance started.
Total System Global Area 608174080 bytes
Fixed Size 1220844 bytes
Variable Size 180358932 bytes
Database Buffers 423624704 bytes
Redo Buffers 2969600 bytes
[oracle@oracle4 dbs]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Wed Aug 19 01:47:18 2015
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: asmdb (not mounted)
RMAN> restore controlfile from '+DATA/asmdb/controlfile/current.260.886430449';
Starting restore at 19-AUG-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: copied control file copy
output filename=+DATA/asmdb/controlfile/current.260.886430449
output filename=+NEWDG/asmdb/controlfile/backup.257.888112073
Finished restore at 19-AUG-15
---紅色標注的是生成的新的控制文件
---這時啟動數據庫至nomount模式
---你會發現參數被修改了:
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
[oracle@oracle4 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Aug 19 01:48:48 2015
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> show parameter control
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string +DATA/asmdb/controlfile/curren
t.260.886430449, +NEWDG/asmdb/controlfile/backup.257.888112073
新控制文件參數變成了前面rman恢復的控制文件的位置,如下:
+DATA/asmdb/controlfile/current.260.886430449 ---這是舊的
+NEWDG/asmdb/controlfile/backup.257.888112073 ---這是新的,我們需要被遷移到的位置,我們發現控制文件已經被遷移到了新的位置,接下來需要刪除舊的控制文件
----3.刪除舊的控制文件,因此將其從控制文件參數中剔除:
SQL> alter system set control_files='+NEWDG/asmdb/controlfile/backup.257.888112073' scope=spfile;
System altered.
SQL> startup force ;
ORACLE instance started.
Total System Global Area 608174080 bytes
Fixed Size 1220844 bytes
Variable Size 180358932 bytes
Database Buffers 423624704 bytes
Redo Buffers 2969600 bytes
Database mounted.
Database opened.
SQL> show parameter control
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time integer 7
control_files string +NEWDG/asmdb/controlfile/backup.257.888112073
至此,控制文件被成功移動到+NEWDG磁盤上。
三、將數據文件遷移到新的磁盤組
環境:舊數據文件放在+data磁盤組上,新的放在+newdg磁盤組上
遷移方法:先在+newdg上做數據文件的鏡像拷貝,再做switch告訴控制文件我們的數據文件在+newdg上,而非+data磁盤上
遷移步驟:如下:
----1.拷貝數據文件
[oracle@oracle4 dbs]$ rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Wed Aug 19 01:51:13 2015
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ASMDB (DBID=630629232)
RMAN> backup as copy database format '+newdg';
Starting backup at 19-AUG-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=144 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00001 name=+DATA/asmdb/datafile/system.256.886430341
output filename=+NEWDG/asmdb/datafile/system.258.888112285 tag=TAG20150819T015122 recid=6 stamp=888112417
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:02:17
channel ORA_DISK_1: starting datafile copy
input datafile fno=00003 name=+DATA/asmdb/datafile/sysaux.257.886430341
output filename=+NEWDG/asmdb/datafile/sysaux.259.888112421 tag=TAG20150819T015122 recid=7 stamp=888112494
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:16
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=+DATA/asmdb/datafile/example.265.886430497
output filename=+NEWDG/asmdb/datafile/example.260.888112497 tag=TAG20150819T015122 recid=8 stamp=888112539
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:47
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=+DATA/asmdb/datafile/undotbs1.258.886430341
output filename=+NEWDG/asmdb/datafile/undotbs1.261.888112547 tag=TAG20150819T015122 recid=9 stamp=888112564
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:26
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=+DATA/asmdb/datafile/users.259.886430341
output filename=+NEWDG/asmdb/datafile/users.262.888112571 tag=TAG20150819T015122 recid=10 stamp=888112572
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile fno=00006 name=+DATA/asmdb/datafile/tbs1.267.886604335
output filename=+NEWDG/asmdb/datafile/tbs1.263.888112573 tag=TAG20150819T015122 recid=11 stamp=888112580
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
copying current control file
output filename=+NEWDG/asmdb/controlfile/backup.264.888112589 tag=TAG20150819T015122 recid=12 stamp=888112601
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 19-AUG-15
channel ORA_DISK_1: finished piece 1 at 19-AUG-15
piece handle=+NEWDG/asmdb/backupset/2015_08_19/nnsnf0_tag20150819t015122_0.265.888112607 tag=TAG20150819T015122 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 19-AUG-15
RMAN> list copy of database;
Key File S Completion Time Ckp SCN Ckp Time Name
------- ---- - --------------- ---------- --------------- ----
6 1 A 19-AUG-15 559320 19-AUG-15 +NEWDG/asmdb/datafile/system.258.888112285
9 2 A 19-AUG-15 559375 19-AUG-15 +NEWDG/asmdb/datafile/undotbs1.261.888112547
7 3 A 19-AUG-15 559349 19-AUG-15 +NEWDG/asmdb/datafile/sysaux.259.888112421
10 4 A 19-AUG-15 559383 19-AUG-15 +NEWDG/asmdb/datafile/users.262.888112571
8 5 A 19-AUG-15 559366 19-AUG-15 +NEWDG/asmdb/datafile/example.260.888112497
11 6 A 19-AUG-15 559385 19-AUG-15 +NEWDG/asmdb/datafile/tbs1.263.888112573
3 6 A 01-AUG-15 514730 01-AUG-15 /home/oracle/tbs1.bak
----拷貝完成
----2.數據文件拷貝已經完成,我們是在數據庫開著的情況下拷貝的,現在需要將數據庫切換到新的文件,切換文件實際是告訴控制文件,數據文件被移到了新的位置。因此這個步驟只是改變控制文件的內容,會很快,但是需要將數據庫置為mount狀態
RMAN> switch database to copy;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of switch to copy command at 08/19/2015 02:00:35
RMAN-06572: database is open and datafile 1 is not offline
----注意,需要啟動數據庫到mount狀態執行switch
RMAN> shutdown immediate;
database closed
database dismounted
Oracle instance shut down
RMAN> startup mount
connected to target database (not started)
Oracle instance started
database mounted
Total System Global Area 608174080 bytes
Fixed Size 1220844 bytes
Variable Size 180358932 bytes
Database Buffers 423624704 bytes
Redo Buffers 2969600 bytes
RMAN> switch database to copy;
datafile 1 switched to datafile copy "+NEWDG/asmdb/datafile/system.258.888112285"
datafile 2 switched to datafile copy "+NEWDG/asmdb/datafile/undotbs1.261.888112547"
datafile 3 switched to datafile copy "+NEWDG/asmdb/datafile/sysaux.259.888112421"
datafile 4 switched to datafile copy "+NEWDG/asmdb/datafile/users.262.888112571"
datafile 5 switched to datafile copy "+NEWDG/asmdb/datafile/example.260.888112497"
datafile 6 switched to datafile copy "+NEWDG/asmdb/datafile/tbs1.263.888112573"
----switch成功,數據庫使用新的數據文件
RMAN> alter database open;
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 08/19/2015 02:01:54
ORA-01113: file 1 needs media recovery
ORA-01110: data file 1: '+NEWDG/asmdb/datafile/system.258.888112285'
RMAN> recover database;
Starting recover at 19-AUG-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=157 devtype=DISK
starting media recovery
media recovery complete, elapsed time: 00:00:02
Finished recover at 19-AUG-15
RMAN> alter database open;
database opened
成功恢復并打開數據庫。
四、將日志文件、臨時文件、參數文件等遷移到新的磁盤組
控制文件和數據文件已經成功移動,日志文件、臨時文件、參數文件需要移動
遷移步驟:如下:
1. 查看數據文件是否正常,并且修改參數使以后新的文件放在+newdg上
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+NEWDG/asmdb/datafile/system.258.888112285
+NEWDG/asmdb/datafile/undotbs1.261.888112547
+NEWDG/asmdb/datafile/sysaux.259.888112421
+NEWDG/asmdb/datafile/users.262.888112571
+NEWDG/asmdb/datafile/example.260.888112497
+NEWDG/asmdb/datafile/tbs1.263.888112573
6 rows selected.
----查看數據文件是否正常
SQL> show parameter create
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
create_bitmap_area_size integer 8388608
create_stored_outlines string
db_create_file_dest string +DATA
db_create_online_log_dest_1 string
db_create_online_log_dest_2 string
db_create_online_log_dest_3 string
db_create_online_log_dest_4 string
db_create_online_log_dest_5 string
SQL> alter system set db_create_file_dest ='+newdg';
----以后新的文件都生成在新的磁盤組
System altered.
----添加臨時文件
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
+DATA/asmdb/tempfile/temp.264.886430485
SQL> create temporary tablespace temp01 tempfile size 20M;
Tablespace created.
SQL> SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
+DATA/asmdb/tempfile/temp.264.886430485
+NEWDG/asmdb/tempfile/temp01.266.888113011
SQL> drop tablespace temp including contents and datafiles;
drop tablespace temp including contents and datafiles
*
ERROR at line 1:
ORA-12906: cannot drop default temporary tablespace
SQL> alter database default temporary tablespace temp01;
----舊的臨時表空間是系統默認臨時表空間,無法刪除,修改后刪除舊的
Database altered.
SQL> drop tablespace temp including contents and datafiles;
Tablespace dropped.
3. 日志文件:在新磁盤添加新成員,刪除舊成員
----查看日志組狀況
SQL> select * from v$log;
GROUP# THREAD# SEQUENCE# BYTES MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIM
------------- ---------
1 1 5 52428800 1 NO CURRENT
559083 19-AUG-15
2 1 3 52428800 1 YES INACTIVE
507040 01-AUG-15
3 1 4 52428800 1 YES INACTIVE
537744 19-AUG-15
----有三個組,給每個組添加新成員
SQL> alter database add logfile member '+newdg' to group 1;
Database altered.
SQL> alter database add logfile member '+newdg' to group 2;
Database altered.
SQL> alter database add logfile member '+newdg' to group 3;
Database altered.
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> /
System altered.
SQL> /
System altered.
----多次切換日志,至少一輪
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
+DATA/asmdb/onlinelog/group_3.263.886430465
+DATA/asmdb/onlinelog/group_2.262.886430459
+DATA/asmdb/onlinelog/group_1.261.886430455
+NEWDG/asmdb/onlinelog/group_1.267.888113109
+NEWDG/asmdb/onlinelog/group_2.268.888113113
+NEWDG/asmdb/onlinelog/group_3.269.888113115
6 rows selected.
----新成員添加成功
SQL> alter database drop logfile member'+DATA/asmdb/onlinelog/group_3.263.886430465';
Database altered.
SQL> alter database drop logfile member'+DATA/asmdb/onlinelog/group_2.262.886430459';
alter database drop logfile member'+DATA/asmdb/onlinelog/group_2.262.886430459'
*
ERROR at line 1:
ORA-01609: log 2 is the current log for thread 1 - cannot drop members
ORA-00312: online log 2 thread 1: '+DATA/asmdb/onlinelog/group_2.262.886430459'
ORA-00312: online log 2 thread 1:
'+NEWDG/asmdb/onlinelog/group_2.268.888113113'
----正在使用的不能刪除,先刪除非current,切換日志后再刪除該成員
SQL> alter database drop logfile member'+DATA/asmdb/onlinelog/group_1.261.886430455';
Database altered.
SQL> alter system switch logfile;
System altered.
SQL> alter database drop logfile member'+DATA/asmdb/onlinelog/group_2.262.886430459';
Database altered.
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
+NEWDG/asmdb/onlinelog/group_1.267.888113109
+NEWDG/asmdb/onlinelog/group_2.268.888113113
+NEWDG/asmdb/onlinelog/group_3.269.888113115
----新成員添加成功,舊成員刪除成功
4. 參數文件:
利用spfile生成pfile,pfile生成新的spfile,最后將pfile指向新的spfile
----查看參數文件
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string +DATA/asmdb/spfileasmdb.ora
SQL> create pfile from spfile;
創建pfile
File created.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> create spfile='+newdg/asmdb/spfileasmdb.ora' from pfile;
----利用pfile生成新的spfile
File created.
SQL> !
[oracle@oracle4 dbs]$ vi initasmdb.ora
spfile='+newdg/asmdb/spfileasmdb.ora'
----pfile指向新的spfile
SQL> startup force
ORACLE instance started.
Total System Global Area 608174080 bytes
Fixed Size 1220844 bytes
Variable Size 180358932 bytes
Database Buffers 423624704 bytes
Redo Buffers 2969600 bytes
Database mounted.
Database opened.
SQL>
----新參數文件添加成功,舊參數文件刪除成功
五、檢查
----檢查
show parameter spfile;
select name from v$controlfile;
select name from v$datafile;
select name from v$tempfile;
select member from v$logfile;
select filename from v$block_change_tracking;
select name from v$flashback_database_logfile;
SQL> show parameter pfile
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
spfile string +NEWDG/asmdb/spfileasmdb.ora
SQL> select name from v$controlfile;
NAME
--------------------------------------------------------------------------------
+NEWDG/asmdb/controlfile/backup.257.888112073
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+NEWDG/asmdb/datafile/system.258.888112285
+NEWDG/asmdb/datafile/undotbs1.261.888112547
+NEWDG/asmdb/datafile/sysaux.259.888112421
+NEWDG/asmdb/datafile/users.262.888112571
+NEWDG/asmdb/datafile/example.260.888112497
+NEWDG/asmdb/datafile/tbs1.263.888112573
6 rows selected.
SQL> select name from v$tempfile;
NAME
--------------------------------------------------------------------------------
+NEWDG/asmdb/tempfile/temp01.266.888113011
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
+NEWDG/asmdb/onlinelog/group_1.267.888113109
+NEWDG/asmdb/onlinelog/group_2.268.888113113
+NEWDG/asmdb/onlinelog/group_3.269.888113115
SQL> select name from v$flashback_database_logfile;
no rows selected
SQL> select filename from v$block_change_tracking;
以上是“如何修改ASM磁盤冗余度”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。