重建控制文件,并且不干净的关闭数据库测试

简介: 重建控制文件,并且不干净的关闭数据库测试: 数据库SHUTDOWN ABORT,删除CONTROLFILE SQL> startup nomount;ORACLE instance started.

重建控制文件,并且不干净的关闭数据库测试:

数据库SHUTDOWN ABORT,删除CONTROLFILE

SQL> startup nomount;
ORACLE instance started.

Total System Global Area  419430400 bytes
Fixed Size                  2021248 bytes
Variable Size             171968640 bytes
Database Buffers          243269632 bytes
Redo Buffers                2170880 bytes
SQL> CREATE CONTROLFILE REUSE DATABASE "XUEXI" RESETLOGS  ARCHIVELOG
  2      MAXLOGFILES 16
  3      MAXLOGMEMBERS 3
  4      MAXDATAFILES 100
  5      MAXINSTANCES 8
  6      MAXLOGHISTORY 292
  7  LOGFILE
  8    GROUP 1 '/oradata/xuexi/redo01.log'  SIZE 50M,
  9    GROUP 2 '/oradata/xuexi/redo02.log'  SIZE 50M,
 10    GROUP 3 '/oradata/xuexi/redo03.log'  SIZE 50M,
 11    GROUP 4 '/oradata/XUEXI/onlinelog/o1_mf_4_8yqwxqsh_.log'  SIZE 50M,
 12    GROUP 5 (
 13      '/oradata/XUEXI/onlinelog/o1_mf_5_8yqx1d59_.log',
 14      '/oradata/XUEXI/onlinelog/o1_mf_5_8yqx1gvx_.log'
 15    ) SIZE 50M,
 16    GROUP 7 (
 17      '/oradata/XUEXI/onlinelog/o1_mf_7_8zl9m1ro_.log',
 18      '/oradata/XUEXI/onlinelog/o1_mf_7_8zl9m3gj_.log',
 19      '/oradata/logfile07.log'
 20    ) SIZE 100M
 21  -- STANDBY LOGFILE
 22  DATAFILE
 23    '/oradata/xuexi/system01.dbf',
 24    '/oradata/xuexi/undotbs01.dbf',
 25    '/oradata/xuexi/sysaux01.dbf',
 26    '/oradata/xuexi/users01.dbf',
 27    '/oradata/xuexi/XUEXI/datafile/o1_mf_tomf_8yqwrdoj_.dbf',
 28    '/oradata/xuexi/omf2.dbf',
 29    '/oradata/xuexi/XUEXI/datafile/testimp01.dbf',
 30    '/oradata/xuexi/XUEXI/datafile/testimp011.dbf',
 31    '/oradata/xuexi/XUEXI/datafile/testo1.dbf',
 32    '/oradata/xuexi/XUEXI/datafile/testo2.dbf'
 33  CHARACTER SET AL32UTF8
 34  ;

Control file created.

SQL> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-01100: database already mounted


SQL> recover database ;
ORA-00283: recovery session canceled due to errors
ORA-01610: recovery using the BACKUP CONTROLFILE option must be done

 

SQL> RECOVER DATABASE USING BACKUP CONTROLFILE;
ORA-00279: change 1917689 generated at 10/04/2013 21:15:57 needed for thread 1
ORA-00289: suggestion : /archive/1_102_822387818.dbf
ORA-00280: change 1917689 for thread 1 is in sequence #102


Specify log: {=suggested | filename | AUTO | CANCEL}
auto
ORA-00308: cannot open archived log '/archive/1_102_822387818.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3


ORA-00308: cannot open archived log '/archive/1_102_822387818.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory

显然这里缺少102这个归档,因为他是当前日志文件,所以我们需要把日志复制到归档目录下,但是那个日志是102呢,这样就可以确定
[oracle@localhost bdump]$ tail -n 4000 alert_xuexi.log |grep Current
  Current log# 4 seq# 100 mem# 0: /oradata/XUEXI/onlinelog/o1_mf_4_8yqwxqsh_.log
  Current log# 4 seq# 100 mem# 0: /oradata/XUEXI/onlinelog/o1_mf_4_8yqwxqsh_.log
  Current log# 5 seq# 101 mem# 0: /oradata/XUEXI/onlinelog/o1_mf_5_8yqx1d59_.log
  Current log# 5 seq# 101 mem# 1: /oradata/XUEXI/onlinelog/o1_mf_5_8yqx1gvx_.log
  Current log# 7 seq# 102 mem# 0: /oradata/XUEXI/onlinelog/o1_mf_7_8zl9m1ro_.log
  Current log# 7 seq# 102 mem# 1: /oradata/XUEXI/onlinelog/o1_mf_7_8zl9m3gj_.log
  Current log# 7 seq# 102 mem# 2: /oradata/logfile07.log
  可以确认/oradata/logfile07.log就是需要的归档
