Thursday, 28 July 2016

Enable or Disable Archivelog Mode in Oracle 11g Database

Enable Archivelog Mode 


Step 1:- Log on to the database and check archivelog mode for database

[oracle@pract1 fra]$ sqlplus "/ as sysdba"

SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 28 18:03:43 2016

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

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

SQL> select instance_name, status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
KMDB             OPEN

SQL> archive log list
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch
Oldest online log sequence     1
Current log sequence           2

Step 2:- Looks like archivelog destination parameter is set to default location. We will change the archivelog destination to new location 

SQL> alter system set log_archive_dest_1='LOCATION=/u01/oradata/KMDB/arch' scope = both;

System altered.

Step 3:- Verify the archivelog destination which is pointing to new location

SQL> archive log list
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /u01/oradata/KMDB/arch
Oldest online log sequence     1
Current log sequence           2

Step 4:- Shutdown the database and start it in mount state

SQL> shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount
ORACLE instance started.

Total System Global Area  839282688 bytes
Fixed Size                  2217992 bytes
Variable Size             494929912 bytes
Database Buffers          339738624 bytes
Redo Buffers                2396160 bytes
Database mounted.

Step 5:- We need to enable archivelog mode and open the database

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            /u01/oradata/KMDB/arch
Oldest online log sequence     1
Next log sequence to archive   2
Current log sequence           2

Disable Archivelog Mode


Step 1:- Check the archivelog mode

SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/oradata/KMDB/arch
Oldest online log sequence     1
Next log sequence to archive   2
Current log sequence           2

Step 2:- Shutdown the database and start it in mount state

SQL> shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount
ORACLE instance started.

Total System Global Area  839282688 bytes
Fixed Size                  2217992 bytes
Variable Size             494929912 bytes
Database Buffers          339738624 bytes
Redo Buffers                2396160 bytes
Database mounted.

Step 3:-We need to set archivelog mode and open the database

SQL> alter database noarchivelog;

Database altered.

SQL> alter database open;

Database altered.

Step 4:- Verify archivelog mode

SQL> archive log list
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            /u01/oradata/KMDB/arch
Oldest online log sequence     1
Next log sequence to archive   2
Current log sequence           2

Possible Errors during activity


ORA-01126: database must be mounted in this instance and not open in any
instance

Case:- 
SQL> alter database archivelog; 
*

ERROR at line 1:
ORA-01126: database must be mounted in this instance and not open in any
instance

Cause:-
This error happens when you try to enable archivelog mode when the database is in open state 

Solution:- 
Shutdown the database and start the database in mount state

No comments:

Post a Comment