Oracle Database replication or cloning is often used to provide a test or development environment. There are multiple methods to generate a clone database, such as using the Cold Standby Method for database cloning (required
Oracle Database replication or cloning is often used to provide a test or development environment. There are multiple methods to generate a clone database, such as using the Cold Standby Method for database cloning (required
Oracle Database replication or cloning is often used to provide a test or development environment. There are multiple methods to generate a clone database, such as using the cold standby mode for database cloning (you need to use nid to modify db_name), hot standby mode for database cloning, and rman mode for database cloning. Because the database is cloned on the same machine, the target database and the original database must be located in different directories. Second, the Database Name (db_name) is not used ). This document describes how to clone a database using a user-managed hot standby mode and provides an example.
1. Hot Standby cloning procedure
A. Create the target database directory
B. Create the target database password file (orapwd)
C. Create a parameter file for the target database (pfile/spfile)
D. Back up the original database and copy the backup file to the target database.
E. Start the target database to the nomount status and create a control file.
F. Restore the target database (recover)
G. open with resetlogs)
H. Check the database and add temporary data files
2. Demonstrate Hot Standby clone Database
--> Demo Environment
SQL> ho cat/etc/issue
Enterprise Linux Server release 5.5 (Carthage)
Kernel \ r on an \ m
SQL> select * from v $ version where rownum <2;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0-Production
SQL> select name, log_mode, open_mode from v $ database;
NAME LOG_MODE OPEN_MODE
-----------------------------------------------------------
SYBO3 ARCHIVELOG READ WRITE
-- Original database name: sybo3
-- Target database name: sybo4
-- Original database Directory:/u01/database/sybo3
-- Target database Directory:/u01/database/sybo4
-- A. Create the target database directory
[Oracle @ linux3 database] $ more sybo4.sh
#! /Bin/sh
Mkdir-p/u01/database
Mkdir-p/u01/database/sybo4/adump
Mkdir-p/u01/database/sybo4/controlf
Mkdir-p/u01/database/sybo4/flash_recovery_area
Mkdir-p/u01/database/sybo4/oradata
Mkdir-p/u01/database/sybo4/redo
Mkdir-p/u01/database/sybo4/dpdump
Mkdir-p/u01/database/sybo4/pfile
Mkdir-p/u01/database/sybo4/db_broker
[Oracle @ linux3 database] $./sybo4.sh
-- B. Create the password file of the target database
$ Orapwd file = $ ORACLE_HOME/dbs/orapwsybo4 password = oracle entries = 10
-- C. Create a parameter file for the target database
-- Generate the initialization parameter file of the target database from the original database
SQL> create pfile = '/u01/oracle/db_1/dbs/initsybo4.ora' from spfile;
-- Modify the parameter file of the target database
$ Sed-I's/sybo3/sybo4/G' $ ORACLE_HOME/dbs/initsybo4.ora
$ Grep sybo3 $ ORACLE_HOME/dbs/initsybo4.ora --> check whether sybo3 characters still exist
-- Final target database parameter file
$ More $ ORACLE_HOME/dbs/initsybo4.ora
Sybo4. _ db_cache_size = 117440512
Sybo4. _ java_pool_size = 4194304
Sybo4. _ large_pool_size = 4194304
Sybo4. _ oracle_base = '/u01/oracle' # ORACLE_BASE set from environment
Sybo4. _ pga_aggregate_target = 150994944
Sybo4. _ sga_target = 226492416
Sybo4. _ shared_io_pool_size = 0
Sybo4. _ shared_pool_size = 92274688
Sybo4. _ streams_pool_size = 0
*. Audit_file_dest = '/u01/database/sybo4/adump /'
*. Audit_trail = 'db'
*. Compatible = '11. 2.0.0.0'
*. Control_files = '/u01/database/sybo4/controlf/control01.ctl', '/u01/database/sybo4/controlf/control02.ctl'
*. Db_block_size = 8192
*. Db_domain = 'orasrv. com'
*. Db_name = 'sybo4'
*. Db_recovery_file_dest = '/u01/database/sybo4/flash_recovery_area /'
*. Db_recovery_file_dest_size = 4039114752
*. Dg_broker_config_file1 = '/u01/database/sybo4/db_broker/dr1sybo4. dat'
*. Dg_broker_config_file2 = '/u01/database/sybo4/db_broker/dr2sybo4. dat'
*. Dg_broker_start = FALSE
*. Diagnostic_dest = '/u01/database/sybo4'
*. Log_archive_dest_1 =''
*. Memory_target = 374341632
*. Open_cursors = 300
*. Processses = 150
*. Remote_login_passwordfile = 'clusive'
*. Undo_tablespace = 'undotbs1'
-- D. Back up the original database and copy the backup file to the target database.
-- Create a temporary table t. The user verifies whether the clone is successful.
SQL> create table t (name varchar2 (10), action varchar2 (20 ));
SQL> insert into t select 'robinson ', 'transfer db' from dual;
SQL> commit;
SQL> alter system archive log current;
-- Prepare a control file script for the target database. The trace file is located in the user_dump_dest directory.
SQL> alter database backup controlfile to trace resetlogs;
-- Back up the original database. If there are many database files, use the hot backup script
SQL> alter database begin backup;
-- Copy the database file to the target database directory
SQL> host cp/u01/database/sybo3/oradata/*/u01/database/sybo4/oradata
SQL> alter database end backup;
-- E. Start the target database to the nomount status and create a control file
$ Export ORACLE_SID = sybo4
$ Sqlplus/as sysdba
SQL> startup nomount pfile =/u01/oracle/db_1/dbs/initsybo4.ora;
ORACLE instance started.
SQL> get sybo4ctl. SQL
1 create controlfile set database "sybo4" RESETLOGS ARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7. LOGFILE
8 GROUP 1'/u01/database/sybo4/redo/redo01.log' SIZE 50 m blocksize 512,
9 GROUP 2'/u01/database/sybo4/redo/redo02.log 'SIZE 50 m blocksize 512,
10 GROUP 3'/u01/database/sybo4/redo/redo03.log' SIZE 50 m blocksize 512
11 DATAFILE
12'/u01/database/sybo4/oradata/system01.dbf ',
13 '/u01/database/sybo4/oradata/sysaux01.dbf ',
14'/u01/database/sybo4/oradata/undotbs01.dbf ',
15'/u01/database/sybo4/oradata/users01.dbf ',
16'/u01/database/sybo4/oradata/example01.dbf'
17 character set AL32UTF8
18 *;
SQL> @ sybo4ctl. SQL
Control file created.