cp /oradata/logfile07.log /archive/1_102_822387818.dbf

SQL> recover database using backup controlfile
ORA-00279: change 1917689 generated at 10/04/2013 21:15:57 needed for thread 1
ORA-00289: suggestion : /archive/1_102_822387818.dbf
ORA-00280: change 1917689 for thread 1 is in sequence #102

Specify log: {=suggested | filename | AUTO | CANCEL}
AUTO
完成后即可
当然也快手动输入你确认的当前归档如下:
SQL> recover database using backup controlfile
ORA-00279: change 1917689 generated at 10/04/2013 21:15:57 needed for thread 1
ORA-00289: suggestion : /archive/1_102_822387818.dbf
ORA-00280: change 1917689 for thread 1 is in sequence #102

Specify log: {=suggested | filename | AUTO | CANCEL}
/oradata/logfile07.log
Log applied.
Media recovery complete.
SQL> alter database open resetlogs;

SQL> alter database open resetlogs;

Database altered.
Log applied.
Media recovery complete.


alter database backup controlfile to trace 全文
/opt/oracle/admin/xuexi/udump/xuexi_ora_5686.trc
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
ORACLE_HOME = /opt/oracle/product/10.2.0/db_1
System name:    Linux
Node name:      localhost.localdomain
Release:        2.6.18-164.el5
Version:        #1 SMP Tue Aug 18 15:51:48 EDT 2009
Machine:        x86_64
Instance name: xuexi
Redo thread mounted by this instance: 1
Oracle process number: 18
Unix process pid: 5686, image: oracle@localhost.localdomain (TNS V1-V3)

*** SERVICE NAME:(SYS$USERS) 2013-10-04 21:38:20.304
*** SESSION ID:(146.91) 2013-10-04 21:38:20.304
*** 2013-10-04 21:38:20.304
-- The following are current System-scope REDO Log Archival related
-- parameters and can be included in the database initialization file.
--
-- LOG_ARCHIVE_DEST=''
-- LOG_ARCHIVE_DUPLEX_DEST=''
--
-- LOG_ARCHIVE_FORMAT=%t_%s_%r.dbf
--
-- DB_UNIQUE_NAME="xuexi"
--
-- LOG_ARCHIVE_CONFIG='SEND, RECEIVE, NODG_CONFIG'
-- LOG_ARCHIVE_MAX_PROCESSES=2
-- STANDBY_FILE_MANAGEMENT=MANUAL
-- STANDBY_ARCHIVE_DEST=?/dbs/arch
-- FAL_CLIENT=''
-- FAL_SERVER=''
--
-- LOG_ARCHIVE_DEST_1='LOCATION=/archive'
-- LOG_ARCHIVE_DEST_1='OPTIONAL REOPEN=300 NODELAY'
-- LOG_ARCHIVE_DEST_1='ARCH NOAFFIRM NOEXPEDITE NOVERIFY SYNC'
-- LOG_ARCHIVE_DEST_1='REGISTER NOALTERNATE NODEPENDENCY'
-- LOG_ARCHIVE_DEST_1='NOMAX_FAILURE NOQUOTA_SIZE NOQUOTA_USED NODB_UNIQUE_NAME'
-- LOG_ARCHIVE_DEST_1='VALID_FOR=(PRIMARY_ROLE,ONLINE_LOGFILES)'
-- LOG_ARCHIVE_DEST_STATE_1=ENABLE
--
-- Below are two sets of SQL statements, each of which creates a new
-- control file and uses it to open the database. The first set opens
-- the database with the NORESETLOGS option and should be used only if
-- the current versions of all online logs are available. The second
-- set opens the database with the RESETLOGS option and should be used
-- if online logs are unavailable.
-- The appropriate set of statements can be copied from the trace into
-- a script. file, edited as necessary, and executed when there is a
-- need to re-create the control file.
--
--     Set #1. NORESETLOGS case
--
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- Additional logs may be required for media recovery of offline
-- Use this only if the current versions of all online logs are
-- available.
-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
--  ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "XUEXI" NORESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/oradata/xuexi/redo01.log'  SIZE 50M,
  GROUP 2 '/oradata/xuexi/redo02.log'  SIZE 50M,
  GROUP 3 '/oradata/xuexi/redo03.log'  SIZE 50M,
  GROUP 4 '/oradata/XUEXI/onlinelog/o1_mf_4_8yqwxqsh_.log'  SIZE 50M,
  GROUP 5 (
    '/oradata/XUEXI/onlinelog/o1_mf_5_8yqx1d59_.log',
    '/oradata/XUEXI/onlinelog/o1_mf_5_8yqx1gvx_.log'
  ) SIZE 50M,
  GROUP 7 (
    '/oradata/XUEXI/onlinelog/o1_mf_7_8zl9m1ro_.log',
    '/oradata/XUEXI/onlinelog/o1_mf_7_8zl9m3gj_.log',
    '/oradata/logfile07.log'
  ) SIZE 100M
