Switch the archive mode of the oarcle Database

Source: Internet
Author: User

In the development and testing environments of Oracle databases, the log mode and automatic archiving mode of databases are generally not set, which is conducive to the adjustment of system applications, the generation of a large number of archive log files will consume a lot of disk space. However, when the system goes online and becomes a production environment, it is very important to set it to log mode and automatically archive it, because this is an important measure to ensure the security of the system and effectively prevent disasters. In this way, the log files between the regular backup database and the two backup intervals can effectively restore the data at any point in time during this period, data loss can be recovered in many cases or minimized. Although the log mode and automatic archiving settings of the Oracle database are not complex, some of the concepts and operation processes are confusing. Based on my experience, the analysis is as follows, the environment used is UNIX (HPUX, solaries, Aix, tru64unix) and oracle8.
  
  ITo enableOarcleAutomatic archiving of logs in databases requires two steps: first, setting the Database Log Mode(Database Log mode,OptionalArchive ModeAndNo archive Mode)In addition, the automatic archiving mode is set.(Automatic Archival,OptionalEnabledAndDisabled).  IIHow to view the current log and automatic archiving Mode settings of the database:
  
You can use the archive log LIST command to view logs.
  
For example:
  
The database system running in log automatic archiving mode displays the following results (generally in the production environment)
  
Svrmgr> archive log list
  
Database Log mode archive Mode
  
Automatic Archival Enabled
  
Archive destination/backup/archivelog
  
Oldest online log sequence 2131
  
Next log sequence to archive 2133
  
Current Log sequence 2133
  
The following figure shows the results of the database system that does not start the Database Log mode or automatically archive (usually the test environment)
  
Svrmgr> archive log list
  
Database Log mode No archive Mode
  
Automatic Archival disabled
  
Archive destination/u01/APP/Oracle/product/8.0.5/dbs/Arch
  
Oldest online log sequence 194
  
Current Log sequence 196
  
  3.Database Log Mode settings
  
When creating a database, you can specify the log mode of the database in the create database statement. If not specified, the default value is noarchivelog. If archive mode is specified during database creation, it will increase the creation time by about 20%, and it will take only a few seconds to set it when you start the instance later, therefore, it is generally not set to archive mode when creating a database.
  
To determine the log Mode settings of a system database, perform the following operations in addition to (2:
  
Svrmgr> select * from V $ Database
  
Name created log_mode checkpoint archive_ch
  
-----------------------------------------------------
  
Orcl 05/21/97 17:55:06 noarchivelog 172185 170808
  
To switch the log mode of a database (switch between archive mode and no archive mode), perform the following steps:
  
1. Shut down the running database instance
  
Svrmgrl> Shutdown
  
Before switching the log mode, you must shut down the running database.
  
2. Back up the database
  
This backup is used together with the logs generated in the future for disaster recovery (it is very important, for example, to change to the archive log mode without this database backup, only log files cannot be recovered from this time point ).
  
3. Start the database instance to the Mount status, but do not open it.
  
Svrmgrl> startup Mount
  
NOTE: If ops is used, open only one database instance for mode switching.
  
4. Switch the Database Log mode.
  
Svrmgrl> alter database archivelog; (set the database to the archive log Mode)
  
Or
  
Svrmgrl> alter database noarchivelog; (set the database to the archive log Mode)
  
5. Open the database
  
Svrmgrl> alter database open;
  
6. confirm that the database is in the archive log mode.
  
Svrmgrl> archive log list;
  
Database Log mode archive Mode
  
Automatic Archival Enabled
  
Archive destination for example: $ ORACLE_HOME/dbs/Arch
  
Oldest on-line log sequence 275
  
Next log sequence 277
  
Current Log sequence 278
  
7. archive the redo logs at this time point
  
Svrmgrl> archive log all;
  
8. confirm that the new log file is under the corresponding archive directory.
  
  ThuAutomatic archiving Mode settings(Automatic Archival,OptionalEnabledAndDisabled)In this mode, the database startsArchProcess, specifically responsibleRedo logsWrite it to the corresponding directory of the system archive device.  
Set parameters in the database parameter file (usually in the $ ORACLE_HOME/dbs/init *. ora file ):
  
Log_archive_start =
  
Log_archive_dest =
  
Log_archive_format =
  
Log_archive_start:
  
If automatic archiving is required, set this parameter to true. If automatic archiving is not required, set this parameter to false.
  
Log_archive_dest:
  
This parameter sets the archive logs path.
  
Log_archive_format:
  
This parameter sets the archive logs naming format. For example, set the format to arch % S. arc.
  
The log file will be: arch1.arc, arch2.arc, arch3.arc
  
These parameter settings take effect only before the database instance is started. To make them take effect during database running, you must restart the database.
  
If the database is running and cannot be restarted immediately, set it to the automatic archiving mode, perform the following operations:
  
Svrmgrl> alter system archive log start;
  
To disable automatic archiving:
  
Svrmgrl> alter system archive log stop;
  
However, if the database restarts, the statement Modification result becomes invalid. The automatic archiving settings are set based on the value of log_archive_start in the system parameter file.
  
  V.Several settings:
  
(1) Database Log mode archive Mode
  
Automatic Archival Enabled
  
This is the setting of Oracle Database logs and archive mode in most production environments. In this case, back up the database regularly (with hot backup and cold backup) and archive logs, it can effectively restore the database to all time points with archived logs.
  
(2) Database Log mode archive Mode
  
Automatic Archival disabled
  
In this case, the database cannot be automatically archived and must be manually archived. If all online logs are full and are not archived manually in time, the database will be hung here because lgwr does not have available online logs to write, only available online logs can be continued. This should be avoided in the production environment.
  
Manual archiving is as follows:
  
Svrmgrl> alter system archive log all;
  
The database will archive online logs
  
(3) Database Log mode No archive Mode
  
Automatic Archival Enabled
  
Some relatively inexperienced administrators only set log_archive_start = true in the database parameter file, and then check that the arch archiving process is up after the database is up, however, although Oracle has made several log switches, but there is still no archiving log, this is the case. If the database is not in arvhivelog mode, redolog will not be archived.
  
(4) Database Log mode No archive Mode
  
Automatic Archival disabled
  
This setting is the default setting of the just-installed Oracle database, and the development environment is mostly like this. Archive is not performed.

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.