如何修改ASM磁盘冗余度-创新互联
小编给大家分享一下如何修改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磁盘冗余度”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注创新互联-成都网站建设公司行业资讯频道!
分享题目:如何修改ASM磁盘冗余度-创新互联
网页网址:http://ybzwz.com/article/ppcid.html