使用RMAN将文件系统迁移到ASM
1,全备数据库PROD
run{
allocate channel c1 device type disk;
allocate channel c2 device type disk;
backup tag 'SH_DB' as compressed backupset format ‘/home/Oracle/full_%U.bak' database
include current controlfile;
backup tag 'SH_ARCH' archivelog al format ‘/home/oracle/arch_%U.bak’l;
release channel c1;
release channel c2;
}
2,确认控制文件的备份片
RMAN> list backup of control file;
/home/oracle/full_03pkgtf4_1_1.bak
3,导出pfile,将控制文件修改为+DATA和+FRA
SYS@PROD >create pfile='/home/oracle/prodpfile' from spfile;
[oracle@single ~]$ vi /home/oracle/prodpfile
*.audit_file_dest='/u01/admin/PROD/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
##*.control_files='/u01/oradata/PROD/control01.ctl','/u01/fast_recovery_area/PROD/control02.ctl'
*.control_files='+DATA/PROD/controlfile/control01.ctl','+FRA/PROD/controlfile/control02.ctl'
*.db_block_size=8192
*.db_create_file_dest='+DATA'
*.db_domain=''
*.db_name='PROD'
##*.db_recovery_file_dest='/u01/fast_recovery_area'
*.db_recovery_file_dest='+FRA'
*.db_recovery_file_dest_size=4385144832
*.diagnostic_dest='/u01'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=PRODXDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=583008256
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
4,删除PROD
SYS@PROD >startup force mount restrict;
SYS@PROD >drop database;
5,创建灾备端所需目录(DBCA删除数据库需要此步骤)
mkdir -p $ORACLE_BASE/admin/PROD/adump
6,创建数据库密码文件 (DBCA删除数据库需要此步骤)
orapwd file=$ORACLE_HOME/dbs/orapwPROD password=oracle entries=5 force=y
7,采用修改过的pfile启动到nomount
$ sqlplus / as sysdba
SYS@PROD >startup nomount pfile=/home/oracle/pfile;
8,将spfile文件创建到+DATA目录下,利用Oracle11g新特性from memory
SYS@PROD >create spfile='+DATA/PROD/spfilePROD.ora' from memory;
9,创建一个pfile来指向spfile。将红色字体内容填写在vi创建的pfile文件中。 在Oracle11g中安装过集群软件都需要这样配置,无论是单实例ASM还是RAC+ASM
SYS@PROD >!vi $ORACLE_HOME/dbs/initPROD.ora
SPFILE='+DATA/PROD/spfilePROD.ora’
10,恢复控制文件到+DATA
RMAN> startup force nomount;
RMAN> restore controlfile from '/home/oracle/full_03pkgtf4_1_1.bak';
11,启动到mount
RMAN> mount database;
12,识别备份集
RMAN> catalog start with '/home/oracle/';
13,恢复数据库,注意关键词set newname 和 switch datafile all是迁移文件系统到ASM的关键。
run{
set newname for datafile 1 to '+DATA';
set newname for datafile 2 to '+DATA';
set newname for datafile 3 to '+DATA';
set newname for datafile 4 to '+DATA';
set newname for tempfile 1 to '+DATA';
restore database;
switch datafile all;
recover database;
}
14,更改联机日志路径为+DATA
SYS@PROD >alter database rename file '/u01/oradata/PROD/redo01.log' to '+DATA';
SYS@PROD >alter database rename file '/u01/oradata/PROD/redo02.log' to '+DATA';
SYS@PROD >alter database rename file '/u01/oradata/PROD/redo03.log' to '+DATA';
15,open resetlogs开库
SYS@PROD >alter database open resetlogs;
16, 如果在set newname tempfile步骤不能成功的迁移tempfile使用下面的命令手工追加
SYS@PROD >alter tablespace temp add tempfile '+DATA' size 10m;
SYS@PROD >alter tablespace temp drop tempfile '/u01/oradata/PROD/temp01.dbf’;
实验结束
--------------------------------------推荐阅读 --------------------------------------
--------------------------------------分割线 --------------------------------------