首页 > 其他分享 >所有控制文件丢失后的恢复

所有控制文件丢失后的恢复

时间:2024-09-12 11:54:11浏览次数:9  
标签:opt 文件 恢复 dbf oradata O19C 丢失 oracle ORA

  1. 使用备份控制文件进行恢复
		a. 准备数据库
		create table tb01(id int);
		insert into tb01 values(1);
		insert into tb01 values(2);
		commit;
		b. 备份控制文件
		SQL> select name from v$controlfile;
		NAME
		--------------------------------------------------------------------------------
		/opt/oracle/oradata/O19C/control01.ctl
		/opt/oracle/oradata/O19C/control02.ctl
		
		[oracle@oracle19c ~]$ cd  /opt/oracle/oradata/O19C
		[oracle@oracle19c O19C]$ cp control0*  /opt/oracle/pbak/
		c. 插入数据
		insert into tb01 values(3);
		commit;
		d. 删除控制文件,模拟控制文件损坏
		[oracle@oracle19c O19C]$ rm -rf control0*
		e. 关闭数据库
		SQL> alter system checkpoint;
		SQL> shutdown abort;     
		ORACLE instance shut down.
		
		f. 还原控制文件
		SQL> startup;      
		ORACLE instance started.
		Total System Global Area 2432695144 bytes
		Fixed Size		    8899432 bytes
		Variable Size		  536870912 bytes
		Database Buffers	 1879048192 bytes
		Redo Buffers		    7876608 bytes
		ORA-00205: error in identifying control file, check alert log for more info
		
		#还原控制文件
		[oracle@oracle19c O19C]$ cp /opt/oracle/pbak/control0* ./
		
		SQL> alter database mount;
		
		SQL> recover database using backup controlfile;   
		#如果打开了flashback 这里会报错:
		
		ORA-00279: change 2249134 generated at 08/19/2024 09:44:41 needed for thread 1
		ORA-00289: suggestion :
		/opt/oracle/product/19c/dbhome_1/dbs/arch1_7_1175272692.dbf
		ORA-00280: change 2249134 for thread 1 is in sequence #7
		
		Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
		auto
		ORA-00308: cannot open archived log
		'/opt/oracle/product/19c/dbhome_1/dbs/arch1_7_1175272692.dbf'
		ORA-27037: unable to obtain file status
		Linux-x86_64 Error: 2: No such file or directory
		Additional information: 7
		
		
		ORA-00308: cannot open archived log
		'/opt/oracle/product/19c/dbhome_1/dbs/arch1_7_1175272692.dbf'
		ORA-27037: unable to obtain file status
		Linux-x86_64 Error: 2: No such file or directory
		Additional information: 7
		--------------------------------------
		
		SQL> recover database using backup controlfile;
		ORA-00279: change 2249134 generated at 08/19/2024 09:44:41 needed for thread 1
		ORA-00289: suggestion :
		/opt/oracle/product/19c/dbhome_1/dbs/arch1_7_1175272692.dbf
		ORA-00280: change 2249134 for thread 1 is in sequence #7
		
		
		Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
		/opt/oracle/oradata/O19C/redo01.log     #这里要按个尝试未归档的日志文件,知道出现下面的情况
		Log applied.
		Media recovery complete.
		
		
		SQL> alter database open;
		alter database open
		*
		ERROR at line 1:
		ORA-01589: must use RESETLOGS or NORESETLOGS option for database open
		SQL> alter database open resetlogs;
		SQL> select * from tb01;
		
			ID
		----------
			 1
			 2
			 3
	g.执行不完全恢复后的全备
  1. 使用备份控制文件进行恢复(备份后新增数据文件)
		a. 现状查看
		SQL> select * from tb01;
			ID
		----------
			 1
			 2
			 3
		SQL> select open_mode from v$database;
		OPEN_MODE
		----------------------------------------
		READ WRITE
		b. 备份控制文件
		SQL> select name from v$controlfile;
		NAME
		--------------------------------------------------------------------------------
		/opt/oracle/oradata/O19C/control01.ctl
		/opt/oracle/oradata/O19C/control02.ctl
		
		[oracle@oracle19c ~]$ cd  /opt/oracle/oradata/O19C
		[oracle@oracle19c O19C]$ cp control0*  /opt/oracle/pbak/
		
		c. 新建表空间
		SQL> create tablespace tbs_aw datafile '/opt/oracle/oradata/O19C/aw01.dbf' size 20M,'/opt/oracle/oradata/O19C/aw02.dbf' size 20M;
		d. 模拟数据库故障
		[oracle@oracle19c O19C]$ rm -rf control0*
		SQL> shutdown abort;
		ORACLE instance shut down.
		e. 还原控制文件
		[oracle@oracle19c O19C]$ cp /opt/oracle/pbak/control0* ./
		f. 恢复数据库
		SQL> startup mount;
		ORACLE instance started.
		
		Total System Global Area 2432695144 bytes
		Fixed Size		    8899432 bytes
		Variable Size		  536870912 bytes
		Database Buffers	 1879048192 bytes
		Redo Buffers		    7876608 bytes
		Database mounted.
		SQL> recover database using backup controlfile;
		ORA-00279: change 2250967 generated at 09/12/2024 10:10:47 needed for thread 1
		ORA-00289: suggestion :
		/opt/oracle/product/19c/dbhome_1/dbs/arch1_1_1179483047.dbf
		ORA-00280: change 2250967 for thread 1 is in sequence #1
		
		Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
		/opt/oracle/oradata/O19C/redo03.log 
		ORA-00339: archived log does not contain any redo
		ORA-00334: archived log: '/opt/oracle/oradata/O19C/redo03.log'
		
		SQL> recover database using backup controlfile;
		ORA-00279: change 2250967 generated at 09/12/2024 10:10:47 needed for thread 1
		ORA-00289: suggestion :
		/opt/oracle/product/19c/dbhome_1/dbs/arch1_1_1179483047.dbf
		ORA-00280: change 2250967 for thread 1 is in sequence #1
		
		Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
		/opt/oracle/oradata/O19C/redo02.log 
		ORA-00326: log begins at change 2351431, need earlier change 2250967
		ORA-00334: archived log: '/opt/oracle/oradata/O19C/redo02.log'
		
		SQL> recover database using backup controlfile;
		ORA-00279: change 2250967 generated at 09/12/2024 10:10:47 needed for thread 1
		ORA-00289: suggestion :
		/opt/oracle/product/19c/dbhome_1/dbs/arch1_1_1179483047.dbf
		ORA-00280: change 2250967 for thread 1 is in sequence #1
		
		Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
		/opt/oracle/oradata/O19C/redo01.log 
		ORA-00283: recovery session canceled due to errors
		ORA-01244: unnamed datafile(s) added to control file by media recovery
		ORA-01110: data file 8: '/opt/oracle/oradata/O19C/aw02.dbf'
		ORA-01110: data file 5: '/opt/oracle/oradata/O19C/aw01.dbf'
		ORA-01112: media recovery not started
		
		SQL>  select file#, name FROM v$datafile;
		     FILE#        NAME
		-------------------------------------------------------------------------
			 1      /opt/oracle/oradata/O19C/system01.dbf
			 3      /opt/oracle/oradata/O19C/sysaux01.dbf
			 4      /opt/oracle/oradata/O19C/undotbs01.dbf
			 5      /opt/oracle/product/19c/dbhome_1/dbs/UNNAMED00005
			 7      /opt/oracle/oradata/O19C/users01.dbf
			 8      /opt/oracle/product/19c/dbhome_1/dbs/UNNAMED00008
			
		SQL> alter database rename file '/opt/oracle/product/19c/dbhome_1/dbs/UNNAMED00005' to '/opt/oracle/oradata/O19C/aw01.dbf';
		SQL> alter database rename file '/opt/oracle/product/19c/dbhome_1/dbs/UNNAMED00008' to '/opt/oracle/oradata/O19C/aw02.dbf';
		
		SQL>  select file#, name FROM v$datafile;
		     FILE#        NAME
		-------------------------------------------------------------------------
			 1      /opt/oracle/oradata/O19C/system01.dbf
			 3      /opt/oracle/oradata/O19C/sysaux01.dbf
			 4      /opt/oracle/oradata/O19C/undotbs01.dbf
			 5      /opt/oracle/oradata/O19C/aw01.dbf
			 7      /opt/oracle/oradata/O19C/users01.dbf
			 8      /opt/oracle/oradata/O19C/aw02.dbf
		
		SQL> recover database using backup controlfile;
		ORA-00279: change 2251400 generated at 09/12/2024 10:19:36 needed for thread 1
		ORA-00289: suggestion : /opt/oracle/product/19c/dbhome_1/dbs/arch1_1_1179483047.dbf
		ORA-00280: change 2251400 for thread 1 is in sequence #1
		
		Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
		/opt/oracle/oradata/O19C/redo01.log 
		ORA-00279: change 2351431 generated at 09/12/2024 10:21:49 needed for thread 1
		ORA-00289: suggestion : /opt/oracle/product/19c/dbhome_1/dbs/arch1_2_1179483047.dbf
		ORA-00280: change 2351431 for thread 1 is in sequence #2
		ORA-00278: log file '/opt/oracle/oradata/O19C/redo01.log' no longer needed for this recovery
		
		Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
		/opt/oracle/oradata/O19C/redo02.log 
		Log applied.
		Media recovery complete.
		
		SQL> alter database open resetlogs;
		g. 进行恢复后的全备