-- STANDBY LOGFILE
DATAFILE
  '/oradata/xuexi/system01.dbf',
  '/oradata/xuexi/undotbs01.dbf',
  '/oradata/xuexi/sysaux01.dbf',
  '/oradata/xuexi/users01.dbf',
  '/oradata/xuexi/XUEXI/datafile/o1_mf_tomf_8yqwrdoj_.dbf',
  '/oradata/xuexi/omf2.dbf',
  '/oradata/xuexi/XUEXI/datafile/testimp01.dbf',
  '/oradata/xuexi/XUEXI/datafile/testimp011.dbf',
  '/oradata/xuexi/XUEXI/datafile/testo1.dbf',
  '/oradata/xuexi/XUEXI/datafile/testo2.dbf'
CHARACTER SET AL32UTF8
;
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822350387.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822350760.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822330757.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822350003.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822349246.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822350252.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822374325.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822387818.dbf';
-- Recovery is required if any of the datafiles are restored backups,
-- or if the last shutdown was not normal or immediate.
RECOVER DATABASE
-- All logs need archiving and a log switch is needed.
ALTER SYSTEM ARCHIVE LOG ALL;
-- Database can now be opened normally.
ALTER DATABASE OPEN;
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP1 ADD TEMPFILE '/oradata/xuexi/temp011.dbf'
     SIZE 19922944  REUSE AUTOEXTEND ON NEXT 8192  MAXSIZE 5120M;
-- End of tempfile additions.
--
--     Set #2. RESETLOGS case
--
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- The contents of online logs will be lost and all backups will
-- be invalidated. Use this only if online logs are damaged.
-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
--  ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "XUEXI" RESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/oradata/xuexi/redo01.log'  SIZE 50M,
  GROUP 2 '/oradata/xuexi/redo02.log'  SIZE 50M,
  GROUP 3 '/oradata/xuexi/redo03.log'  SIZE 50M,
  GROUP 4 '/oradata/XUEXI/onlinelog/o1_mf_4_8yqwxqsh_.log'  SIZE 50M,
  GROUP 5 (
    '/oradata/XUEXI/onlinelog/o1_mf_5_8yqx1d59_.log',
    '/oradata/XUEXI/onlinelog/o1_mf_5_8yqx1gvx_.log'
  ) SIZE 50M,
  GROUP 7 (
    '/oradata/XUEXI/onlinelog/o1_mf_7_8zl9m1ro_.log',
    '/oradata/XUEXI/onlinelog/o1_mf_7_8zl9m3gj_.log',
    '/oradata/logfile07.log'
  ) SIZE 100M
-- STANDBY LOGFILE
DATAFILE
  '/oradata/xuexi/system01.dbf',
  '/oradata/xuexi/undotbs01.dbf',
  '/oradata/xuexi/sysaux01.dbf',
  '/oradata/xuexi/users01.dbf',
  '/oradata/xuexi/XUEXI/datafile/o1_mf_tomf_8yqwrdoj_.dbf',
  '/oradata/xuexi/omf2.dbf',
  '/oradata/xuexi/XUEXI/datafile/testimp01.dbf',
  '/oradata/xuexi/XUEXI/datafile/testimp011.dbf',
  '/oradata/xuexi/XUEXI/datafile/testo1.dbf',
  '/oradata/xuexi/XUEXI/datafile/testo2.dbf'
CHARACTER SET AL32UTF8
;
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822350387.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822350760.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822330757.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822350003.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822349246.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822350252.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822374325.dbf';
-- ALTER DATABASE REGISTER LOGFILE '/archive/1_1_822387818.dbf';
-- Recovery is required if any of the datafiles are restored backups,
-- or if the last shutdown was not normal or immediate.
RECOVER DATABASE USING BACKUP CONTROLFILE
-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP1 ADD TEMPFILE '/oradata/xuexi/temp011.dbf'
     SIZE 19922944  REUSE AUTOEXTEND ON NEXT 8192  MAXSIZE 5120M;
