Configuring the Database Archiving Mode_hive

归档的内容, 在 oracle10g 以后, 只需要设置以下方面内容:

1. 将数据库设置成 archivelog 模式

    startup mount -> alter database archivelog

2. 设置 archivelog 归档文件的路径

    alter system set log_archive_dest_1="location=/u01/app/oracle/archivelog" scope=both;

3. 设置 归档日志的格式

    alter system set log_archive_format=”arch%t_%s_%r.arc” scope=spfile;

至于数据库启动后, 自动启动归档日志的那个参数, 就不需要了, 因为 oracle10g 以后就会自动设置自动启动

一般都是自动归档

后面几章的备份与恢复, 是严格以来 archivelog 模式的, 如果不是archivelog 模式, 那么数据库只能恢复到上次的全备份.


- 调节成自动归档步骤(个人设定)

需要设定的参数有: (其余参数先默认就可以了) 

1. 归档的地址(本地和远程)

alter system set log_archive_dest_1="location=/u01/app/oracle/archivelog" scope=both;  -- 本地

2. 归档文件的 format

alter system set log_archive_format=”arch%s.arc” scope=spfile;

oracle 10g 以后对这个format 有了要求, 所以修改为 alter system set log_archive_format=”arch_%t_%s.”

3. 设置自动归档 alter system set log_archive_format=”arch%t_%s_%r.arc” scope=spfile;

alter system set log_archive_start=true scope=spfile; (只能下次启动生效 )

 

以上设置完这三个参数以后, 就可以自动进入归档模式

 

1. 首先要把数据库设置成归档模式(参考下边设置archivelog的细节, 要将database设置成mount状态)

    startup mount -> alter database archivelog ( 注意: 默认的就是自动的,如果你想要手动的,请参考如下)

    alter database archivelog manual;

2.   启动归档 (如果没有设置自动的话)

archive log start

3. 设置归档文件路径

    alter system set log_archive_dest_1="location=/u01/app/oracle/archivelog" scope=both;  -- 本地

注: 可以通过 archive log list ( 查看 archivelog 状态 ) 

     select log_mode from v$database;

4. 设置instance启动就立刻进入归档模式

    alter system set log_archive_start=true scope=spfile; ( 只能下次启动生效 )


 

Configuring the Database Archiving Mode_归档日志_02

All transactions are recorded in the online redo log files. This allows for automatic recovery of transactions in the event of a database failure.

If the database is configured for Noarchivelog mode, no redo history is saved to archived log files, and recovery operations are limited ( 为什么受限制 ? ) and a loss of transaction work may occur. ( 很多的 transaction 可能会丢失 ).This is the result of the automatic recycling of log files, where older log files needed for recovery are overwritten and only the most recent part of the transaction history is available. ( 个人感觉是这样,如果发生 media fault 例如磁盘损坏, 那么很可能比如一天的数据在磁盘中没有保存下来,那这样的话, 很可能需要从全备份开始来, 从全备份开始的话, 如果没有历史记录, 那么在现在的 redo log file 之前的, 并且在全备份之后的内容, 就会丢失了. 所以, 这里的全备以后要存储到别的地方, 保证不会被损坏, 另外, 所有的全备之后的 archivelog file 也要全部保存, 否则就没有意义了 )

个人推理正确 : After redo logs are overwritten, media recovery is only possible to the last full backup.

如果只是instance error, 那没有关系, 因为只需要 redo log file 就可以了, 因为每次发生 log switch 都会触发一个 check point, 这样, 数据库会同步一次, 而每次instance error发生时, 找到最近一次检查点之后进行操作恢复.

Configuring the Database Archiving Mode_自动启动_03

Configuring the Database Archiving Mode_oracle_04

Configuring the Database Archiving Mode_归档日志_05

Configuring the Database Archiving Mode_归档日志_06

Configuring the Database Archiving Mode_数据库_07

archivelog 只是将 redo log file 的历史保存, redo log file 自己本身还是循环使用, 也就是说, 针对 redo log file 本身来说, archivelog 和 Noarchivelog 模式 是一样的。

Configuring the Database Archiving Mode_数据库_08

 

Archiving Requirements

The database must be in Archivelog mode.Issuing the command to put the database into Archivelog mode updates the control file. The ARCn background processes can be enabled to implement automatic archiving.

Configuring the Database Archiving Mode_hive_09

Configuring the Database Archiving Mode_归档日志_10

Note: After the mode has been changed from Noarchivelog mode to Archivelog, you must back up all the datafiles and the control file.

Configuring the Database Archiving Mode_hive_11

Configuring the Database Archiving Mode_oracle_12

推荐使用自动方式 ( 必须的 )

Configuring the Database Archiving Mode_自动启动_13

Configuring the Database Archiving Mode_归档日志_14

Configuring the Database Archiving Mode_数据库_15

Configuring the Database Archiving Mode_hive_16

Configuring the Database Archiving Mode_hive_17

可随意调节 ARCn processes 的数量, 比如系统忙的时候, 需要比较多的 ARCn process, 那么就可以增加几个 ARCn 进程, 而如果系统比较闲的时候, 就可以 kill 几个 ARCn .

Configuring the Database Archiving Mode_归档日志_18

Configuring the Database Archiving Mode_数据库_19

Configuring the Database Archiving Mode_hive_20

Configuring the Database Archiving Mode_自动启动_21

注: 以上内容数据库已经是在 ARchivelog mode 的状态下.

Configuring the Database Archiving Mode_自动启动_22

Configuring the Database Archiving Mode_oracle_23

Configuring the Database Archiving Mode_oracle_24

Configuring the Database Archiving Mode_hive_25

Configuring the Database Archiving Mode_数据库_26

虽然不推荐使用 manually Archiving, 但是有一项功能是好的, 如下:

In addition, you can use manual archiving when automatic archiving is enabled to re-archive an inactive group to another destination. ( 当然你要有权限 ALTER SYSTEM ARCHIVELOG )

 

Configuring the Database Archiving Mode_oracle_27

Configuring the Database Archiving Mode_归档日志_28

Configuring the Database Archiving Mode_归档日志_29

Configuring the Database Archiving Mode_数据库_30

Configuring the Database Archiving Mode_数据库_31

Configuring the Database Archiving Mode_自动启动_32

Configuring the Database Archiving Mode_数据库_33

Configuring the Database Archiving Mode_hive_34

Configuring the Database Archiving Mode_oracle_35

Configuring the Database Archiving Mode_oracle_36

Configuring the Database Archiving Mode_归档日志_37

LOG_ARCHIVE_DEST_STATE_n 这个参数是设定对应的 LOG_ARCHIVE_DEST_n 这个地址是否可用的参数

Configuring the Database Archiving Mode_hive_38

Configuring the Database Archiving Mode_oracle_39

Configuring the Database Archiving Mode_oracle_40

Configuring the Database Archiving Mode_数据库_41