How to Set archive mode and non-archive mode for Oracle databases

Source: Internet
Author: User

OracleIn database operations, the database can be setArchive ModeAndNon-archive Mode. Archive mode stores all transaction logs, including redolog and archivelog, but not archive mode only records redolog. We often set it to archive mode and non-archive mode based on the needs of our work. In this article, we will introduce their setup process. Let's take a look at it.

-View the oracle archiving Mode

 
 
  1. SQL> conn evan/evan (dba)
  2.  
  3. Connected.
  4.  
  5. SQL> archive log list
  6.  
  7. ORA-01031: insufficient privileges
  8.  
  9. SQL> conn/as sysdba -- archive log list must be executed by sysdba
  10.  
  11. Connected.
  12.  
  13. SQL> archive log list
  14.  
  15. Database log mode No Archive Mode
  16.  
  17. Automatic archival Disabled
  18.  
  19. Archive destination USE_DB_RECOVERY_FILE_DEST
  20.  
  21. Oldest online log sequence 2
  22.  
  23. Current log sequence 4
  24.  
  25. Query v $ database
  26.  
  27. SQL> select name, log_mode from v $ database;
  28.  
  29. NAME LOG_MODE
  30.  
  31. ---------------------
  32.  
  33. ORALIFE NOARCHIVELOG

Ii. Modify the archive Mode

Archive log location. Oracle 10 Gb can generate multiple identical logs and store multiple locations to prevent accidents.

 
 
  1. SQL> alter system set log_archive_dest_1 = 'location =/oracle/10g/oracle/log/archive_log ';
  2.  
  3. System altered.
  4.  
  5. SQL> alter system set log_archive_dest_2 = 'location =/oracle/10g/oracle/log/archive_log2 ';
  6.  
  7. System altered.
  8.  
  9. SQL> shutdown immediate
  10.  
  11. ORA-01031: insufficient privileges
  12.  
  13. SQL> conn/as sysdba
  14.  
  15. Connected.
  16.  
  17. SQL> shutdown immediate
  18.  
  19. Database closed.
  20.  
  21. Database dismounted.
  22.  
  23. ORACLE instance shut down.
  24.  
  25. SQL> startup mount
  26.  
  27. ORACLE instance started.
  28.  
  29. Total System Global Area 528482304 bytes
  30.  
  31. Fixed Size 1220360 bytes
  32.  
  33. Variable Size 163578104 bytes
  34.  
  35. Database Buffers 356515840 bytes
  36.  
  37. Redo Buffers 7168000 bytes
  38.  
  39. Database mounted.
  40.  
  41. SQL> alter database archivelog; -- sets the archive mode.
  42.  
  43. Database altered.
  44.  
  45. SQL> alter database open;
  46.  
  47. Database altered.

Configure the archive file format (starting from oracle 10 Gb, it must contain % s, % t, % r)

 
 
  1. SQL> alter system set log_archive_format = "archive _ % t _ % s _ % r. arclog" scope = spfile;
  2.  
  3. System altered.
  4.  
  5. SQL> shutdown immediate
  6.  
  7. Database closed.
  8.  
  9. Database dismounted.
  10.  
  11. ORACLE instance shut down.
  12.  
  13. SQL> startup mount
  14.  
  15. ORACLE instance started.
  16.  
  17. Total System Global Area 528482304 bytes
  18.  
  19. Fixed Size 1220360 bytes
  20.  
  21. Variable Size 163578104 bytes
  22.  
  23. Database Buffers 356515840 bytes
  24.  
  25. Redo Buffers 7168000 bytes
  26.  
  27. Database mounted.
  28.  
  29. SQL> archive log list -- check whether archive exists
  30.  
  31. Database log mode Archive Mode
  32.  
  33. Automatic archival Enabled -- Automatic archiving Enabled
  34.  
  35. Archive destination/oracle/10g/oracle/log/archive_log2
  36.  
  37. Oldest online log sequence 2
  38.  
  39. Next log sequence to archive 4
  40.  
  41. Current log sequence 4
  42.  
  43. SQL> select destination from v $ archive_dest; -- view the location of the archived log
  44.  
  45. DESTINATION
  46.  
  47. --------------------------------------------------------------------------------
  48.  
  49. /Oracle/10g/oracle/log/archive_log
  50.  
  51. /Oracle/10g/oracle/log/archive_log2
  52.  
  53. 10 rows selected.

You can also configure the number of archiving processes

 
 
  1. alter system set log_archive_max_processes=n 

3. Change to non-archive Mode

 
 
  1. SQL> startup mount
  2.  
  3. ORACLE instance started.
  4.  
  5. Total System Global Area 528482304 bytes
  6.  
  7. Fixed Size 1220360 bytes
  8.  
  9. Variable Size 167772408 bytes
  10.  
  11. Database Buffers 352321536 bytes
  12.  
  13. Redo Buffers 7168000 bytes
  14.  
  15. Database mounted.
  16.  
  17. SQL> alter database noarchivelog;
  18.  
  19. Database altered.
  20.  
  21. SQL> alter system set log_archive_dest_1 = '';
  22.  
  23. System altered.
  24.  
  25. SQL> alter system set log_archive_dest_2 = '';
  26.  
  27. System altered.
  28.  
  29. SQL> alter system set log_archive_dest_10 = 'location = USE_DB_RECOVERY_FILE_DEST '; -- restore to original
  30.  
  31. System altered.
  32.  
  33. SQL> archive log list
  34.  
  35. Database log mode No Archive Mode
  36.  
  37. Automatic archival Disabled
  38.  
  39. Archive destination USE_DB_RECOVERY_FILE_DEST
  40.  
  41. Oldest online log sequence 6
  42.  
  43. Current log sequence 8
  44.  
  45. SQL> shutdown immediate
  46.  
  47. ORA-01109: database not open
  48.  
  49. Database dismounted.
  50.  
  51. ORACLE instance shut down.
  52.  
  53. SQL> startup mount
  54.  
  55. ORACLE instance started.
  56.  
  57. Total System Global Area 528482304 bytes
  58.  
  59. Fixed Size 1220360 bytes
  60.  
  61. Variable Size 167772408 bytes
  62.  
  63. Database Buffers 352321536 bytes
  64.  
  65. Redo Buffers 7168000 bytes
  66.  
  67. Database mounted.
  68.  
  69. SQL> archive log list
  70.  
  71. Database log mode No Archive Mode
  72.  
  73. Automatic archival Disabled
  74.  
  75. Archive destination USE_DB_RECOVERY_FILE_DEST
  76.  
  77. Oldest online log sequence 6
  78.  
  79. Current log sequence 8

There are so many settings for Oracle Database archive mode and non-archive mode. If you want to know

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.