数据环境:
SQL> select * from v$version; BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production PL/SQL Release 11.2.0.1.0 - Production CORE 11.2.0.1.0 Production TNS for Linux: Version 11.2.0.1.0 - Production NLSRTL Version 11.2.0.1.0 - Production
1. 归档日志概念
什么是归档重做日志:An archived redo log file is a copy of one of the filled members of a redo log group. It includes the redo entries and the unique log sequence number of the identical member of the redo log group. For example, if you are multiplexing your redo log, and if group 1 contains identical member files a_log1 andb_log1, then the archiver process (ARCn) will archive one of these member files. Should a_log1 become corrupted, then ARCn can still archive the identical b_log1. The archived redo log contains a copy of every group created since you enabled archiving.归档重做日志:就是在归档模式下,对非活动重做日志进行备份。有后台ARCn进程进行归档备份
[oracle@localhost orcl]$ ps -ef|grep arcoracle 3835 1 0 01:26 00:00:01 ora_arc0_orcloracle 3837 1 0 01:26 00:00:01 ora_arc1_orcloracle 3839 1 0 01:26 00:00:01 ora_arc2_orcloracle 3841 1 0 01:26 00:00:00 ora_arc3_orcl
2. 归档和非归档模式切换
模式切换需要在mount状态才可切换
SQL> startup mount;
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 92
Next log sequence to archive 94
Current log sequence 94
归档模式切换到非归档模式:
SQL> alter database noarchivelog;
Database altered.
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 92
Current log sequence 94
非归档模式切换到归档模式:
SQL> alter database archivelog;
Database altered.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 93
Next log sequence to archive 95
Current log sequence 95
如果非归档模式切换到归档模式,报ORA-00265: instance recovery required, cannot set ARCHIVELOG mode
SQL> alter database archivelog;
alter database archivelog
*
ERROR at line 1:
ORA-00265: instance recovery required, cannot set ARCHIVELOG mode
错误原因:在非归档模式下,直接用shutdown abort关闭数据,导致ora-00265错误
解决方法:把数据启动到open状态,然后shutdown immediate关闭数据,重新把数据库启动mount状态
3. 配置归档进程
oracle 11g 默认归档进程是4
SQL> show parameter log_archive_max_processes;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_max_processes integer 4
后台进程:
[oracle@localhost ~]$ ps -ef|grep arc
oracle 9164 1 0 17:12 00:00:00 ora_arc0_orcl
oracle 9166 1 1 17:12 00:00:00 ora_arc1_orcl
oracle 9168 1 1 17:12 00:00:00 ora_arc2_orcl
oracle 9170 1 1 17:12 00:00:00 ora_arc3_orcl
修改归档进程数量:
例如开启10个归档进程
SQL> alter system set log_archive_max_processes=10;
System altered.
SQL> show parameter log_archive_max_processes;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_max_processes integer 10
[oracle@localhost ~]$ ps -ef|grep arc
oracle 9164 1 0 17:12 00:00:00 or