文件系统怎样迁移到ASM

文件系统怎样迁移到ASM,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。

网站建设哪家好,找创新互联公司!专注于网页设计、网站建设、微信开发、重庆小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了湛江免费建站欢迎大家使用!

数据库全备 仅仅是一个databse的全备,没有任何额外的附加功能,仅
0 级 增量备份 既是数据库的全备,又是,0级增量备份,在此基础上,可以后续执行增量备份
结论 因此推荐使用0级增量备份做数据库的全备

最好是以grid用户进入asm 环境

  1. [oracle@sink~]$ su- grid

  2. Password:

  3. [grid@sink~]$ asmcmd

做完 0 级 增量备份后的备份文件

  1. ASMCMD> pwd

  2. +data/sink

  3. ASMCMD> ls

  4. BACKUPSET/

  5. CONTROLFILE/

  6. DATAFILE/

  7. PARAMETERFILE/

查看刚才做的 0级增量 备份

  1. RMAN>listcopyofdatabase;

  2. Listof Datafile Copies

  3. =======================

  4. KeyFile S Completion Time Ckp SCN    Ckp Time

  5. ------- ---- - --------------- ---------- ---------------

  6. 9       1    A 06-JAN-18       1218041    06-JAN-18

  7.         Name:+DATA/sink/datafile/system.258.964712643

  8.         Tag: ORA_ASM_MIGRATION

  9. 8       2    A 06-JAN-18       1218040    06-JAN-18

  10.         Name:+DATA/sink/datafile/sysaux.257.964712643

  11.         Tag: ORA_ASM_MIGRATION

  12. 4       3    A 06-JAN-18       1218045    06-JAN-18

  13.         Name:+DATA/sink/datafile/undotbs1.261.964712645

  14.         Tag: ORA_ASM_MIGRATION

  15. 6       4    A 06-JAN-18       1218050    06-JAN-18

  16.         Name:+DATA/sink/datafile/users.263.964712657

  17.         Tag: ORA_ASM_MIGRATION

  18. 7       5    A 06-JAN-18       1218043    06-JAN-18

  19.         Name:+DATA/sink/datafile/example.260.964712643

  20.         Tag: ORA_ASM_MIGRATION

  21. 3       6    A 06-JAN-18       1218042    06-JAN-18

  22.         Name:+DATA/sink/datafile/tbssss.259.964712643

  23.         Tag: ORA_ASM_MIGRATION

  24. RMAN>

转储spfile到

  1. RMAN> restore spfile to'+DATA/spfilesink.ora';

  2. Starting restore at 06-JAN-18

  3. using target database control file instead of recovery catalog

  4. allocated channel: ORA_DISK_1

  5. channel ORA_DISK_1: SID=18 device type=DISK

  6. channel ORA_DISK_1: starting datafile backup set restore

  7. channel ORA_DISK_1: restoring SPFILE

  8. output file name=+DATA/spfilesink.ora

  9. channel ORA_DISK_1: reading from backup piece +DATA/sink/backupset/2018_01_06/nnsnn0_ora_asm_migration_0.264.964712657

  10. channel ORA_DISK_1: piece handle=+DATA/sink/backupset/2018_01_06/nnsnn0_ora_asm_migration_0.264.964712657 tag=ORA_ASM_MIGRATION

  11. channel ORA_DISK_1: restored backup piece 1

  12. channel ORA_DISK_1: restore complete, elapsed time: 00:00:04

  13. Finished restore at 06-JAN-18

查看转储spfile参数文件后的  在ASM中的 路径状态

  1. ASMCMD> pwd

  2. +data

  3. ASMCMD> ls

  4. ASM/

  5. SINK/

  6. spfilesink.ora

  7. ASMCMD>

修改并查看pfile中的内容,使其内容指向ASM中spfile的spfilesink.ora的路径,有意思!

  1. [oracle@sink dbs]$ pwd

  2. /u01/app/oracle/product/11.2.0/dbhome_1/dbs

  3. [oracle@sink dbs]$ ls

  4. afiedt.buf   hc_test.dat  initsink.ora  lkSINK  orapwsink  snapcf_sink.f

  5. hc_sink.dat  init.ora     inittest.ora  lkTEST  orapwtest  spfilesink.ora

  6. [oracle@sink dbs]$ vim initsink.ora

  7. [oracle@sink dbs]$ cat initsink.ora

  8. spfile='+DATA/spfilesink.ora'

  9. [oracle@sink dbs]$

