Oracle 12c (12.1.) 开启归档模式的操作与11G数据库一致。下面记录下oracle 12c开启归档并调整归档文件格式的步骤。
首先查看当前数据库是否归档、是否开启闪回数据
SQL> archive log list
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination /u01/app/oracle/product/12.1.0/db_1/dbs/arch
Oldest online log sequence 11
Current log sequence 13
SQL> show parameter recovery
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string
db_recovery_file_dest_size big integer 0
recovery_parallelism integer 0
可以看到,我们新建数据库未开始闪回数据库和归档模式。下一步,如果开启归档,数据库必须运行在mount状态;接下来的操作就是停止并启动到mount状态
SQL> shutdown
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 566231040 bytes
Fixed Size 2926808 bytes
Variable Size 276825896 bytes
Database Buffers 281018368 bytes
Redo Buffers 5459968 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/product/12.1.0/db_1/dbs/arch
Oldest online log sequence 11
Next log sequence to archive 13
Current log sequence 13
归档日志保存的位置是/u01/app/oracle/product/12.1.0/db_1/arch,与以往的USE_DB_RECOVERY_FILE_DEST 不同。在这里我们可以根据需要调整下归档日志的保存位置
SQL> alter system set log_archive_dest_1='location=/u01/app/oracle/archivelog';
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/archivelog
Oldest online log sequence 11
Next log sequence to archive 13
Current log sequence 13
在目录/u01/app/oracle/archivelog下 ,查看归档日志类似以下格式
[oracle@otars archivelog]$ ll
total 25868
-rw-r-----. 1 oracle oinstall 21217792 Feb 14 22:35 1_13_935927047.dbf
-rw-r-----. 1 oracle oinstall 774144 Feb 14 22:37 1_14_935927047.dbf
-rw-r-----. 1 oracle oinstall 3584 Feb 14 22:37 1_15_935927047.dbf
-rw-r-----. 1 oracle oinstall 4486656 Feb 14 23:11 1_16_935927047.dbf
这种格式的文件很容易与数据文件混淆,可通过参数log_archive_format进行格式化,该参数重启DB后生效。归档进程log_archive_max_processes调整为8 ---
SQL> alter system set log_archive_format = "archive_%t_%s_%r.log" scope=spfile;
SQL> alter system set log_archive_max_processes = 8;
: