啟動/關閉數據庫歸檔(ARCHIVELOG)模式
2024-07-21 02:33:58
供稿:網友
Oracle數據庫可以運行在2種模式下:歸檔模式(archivelog)和非歸檔模式(noarchivelog)
歸檔模式可以提高Oracle數據庫的可恢復性,生產數據庫都應該運行在此模式下,歸檔模式應該和相應的備份策略相結合,只有歸檔模式沒有相應的備份策略只會帶來麻煩。
本文簡單介紹如何啟用和關閉數據庫的歸檔模式。
1.shutdown normal或shutdown immediate關閉數據庫
[oracle@jumper oracle]$ sqlplus "/ as sysdba"
SQL*Plus: Release 9.2.0.4.0 - PRodUCtion on Sat Oct 15 15:48:36 2005
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Connected to:
Oracle9i Enterprise Edition Release 9.2.0.4.0 - Production
With the Partitioning option
JServer Release 9.2.0.4.0 - Production
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
2.啟動數據庫到mount狀態
SQL> startup mount;
ORACLE instance started.
Total System Global Area 101782828 bytes
Fixed Size 451884 bytes
Variable Size 37748736 bytes
Database Buffers 62914560 bytes
Redo Buffers 667648 bytes
Database mounted.
3.啟用或停止歸檔模式
假如要啟用歸檔模式,此處使用
alter database archivelog 命令。
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 /opt/oracle/oradata/conner/archive
Oldest online log sequence 148
Next log sequence to archive 151
Current log sequence 151
假如需要停止歸檔模式,此處使用:
alter database noarchivelog 命令。
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 101782828 bytes
Fixed Size 451884 bytes
Variable Size 37748736 bytes
Database Buffers 62914560 bytes
Redo Buffers 667648 bytes
Database mounted.
SQL> alter database noarchivelog;
Database altered.
SQL> alter database open;
Database altered.
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Enabled
Archive destination /opt/oracle/oradata/conner/archive
Oldest online log sequence 149
Current log sequence 152
4.修改相應的初始化參數
Oracle10g之前,你還需要修改初始化參數使數據庫處于自動歸檔模式。
在pfile/spfile中設置如下參數:
log_archive_start = true
重啟數據庫此參數生效,此時數據庫處于自動歸檔模式。
也可以在數據庫啟動過程中,手工執行:
archive log start
使數據庫啟用自動歸檔,但是重啟后數據庫仍然處于手工歸檔模式。
從Oracle10g開始,log_archive_start參數已經廢除