文件系统怎样迁移到ASM
文件系统怎样迁移到ASM,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。
网站建设哪家好,找创新互联公司!专注于网页设计、网站建设、微信开发、重庆小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了湛江免费建站欢迎大家使用!
数据库全备 | 仅仅是一个databse的全备,没有任何额外的附加功能,仅 |
0 级 增量备份 | 既是数据库的全备,又是,0级增量备份,在此基础上,可以后续执行增量备份 |
结论 | 因此推荐使用0级增量备份做数据库的全备 |
最好是以grid用户进入asm 环境
[oracle@sink~]$ su- grid
Password:
[grid@sink~]$ asmcmd
做完 0 级 增量备份后的备份文件
ASMCMD> pwd
+data/sink
ASMCMD> ls
BACKUPSET/
CONTROLFILE/
DATAFILE/
PARAMETERFILE/
查看刚才做的 0级增量 备份
RMAN>listcopyofdatabase;
Listof Datafile Copies
=======================
KeyFile S Completion Time Ckp SCN Ckp Time
------- ---- - --------------- ---------- ---------------
9 1 A 06-JAN-18 1218041 06-JAN-18
Name:+DATA/sink/datafile/system.258.964712643
Tag: ORA_ASM_MIGRATION
8 2 A 06-JAN-18 1218040 06-JAN-18
Name:+DATA/sink/datafile/sysaux.257.964712643
Tag: ORA_ASM_MIGRATION
4 3 A 06-JAN-18 1218045 06-JAN-18
Name:+DATA/sink/datafile/undotbs1.261.964712645
Tag: ORA_ASM_MIGRATION
6 4 A 06-JAN-18 1218050 06-JAN-18
Name:+DATA/sink/datafile/users.263.964712657
Tag: ORA_ASM_MIGRATION
7 5 A 06-JAN-18 1218043 06-JAN-18
Name:+DATA/sink/datafile/example.260.964712643
Tag: ORA_ASM_MIGRATION
3 6 A 06-JAN-18 1218042 06-JAN-18
Name:+DATA/sink/datafile/tbssss.259.964712643
Tag: ORA_ASM_MIGRATION
RMAN>
转储spfile到
RMAN> restore spfile to'+DATA/spfilesink.ora';
Starting restore at 06-JAN-18
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: restoring SPFILE
output file name=+DATA/spfilesink.ora
channel ORA_DISK_1: reading from backup piece +DATA/sink/backupset/2018_01_06/nnsnn0_ora_asm_migration_0.264.964712657
channel ORA_DISK_1: piece handle=+DATA/sink/backupset/2018_01_06/nnsnn0_ora_asm_migration_0.264.964712657 tag=ORA_ASM_MIGRATION
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
Finished restore at 06-JAN-18
查看转储spfile参数文件后的 在ASM中的 路径状态
ASMCMD> pwd
+data
ASMCMD> ls
ASM/
SINK/
spfilesink.ora
ASMCMD>
修改并查看pfile中的内容,使其内容指向ASM中spfile的spfilesink.ora的路径,有意思!
[oracle@sink dbs]$ pwd
/u01/app/oracle/product/11.2.0/dbhome_1/dbs
[oracle@sink dbs]$ ls
afiedt.buf hc_test.dat initsink.ora lkSINK orapwsink snapcf_sink.f
hc_sink.dat init.ora inittest.ora lkTEST orapwtest spfilesink.ora
[oracle@sink dbs]$ vim initsink.ora
[oracle@sink dbs]$ cat initsink.ora
spfile='+DATA/spfilesink.ora'
[oracle@sink dbs]$
再次进入SQL环境,启动到nomount,设置spfile路径指向,并查看相关参数是否操作生效!成功了!
[oracle@sink dbs]$!sql
sqlplus/as sysdba
SQL*Plus:Release 11.2.0.4.0 Productionon Sat Jan 6 16:30:19 2018
Copyright(c) 1982, 2013, Oracle.All rights reserved.
Connectedto:
OracleDatabase 11g Enterprise EditionRelease 11.2.0.4.0- 64bit Production
With the Partitioning,Automatic Storage Management, OLAP,Data Mining
andReal Application Testing options
16:30:19 SYS@ sink>startupforce nomount;
ORACLE instance started.
Total System Global Area 835104768 bytes
FixedSize 2257840 bytes
VariableSize 553651280 bytes
Database Buffers 276824064 bytes
Redo Buffers 2371584 bytes
16:30:38 SYS@ sink>alter systemset db_create_file_dest='+DATA';
System altered.
Elapsed: 00:00:00.01
16:31:23 SYS@ sink>show parametercreate;
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
16:31:33 SYS@ sink>
自上一步之后,查看数据库启动状态,然后satrtup force,将他启动到opened状态
16:31:33 SYS@ sink>select statusfrom v$instance;
STATUS
------------
STARTED
1row selected.
Elapsed: 00:00:00.00
16:35:24 SYS@ sink>alterdatabase open;
alterdatabase open
*
ERROR at line 1:
ORA-01507:databasenot mounted
Elapsed: 00:00:00.00
16:35:39 SYS@ sink>startupforce;
ORACLE instance started.
Total System Global Area 835104768 bytes
FixedSize 2257840 bytes
VariableSize 553651280 bytes
Database Buffers 276824064 bytes
Redo Buffers 2371584 bytes
Database mounted.
Database opened.
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,方便之后的数据文件迁移
SYS@ sink>r
1*selectfile#,namefrom v$datafile
FILE# NAME
---------- -------------------------------------------------------
1/u01/app/oracle/oradata/sink/system01.dbf
2/u01/app/oracle/oradata/sink/sysaux01.dbf
3/u01/app/oracle/oradata/sink/undotbs01.dbf
4/u01/app/oracle/oradata/sink/users01.dbf
5/u01/app/oracle/oradata/sink/example01.dbf
6+DATA/sink/datafile/tbssss.256.963504823
6rows selected.
Elapsed: 00:00:00.01
转储控制文件失败,看错误信息提示:意思是在数据库是mount或者open执行这条语句没有使用TO语句,
RMAN> restore controlfilefrom'/u01/app/oracle/oradata/sink/control01.ctl';
Starting restore at 06-JAN-18
using targetdatabase controlfileinsteadof recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=42 devicetype=DISK
RMAN-00571:===========================================================
RMAN-00569:=============== ERROR MESSAGE STACK FOLLOWS===============
RMAN-00571:===========================================================
RMAN-03002: failureof restore command at 01/06/2018 16:45:57
RMAN-06496: must use theTO clause when thedatabaseis mountedor open
这次加了to语句还是不行,后来纠结了一阵子,发现转储控制文件发现必须要oralce处于nomount状态
RMAN> restore controlfilefrom'/u01/app/oracle/oradata/sink/control01.ctl'to'+data/';
RMAN-00571:===========================================================
RMAN-00569:=============== ERROR MESSAGE STACK FOLLOWS===============
RMAN-00571:===========================================================
RMAN-00558: error encountered while parsinginput commands
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, (, ;"
RMAN-01007: at line 1column 71file: standardinput
找到头绪之后,将数据库启动到nomount状态
[oracle@sink dbs]$!sql
sqlplus/as sysdba
SQL*Plus:Release 11.2.0.4.0 Productionon Sat Jan 6 16:48:57 2018
Copyright(c) 1982, 2013, Oracle.All rights reserved.
Connectedto:
OracleDatabase 11g Enterprise EditionRelease 11.2.0.4.0- 64bit Production
With the Partitioning,Automatic Storage Management, OLAP,Data Mining
andReal Application Testing options
16:48:57 SYS@ sink>select statusfrom v$instance;
STATUS
------------
OPEN
1row selected.
Elapsed: 00:00:00.01
16:49:10 SYS@ sink>startup nomount;
ORA-01081: cannotstart already-running ORACLE- shut it down first
16:49:17 SYS@ sink>startupforce nomount;
ORACLE instance started.
Total System Global Area 835104768 bytes
FixedSize 2257840 bytes
VariableSize 553651280 bytes
Database Buffers 276824064 bytes
Redo Buffers 2371584 bytes
16:49:33 SYS@ sink>select statusfrom v$instance;
STATUS
------------
STARTED
1row selected.
Elapsed: 00:00:00.01
16:49:57 SYS@ sink>
好了,经过一翻纠结,终于成功了,控制文件转储成功!
RMAN> restore controlfilefrom'/u01/app/oracle/oradata/sink/control01.ctl';
Starting restore at 06-JAN-18
using targetdatabase controlfileinsteadof recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=23 devicetype=DISK
channel ORA_DISK_1: copied controlfilecopy
outputfile name=+DATA/sink/controlfile/current.266.964717197
outputfile name=+DATA/sink/controlfile/current.267.964717197
Finished restore at 06-JAN-18
RMAN>
查看控制文件迁移后的效果
ASMCMD> pwd
+data/sink/controlfile
ASMCMD> ls
Backup.262.964712653
current.266.964717197
current.267.964717197
在RMAN环境中将数据库切到mount状态,switch...修改控制文件用datafile copy做当前DB的datafile使用
RMAN>alterdatabase mount;
database mounted
released channel: ORA_DISK_1
RMAN> switchdatabasetocopy;
using targetdatabase controlfileinsteadof recovery catalog
datafile 1 switchedto datafilecopy"+DATA/sink/datafile/system.258.964712643"
datafile 2 switchedto datafilecopy"+DATA/sink/datafile/sysaux.257.964712643"
datafile 3 switchedto datafilecopy"+DATA/sink/datafile/undotbs1.261.964712645"
datafile 4 switchedto datafilecopy"+DATA/sink/datafile/users.263.964712657"
datafile 5 switchedto datafilecopy"+DATA/sink/datafile/example.260.964712643"
datafile 6 switchedto datafilecopy"+DATA/sink/datafile/tbssss.259.964712643"
直接exit退出rman环境,然后直接!sql进入SQL环境,注意数据库状态仍然为mount,查看dataifle的路径
RMAN>exit
Recovery Manager complete.
[oracle@sink dbs]$!sql
sqlplus/as sysdba
SQL*Plus:Release 11.2.0.4.0 Productionon Sat Jan 6 17:42:31 2018
Copyright(c) 1982, 2013, Oracle.All rights reserved.
Connectedto:
OracleDatabase 11g Enterprise EditionRelease 11.2.0.4.0- 64bit Production
With the Partitioning,Automatic Storage Management, OLAP,Data Mining
andReal Application Testing options
17:42:41 SYS@ sink>col namefor a55
17:42:57 SYS@ sink>r
1*select namefrom v$datafile
NAME
-------------------------------------------------------
+DATA/sink/datafile/system.258.964712643
+DATA/sink/datafile/sysaux.257.964712643
+DATA/sink/datafile/undotbs1.261.964712645
+DATA/sink/datafile/users.263.964712657
+DATA/sink/datafile/example.260.964712643
+DATA/sink/datafile/tbssss.259.964712643
6rows selected.
Elapsed: 00:00:00.01
17:42:58 SYS@ sink>
recover databse(应用 )开多个channel加快recover速度,生产DB很大,恢复时间很长,这是不错的办法
RMAN>run{
2> allocate channel dev1 devicetype disk;
3> allocate channel dev2 devicetype disk;
4> allocate channel dev3 devicetype disk;
5> allocate channel dev4 devicetype disk;
6>recoverdatabase;
7>}
released channel: ORA_DISK_1
allocated channel: dev1
channel dev1: SID=25 devicetype=DISK
allocated channel: dev2
channel dev2: SID=26 devicetype=DISK
allocated channel: dev3
channel dev3: SID=27 devicetype=DISK
allocated channel: dev4
channel dev4: SID=28 devicetype=DISK
Startingrecover at 06-JAN-18
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finishedrecover at 06-JAN-18
released channel: dev1
released channel: dev2
released channel: dev3
released channel: dev4
RMAN>
exit,进入sql环境,打开到open,看临时文件name,临时表空间name,
RMAN> exit
Recovery Manager complete.
[oracle@sink dbs]$!sql
sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Sat Jan 6 17:57:16 2018
Copyright(c) 1982, 2013, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0- 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real Application Testing options
17:59:16 SYS @ sink>alter database open;
Database altered.
Elapsed: 00:00:02.44
17:59:50 SYS @ sink>selectname from v$tempfile;
NAME
-------------------------------------------------------
/u01/app/oracle/oradata/sink/temp01.dbf
1 row selected.
Elapsed: 00:00:00.02
18:00:05 SYS @ sink>select tablespace_name,contents from dba_tablespaces;
TABLESPACE_NAME CONTENTS
---------------------------------------
SYSTEM PERMANENT
SYSAUX PERMANENT
UNDOTBS1 UNDO
TEMP TEMPORARY
USERS PERMANENT
EXAMPLE PERMANENT
TBSSSS PERMANENT
7 rows selected.
Elapsed: 00:00:00.01
把临时表空间temp里面的临时文件temp01.dbf加入到ASM中的+date目录下
18:00:24 SYS@ sink>altertablespace tempadd tempfile'+data';
Tablespace altered.
Elapsed: 00:00:00.11
18:01:27 SYS@ sink>select namefrom v$tempfile;
NAME
-------------------------------------------------------
/u01/app/oracle/oradata/sink/temp01.dbf
+DATA/sink/tempfile/temp.268.964720887
2rows selected.
Elapsed: 00:00:00.01
因为只有一个临时表空间的一个临时文件所以无法删除,多个就能成功,一直到最后一个就不能这样删除了
18:12:22 SYS@ sink>altertablespace tempdrop tempfile'/u01/app/oracle/oradata/sink/temp01.dbf';
Tablespace altered.
Elapsed: 00:00:00.12
18:13:35 SYS@ sink>select namefrom v$tempfile;
NAME
-------------------------------------------------------
/u01/app/oracle/oradata/sink/temp01.dbf
+DATA/sink/tempfile/temp.268.964720887
2rows selected.
Elapsed: 00:00:00.01
上一步中DB处于open,以上操作将临时文件删至1个的时候,就不能继续删除,得将DB置于mount状态才行
18:14:03 SYS@ sink>shutdownimmediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
-
新闻名称:文件系统怎样迁移到ASM
标题路径:http://scjbc.cn/article/pihods.html