Oracle归档日志(翻译)

网址:http://cuddletech.com/articles/oracle/node58.html

      http://cuddletech.com/articles/index.shtml

参考网址:http://blog.csdn.net/tianlesoftware/article/details/4693470

           http://blog.csdn.net/tianlesoftware/article/details/5674309

    启用归档日至模式

Enabling ARCHIVELOG Mode

        Most of the High Availability features of Oracle require yaou to enable ARCHIVELOG mode for your database. When you enable this mode redo logs will be archived instead of overwritten. The archivelogs are stored in a seperate place usually can backed up regularly by your standard filesystem backup system (NetBackup or whatever). Archive logs are utilized by RMAN, Data Guard, Flashback and many others.

      Oracle许多的高可用的特性要求启用数据库的归档日志模式,当你启用归档日志模式,重做日志将会被归档而不是覆盖掉,归档日志被存放在分开的地方-通常是在备份文件系统中,归档日志可以用于RMAN,Data Guard,闪回和其他地方。

      If your going to enable archivelog mode on a real database thats important to you, I would recommend shutting down the database and doing a cold backup just in case. Keeping a "final noarchivelog mode backup" seems to be a good and excepted practice.

     如果你在一个非常重要的数据库中去启用归档日志模式,我建议你 Shut Down数据库,并对数据库做一个冷备(关闭状态备份,一致备份),

      Enabling archive mode is simple, just connect to your database in mounted but closed mode (startup mount) and alter the database. But if you don't tune a little you'll run into problems down the road, so lets specify some parameters too. Namely, consider LOG_ARCHIVE_DEST.

      启用归档模式非常的简单,连接你的数据库在mount状态但是处于关闭模式(使用startup mount),并且修改数据库,当前你还需要设置一些参数-也就是LOG_ARCHIVE_DEST(归档地址)

      Lets start by checking the current archive mode.(查看当前的数据库的归档模式)

SQL> SELECT LOG_MODE FROM SYS.V$DATABASE;

LOG_MODE
------------
NOARCHIVELOG

      So we're in NOARCHIVELOG mode and we need to change. We can use a database alter statement, but that won't be perminant, so lets just update the pfile directly. The pfile should be in either $ORACLE_BASE/admin/SID/pfile or $ORACLE_HOME/admin/SID/pfile. I'll add the following lines to the end of the file:

     当前处于非归档模式,我们需要进行改变,我们可以使用数据库的alter database语句,但是这不是永久改变的,所有我么需要直接修改spfile文件,spfile存在$ORACLE_BASE/admin/SID/pfile 或者$ORACLE_HOME/admin/SID/pfile第之下,可以直接在文件的末尾添加下列两行数据:

############################
# Archive Log Destinations -benr(10/15/04)
############################
log_archive_dest_1='location=/u02/oradata/cuddle/archive'
log_archive_start=TRUE

      Note that we're not actually required to specify the location of the log destination, but if you don't it'll end up in strange places (in my test it went to $ORACLE_HOME/dbs making a mess). You can specify as many as 10 diffrent archive log destinations by using the paramters log_archive_dest_1 through log_archive_dest_10. Remember, if you run out of space in your archive log destination the database will shut down!

    说明:实际上我们不需要指定日志的地址,但是,如果我们不进行指定,他将会存储在特定的地址,可以通过 log_archive_dest_N可以指定10个不同的归档日志地址,记住:当归档日志的地址满了之后,数据库将会挂起,直接Shut Down。

Now we can startup the database in mount mode and put it in archivelog mode.

[oracle@vixen pfile]$sqlplus sys/passwd as sysdba;
SQL*Plus: Release 10.1.0.2.0 - Production on Fri Oct 15 16:00:58 2004
Copyright (c) 1982, 2004, Oracle.  All rights reserved.
Connected to an idle instance.

SQL> startup mount
ORACLE instance started.

Total System Global Area  184549376 bytes
Fixed Size                  1300928 bytes
Variable Size             157820480 bytes
Database Buffers           25165824 bytes
Redo Buffers                 262144 bytes
Database mounted.

SQL> alter database archivelog;
Database altered.

SQL> alter database open;
Database altered.

       You can see here that we put the database in ARCHIVELOG mode by using the SQL statement "alter database archivelog", but Oracle won't let us do this unless the instance is mounted but not open. To make the change we shutdown the instance, and then startup the instance again but this time with the "mount" option which will mount the instance but not open it. Then we can enable ARCHIVELOG mode and open the database fully with the "alter database open" statement.

   我们通过SQL语句 "alter database archivelog"修改数据的归档模式,同理可得:当我们要取消归档日志模式,可以使用如下的SQL语句: "alter database noarchivelog",只有实例处于mount阶段但是没有打开,O染成了才允许我们进行如上的操作。为了进行归档模式的修改,我们需要关闭实例,然后,以mount模式启动数据库,在这种情况下,将会加载数据库,但是数据库处于未打开的状态,这时候,我们可以启用归档日至模式,随后,我们可以使用"alter database open"来打开我们的数据库。

