说明,只要是同样系统,同样数据库版本,是可以做冷备恢复。冷备份数据必须是数据库不在open状态下。以oracle11gR2为例。
一、冷备份与冷恢复
具体步骤如下。
1. 复制旧的数据库文件
(2) 关闭DB :
(3) 复制文件到其他地方存储实现备份
1)复制三个文件夹
2. Oracle重新建库恢复
(1)创建一个和原来一样的数据库。(安装路径和数据库名必须和原来一致)
(2)停止数据库shutdown immediate;
(3)复制安装目录下的admin、oradata、flash_recovery_area覆盖,复制database(PWDfile、pfile) 覆盖
(4)启动数据库 startup;
备注:
无归档模式:将备份文件拷贝回原来的目录即可,然后启动数据库。
归档模式:
①将数据文件、控制文件拷贝回原来目录
②SQL>startup mount;
SQL>recover database using backup controlfile;
③将相应的归档日志和联机日志拖到CMD命令窗口进行跑日志。
④SQL>alter database open resetlogs;
3. 软件重装恢复
此时,操作系统重装,如果做冷备恢复,要保证相同操作系统,相同的数据库版本。形势如同异机恢复。
A、不创建实例:(源机上的数据库名字为orcl)
(1) 恢复oradata/orcl目录
在目标机上的oradata目录下建立orcl文件夹,然后进行数据覆盖。
(3) 建立服务
STARTUP NOMOUNT CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS ARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292 LOGFILE GROUP 1 'E:APPADMINISTRATORORADATAORCLREDO01.LOG' SIZE 50M BLOCKSIZE 512, GROUP 2 'E:APPADMINISTRATORORADATAORCLREDO02.LOG' SIZE 50M BLOCKSIZE 512, GROUP 3 'E:APPADMINISTRATORORADATAORCLREDO03.LOG' SIZE 50M BLOCKSIZE 512 -- STANDBY LOGFILE DATAFILE 'E:APPADMINISTRATORORADATAORCLSYSTEM01.DBF', 'E:APPADMINISTRATORORADATAORCLSYSAUX01.DBF', 'E:APPADMINISTRATORORADATAORCLUNDOTBS01.DBF', 'E:APPADMINISTRATORORADATAORCLUSERS01.DBF', 'E:APPADMINISTRATORORADATAORCLEXAMPLE01.DBF', 'E:APPADMINISTRATORORADATAORCLYTQ.DBF', 'E:APPADMINISTRATORORADATAORCLJHH', 'E:APPADMINISTRATORPRODUCT11.2.0DBHOME_1DATABASESDE_TBS', 'I:JECMSDBDB_BK_DATARMAN_LOCAL_1805RMAN_BKUP_1805.DBF' CHARACTER SET ZHS16GBK ;
(5) 数据库设置SID和启动服务
c:>set ORACLE_SID=orcl c:>sqlplus "/as sysdba" SQL>create spfile from pfile='c:pfile.txt'; SQL>@c:createctl.sql; SQL>shutdown immediate; SQL>startup; SQL>alter database open resetlogs;
备注:
如果(4)、(5)不好用,可以用下面的方法修改这些路径不一致的问题(反正笔者电脑上冷备份恢复时,上面的两个步骤就不好用):
1)SQL>下执行如下语句,恢复控制文件
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "ORCL" NORESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
2)修改日志、DBF的路径
alter database rename file 'E:APPADMINISTRATORORADATAORCLREDO01.LOG' to 'E:IDEPROSoracle_homeoradataorclREDO01.LOG'; alter database rename file 'E:APPADMINISTRATORORADATAORCLREDO02.LOG' to 'E:IDEPROSoracle_homeoradataorclREDO02.LOG'; alter database rename file 'E:APPADMINISTRATORORADATAORCLREDO03.LOG' to 'E:IDEPROSoracle_homeoradataorclREDO03.LOG'; alter database rename file 'E:APPADMINISTRATORORADATAORCLSYSTEM01.DBF' to 'E:IDEPROSoracle_homeoradataorclSYSTEM01.DBF'; alter database rename file 'E:APPADMINISTRATORORADATAORCLSYSAUX01.DBF' to 'E:IDEPROSoracle_homeoradataorclSYSAUX01.DBF'; alter database rename file 'E:APPADMINISTRATORORADATAORCLUNDOTBS01.DBF' to 'E:IDEPROSoracle_homeoradataorclUNDOTBS01.DBF'; alter database rename file 'E:APPADMINISTRATORORADATAORCLUSERS01.DBF' to 'E:IDEPROSoracle_homeoradataorclUSERS01.DBF'; alter database rename file 'E:APPADMINISTRATORORADATAORCLEXAMPLE01.DBF' to 'E:IDEPROSoracle_homeoradataorclEXAMPLE01.DBF'; alter database rename file 'E:APPADMINISTRATORORADATAORCLYTQ.DBF' to 'E:IDEPROSoracle_homeoradataorclYTQ.DBF'; alter database rename file 'E:APPADMINISTRATORORADATAORCLJHH' to 'E:IDEPROSoracle_homeoradataorclJHH'; alter database rename file 'E:APPADMINISTRATORPRODUCT11.2.0DBHOME_1DATABASESDE_TBS' to 'E:IDEPROSoracle_homeoradataorclSDE_TBS'; alter database rename file 'I:JECMSDBDB_BK_DATARMAN_LOCAL_1805RMAN_BKUP_1805.DBF' to 'E:IDEPROSoracle_homeoradataorclRMAN_BKUP_1805.DBF'; 修改oracle_homeoradataorcl下及相关文件的路径
ORCL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )
B、创建实例方式(实例SID与源机数据库SID一致)
(1) 替换和覆盖oradataorcl目录(2) 密码文件覆盖
(3) 控制文件恢复
复制代码代码如下:
c:>sqlplus "/as sysdba" SQL>@c:createctl.sql; SQL>shutdown immediate; SQL>startup; SQL>alter database open resetlogs;
(4) 在networkadmin下的tnsnames.ora中添加如下片段
复制代码代码如下:
ORCL = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = orcl) ) )
二、问题与解决
1. ORA-03113: 通信通道的文件结尾
在从mount状态下,启动时出现;或者从startup命令启动时出现。
详情请参考文章
Oracle错误——ORA-03113:通信通道的文件结尾 解决办法
如何釋放 DB_RECOVERY_FILE_DEST_SIZE
解决方法:
(1) 查看diag dbmsoracleoracle race下的oracle_ora_xxxx.trc错误日志
Oracle出现错误,于是去错误日志里去找问题根源:在 e:appkangdiag dbmsoracleoracle race文件夹下找到oracle_ora_6320.trc文件,打开显示错误日志:
ORA-19815: WARNING: db_recovery_file_dest_size of 4102029312 bytes is 100.00% used, and has 0 remaining bytes available. ************************************************************************ You have following choices to free up space from recovery area: 1. Consider changing RMAN RETENTION POLICY. If you are using Data Guard, then consider changing RMAN ARCHIVELOG DELETION POLICY. 2. Back up files to tertiary device such as tape using RMAN BACKUP RECOVERY AREA command. 3. Add disk space and increase db_recovery_file_dest_size parameter to reflect the new space. 4. Delete unnecessary files using RMAN DELETE command. If an operating system command was used to delete files, then use RMAN CROSSCHECK and DELETE EXPIRED commands. ************************************************************************ ORA-19809: limit exceeded for recovery files ORA-19804: cannot reclaim 38451712 bytes disk space from 4102029312 limit *** 2018-08-09 17:47:48.882 4132 krsh.c ARC1: Error 19809 Creating archive log file to 'E:IDEPROSORACLE_HOMEFLASH_RECOVERY_AREAORCLARCHIVELOG2018_08_09O1_MF_1_5330_%U_.ARC' *** 2018-08-09 17:47:48.882 2747 krsi.c krsi_dst_fail: dest:1 err:19809 force:0 blast:1 DDE rules only execution for: ORA 312 ----- START Event Driven Actions Dump ---- ---- END Event Driven Actions Dump ---- ----- START DDE Actions Dump ----- Executing SYNC actions ----- START DDE Action: 'DB_STRUCTURE_INTEGRITY_CHECK' (Async) ----- DDE Action 'DB_STRUCTURE_INTEGRITY_CHECK' was flood controlled ----- END DDE Action: 'DB_STRUCTURE_INTEGRITY_CHECK' (FLOOD CONTROLLED, 0 csec) ----- Executing ASYNC actions ----- END DDE Actions Dump (total 0 csec) ----- *** 2018-08-09 17:47:48.882 4529 kcrr.c ORA-16038: log 2 sequence# 5330 cannot be archived ORA-19809: limit exceeded for recovery files ORA-00312: online log 2 thread 1: 'E:IDEPROSORACLE_HOMEORADATAORCLREDO02.LOG'
(2) 找出问题根源
从这里我们发现了问题的根源:
ORA-19815: WARNING: db_recovery_file_dest_size of 4102029312 bytes is 100.00% used, and has 0 remaining bytes available.
是db_recovery_file_dest_size也叫归档日志空间不足导致的,既然找到问题的根源,那解决起来也就容易了。 (3) 确定解决方法 ---设置归档日志空间的大小 空间小,那摆在我们面前办法就是,一个是将空间设置大点,另一个就是将多余的文件删除掉即可,那么我们就将这两个办法都使用一下。 CMD命令窗口启动: 方法1:设置归档日志空间的大小
-- at cmd sqlplus / as sysdba -- at sql shutdown abort ----关闭进程 startup mount ---- 装载数据库 select * from v$recovery_file_dest; ---查询归档日志 exit -- at cmd rman target / -- at rman db_recovery_file_dest_size = 6442450944; --设置归档日志空间为6G (6*1024*1024*1024) Exit ---到这里空间大小已经设置完成
方法2: 删除归档日志
rman target / -----进入rman工具窗口 RMAN>crosscheck archivelog all; --运行这个命令可以把无效的expired的archivelog标出来。 RMAN>delete noprompt archivelog until time "sysdate -3"; -- -即删除3天前的归档日志
2. ORA-39700: database must be opened with UPGRADE option
具体请参考
ORA-00704: bootstrap process failure ORA-39700: database must be opened with UPGRADE option
Oracle案例04——ORA-39700: database must be opened with UPGRADE option
错误出现的过程
SQL> startup ORA-01081: 无法启动已在运行的 ORACLE - 请首先关闭它 SQL> shutdown immediate ORA-01109: 数据库未打开 已经卸载数据库。 ORACLE 例程已经关闭。 SQL> startup ORACLE 例程已经启动。 Total System Global Area 3340451840 bytes Fixed Size 2180344 bytes Variable Size 1828719368 bytes Database Buffers 1493172224 bytes Redo Buffers 16379904 bytes 数据库装载完毕。 ORA-01092: ORACLE instance terminated. Disconnection forced ORA-00704: bootstrap process failure ORA-39700: database must be opened with UPGRADE option 进程 ID: 7660 会话 ID: 191 序列号: 3 SQL>
解决方法
通过数据字典升级解决
C:WindowsSystem32>sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on 星期四 8月 9 19:09:30 2018 Copyright (c) 1982, 2010, Oracle. All rights reserved. 已连接到空闲例程。 SQL> startup upgrade; ORACLE 例程已经启动。 Total System Global Area 3340451840 bytes Fixed Size 2180344 bytes Variable Size 1828719368 bytes Database Buffers 1493172224 bytes Redo Buffers 16379904 bytes 数据库装载完毕。 数据库已经打开。 SQL>
(2)查看预升级信息
SQL> @$ORACLE_HOME/rdbms/admin/utlu112i.sql
(3)执行升级脚本
SQL> @$ORACLE_HOME/rdbms/admin/catupgrd.sql
//这个过程时间比较长, 执行完上面操作执行,也可重新正常打开数据库即可。
SQL> @$ORACLE_HOME/rdbms/admin/utlu112s.sql
SQL> @$ORACLE_HOME/rdbms/admin/catuppst.sql
SQL> @$ORACLE_HOME/rdbms/admin/utlrp.sql
(4)重启数据库
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup;
3. ORA-01589: 要打开数据库则必须使用 RESETLOGS 或 NORESETLOGS 选项
参考 ORA-01589: 要打开数据库则必须使用 RESETLOGS 或 NOR
冷备份1.1中的内容后,在原地回复这些dbf文件,及参数、日志、控制重新覆盖在目标位置后,重新在sqlplus下执行1.2的步骤后,可能会出现如上的错误。解决办法如下:
SQL> alter database open resetlogs; alter database open resetlogs * ERROR 位于第 1 行: ORA-01113: 文件 1 需要介质恢复 ORA-01110: 数据文件 1: 'E:ORACLEORADATAEYGLESYSTEM01.DBF' SQL> recover database using backup controlfile; ORA-00279: 更改 1670743 (在 04/17/2008 14:13:16 生成) 对于线程 1 是必需的 ORA-00289: 建议: E:ORACLEORA92RDBMSARC00030.001 ORA-00280: 更改 1670743 对于线程 1 是按序列 # 30 进行的 指定日志: {=suggested | filename | AUTO | CANCEL} E:oracleoradataEYGLEREDO01.LOG ORA-00310: 存档日志包含序列 29;要求序列 30 ORA-00334: 归档日志: 'E:ORACLEORADATAEYGLEREDO01.LOG' SQL> recover database using backup controlfile; ORA-00279: 更改 1670743 (在 04/17/2008 14:13:16 生成) 对于线程 1 是必需的 ORA-00289: 建议: E:ORACLEORA92RDBMSARC00030.001 ORA-00280: 更改 1670743 对于线程 1 是按序列 # 30 进行的 指定日志: {=suggested | filename | AUTO | CANCEL} E:oracleoradataEYGLEREDO02.LOG 已应用的日志。 完成介质恢复。 SQL> alter database open resetlogs; 数据库已更改。