Oracle replication Database "Weber produced"

Source: Internet
Author: User

I. Overview

In the company, we often face a situation. After we have worked out the operation of the database, we can not execute it on the real database, we need to test it in the standby database, the data on the backup data and the real database are identical. The database we're talking about doesn't refer to a mirrored backup like RAID1. It means cloning the database and putting the data in another database. In the backup database we complete the execution of the scenario to ensure that it is ready to be deployed on the real machine.

Second, classification

There are many ways to replicate a database today:

1. Copying the database manually

2.RMAN Copy Database

Third, the environment

vmware:8.0

Linux:rhel5

Oracle:release 10.2.0.5.0

Oracle_sid:orcl

Environment Description: I opened a virtual machine, can actually open two virtual machines to simulate the best, but the configuration of the book is limited, only in the case of the virtual machine to open the database replication simulation. But they're basically the same.

Iv. Manual copying of databases

1. First create a backup script: backup.sh

 as sysdba<<EOF        ALTER DATABASE begin backup;        ! Cp-v/U01/APP/ORACLE/ORADATA/ORCL/*DBF/U01/BACKUP/HOTBK        ALTER DATABASE end backup;        ALTER DATABASE backup Controlfile to trace as             '/u01/backup/hotbk/control.trace ' reuse;        ALTER DATABASE backup Controlfile to '/u01/backup/hotbk/control.bak ' reuse;        Create pfile= '/u01/backup/hotbk/initorcl.ora ' from SPFile;        alter system switch logfile;        alter system switch logfile;        alter system switch logfile;        Exit        EOF        echo "Backup is complete!!!"

2. Assigning permissions to Scripts

chmod +x backup.sh

3. Execute the Script

./backup.sh

4. Wait for the backup to succeed

Cp/u01/backup/hotbk/initorcl.ora  $ORACLE _home/dbs/initcddx.ora

5. All we have to do is modify our parameter file.

VI $ORACLE _home/dbs/initcddx.ora

6. Why modify the parameter file? Because the database boot to mount state requires a parameter file, the parameter file contains the database instance name and so on. Specifically what else can own Baidu.

Execution:%s/orcl/CDDX
-p/u01/app/oracle/admin/cddx/{a,b,c,u}dump -p/u01/app/oracle/oradata/cddx/

7. After modifying the parameter file we can log into the database, we need to modify the environment variables before logging into the database, because the previous environment variable is ORCL, if not modified immediately start to ORCL this database up.

Export ORACLE_SID=CDDX

8. Log into the database and create a parameter file

 as Sysdbasql  from Pfile;

9.startup Nomount to view the entire database instance and status, this time to apply to the parameter file after the database started to the Nomount state.

10. After we have trace the control file, we will now modify the control file:

Modify/u01/backup/hotbk/control.trace:

11. Delete more than 55 lines of content, keep the following: In fact, we have to do is to reconstruct the control file; Change Place: First row set DATABASE CDDX resetlogs, replace all ORCL with CDDX

CREATE controlfile SET DATABASE cddx resetlogs ARCHIVELOG maxlogfiles -maxlogmembers3Maxdatafiles -maxinstances8maxloghistory292LOGFILE GROUP1 '/u01/app/oracle/oradata/cddx/redo01.log'SIZE 50M, GROUP2 '/u01/app/oracle/oradata/cddx/redo02.log'SIZE 50M, GROUP3 '/u01/app/oracle/oradata/cddx/redo03.log'SIZE 50M--STANDBY Logfiledatafile'/u01/app/oracle/oradata/cddx/system01.dbf',  '/u01/app/oracle/oradata/cddx/undotbs01.dbf',  '/u01/app/oracle/oradata/cddx/sysaux01.dbf',  '/u01/app/oracle/oradata/cddx/users01.dbf',  '/u01/app/oracle/oradata/cddx/example01.dbf'CHARACTER SET Al32utf8

Then copy the previously backed up data file to the/u01/app/oracle/oradata/weber/

cp/u01/backup/hotbk//u01/app/oracle/oradata/weber/

12. Next to SQL, execute:

Sql>Get/u01/backup/hotbk/Control.trace1CREATE controlfile SET DATABASE cddx resetlogs ARCHIVELOG2Maxlogfiles -  3Maxlogmembers3  4Maxdatafiles -  5Maxinstances8  6Maxloghistory292  7LOGFILE8GROUP1 '/u01/app/oracle/oradata/cddx/redo01.log'SIZE 50M,9GROUP2 '/u01/app/oracle/oradata/cddx/redo02.log'SIZE 50M,TenGROUP3 '/u01/app/oracle/oradata/cddx/redo03.log'SIZE 50M One--STANDBY LOGFILE Adatafile -    '/u01/app/oracle/oradata/cddx/system01.dbf',  -    '/u01/app/oracle/oradata/cddx/undotbs01.dbf',  the    '/u01/app/oracle/oradata/cddx/sysaux01.dbf',  -    '/u01/app/oracle/oradata/cddx/users01.dbf',  -    '/u01/app/oracle/oradata/cddx/example01.dbf'  -*CHARACTER SET Al32utf8 +/Control file created. The state of the instance is automatically changed to mounted after you create it

13. Now we are going to restore the database:

Sql>recover database until Cancel

14. Recovery may be error, if the error is to use REDO1 this log file for recovery

15. Open the database at this time

Sql>alter database open resetlogs;

16. Querying the status of the database and the database ID

sql> ALTER DATABASE open Resetlogs;database altered. SQLSelect from v$instance; STATUS------------opensqlSelect from v$database;      DBID----------1387955536SQLSelect from v$database;      DBID----------1387955536

17. This time the two database dbid is the same, this time need to change the dbid change dbid, this time need to put the database mounted state, and then execute in the operating system.

Nid target=sys/rootroot enter y and then restart the database to change dbid An error occurs when you open the database: DB mounted. ORA-01589  for database open requires that we have to reset the ordinal of the archive log. 

18. View the database ID

Select  from v$database;      DBID----------2725151620 was originally:1387955536

V. Rman replication Database

Oracle replication Database "Weber produced"

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.