分享更有价值
被信任是一种快乐

如何修改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/assysdba

SQL*Plus:Release10.2.0.1.0-ProductiononWed Aug 19 01:17:26 2015

Copyright(c)1982,2005,Oracle.Allrights reserved.

Connectedto:
OracleDatabase10g Enterprise EditionRelease10.2.0.1.0-Production
Withthe Partitioning,OLAPandDataMining options

SQL>selectstate,name,typefromv$asm_diskgroup;

STATE NAMETYPE
———– —————————— ——
MOUNTEDDATANORMAL
MOUNTEDRECOVEREXTERN
MOUNTED NEWDG EXTERN

—-这里,我们创建了一个新的ASM磁盘组,名为NEWDG,外部冗余。
环境:旧控制文件放在+data磁盘组上,新的放在+newdg磁盘组上
迁移方法:先在+newdg上增加一个控制文件,再删除+data磁盘上旧的控制文件
迁移步骤:如下:

—-1.将参数文件中,控制文件的参数由+DATA磁盘上的一个路径改为两个路径,
SQL>altersystemsetcontrol_files=’+DATA/asmdb/controlfile/current.260.886430449′,’+newdg’scope=spfile;

—-2. 改为两个路径以后,由于第二个文件并不存在,会报错。
—-这时重启数据库至nomount模式,使用rman从第一个控制文件恢复第二个控制文件

SQL>startupforcenomount;
ORACLE instance started.
Total System Global Area 608174080 bytes
FixedSize1220844 bytes
VariableSize180358932 bytes
DatabaseBuffers 423624704 bytes
Redo Buffers 2969600 bytes

[oracle@oracle4 dbs]$rman target/
Recovery Manager:Release10.2.0.1.0-ProductiononWed Aug 19 01:47:18 2015
Copyright(c)1982,2005,Oracle.Allrights reserved.
connectedtotargetdatabase:asmdb(notmounted)

RMAN>restore controlfilefrom’+DATA/asmdb/controlfile/current.260.886430449′;

Starting restore at 19-AUG-15
usingtargetdatabasecontrolfileinsteadofrecovery catalog
allocated channel:ORA_DISK_1
channel ORA_DISK_1:sid=156 devtype=DISK

channel ORA_DISK_1:copied controlfilecopy
output filename=+DATA/asmdb/controlfile/current.260.886430449
output filename=+NEWDG/asmdb/controlfile/backup.257.888112073
Finished restore at 19-AUG-15

—红色标注的是生成的新的控制文件
—这时启动数据库至nomount模式
—你会发现参数被修改了:

RMAN>alterdatabasemount;
databasemounted
released channel:ORA_DISK_1

[oracle@oracle4 dbs]$sqlplus/assysdba
SQL*Plus:Release10.2.0.1.0-ProductiononWed Aug 19 01:48:48 2015
Copyright(c)1982,2005,Oracle.Allrights reserved.
Connectedto:
OracleDatabase10g Enterprise EditionRelease10.2.0.1.0-Production
Withthe Partitioning,OLAPandDataMining options

SQL>showparameter control
NAMETYPEVALUE
———————————— ———– ——————————
control_file_record_keep_timeinteger7
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>altersystemsetcontrol_files=’+NEWDG/asmdb/controlfile/backup.257.888112073’scope=spfile;

System altered.

SQL>startupforce;
ORACLE instance started.

Total System Global Area 608174080 bytes
FixedSize1220844 bytes
VariableSize180358932 bytes
DatabaseBuffers 423624704 bytes
Redo Buffers 2969600 bytes
Databasemounted.

Databaseopened.
SQL>showparameter control

NAMETYPEVALUE
———————————— ———– ——————————
control_file_record_keep_timeinteger7
control_files string+NEWDG/asmdb/controlfile/backup.257.888112073 至此,控制文件被成功移动到+NEWDG磁盘上。

三、将数据文件迁移到新的磁盘组
环境:旧数据文件放在+data磁盘组上,新的放在+newdg磁盘组上
迁移方法:先在+newdg上做数据文件的镜像拷贝,再做switch告诉控制文件我们的数据文件在+newdg上,而非+data磁盘上
迁移步骤:如下:

—-1.拷贝数据文件
[oracle@oracle4 dbs]$rman target/
Recovery Manager:Release10.2.0.1.0-ProductiononWed Aug 19 01:51:13 2015
Copyright(c)1982,2005,Oracle.Allrights reserved.
connectedtotargetdatabase:ASMDB(DBID=630629232)

RMAN>backupascopydatabaseformat’+newdg’;