再次进入SQL环境,启动到nomount,设置spfile路径指向,并查看相关参数是否操作生效!成功了!

  1. [oracle@sink dbs]$!sql

  2. sqlplus/as sysdba

  3. SQL*Plus:Release 11.2.0.4.0 Productionon Sat Jan 6 16:30:19 2018

  4. Copyright(c) 1982, 2013, Oracle.All rights reserved.

  5. Connectedto:

  6. OracleDatabase 11g Enterprise EditionRelease 11.2.0.4.0- 64bit Production

  7. With the Partitioning,Automatic Storage Management, OLAP,Data Mining

  8. andReal Application Testing options

  9. 16:30:19 SYS@ sink>startupforce nomount;

  10. ORACLE instance started.

  11. Total System Global Area  835104768 bytes

  12. FixedSize            2257840 bytes

  13. VariableSize          553651280 bytes

  14. Database Buffers      276824064 bytes

  15. Redo Buffers            2371584 bytes

  16. 16:30:38 SYS@ sink>alter systemset db_create_file_dest='+DATA';

  17. System altered.

  18. Elapsed: 00:00:00.01

  19. 16:31:23 SYS@ sink>show parametercreate;

  20. NAME                TYPE    VALUE

  21. ------------------------------------ ----------- ------------------------------

  22. create_bitmap_area_size     integer     8388608

  23. create_stored_outlines             string

  24. db_create_file_dest             string    +DATA

  25. db_create_online_log_dest_1         string

  26. db_create_online_log_dest_2         string

  27. db_create_online_log_dest_3         string

  28. db_create_online_log_dest_4         string

  29. db_create_online_log_dest_5         string

  30. 16:31:33 SYS@ sink>

自上一步之后,查看数据库启动状态,然后satrtup force,将他启动到opened状态

  1. 16:31:33 SYS@ sink>select statusfrom v$instance;

  2. STATUS

  3. ------------

  4. STARTED

  5. 1row selected.

  6. Elapsed: 00:00:00.00

  7. 16:35:24 SYS@ sink>alterdatabase open;

  8. alterdatabase open

  9. *

  10. ERROR at line 1:

  11. ORA-01507:databasenot mounted

  12. Elapsed: 00:00:00.00

  13. 16:35:39 SYS@ sink>startupforce;

  14. ORACLE instance started.

  15. Total System Global Area  835104768 bytes

  16. FixedSize            2257840 bytes

  17. VariableSize          553651280 bytes

  18. Database Buffers      276824064 bytes

  19. Redo Buffers            2371584 bytes

  20. Database mounted.

  21. Database opened.

  22. 16:36:24 SYS@ sink>

oracle启动到某一状态的时候 之后启动的情况
satrtup nomount
alter database mount alter database open
startup mount alter database open --------------------------
startup (open) ---------------------------- --------------------------
oracle启动到某一状态之后,只能一步一步的启动,直至open状态,不能越级实行后续启动

这里查询一下数据文件的file#和name,方便之后的数据文件迁移

  1. SYS@ sink>r

  2.   1*selectfile#,namefrom v$datafile

  3.      FILE# NAME

  4. ---------- -------------------------------------------------------

  5.      1/u01/app/oracle/oradata/sink/system01.dbf

  6.      2/u01/app/oracle/oradata/sink/sysaux01.dbf

  7.      3/u01/app/oracle/oradata/sink/undotbs01.dbf

  8.      4/u01/app/oracle/oradata/sink/users01.dbf

  9.      5/u01/app/oracle/oradata/sink/example01.dbf

  10.      6+DATA/sink/datafile/tbssss.256.963504823

  11. 6rows selected.

  12. Elapsed: 00:00:00.01

转储控制文件失败,看错误信息提示:意思是在数据库是mount或者open执行这条语句没有使用TO语句,

  1. RMAN> restore controlfilefrom'/u01/app/oracle/oradata/sink/control01.ctl';

  2. Starting restore at 06-JAN-18

  3. using targetdatabase controlfileinsteadof recovery catalog

  4. allocated channel: ORA_DISK_1

  5. channel ORA_DISK_1: SID=42 devicetype=DISK

  6. RMAN-00571:===========================================================

  7. RMAN-00569:=============== ERROR MESSAGE STACK FOLLOWS===============

  8. RMAN-00571:===========================================================

  9. RMAN-03002: failureof restore command at 01/06/2018 16:45:57

  10. RMAN-06496: must use theTO clause when thedatabaseis mountedor open

