Oracle 数据库重做日志切换

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18850005/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 01:55:31  来源:igfitidea点击:

Oracle database redo log switch

oraclelogging

提问by robertpas

I want to recreate the redo logs of an Oracle database, but I seem to have hit a dead end.

我想重新创建一个 Oracle 数据库的重做日志,但我似乎陷入了死胡同。

When i call

当我打电话

SELECT GROUP#, ARCHIVED, STATUS FROM V$LOG;

I get the following

我得到以下

 GROUP# ARC STATUS
---------- --- ----------------
     1 NO  CURRENT
     4 YES UNUSED
     3 YES UNUSED
     2 YES UNUSED

The thing is, I have to delete the redo log number 1, but can't because #1 is the current redo log. How do I switch between logs?

问题是,我必须删除重做日志编号 1,但不能因为 #1 是当前重做日志。如何在日志之间切换?

I have also tried ALTER SYSTEM SWITCH LOGFILE;, but I get an error saying that the Database is not open. ORA-01109. The database is only mounted(not in read write mode), and I cannot open itdue to the redo logs being corrupt. Also, to even mount the database redolog1 from another DB was used. #2,#3 and #4 were recreated successfully because they were not current.

我也试过ALTER SYSTEM SWITCH LOGFILE;,但我收到一条错误消息,说数据库未打开。ORA-01109. 数据库仅挂载(未处于读写模式),由于重做日志已损坏,我无法打开它。此外,甚至使用了从另一个数据库安装数据库 redolog1。#2、#3 和 #4 已成功重新创建,因为它们不是最新的。

Does anyone have any idea? Any help is much appreciated.

有谁有想法吗?任何帮助深表感谢。

Thanks in advance!

提前致谢!

回答by Nick Krasnov

This error(ORA-01109) indicates that you are trying to perform an operation on a closed database. So, probably, your database instance has been started with only option mount, leaving database closed. You simply need to open database and retry alter systemcommand:

此错误 (ORA-01109) 表示您正在尝试对已关闭的数据库执行操作。因此,可能您的数据库实例仅使用 option 启动mount,而使数据库关闭。您只需要打开数据库并重试alter system命令:

SQL> alter system switch logfile;
alter system switch logfile
*
ERROR at line 1:
ORA-01109: database not open 


SQL> alter database open;

Database altered.

SQL> alter system switch logfile;

System altered.


Edit

编辑

if you are getting this error

如果您收到此错误

SQL> alter database open; alter database open * ERROR at line 1:
ORA-00305: log 1 of thread 1 inconsistent; belongs to another database
ORA-00312: online log 1 thread 1: '/oradata/DB/PRBT/redo1B.log'
ORA-00305: log 1 of thread 1 inconsistent; belongs to another database
ORA-00312: online log 1 thread 1: '/oradata/DB/PRBT/redo1A.log'

SQL> 更改数据库打开;更改数据库打开 * 第 1 行出现错误:
ORA-00305:线程 1 的日志 1 不一致;属于另一个数据库
ORA-00312:在线日志 1 线程 1:'/oradata/DB/PRBT/redo1B.log'
ORA- 00305 :线程 1 的日志 1 不一致;属于另一个数据库
ORA-00312: online log 1 thread 1: '/oradata/DB/PRBT/redo1A.log'

while trying to open your database, it's very likely that database ID in the log file and database ID in control file do not match. To put it simply, log file from a different database. To bring your database to live you could try the following;

在尝试打开数据库时,日志文件中的数据库 ID 和控制文件中的数据库 ID 很可能不匹配。简而言之,就是一个不同数据库的日志文件。要使您的数据库生效,您可以尝试以下操作;

  1. Mount your database
  2. recover database until cancel
  3. Then open database with resetlogs option
  1. 挂载你的数据库
  2. 恢复数据库直到取消
  3. 然后使用 resetlogs 选项打开数据库

Example:

例子:

SQL> startup mount;
ORACLE instance started.
Database mounted.

SQL> recover database until cancel;
Media recovery complete.

SQL> alter database open resetlogs;

Database altered.