现在的位置: 首页 > 综合 > 正文

Oracle10g自动归档(archive)及其路径设置(log_archive_dest、log_archive_dest_n)

2013年10月03日 ⁄ 综合 ⁄ 共 2810字 ⁄ 字号 评论关闭

作者:gtlions 【转载时请以超链接心事标明文章出处作者信息,谢谢.】

链接:http://blog.csdn.net/gtlions/archive/2010/04/06/5455418.aspx

----------------------------------------------------------------------------------------------------------

oracle的日志归档功能是数据备份和恢复的保障,下面首先还原下自动归档的切换过程。

1、从非归档模式切换到自动归档模式(no archivie to archive)

[oracle@itd-crmtest-120 ~]$ source .bash_profile;
[oracle@itd-crmtest-120 ~]$ export NLS_LANG=AMERICAN_AMERICA.UTF8;
[oracle@itd-crmtest-120 ~]$ sqlplus "/as sysdba";

SQL*Plus: Release 10.2.0.4.0 - Production on Tue Apr 6 16:35:03 2010

Copyright (c) 1982, 2007, Oracle. All Rights Reserved.

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination /oradata/crmtest01/arch
Oldest online log sequence 508
Current log sequence 510
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area 1207959552 bytes
Fixed Size 2083528 bytes
Variable Size 419431736 bytes
Database Buffers 771751936 bytes
Redo Buffers 14692352 bytes
Database mounted.
SQL> alter database archivelog;

Database altered.

SQL> alter system set log_archive_dest='/oradata/crmtest01/arch' scope=both;

System altered.

SQL> alter database open;

Database altered.

SQL> !cd /oradata/crmtest01/arch

SQL> !ls
Desktop

SQL> ! ls /oradata/crmtest01/arch;

SQL> alter system switch logfile;

System altered.

SQL> !ls /oradata/crmtest01/arch;
1_510_715202251.dbf

SQL> /

System altered.

SQL> !ls /oradata/crmtest01/arch
1_510_715202251.dbf 1_511_715202251.dbf

上述过程就是个将数据库从非归档模式切换到自动归档模式。

2、log_archive_dest_n的设置

该参数无法和log_archive_dest同时使用,这2个参数只能选择一个。

如果要使用该参数,必须先将log_archive_dest清空:

SQL> alter system reset log_archive_dest scope=spfile sid='*';

System altered.

或者可以使用

SQL> alter system reset log_archive_dest='' scope=spfile;

System altered.

重启数据库后恢复为默认路径,然后再进行设置log_archive_dest_n:

SQL> shutdown immediate;
ORA-01109: database not open

Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area 1207959552 bytes
Fixed Size 2083528 bytes
Variable Size 419431736 bytes
Database Buffers 771751936 bytes
Redo Buffers 14692352 bytes
Database mounted.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oracle/ora10g/dbs/arch
Oldest online log sequence 510
Next log sequence to archive 512
Current log sequence 512
SQL> alter system set log_archive_dest_1='location=/oradata/crmtest01/arch01/' scope=both;

System altered.

SQL> alter database open;

Database altered.

SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oradata/crmtest01/arch01/
Oldest online log sequence 510
Next log sequence to archive 512
Current log sequence 512
SQL> alter system switch logfile;

System altered.

SQL> !ls -a /oradata/crmtest01/reco;
. ..

SQL> !ls -a /oradata/crmtest01/arch01;
. .. 1_512_715202251.dbf

SQL> /

System altered.

上述过程就是设置N路径。

 

-The End-

抱歉!评论已关闭.