Starting backup at 19-AUG-15
usingtargetdatabasecontrolfileinsteadofrecovery catalog
allocated channel:ORA_DISK_1
channel ORA_DISK_1:sid=144 devtype=DISK
channel ORA_DISK_1:starting datafilecopy
inputdatafile 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:datafilecopycomplete,elapsed time:00:02:17
channel ORA_DISK_1:starting datafilecopy
inputdatafile 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:datafilecopycomplete,elapsed time:00:01:16
channel ORA_DISK_1:starting datafilecopy
inputdatafile 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:datafilecopycomplete,elapsed time:00:00:47
channel ORA_DISK_1:starting datafilecopy
inputdatafile 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:datafilecopycomplete,elapsed time:00:00:26
channel ORA_DISK_1:starting datafilecopy
inputdatafile 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:datafilecopycomplete,elapsed time:00:00:03
channel ORA_DISK_1:starting datafilecopy
inputdatafile 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:datafilecopycomplete,elapsed time:00:00:15
channel ORA_DISK_1:starting datafilecopy
copyingcurrentcontrolfile
output filename=+NEWDG/asmdb/controlfile/backup.264.888112589 tag=TAG20150819T015122 recid=12 stamp=888112601
channel ORA_DISK_1:datafilecopycomplete,elapsed time:00:00:15
channel ORA_DISK_1:starting full datafile backupset
channel ORA_DISK_1:specifying datafile(s)inbackupset
includingcurrentSPFILEinbackupset
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=TAG20150819T015122comment=NONE
channel ORA_DISK_1:backupsetcomplete,elapsed time:00:00:02
Finished backup at 19-AUG-15

RMAN>listcopyofdatabase;

KeyFileS 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>switchdatabasetocopy;

RMAN-00571:===========================================================
RMAN-00569:===============ERROR MESSAGE STACK FOLLOWS===============
RMAN-00571:===========================================================
RMAN-03002:failureofswitchtocopycommand at 08/19/2015 02:00:35
RMAN-06572:databaseisopenanddatafile 1isnotoffline
—-注意,需要启动数据库到mount状态执行switch

RMAN>shutdownimmediate;

databaseclosed
databasedismounted
Oracle instance shut down

RMAN>startupmount

connectedtotargetdatabase(notstarted)
Oracle instance started
databasemounted

Total System Global Area 608174080 bytes

FixedSize1220844 bytes
VariableSize180358932 bytes
DatabaseBuffers 423624704 bytes
Redo Buffers 2969600 bytes
RMAN>switchdatabasetocopy;

datafile 1 switchedtodatafilecopy”+NEWDG/asmdb/datafile/system.258.888112285″
datafile 2 switchedtodatafilecopy”+NEWDG/asmdb/datafile/undotbs1.261.888112547″
datafile 3 switchedtodatafilecopy”+NEWDG/asmdb/datafile/sysaux.259.888112421″
datafile 4 switchedtodatafilecopy”+NEWDG/asmdb/datafile/users.262.888112571″
datafile 5 switchedtodatafilecopy”+NEWDG/asmdb/datafile/example.260.888112497″
datafile 6 switchedtodatafilecopy”+NEWDG/asmdb/datafile/tbs1.263.888112573″

—-switch成功,数据库使用新的数据文件
RMAN>alterdatabaseopen;

RMAN-00571:===========================================================
RMAN-00569:===============ERROR MESSAGE STACK FOLLOWS===============
RMAN-00571:===========================================================
RMAN-03002:failureofalterdb command at 08/19/2015 02:01:54
ORA-01113:file1 needs media recovery
ORA-01110:datafile1:’+NEWDG/asmdb/datafile/system.258.888112285′

RMAN>recoverdatabase;

Startingrecoverat 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

Finishedrecoverat 19-AUG-15

RMAN>alterdatabaseopen;

databaseopened 成功恢复并打开数据库。

四、将日志文件、临时文件、参数文件等迁移到新的磁盘组
控制文件和数据文件已经成功移动,日志文件、临时文件、参数文件需要移动
迁移步骤:如下:
1. 查看数据文件是否正常,并且修改参数使以后新的文件放在+newdg上

SQL>selectnamefromv$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

6rowsselected.
—-查看数据文件是否正常

SQL>showparametercreate

NAMETYPEVALUE
———————————— ———– ——————————
create_bitmap_area_sizeinteger8388608
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>altersystemsetdb_create_file_dest=’+newdg’;
—-以后新的文件都生成在新的磁盘组
System altered.

—-添加临时文件

SQL>selectnamefromv$tempfile;
NAME
——————————————————————————–
+DATA/asmdb/tempfile/temp.264.886430485

SQL>createtemporarytablespacetemp01 tempfilesize20M;
Tablespacecreated.
SQL>SQL>selectnamefromv$tempfile;

NAME
——————————————————————————–
+DATA/asmdb/tempfile/temp.264.886430485
+NEWDG/asmdb/tempfile/temp01.266.888113011

SQL>droptablespacetempincludingcontentsanddatafiles;
droptablespacetempincludingcontentsanddatafiles
*
ERROR at line 1:
ORA-12906:can免费主机域名notdropdefaulttemporarytablespace

SQL>alterdatabasedefaulttemporarytablespacetemp01;
—-旧的临时表空间是系统默认临时表空间,无法删除,修改后删除旧的
Databasealtered.

SQL>droptablespacetempincludingcontentsanddatafiles;
Tablespacedropped.

3. 日志文件:在新磁盘添加新成员,删除旧成员

