在数据库安装时可以选择归档模式,也可以在数据库安装完成后切换成归档模式。模式的切换只能在mount状态下执行,如果在open状态下执行,则会报如下的错误:
sql> alter database noarchivelog;
alter database noarchivelog
*
ERROR at line 1:
ORA-01126: database must be mounted in this instance and not open in any
instance
如果在nomount状态下执行,则会报如下错误:
sql> alter database noarchivelog;
alter database noarchivelog
*
ERROR at line 1:
ORA-01507: database not mounted
归档切换到非归档
在数据库mount阶段执行alter database noarchivelog;
sql> archive log list;
Database log mode Archive Mode#原先为归档模式
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST #归档文件存放的位置
Oldest online log sequence 129
Next log sequence to archive 131
Current log sequence 131
sql> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
sql> startup mount;
ORACLE instance started.
Total System Global Area 776646656 bytes
Fixed Size 2217384 bytes
Variable Size 482347608 bytes
Database Buffers 289406976 bytes
Redo Buffers 2674688 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 Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 129
Current log sequence 131
非归档切换到归档
1、继续面的例子,当前数据库处于非归档模式,如果直接修改成归档模式,那么归档日志存放的位置为DB_RECOVERY_FILE_DEST。
sql> show parameter db_recovery
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string /u01/app/oracle/flash_recovery_area
db_recovery_file_dest_size big integer 3882M
闪回恢复区只有3882M的空间,如果不满足需要,可以修改归档的位置。
sql> alter system set log_archive_dest_1="location=/u01/app/oracle/archive";
sql> shutdown immediate;
sql> startup mount;
sql> alter database archivelog;
sql> alter database open;
sql> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/archive
Oldest online log sequence 129
Next log sequence to archive 131
Current log sequence 131
原文链接:https://www.f2er.com/oracle/211102.html