首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

复原种子数据库练习

2013-09-15 
还原种子数据库练习种子数据库的控制文件位置:$ORACLE_HOME/assistants/dbca/templates/Seed_Database.ctl

还原种子数据库练习
种子数据库的控制文件位置:$ORACLE_HOME/assistants/dbca/templates/Seed_Database.ctl种子数据库的备份片位置:$ORACLE_HOME/assistants/dbca/templates/Seed_Database.dfb大体步骤如下:编辑一个pfile启动到nomount,然后通过控制文件启动到mount状态,恢复数据库文件,然后启动数据库。
1.随便编辑一个pfile,只添加上Db_name和控制文件路径即可[oracle@elvis-desktop dbs]$ vi initORCL.ora db_name='ORCL'control_files='/oracle/oradata/ORCL/control1.ctl'2.定义一个ORACLE_SID,创建存放数据库文件的目录 [oracle@elvis-desktop dbs]$ export ORACLE_SID=ORCL[oracle@elvis-desktop dbs]$ mkdir /oracle/oradata/ORCL/3.把种子数据库的控制文件拷贝到pfile中的路径,并且修改成相应的名字,使用pfile启动到nomount状态[oracle@elvis-desktop dbs]$ rman target /Recovery Manager: Release 11.2.0.3.0 - Production on Thu Sep 5 13:45:33 2013Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.connected to target database (not started)RMAN> startup nomount pfile='/oracle/product/11.2.0/dbhome_1/dbs/initORCL.ora';Oracle instance startedTotal System Global Area 238034944 bytesFixed Size 2227136 bytesVariable Size 180356160 bytesDatabase Buffers 50331648 bytesRedo Buffers 5120000 bytes4.启动数据库到mount状态RMAN> alter database mount;RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of alter db command at 09/05/2013 13:52:32ORA-01103: database name 'SEEDDATA' in control file is not 'ORCL'------->>>此处报数据库的名字为SEEDDATA,将pfile中的db_name修改成SEEDDATA,重启数据库,启动到mount状态[oracle@elvis-desktop dbs]$ vi initORCL.ora db_name='SEEDDATA'control_files='/oracle/oradata/ORCL/control01.ctl'RMAN> alter database mount;RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of alter db command at 09/05/2013 13:53:12ORA-01103: database name 'SEEDDATA' in control file is not 'ORCL'RMAN> shutdown abort;Oracle instance shut downRMAN> startup nomount pfile='/oracle/product/11.2.0/dbhome_1/dbs/initORCL.ora';connected to target database (not started)Oracle instance startedTotal System Global Area 238034944 bytesFixed Size 2227136 bytesVariable Size 180356160 bytesDatabase Buffers 50331648 bytesRedo Buffers 5120000 bytesRMAN> alter database mount;database mounted5.注册数据库备份片的位置,开始恢复数据库RMAN> catalog start with '/oracle/product/11.2.0/dbhome_1/assistants/dbca/templates/Seed_Database.dfb';searching for all files that match the pattern /oracle/product/11.2.0/dbhome_1/assistants/dbca/templates/Seed_Database.dfbList of Files Unknown to the Database=====================================File Name: /oracle/product/11.2.0/dbhome_1/assistants/dbca/templates/Seed_Database.dfbDo you really want to catalog the above files (enter YES or NO)? YEScataloging files...cataloging doneList of Cataloged Files=======================File Name: /oracle/product/11.2.0/dbhome_1/assistants/dbca/templates/Seed_Database.dfbRMAN> crosscheck backup; ----->>>检查备份集的有效性using channel ORA_DISK_1crosschecked backup piece: found to be 'EXPIRED'backup piece handle=/ade/b/385031636/oracle/oradata/Seed_Database.dfb RECID=1 STAMP=762085401crosschecked backup piece: found to be 'AVAILABLE'backup piece handle=/oracle/product/11.2.0/dbhome_1/assistants/dbca/templates/Seed_Database.dfb RECID=2 STAMP=825342912Crosschecked 2 objectsRMAN> delete expired backup; ----->>>>删除过期备份using channel ORA_DISK_1List of Backup PiecesBP Key BS Key Pc# Cp# Status Device Type Piece Name------- ------- --- --- ----------- ----------- ----------1 1 1 1 EXPIRED DISK /ade/b/385031636/oracle/oradata/Seed_Database.dfbDo you really want to delete the above objects (enter YES or NO)? YESdeleted backup piecebackup piece handle=/ade/b/385031636/oracle/oradata/Seed_Database.dfb RECID=1 STAMP=762085401Deleted 1 EXPIRED objectsRMAN> list backup; ----->>>>检查备份集的相关信息List of Backup Sets===================BS Key Type LV Size Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ ---------------1 Full 253.38M DISK 00:00:58 17-SEP-11 BP Key: 2 Status: AVAILABLE Compressed: YES Tag: Piece Name: /oracle/product/11.2.0/dbhome_1/assistants/dbca/templates/Seed_Database.dfbList of Datafiles in backup set 1File LV Type Ckp SCN Ckp Time Name---- -- ---- ---------- --------- ----1 Full 995547 17-SEP-11 /ade/b/385031636/oracle/oradata/seeddata/system01.dbf2 Full 995547 17-SEP-11 /ade/b/385031636/oracle/oradata/seeddata/sysaux01.dbf3 Full 995547 17-SEP-11 /ade/b/385031636/oracle/oradata/seeddata/undotbs01.dbf4 Full 995547 17-SEP-11 /ade/b/385031636/oracle/oradata/seeddata/users01.dbf------->>>上述检查后,我们就该知道要修改数据文件的名字到新的目录RMAN> restore database;Starting restore at 05-SEP-13using channel ORA_DISK_1channel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_DISK_1: restoring datafile 00001 to /ade/b/385031636/oracle/oradata/seeddata/system01.dbfchannel ORA_DISK_1: restoring datafile 00002 to /ade/b/385031636/oracle/oradata/seeddata/sysaux01.dbfchannel ORA_DISK_1: restoring datafile 00003 to /ade/b/385031636/oracle/oradata/seeddata/undotbs01.dbfchannel ORA_DISK_1: restoring datafile 00004 to /ade/b/385031636/oracle/oradata/seeddata/users01.dbfchannel ORA_DISK_1: reading from backup piece /oracle/product/11.2.0/dbhome_1/assistants/dbca/templates/Seed_Database.dfbchannel ORA_DISK_1: ORA-19870: error while restoring backup piece /oracle/product/11.2.0/dbhome_1/assistants/dbca/templates/Seed_Database.dfbORA-19504: failed to create file "/ade/b/385031636/oracle/oradata/seeddata/system01.dbf"ORA-27040: file create error, unable to create fileLinux-x86_64 Error: 2: No such file or directoryAdditional information: 1failover to previous backupcreating datafile file number=1 name=/ade/b/385031636/oracle/oradata/seeddata/system01.dbfRMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of restore command at 09/05/2013 13:59:56ORA-01180: can not create datafile 1ORA-01110: data file 1: '/ade/b/385031636/oracle/oradata/seeddata/system01.dbf'-------------------->>>>果然提示报错,不能创建相关的目录。我们要修改到指定的位置/oracle/oradata/ORCL/-------------------->>>>修改数据库文件名字,switch datafile all就是更新控制文件的意思RMAN> run{set newname for datafile '/ade/b/385031636/oracle/oradata/seeddata/system01.dbf' to '/oracle/oradata/ORCL/system01.dbf';set newname for datafile '/ade/b/385031636/oracle/oradata/seeddata/sysaux01.dbf' to '/oracle/oradata/ORCL/sysaux01.dbf';set newname for datafile '/ade/b/385031636/oracle/oradata/seeddata/undotbs01.dbf' to '/oracle/oradata/ORCL/undotbs01.dbf';set newname for datafile '/ade/b/385031636/oracle/oradata/seeddata/users01.dbf' to '/oracle/oradata/ORCL/users01.dbf';restore database;switch datafile all;recover database;}executing command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEStarting restore at 05-SEP-13using channel ORA_DISK_1channel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_DISK_1: restoring datafile 00001 to /oracle/oradata/ORCL/system01.dbfchannel ORA_DISK_1: restoring datafile 00002 to /oracle/oradata/ORCL/sysaux01.dbfchannel ORA_DISK_1: restoring datafile 00003 to /oracle/oradata/ORCL/undotbs01.dbfchannel ORA_DISK_1: restoring datafile 00004 to /oracle/oradata/ORCL/users01.dbfchannel ORA_DISK_1: reading from backup piece /oracle/product/11.2.0/dbhome_1/assistants/dbca/templates/Seed_Database.dfbchannel ORA_DISK_1: piece handle=/oracle/product/11.2.0/dbhome_1/assistants/dbca/templates/Seed_Database.dfb tag=NULLchannel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:02:05Finished restore at 05-SEP-13datafile 1 switched to datafile copyinput datafile copy RECID=5 STAMP=825343689 file name=/oracle/oradata/ORCL/system01.dbfdatafile 2 switched to datafile copyinput datafile copy RECID=6 STAMP=825343689 file name=/oracle/oradata/ORCL/sysaux01.dbfdatafile 3 switched to datafile copyinput datafile copy RECID=7 STAMP=825343689 file name=/oracle/oradata/ORCL/undotbs01.dbfdatafile 4 switched to datafile copyinput datafile copy RECID=8 STAMP=825343689 file name=/oracle/oradata/ORCL/users01.dbfStarting recover at 05-SEP-13using channel ORA_DISK_1starting media recoveryRMAN-08187: WARNING: media recovery until SCN 995547 completeFinished recover at 05-SEP-13------------->>>>成功recover,显示这是个介质恢复,只完成SCN号995547,属于不完全恢复RMAN> ALTER DATABASE OPEN;RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of alter db command at 09/05/2013 14:08:19ORA-01589: must use RESETLOGS or NORESETLOGS option for database open------------>>>>由于是介质恢复,所以需要以resetlog的方式打开RMAN> ALTER DATABASE OPEN RESETLOGS;RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of alter db command at 09/05/2013 14:08:25ORA-00349: failure obtaining block size for '/ade/b/385031636/oracle/oradata/seeddata/redo01.log'ORA-27041: unable to open fileLinux-x86_64 Error: 2: No such file or directoryAdditional information: 9---------缺少redo文件,添加3个redo log文件,并且要修改位置RMAN> ALTER DATABASE OPEN RESETLOGS;RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of alter db command at 09/05/2013 14:10:02ORA-00349: failure obtaining block size for '/ade/b/385031636/oracle/oradata/seeddata/redo03.log'ORA-27041: unable to open fileLinux-x86_64 Error: 2: No such file or directoryAdditional information: 9------上述缺少redolog文件,需要建立redo log文件[oracle@elvis-desktop dbs]$ export ORACLE_SID=ORCL[oracle@elvis-desktop dbs]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.3.0 Production on Thu Sep 5 14:08:51 2013Copyright (c) 1982, 2011, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> select status from v$instance;STATUS------------MOUNTEDSQL> alter database rename file '/ade/b/385031636/oracle/oradata/seeddata/redo01.log' to '/oracle/oradata/ORCL/redo01.log';Database altered.SQL> alter database rename file '/ade/b/385031636/oracle/oradata/seeddata/redo02.log' to '/oracle/oradata/ORCL/redo02.log';Database altered.SQL> alter database rename file '/ade/b/385031636/oracle/oradata/seeddata/redo03.log' to '/oracle/oradata/ORCL/redo03.log';Database altered.RMAN> ALTER DATABASE OPEN RESETLOGS;database opened---------->>>>>>数据库成功打开,需要做一次全备[oracle@elvis-desktop dbs]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.3.0 Production on Thu Sep 5 14:10:52 2013Copyright (c) 1982, 2011, Oracle. All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> select status from v$instance;STATUS------------OPEN------------------->>>>为新数据库创建spfile,并且重启数据库SQL> create spfile from pfile;File created.SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.SQL> startupORACLE instance started.Total System Global Area 238034944 bytesFixed Size 2227136 bytesVariable Size 180356160 bytesDatabase Buffers 50331648 bytesRedo Buffers 5120000 bytesDatabase mounted.Database opened.SQL> show parameter spfile;NAME TYPE VALUE------------------------------------ ----------- ------------------------------spfile string /oracle/product/11.2.0/dbhome_1/dbs/spfileORCL.oraSQL> show parameter name;NAME TYPE VALUE------------------------------------ ----------- ------------------------------db_file_name_convert stringdb_name string SEEDDATAdb_unique_name string SEEDDATAglobal_names boolean FALSEinstance_name string ORCLlock_name_space stringlog_file_name_convert stringprocessor_group_name stringservice_names string SEEDDATA--------------------->>>>恢复成功,可以看到数据库以spfile启动,并且实例名和数据库名不一样

热点排行