—-查看日志组状况
SQL>select*fromv$log;
GROUP#THREAD#SEQUENCE#BYTES MEMBERS ARC STATUS
———- ———- ———- ———- ———- — —————-
FIRST_CHANGE# FIRST_TIM
————- ———
1 1 5 52428800 1 NOCURRENT
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>alterdatabaseaddlogfilemember’+newdg’togroup1;
Databasealtered.
SQL>alterdatabaseaddlogfilemember’+newdg’togroup2;
Databasealtered.
SQL>alterdatabaseaddlogfilemember’+newdg’togroup3;
Databasealtered.

SQL>altersystem switch logfile;
System altered.
SQL>/
System altered.
SQL>/
System altered.
SQL>/
System altered.
—-多次切换日志,至少一轮

SQL>selectmemberfromv$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
6rowsselected.

—-新成员添加成功
SQL>alterdatabasedroplogfilemember’+DATA/asmdb/onlinelog/group_3.263.886430465′;
Databasealtered.

SQL>alterdatabasedroplogfilemember’+DATA/asmdb/onlinelog/group_2.262.886430459′;
alterdatabasedroplogfilemember’+DATA/asmdb/onlinelog/group_2.262.886430459′
*
ERROR at line 1:
ORA-01609:log2isthecurrentlogforthread 1-cannotdropmembers
ORA-00312:onlinelog2 thread 1:’+DATA/asmdb/onlinelog/group_2.262.886430459′
ORA-00312:onlinelog2 thread 1:
‘+NEWDG/asmdb/onlinelog/group_2.268.888113113’
—-正在使用的不能删除,先删除非current,切换日志后再删除该成员

SQL>alterdatabasedroplogfilemember’+DATA/asmdb/onlinelog/group_1.261.886430455′;
Databasealtered.

SQL>altersystem switch logfile;
System altered.

SQL>alterdatabasedroplogfilemember’+DATA/asmdb/onlinelog/group_2.262.886430459′;
Databasealtered.

SQL>selectmemberfromv$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>showparameter spfile
NAMETYPEVALUE
———————————— ———– ——————————
spfile string+DATA/asmdb/spfileasmdb.ora

SQL>createpfilefromspfile;
创建pfile
Filecreated.

SQL>shutdownimmediate;
Databaseclosed.
Databasedismounted.
ORACLE instance shut down.
SQL>createspfile=’+newdg/asmdb/spfileasmdb.ora’frompfile;
—-利用pfile生成新的spfile
Filecreated.

SQL>!
[oracle@oracle4 dbs]$vi initasmdb.ora

spfile=’+newdg/asmdb/spfileasmdb.ora’
—-pfile指向新的spfile

SQL>startupforce
ORACLE instance started.

Total System Global Area 608174080 bytes
FixedSize1220844 bytes
VariableSize180358932 bytes
DatabaseBuffers 423624704 bytes
Redo Buffers 2969600 bytes
Databasemounted.
Databaseopened.
SQL>
—-新参数文件添加成功,旧参数文件删除成功

五、检查

—-检查
showparameter spfile;
selectnamefromv$controlfile;
selectnamefromv$datafile;
selectnamefromv$tempfile;
selectmemberfromv$logfile;
selectfilenamefromv$block_change_tracking;
selectnamefromv$flashback_database_logfile;

SQL>showparameter pfile
NAMETYPEVALUE
———————————— ———– ——————————
spfile string+NEWDG/asmdb/spfileasmdb.ora

SQL>selectnamefromv$controlfile;
NAME
——————————————————————————–
+NEWDG/asmdb/controlfile/backup.257.888112073

SQL>selectnamefromv$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

6rowsselected.

SQL>selectnamefromv$tempfile;
NAME
——————————————————————————–
+NEWDG/asmdb/tempfile/temp01.266.888113011

SQL>selectmemberfromv$logfile;
MEMBER
——————————————————————————–
+NEWDG/asmdb/onlinelog/group_1.267.888113109
+NEWDG/asmdb/onlinelog/group_2.268.888113113
+NEWDG/asmdb/onlinelog/group_3.269.888113115

SQL>selectnamefromv$flashback_database_logfile;
norowsselected

SQL>selectfilenamefromv$block_change_tracking; 以上是“如何修改ASM磁盘冗余度”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注云技术行业资讯频道!

相关推荐: 怎么使用快照和AOF将Redis数据持久化到硬盘中

这篇文章主要介绍“怎么使用快照和AOF将Redis数据持久化到硬盘中”,在日常操作中,相信很多人在怎么使用快照和AOF将Redis数据持久化到硬盘中问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”怎么使用快照和AOF将Redis数…

文章页内容下
赞(0) 打赏
版权声明:本站采用知识共享、学习交流,不允许用于商业用途;文章由发布者自行承担一切责任,与本站无关。
文章页正文下
文章页评论上

云服务器、web空间可免费试用

宝塔面板主机、支持php,mysql等,SSL部署;安全高速企业专供99.999%稳定,另有高防主机、不限制内容等类型,具体可咨询QQ:360163164,Tel同微信:18905205712

主机选购导航云服务器试用

登录

找回密码

注册