Oracle Database User-managed control file backup and recovery

Source: Internet
Author: User

InOracleDatabase,Control FileIs very important. It is used to record and maintain databases. When the database is restored, the server process and background process need to read various backup-related information from the control file. If the control file is corrupted, the backup information will be lost. Although the use of diverse control files can prevent Control File Corruption, control files should be backed up on a regular basis due to the importance of control files. When the database configuration changes, you must back up the control file.

Commands that involve database configuration changes:

 
 
  1. alter database [add|drop] logfile  
  2.  
  3. alter database [add|drop] logfile member  
  4.  
  5. alter database [add|drop] logfile group  
  6.  
  7. alter database [noarchivelog|archivelog]  
  8.  
  9. alter database rename file  
  10.  
  11. create tablespace  
  12.  
  13. alter tablespace [add|rename] datafile  
  14.  
  15. alter tablespace [read write|read only]  
  16.  
  17. drop tablespace 

Control file backup in three ways

1) Use the OS command to copy

1) Use the alter database command to generate a control file copy in the open state.

2) In the open state, use the alter database backup controlfile to trace command to back up the control file to the trace file

Two methods are available to control file recovery.

1) Use recover database using backup controlfile in the mount status

2) in the mount status, the trace file is generated and restored.

2-2 example:

 
 
  1. [Oracle @ localhost ~] $ Rlsqlplus/as sysdba
  2.  
  3. SQL * Plus: Release 10.2.0.1.0-Production on Monday August 1 21:40:03 2011
  4.  
  5. Copyright (c) 1982,200 5, Oracle. All rights reserved.
  6.  
  7. Connected to an idle instance.
  8.  
  9. SQL> startup
  10.  
  11. ORACLE instance started.
  12.  
  13. Total System Global Area 528482304 bytes
  14.  
  15. Fixed Size 1220360 bytes
  16.  
  17. Variable Size 176161016 bytes
  18.  
  19. Database Buffers 343932928 bytes
  20.  
  21. Redo Buffers 7168000 bytes
  22.  
  23. Database mounted.
  24.  
  25. Database opened.

-- Generate a control file copy in the open state

 
 
  1. SQL> alter database backup controlfile
  2.  
  3. 2'/oracle/10g/oracle/bakup/database/oralife. ctl ';
  4.  
  5. Alter database backup controlfile
  6.  
  7. *
  8.  
  9. ERROR at line 1:
  10.  
  11. ORA-01580: error creating control backup file
  12.  
  13. /Oracle/10g/oracle/bakup/database/oralife. ctl
  14.  
  15. ORA-27038: created file already exists
  16.  
  17. Additional information: 1
  18.  
  19. SQL> alter database backup controlfile
  20.  
  21. 2 '/oracle/10g/oracle/bakup/database/oralife. ctl' reuse; -- reuse is used to overwrite the original control file copy
  22.  
  23. Database altered.

-- Manually delete all control file simulated file loss

 
 
  1. SQL> ho rm /oracle/10g/oracle/product/10.2.0/oradata/oralife/*.ctl; 

-- Use evan to log on and add data

 
 
  1. SQL> conn evan/evan  
  2.  
  3. Connected.  
  4.  
  5. SQL> select * from t_evan;  
  6.  
  7. TEXT  
  8.  
  9. --------------------------------------------------------------------------------  
  10.  
  11. oracle  
  12.  
  13. java  
  14.  
  15. spring  
  16.  
  17. hibernate  
  18.  
  19. hibernate  
  20.  
  21. SQL> insert into t_evan values('added');  
  22.  
  23. 1 row created.  
  24.  
  25. SQL> commit;  
  26.  
  27. Commit complete.  
  28.  
  29. SQL> conn / as sysdba  
  30.  
  31. Connected.  
  32.  
  33. SQL> shutdown immediate  
  34.  
  35. ORA-00210: cannot open the specified control file  
  36.  
  37. ORA-00202: control file: '/oracle/10g/oracle/product/10.2.0/oradata/oralife/control01.ctl'  
  38.  
  39. ORA-27041: unable to open file  
  40.  
  41. Linux Error: 2: No such file or directory  
  42.  
  43. Additional information: 3  
  44.  
  45. SQL> shutdown abort  
  46.  
  47. ORACLE instance shut down. 

-- Alter_oralife.log:

 
 
  1. Mon Aug  1 23:13:51 2011  
  2.  
  3. ORA-00202: control file: '/oracle/10g/oracle/product/10.2.0/oradata/oralife/control01.ctl'  
  4.  
  5. ORA-27037: unable to obtain file status  
  6.  
  7. Linux Error: 2: No such file or directory  
  8.  
  9. Additional information: 3 

-- Copy the control file to the target path

 
 
  1. SQL> ho cp/oracle/10g/oracle/bakup/database/oralife. ctl/oracle/10g/oracle/product/10.2.0/oradata/oralife/control01.ctl
  2.  
  3. SQL> alter system set control_files = '/oracle/10g/oracle/product/10.2.0/oradata/oralife/control01.ctl' scope = spfile; -- modify the control_files parameter to specify available control files
  4.  
  5. System altered.
  6.  
  7. SQL> startup force mount
  8.  
  9. ORACLE instance started.
  10.  
  11. Total System Global Area 528482304 bytes
  12.  
  13. Fixed Size 1220360 bytes
  14.  
  15. Variable Size 138412280 bytes
  16.  
  17. Database Buffers 381681664 bytes
  18.  
  19. Redo Buffers 7168000 bytes
  20.  
  21. Database mounted.

-- Generate a trace file

 
 
  1. SQL> alter database backup controlfile to trace noresetlogs;  
  2.  
  3. Database altered.  
  4.  
  5. SELECT c.VALUE || '/' || d.instance_name || '_ora_' || a.spid || '.trc' TRACE  
  6.  
  7. FROM v$process a, v$session b, v$parameter c, v$instance d  
  8.  
  9. WHERE a.addr = b.paddr  
  10.  
  11. AND b.audsid = USERENV ('sessionid')  
  12.  
  13. AND c.NAME = 'user_dump_dest';  
  14.  
  15. TRACE  
  16.  
  17. --------------------------------------------------------------------------------  
  18.  
  19. /oracle/10g/oracle/product/10.2.0/db_1/admin/oralife/udump/oralife_ora_4558.trc  
  20.  
  21. SQL> shutdown immediate  
  22.  
  23. ORA-01109: database not open  
  24.  
  25. Database dismounted.  
  26.  
  27. ORACLE instance shut down. 

-- Open the trace file, remove comments, execute the script in the shutdown state, and create the control file.

-- Use evan to log on and verify the data

 
 
  1. SQL> conn evan/evan  
  2.  
  3. Connected.  
  4.  
  5. SQL> select * from t_evan;  
  6.  
  7. TEXT  
  8.  
  9. --------------------------------------------------------------------------------  
  10.  
  11. oracle  
  12.  
  13. java  
  14.  
  15. spring  
  16.  
  17. hibernate  
  18.  
  19. hibernate  
  20.  
  21. added  
  22.  
  23. 6 rows selected. 

The data is not lost.

 
 
  1. SQL> select name from v$controlfile;  
  2.  
  3. NAME  
  4.  
  5. --------------------------------------------------------------------------------  
  6.  
  7. /oracle/10g/oracle/product/10.2.0/oradata/oralife/control01.ctl 

In this case, multiple control files need to be rebuilt to ensure the security of database configuration.

Here is an introduction to the backup and recovery of the Oracle Database Control file. I hope this introduction will bring you some benefits!

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.