分类: Oracle
2007-10-08 14:57:15
Oracle数据库可以运行在2种模式下:归档模式(archivelog)和非归档模式(noarchivelog)。归档模式可以提高Oracle数据库的可恢复性,生产数据库都应该运行在此模式下,归档模式应该和相应的备份策略相结合,只有归档模式没有相应的备份策略只会带来麻烦。
检查归档模式命令:
SQL> archive log list Database log mode No Archive Mode Automatic archival Disabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 15 Current log sequence 17 |
设置归档模式:
SQL> shutdown immediate; Database closed. Database dismounted. ORACLE instance shut down. SQL> startup mount ORACLE instance started. Total System Global Area 1258291200 bytes Fixed Size 1219160 bytes Variable Size 318768552 bytes Database Buffers 922746880 bytes Redo Buffers 15556608 bytes Database mounted. SQL> alter database archivelog; Database altered. SQL> alter database open; 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 15 Next log sequence to archive 17 Current log sequence 17 |
如果需要停止归档模式,使用:alter database noarchivelog 命令。Oracle10g之前,你还需要修改初始化参数使数据库处于自动归档模式。在pfile/spfile中设置如下参数:
log_archive_start = true |
重启数据库此参数生效,此时数据库处于自动归档模式。也可以在数据库启动过程中,手工执行:
archive log start |
使数据库启用自动归档,但是重启后数据库仍然处于手工归档模式。10g使用db_recovery_file_dest来作为归档日志的存放地。
SQL> show parameter db_recovery NAME TYPE VALUE db_recovery_file_dest string /home/oracle/ora10g/flash_reco very_area/ db_recovery_file_dest_size big integer 20G |
可以修改db_recovery_file_dest_size参数的大小
alter system set db_recovery_file_dest_size=21474836480 |
由非归档模式改归档模式必须重启动数据库.
oracle9i
准备:
1. 查看是否为归档模式:
archive log list;
2. 如果目前是使用spfile启动:
create pfile=’xxxxx’ from spfile;对初始化文件进行备份
3 规划归档日志存储空间.归档目标
4. 归档日志格式
按以下步骤更改:
1. alter system set log_archive_start = true scope=spfile;
2. alter system set log_archive_dest_1 = 'location=c:\' scope=spfile;
3. alter system set log_archive_format = 'arch%s_%t.arc' scope=spfile;
4. shutdown immediate;
5. startup mount;
6. alter database archivelog;
7. alter database open;
8. archive log list;
9. alter system switch logfile;
手工归档在线重做日志:alter system switch logfile;