-- End of tempfile additions.
--

相关文章
|
2月前
|
SQL 关系型数据库 MySQL
数据库导入SQL文件:全面解析与操作指南
在数据库管理中,将SQL文件导入数据库是一个常见且重要的操作。无论是迁移数据、恢复备份,还是测试和开发环境搭建,掌握如何正确导入SQL文件都至关重要。本文将详细介绍数据库导入SQL文件的全过程,包括准备工作、操作步骤以及常见问题解决方案,旨在为数据库管理员和开发者提供全面的操作指南。一、准备工作在导
430 0
|
4天前
|
Linux Shell 网络安全
Kali Linux系统Metasploit框架利用 HTA 文件进行渗透测试实验
本指南介绍如何利用 HTA 文件和 Metasploit 框架进行渗透测试。通过创建反向 shell、生成 HTA 文件、设置 HTTP 服务器和发送文件,最终实现对目标系统的控制。适用于教育目的,需合法授权。
29 9
Kali Linux系统Metasploit框架利用 HTA 文件进行渗透测试实验
|
9天前
|
关系型数据库 MySQL 数据库
数据库数据恢复—MYSQL数据库文件损坏的数据恢复案例
mysql数据库文件ibdata1、MYI、MYD损坏。 故障表现:1、数据库无法进行查询等操作;2、使用mysqlcheck和myisamchk无法修复数据库。
|
13天前
|
SQL 关系型数据库 MySQL
MySQL导入.sql文件后数据库乱码问题
本文分析了导入.sql文件后数据库备注出现乱码的原因,包括字符集不匹配、备注内容编码问题及MySQL版本或配置问题,并提供了详细的解决步骤,如检查和统一字符集设置、修改客户端连接方式、检查MySQL配置等,确保导入过程顺利。
|
2月前
|
运维
【运维基础知识】用dos批处理批量替换文件中的某个字符串(本地单元测试通过,部分功能有待优化,欢迎指正)
该脚本用于将C盘test目录下所有以t开头的txt文件中的字符串“123”批量替换为“abc”。通过创建批处理文件并运行,可实现自动化文本替换,适合初学者学习批处理脚本的基础操作与逻辑控制。
173 56
|
21天前
|
Oracle 关系型数据库 数据库
Oracle数据恢复—Oracle数据库文件有坏快损坏的数据恢复案例
一台Oracle数据库打开报错,报错信息: “system01.dbf需要更多的恢复来保持一致性,数据库无法打开”。管理员联系我们数据恢复中心寻求帮助,并提供了Oracle_Home目录的所有文件。用户方要求恢复zxfg用户下的数据。 由于数据库没有备份,无法通过备份去恢复数据库。
|
26天前
|
数据库连接 Go 数据库
Go语言中的错误注入与防御编程。错误注入通过模拟网络故障、数据库错误等,测试系统稳定性
本文探讨了Go语言中的错误注入与防御编程。错误注入通过模拟网络故障、数据库错误等,测试系统稳定性;防御编程则强调在编码时考虑各种错误情况,确保程序健壮性。文章详细介绍了这两种技术在Go语言中的实现方法及其重要性,旨在提升软件质量和可靠性。
27 1
|
2月前
|
SQL 关系型数据库 MySQL
|
2月前
|
存储 关系型数据库 MySQL
PACS系统 中 dicom 文件在mysql 8.0 数据库中的 存储和读取(pydicom 库使用)
PACS系统 中 dicom 文件在mysql 8.0 数据库中的 存储和读取(pydicom 库使用)
42 2
|
3月前
|
Oracle 关系型数据库 数据库
数据库数据恢复—Oracle数据库文件出现坏块的数据恢复案例
打开oracle数据库报错“system01.dbf需要更多的恢复来保持一致性,数据库无法打开”。 数据库没有备份,无法通过备份去恢复数据库。用户方联系北亚企安数据恢复中心并提供Oracle_Home目录中的所有文件,急需恢复zxfg用户下的数据。 出现“system01.dbf需要更多的恢复来保持一致性”这个报错的原因可能是控制文件损坏、数据文件损坏,数据文件与控制文件的SCN不一致等。数据库恢复工程师对数据库文件进一步检测、分析后,发现sysaux01.dbf文件损坏,有坏块。 修复并启动数据库后仍然有许多查询报错,export和data pump工具使用报错。从数据库层面无法修复数据库。
数据库数据恢复—Oracle数据库文件出现坏块的数据恢复案例