这次加了to语句还是不行,后来纠结了一阵子,发现转储控制文件发现必须要oralce处于nomount状态

  1. RMAN> restore controlfilefrom'/u01/app/oracle/oradata/sink/control01.ctl'to'+data/';

  2. RMAN-00571:===========================================================

  3. RMAN-00569:=============== ERROR MESSAGE STACK FOLLOWS===============

  4. RMAN-00571:===========================================================

  5. RMAN-00558: error encountered while parsinginput commands

  6. RMAN-01009: syntax error: found"to": expecting oneof:"archivelog, channel, check, controlfile, database, datafile, device, force, from, high, preview, primary, skip readonly, spfile, standby, tablespace, to restore point, until restore point, until, validate, (, ;"

  7. RMAN-01007: at line 1column 71file: standardinput

 找到头绪之后,将数据库启动到nomount状态

  1. [oracle@sink dbs]$!sql

  2. sqlplus/as sysdba

  3. SQL*Plus:Release 11.2.0.4.0 Productionon Sat Jan 6 16:48:57 2018

  4. Copyright(c) 1982, 2013, Oracle.All rights reserved.

  5. Connectedto:

  6. OracleDatabase 11g Enterprise EditionRelease 11.2.0.4.0- 64bit Production

  7. With the Partitioning,Automatic Storage Management, OLAP,Data Mining

  8. andReal Application Testing options

  9. 16:48:57 SYS@ sink>select statusfrom v$instance;

  10. STATUS

  11. ------------

  12. OPEN

  13. 1row selected.

  14. Elapsed: 00:00:00.01

  15. 16:49:10 SYS@ sink>startup nomount;

  16. ORA-01081: cannotstart already-running ORACLE- shut it down first

  17. 16:49:17 SYS@ sink>startupforce nomount;

  18. ORACLE instance started.

  19. Total System Global Area  835104768 bytes

  20. FixedSize            2257840 bytes

  21. VariableSize          553651280 bytes

  22. Database Buffers      276824064 bytes

  23. Redo Buffers            2371584 bytes

  24. 16:49:33 SYS@ sink>select statusfrom v$instance;

  25. STATUS

  26. ------------

  27. STARTED

  28. 1row selected.

  29. Elapsed: 00:00:00.01

  30. 16:49:57 SYS@ sink>

好了,经过一翻纠结,终于成功了,控制文件转储成功!

  1. RMAN> restore controlfilefrom'/u01/app/oracle/oradata/sink/control01.ctl';

  2. Starting restore at 06-JAN-18

  3. using targetdatabase controlfileinsteadof recovery catalog

  4. allocated channel: ORA_DISK_1

  5. channel ORA_DISK_1: SID=23 devicetype=DISK

  6. channel ORA_DISK_1: copied controlfilecopy

  7. outputfile name=+DATA/sink/controlfile/current.266.964717197

  8. outputfile name=+DATA/sink/controlfile/current.267.964717197

  9. Finished restore at 06-JAN-18

  10. RMAN>

查看控制文件迁移后的效果

  1. ASMCMD> pwd

  2. +data/sink/controlfile

  3. ASMCMD> ls

  4. Backup.262.964712653

  5. current.266.964717197

  6. current.267.964717197

在RMAN环境中将数据库切到mount状态,switch...修改控制文件用datafile copy做当前DB的datafile使用

  1. RMAN>alterdatabase mount;

  2. database mounted

  3. released channel: ORA_DISK_1

  4. RMAN> switchdatabasetocopy;

  5. using targetdatabase controlfileinsteadof recovery catalog

  6. datafile 1 switchedto datafilecopy"+DATA/sink/datafile/system.258.964712643"

  7. datafile 2 switchedto datafilecopy"+DATA/sink/datafile/sysaux.257.964712643"

  8. datafile 3 switchedto datafilecopy"+DATA/sink/datafile/undotbs1.261.964712645"

  9. datafile 4 switchedto datafilecopy"+DATA/sink/datafile/users.263.964712657"

  10. datafile 5 switchedto datafilecopy"+DATA/sink/datafile/example.260.964712643"

  11. datafile 6 switchedto datafilecopy"+DATA/sink/datafile/tbssss.259.964712643"

直接exit退出rman环境,然后直接!sql进入SQL环境,注意数据库状态仍然为mount,查看dataifle的路径

  1. RMAN>exit

  2. Recovery Manager complete.

  3. [oracle@sink dbs]$!sql

  4. sqlplus/as sysdba

  5. SQL*Plus:Release 11.2.0.4.0 Productionon Sat Jan 6 17:42:31 2018

  6. Copyright(c) 1982, 2013, Oracle.All rights reserved.

  7. Connectedto:

  8. OracleDatabase 11g Enterprise EditionRelease 11.2.0.4.0- 64bit Production

  9. With the Partitioning,Automatic Storage Management, OLAP,Data Mining

  10. andReal Application Testing options

  11. 17:42:41 SYS@ sink>col namefor a55

  12. 17:42:57 SYS@ sink>r

  13.   1*select namefrom v$datafile

  14. NAME

  15. -------------------------------------------------------

  16. +DATA/sink/datafile/system.258.964712643

  17. +DATA/sink/datafile/sysaux.257.964712643

  18. +DATA/sink/datafile/undotbs1.261.964712645

  19. +DATA/sink/datafile/users.263.964712657

  20. +DATA/sink/datafile/example.260.964712643

  21. +DATA/sink/datafile/tbssss.259.964712643

  22. 6rows selected.

  23. Elapsed: 00:00:00.01

  24. 17:42:58 SYS@ sink>