There are several system views that can provide us with information reguarding archives, such as:

以下是归档中经常使用的视图:

V$DATABASE
Identifies whether the database is in ARCHIVELOG or NOARCHIVELOG mode and whether MANUAL (archiving mode) has been specified.
V$ARCHIVED_LOG
Displays historical archived log information from the control file. If you use a recovery catalog, the RC_ARCHIVED_LOG view contains similar information.
V$ARCHIVE_DEST
Describes the current instance, all archive destinations, and the current value, mode, and status of these destinations.
V$ARCHIVE_PROCESSES
Displays information about the state of the various archive processes for an instance.
V$BACKUP_REDOLOG
Contains information about any backups of archived logs. If you use a recovery catalog, the RC_BACKUP_REDOLOG contains similar information.
V$LOG
Displays all redo log groups for the database and indicates which need to be archived.
V$LOG_HISTORY
Contains log history information such as which logs have been archived and the SCN range for each archived log.

Using these tables we can verify that we are infact in ARCHIVELOG mode:

SQL> select log_mode from v$database;

LOG_MODE
------------
ARCHIVELOG

SQL> select DEST_NAME,STATUS,DESTINATION from V$ARCHIVE_DEST;

Learn more about managing archive redo logs in the Oracle Database Administrator's Guide:

---------------------------------------------------------------------------------

和归档模式有关的几个参数:

使用LOG_ARCHVEI_DEST_n 参数可以定义10个不同的归档日志目标。这些目录可以是本地目录,网络目录。

下面对一些参数做相关说明:

(1) LOG_ARCHIVE_STAT_n 参数:该参数为每个归档日志定义两种不同的状态: ENABLE和 DEFER,如果是ENABLE,则该归档目录是有效的,如果是DEFER,就不会在指定的LOG_ARCHIVE_DEST_n 进行归档。

(2) LOG_ARCHIVE_FORMAT 参数: Oracle 创建归档日志时,按按参数指定的格式,重命名归档日志。

(3) LOG_ARCHIVE_MIN_SUCCEED_DEST:  允许DBA定义归档日志目标副本的最小数据,这些副本必须成功。这样Oracle 才可以重用关联的redo online log

设置归档日志的格式:

格式参数的说明:

1:%d :唯一的数据库标识,如果多个数据库归档到同一个目录,这是必须的。

2:%t :线程号,显示为V$INSTANCE视图的THREAD#列。除了在RAC数据库中使用之外,这个变量没有任何的意义。

3:%r :场景(incarnation)号,如果进行了不完全恢复,这个变量就变得十分的重要,后面会进行详细的描述该变量。

4:%s :日志切换序列号,这个变量可以保证任何一个数据库中的归档日志文件都不会被彼此重写。

系统默认的格式为:

1 SQL> alter system set log_archive_max_processes = 5; 
2 SQL> alter system set log_archive_format ="archive_%t_%s_%r.log" scope=spfile;

Oracle默认的使用LOG_ARCHIVE_DEST_10作为Oracle的归档日志存放地

可以使用:

--强制切换日志,生成归档日志文件
ALTER SYSTEM SWITCH LOGFILE;
--强制的发出检察点进程
ALTER SYSTEM CHECKPOINT;

可以使用下面的命令重置:LOG_ARCHIVE_DEST_N为空,注意,没有使用LOCATION参数,但是在执行具体的归档位置的时候,需要使用location参数:

 alter system set log_archive_dest_1='';

在恢复和归档模式中常用的视图:

 1 SELECT * FROM v$rman_configuration;
 2 SELECT * FROM v$backup_files;
 3 SELECT * FROM v$backup_archivelog_details;
 4 SELECT * FROM v$backup_copy_details;
 5 SELECT * FROM v$backup_controlfile_details;
 6 SELECT * FROM v$backup_datafile_summary;
 7 SELECT * FROM v$backup_piece;
 8 SELECT * FROM v$backup_spfile;
 9 SELECT * FROM v$backup_redolog;
10 SELECT * FROM v$flash_recovery_area_usage;
11 SELECT * FROM v$parameter t WHERE t.name LIKE '%arch%';
12 SELECT * FROM v$parameter t WHERE t.name LIKE '%ontrol%';
13 SELECT * FROM v$archive_dest;
14 SELECT * FROM v$archive;
15 SELECT * FROM v$archive_dest_status;
16 SELECT * FROM v$archive_processes;
17 SELECT * FROM v$flash_recovery_area_usage;
18 SELECT * FROM v$log;
19 SELECT * FROM v$archive_dest;
20 SELECT * FROM v$archive_dest_status;
21 SELECT * FROM v$archived_log;
22 SELECT * FROM v$recovery_file_dest;
23 SELECT * FROM v$recovery_file_status;
24 SELECT * FROM v$recovery_log;
25 SELECT * FROM v$recovery_status;
26 SELECT * FROM v$log_history

---------

 

原文地址:https://www.cnblogs.com/caroline/p/2615780.html