Detailed description of Oracle DataGuard data backup solution

Source: Internet
Author: User

Oracle elastic uard is a database-level HA solution. Its primary functions include redundancy, data protection, and fault recovery.

When the "transaction consistency" of the production database is used, the physical full backup (or physical COPY) of the production database is used to create the standby database, the slave database automatically maintains the slave database through the archive logs (or redo entries) transmitted from the production database. Apply the redo data to the slave database. This document describes how to use RMAN backup to create a standby uard ).

I. Overview of Oracle DataGuard Environment

1. Software Environment

Operating System Red Linux Enterprise as 5

Database Version: Oracle 10g release 2

2. primary databae

IP: 192.168.18.1

ORACLE_SID = db1

Db_unique_name = db1

3. standby database

IP: 192.168.18.2

ORACLE_SID = standby

Db_unique_name = standby

2. Preparations for the primary database (db1)

1. Set the master database to Force logging

 
 
  1. SQL> alter database force logging;  

2. Create a password file

 
 
  1. cd $ORACLE_HOME/dbs/  
  2. orapwdfile=orapwdb1 password=123456 force=y  

3. Modify the initialization parameters of the master database.

 
 
  1. alter system set log_archive_config='dg_config=(db1,standby)' scope=both;  
  2. alter system set log_archive_dest_1='location=/u01/db1/arch' scope=both;  
  3. alter system set db_unique_name='db1' scope=both;  

4. Generate Database Backup

 
 
  1. RMAN> connect target sys/123456  
  2. RMAN> backup database format='/oracle/rmanback/%d_%s.dbf' plus archivelog;  
  3. [oracle@oracle rmanback]$ ls  
  4. DB1_1.dbfDB1_2.dbf  

5. Generate the control file of the slave Database

 
 
  1. SQL>alter database create standby controlfile as '/oracle/rmanback/ctontrl01.ctl  

6. Configure the listener. ora and tnsnames. ora files.

Start lintener. ora,

 
 
  1. [oracle@oracle dbs]$ lsnrctl status  
  2. LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 14-JUN-2009 02:54:29  
  3. Service "db1" has 1 instance(s).  
  4. Instance "db1", status READY, has 1 handler(s) for this service...  
  5. Service "db1_XPT" has 1 instance(s).  
  6. Instance "db1", status READY, has 1 handler(s) for this service...  
  7. The command completed successfully  

Configure rnsnames. ora

 
 
  1. vi $ORACLE_HOME/network/admin/tnsnames.ora  
  2. db1 =  
  3.   (DESCRIPTION =  
  4.     (ADDRESS_LIST =  
  5.       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.18.1)(PORT = 1521))  
  6.     )  
  7.     (CONNECT_DATA =  
  8.       (SERVICE_NAME = db1)  
  9. standby =  
  10.   (DESCRIPTION =  
  11.     (ADDRESS_LIST =  
  12.       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.18.2)(PORT = 1521))  
  13.     )  
  14.     (CONNECT_DATA =  
  15.       (SERVICE_NAME = standby)  
  16.     )  
  17.   ) 

3. Create a standby database

1. Set environment variables and install oracle software

 
 
  1. # Set the environment variable to the same as that of the master database 
  2. # Installing only the uninstallation Software 
  3. ./RunInstaller-silent-responseFile/tmp/installoracle. rsp

2. Create related directories

 
 
  1. Cd $ ORACLE_HOME/dbs/
  2. Orapwdfile = orapwSID password = 123456 force = y
  3. # Note that the password must be the same as that of the master database; otherwise, the archive fails. 

3. Create a password file

 
 
  1. Cd $ ORACLE_HOME/dbs/
  2. Orapwd file = orapwSID password = 123456 force = y
  3. # Note that the password must be the same as that of the master database; otherwise, the archive fails. 

3. Create a parameter file (pfile)

 
 
  1. db_name = standby   
  2. shared_pool_size = 120M  
  3. undo_management = AUTO  
  4. undo_tablespace = undotbs  
  5. sga_max_size = 200M  
  6. sga_target = 160M  
  7. db_2k_cache_size = 4M  
  8.    
  9. standby_file_management=AUTO  
  10. fal_server='db1' 
  11. fal_client='standby' 
  12. log_archive_dest_1='location=/u01/app/oracle/product/10.2.0/dbs/arch' 
  13. log_archive_dest_2='SERVICE=db1 REOPEN=300' 
  14. log_archive_dest_state_1='ENABLE' 
  15. log_archive_dest_state_2='ENABLE'  

4. CP master database RMAN backup and control file to slave Database

Note: The backup storage location must be the same as that of the primary database RMAN backup file. The storage location of the control file must be the same as that of the standby database controlfile generated.

 
 
  1. scp /oracle/rmanback/*.dbf root@192.168.18.2:/oracle/rmanback/  
  2. scp /oracle/rmanback/*.ctl root@192.168.18.2:/oracle/oracle/oradata/standby/  

5. Use the backup control file to enable the backup database to mount

 
 
  1. SQL>connect / as sysdba  
  2. connnpcted to an idle instance.  
  3. SQL>startup nomount pfile=$ORACLE_HOME/dbs/initstandby.ora  
  4. SQL>alter database mount standby database 

6. Configure the listener. ora and tnsnames. ora files.

Start listener as the master database, and configure tnsnames. ora as the master database,

When the listener of the Master/Slave database is started, perform the test. The test is successful in the following example.

 
 
  1. tnsping db1  
  2. tnsping standby  
  3. SQL> sqlplus sys/123456@db1  
  4. SQL> sqlplus sys/123456@standby  

7. Dump the database

 
 
  1. RMAN>connect target /  
  2. connected to target database:TEST(DBID=788075692)  
  3. RMAN> restore database  

8. Restore the database.

 
 
  1. SQL> recover managed standby database disconnect from session;
  2. # If you want to apply logs manually, run the following command: 
  3. SQL> recover standic standby database;

9. Check whether the standby database is successfully created.

A. Switch logs on the primary database

 
 
  1. SQL> alter system switch logfile  

B. Run the following statement on primary database

 
 
  1. SQL> select max(sequence#) from v$archived_log;  
  2. MAX(SEQUENCE#)  
  3. --------------  
  4. 17  

C. Run the following statement on standby database

 
 
  1. SQL> select sequence# ,applied from v$archived_log order by sequence#;  
  2.  SEQUENCE# APP  
  3. --------------------- ---  
  4. 15YES  
  5. 16YES  
  6. 17YES  

If the status of the max sequence # app in the previous step is YES, the standby database is successfully created.

10. Start with spfile and set it to read-only

 
 
  1. SQL> create spfile from pfile;  
  2. SQL> shutdown immedaite  
  3. SQL> startup mount  
  4. SQL> alter database recover managed standby database disconnect from session;  
  5. SQL> alter database open read only;  

The above is the procedure for Oracle DataGuard data backup. This article is from the "pursuit" blog.

  1. OOP concepts in Oracle databases
  2. Effect of disk sorting on Oracle database performance (1)
  3. Prospective role in Oracle Database Maintenance
  4. Use Resource Manager to optimize Oracle Performance
  5. Rollback Segment optimization for Oracle Performance Optimization

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.