recover databse(应用 )开多个channel加快recover速度,生产DB很大,恢复时间很长,这是不错的办法

  1. RMAN>run{

  2. 2> allocate channel dev1 devicetype disk;

  3. 3> allocate channel dev2 devicetype disk;

  4. 4> allocate channel dev3 devicetype disk;

  5. 5> allocate channel dev4 devicetype disk;

  6. 6>recoverdatabase;

  7. 7>}

  8. released channel: ORA_DISK_1

  9. allocated channel: dev1

  10. channel dev1: SID=25 devicetype=DISK

  11. allocated channel: dev2

  12. channel dev2: SID=26 devicetype=DISK

  13. allocated channel: dev3

  14. channel dev3: SID=27 devicetype=DISK

  15. allocated channel: dev4

  16. channel dev4: SID=28 devicetype=DISK

  17. Startingrecover at 06-JAN-18

  18. starting media recovery

  19. media recovery complete, elapsed time: 00:00:00

  20. Finishedrecover at 06-JAN-18

  21. released channel: dev1

  22. released channel: dev2

  23. released channel: dev3

  24. released channel: dev4

  25. RMAN>

exit,进入sql环境,打开到open,看临时文件name,临时表空间name,

  1. RMAN> exit

  2. Recovery Manager complete.

  3. [oracle@sink dbs]$!sql

  4. sqlplus / as sysdba

  5. SQL*Plus: Release 11.2.0.4.0 Production on Sat Jan 6 17:57:16 2018

  6. Copyright(c) 1982, 2013, Oracle. All rights reserved.

  7. Connected to:

  8. Oracle Database 11g Enterprise Edition Release 11.2.0.4.0- 64bit Production

  9. With the Partitioning, Automatic Storage Management, OLAP, Data Mining

  10. and Real Application Testing options

  11. 17:59:16 SYS @ sink>alter database open;

  12. Database altered.

  13. Elapsed: 00:00:02.44

  14. 17:59:50 SYS @ sink>selectname from v$tempfile;

  15. NAME

  16. -------------------------------------------------------

  17. /u01/app/oracle/oradata/sink/temp01.dbf

  18. 1 row selected.

  19. Elapsed: 00:00:00.02

  20. 18:00:05 SYS @ sink>select tablespace_name,contents from dba_tablespaces;

  21. TABLESPACE_NAME            CONTENTS

  22. ---------------------------------------

  23. SYSTEM                   PERMANENT

  24. SYSAUX                   PERMANENT

  25. UNDOTBS1               UNDO

  26. TEMP                   TEMPORARY

  27. USERS                   PERMANENT

  28. EXAMPLE                PERMANENT

  29. TBSSSS                   PERMANENT

  30. 7 rows selected.

  31. Elapsed: 00:00:00.01

把临时表空间temp里面的临时文件temp01.dbf加入到ASM中的+date目录下

  1. 18:00:24 SYS@ sink>altertablespace tempadd tempfile'+data';

  2. Tablespace altered.

  3. Elapsed: 00:00:00.11

  4. 18:01:27 SYS@ sink>select namefrom v$tempfile;

  5. NAME

  6. -------------------------------------------------------

  7. /u01/app/oracle/oradata/sink/temp01.dbf

  8. +DATA/sink/tempfile/temp.268.964720887

  9. 2rows selected.

  10. Elapsed: 00:00:00.01

因为只有一个临时表空间的一个临时文件所以无法删除,多个就能成功,一直到最后一个就不能这样删除了

  1. 18:12:22 SYS@ sink>altertablespace tempdrop tempfile'/u01/app/oracle/oradata/sink/temp01.dbf';

  2. Tablespace altered.

  3. Elapsed: 00:00:00.12

  4. 18:13:35 SYS@ sink>select namefrom v$tempfile;

  5. NAME

  6. -------------------------------------------------------

  7. /u01/app/oracle/oradata/sink/temp01.dbf

  8. +DATA/sink/tempfile/temp.268.964720887

  9. 2rows selected.

  10. Elapsed: 00:00:00.01

上一步中DB处于open,以上操作将临时文件删至1个的时候,就不能继续删除,得将DB置于mount状态才行

  1. 18:14:03 SYS@ sink>shutdownimmediate;

  2. Database closed.

  3. Database dismounted.

  4. ORACLE instance shut down.


  5. 新闻名称:文件系统怎样迁移到ASM
    标题路径:http://scjbc.cn/article/pihods.html

其他资讯