标签:opt,文件,恢复,dbf,oradata,O19C,丢失,oracle,ORA
From: https://blog.51cto.com/ablewang/11990448

相关文章

  • 在线重做日志丢失后的恢复
    丢失多路复用日志组成员的恢复 a.准备数据 #创建一个新的日志组 SQL>selectgroup#,memberfromv$logfile; GROUP#MEMBER ----------------------------------------------- 3/opt/oracle/oradata/O19C/redo03.log 2/opt/oracle/oradata/O19C/r......
  • 硬盘数据恢复工具,测评八款软件 帮你恢复删除的文件
    在日常使用电脑的时候,很多用户都有过误删除重要文件、硬盘无法访问或是格式化后丢失重要数据的经历。幸运的是,这些重要的数据并非在删除或硬盘格式化后就完全消失不见了,我们借助硬盘数据恢复工具仍然有很大几率恢复丢失的数据。今天会和大家讨论一下硬盘数据恢复工具的工作原理和局......
  • 硬盘数据恢复工具,测评八款软件 帮你恢复删除的文件
    在日常使用电脑的时候,很多用户都有过误删除重要文件、硬盘无法访问或是格式化后丢失重要数据的经历。幸运的是,这些重要的数据并非在删除或硬盘格式化后就完全消失不见了,我们借助硬盘数据恢复工具仍然有很大几率恢复丢失的数据。今天会和大家讨论一下硬盘数据恢复工具的工作原理和局......
  • mysql 5.7 删除ibdata1 、ib_logfile 文件的数据恢复
    简介:本文记录删除ibdata1、ib_logfile文件被意外删除且无法还原或损坏的解决方案,当删除后没有重启mysql可以查询进程号,找到删除的文件可以还原回来。参考其他文章。本文介绍ibdata1、ib_logfile文件无法找到或异常没有备份的情况处理。 新安装一台mysql用作从库......
  • 使用go来做加密解密文件或者字符串
    你可以使用Linux命令行中的openssl或gpg进行加密,然后在Go程序中使用相关的库来解密。方案1:使用OpenSSL进行加密,Go程序解密1.命令行加密使用openssl在命令行中对token进行加密,并保存加密结果:echo-n"your_token"|opensslenc-aes-256-cbc-a-salt-pas......
  • JMeter jmx脚本文件解析
    JMeter——jmx脚本文件解析_jmx文件线程组解析-CSDN博客<?xmlversion="1.0"encoding="UTF-8"?><jmeterTestPlanversion="1.2"properties="5.0"jmeter="5.5"><hashTree><TestPlanguiclass="TestP......
  • 使用Python递归比较两个文件夹下所有文件内容不同的文件
    比较两份源代码文件异同使用Python递归比较两个文件夹下所有同名文件内容中存在不同的文件。这么做的应用场景是做代码审计的时候,通过比对两份相同项目的源代码,一份是破解的版本一份是正版的版本,比对破解的版本更改了哪些代码,从而挖掘后门代码。具体代码如下:importosimpo......
  • Apache+PHP设置支持大文件上传
    一、Apache配置文件(httpd.conf)更改FastCGI进程能够处理的HTTP请求的最大长度限制,单位为字节(Bytes) FcgidMaxRequestLen524288000 二、PHP配置文件(php.ini) #是否允许通过HTTP上传文件的开关。默认为ON即是开【一般不做修改】file_uploads=On#上传服务器时存储......
  • HEXDUMP.EXE 是一个常用的工具,用于查看和显示二进制文件的内容,以十六进制格式呈现。它
    HEXDUMP.EXE是一种早期的计算机程序,用于显示文件的十六进制表示。其起源可以追溯到早期的计算机系统,特别是在UNIX操作系统中。最早的hexdump工具出现在UNIX系统中,它允许用户以十六进制和ASCII格式查看文件内容。这个工具在许多操作系统和编程环境中都得到了实现和扩展,以......
  • Python中如何将图片资源打包进exe文件
    目录一、安装PyInstaller二、准备图片资源三、修改图片资源的引用方式1.使用Base64编码2.修改资源路径的引用1.打包命令2.打包后的文件3.运行exe文件五、案例与测试六、总结在Python开发中,经常需要将图片等资源文件与Python脚本一起打包成独立的可执行文件(ex......