RMAN-based database cloning on the same machine

Source: Internet
Author: User

Oracle Database cloning is also called Oracle Database Replication. It can be achieved through user management or RMAN. In addition, Oracle recommends using RMAN because it is easy to use and hides its complicated logic. You can just run a duplicate command to drink tea. Of course, preparations in the early stage are indispensable, such as creating the corresponding dump directory, preparing the parameter file, and configuring the listener. This article describes how to use RMAN to clone databases on the same machine in Oracle 11g.

RMAN duplicate Database

1. Several types of RMAN cloning
A. Use RMAN backup to clone and access the target database (that is, the original database), that is, the connection between Oracle net and the target database is maintained during replication.
B. Clone the database using RMAN backup and do not access the target database. For example, if the network is disconnected or the target database is unavailable, the connection to the target database is lost due to human or fault.
C. directly use the active database for cloning, real-time backup, and cloning!

2. What did RMAN clone do?
The RMAN clone connects to a secondary instance as needed or does not connect to the target database. This auxiliary instance is the copied instance.
We know that each database has at least one instance corresponding to it. In the RAC environment, multiple instances can correspond to one database.
Therefore, we should first create a nomount State Auxiliary instance to allocate memory and a series of background processes before cloning the database.
With the instance, it is easy to do. RMAN generates control files for the auxiliary instance, restores the database based on the instance, recovers the database, and other N-plus operations without pulling.
Who depends on N operations? The command is to release duplicate target databaseto aux_db.
Then how does RMAN connect to the secondary instance? Similar to connecting to target or catalog, connect auxiliary name/pwd @ tnsstring
Generally, for disk backup and restoration operations, RMAN will automatically create and allocate corresponding channels, and the secondary instance is no exception. Of course, it is automatically assigned a secondary channel.
In the case of tape media, it is a little troublesome. You need to manually specify the channel and degree of parallelism.
Next, let's briefly describe what we have done in different stages of RMAN cloning. For information on data file location conversion during database cloning, see: RMAN database clone File Location Conversion Method
A. RMAN determines the backup attributes, locations, and so on, so that the backup is available.
B. RMAN allocates channel and Auxiliary Channel parameter settings for the auxiliary instance
C. Restore the data file to the secondary instance using RMAN (the target database control file is used at this time)
D. Create a control file for the auxiliary instance using RMAN.
E. Restore the archived logs as needed and restore the media accordingly.
F. Reset the dbid of the secondary instance and open the database using open resetlog. An online redo log file is created.

3. General steps for RMAN cloning
A. Back up the target database (depending on the clone type you need. If the host is different, perform ftp. This step can also be placed after Step e and before step f)
B. Create the corresponding dump folder.
C. Configure the auxiliary instance parameter file
D. Generate a password file for the secondary instance
E. Configure the secondary instance listener
F. perform database cloning (after the secondary instance is started to nomount)
H. Verification results

4. close contact between RMAN and machine cloning

-- Environment:
-- Target database: sybo3/u01/database/sybo3
-- Auxiliary database: sybo5/u01/database/sybo5
-- Note:
-- If you do not know much about the following descriptions, such as creating parameter files, password files, and listeners, refer to the descriptions in the following links. Second, this demonstration uses the backup file and connects to the target db
Http://blog.csdn.net/robinson_0612/article/category/827734 (architecture-related)
-- Http://blog.csdn.net/robinson_0612/article/category/828434 (network configuration related)

[Oracle @ linux3 database] $ 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


A. Back up the target database
-- Generate test data that is successfully cloned for subsequent verification
SQL> insert into t select 'Jackson ', 'transfer DB by rman' from dual;

SQL> commit;

SQL> select * from t;

NAME ACTION
------------------------------
Robinson Transfer DB
Jackson Transfer DB by rman

SQL> alter system archive log current;

[Oracle @ linux3 ~] $ Rman target/

Recovery Manager: Release 11.2.0.1.0-Production on Thu Jul 25 08:39:42 2013

Copyright (c) 1982,200 9, Oracle and/or its affiliates. All rights reserved.

Connected to target database: SYBO3 (DBID = 2347733014)

RMAN> backup database include current controlfile plus archivelog delete input;

Piece handle =/u01/database/sybo3/flash_recovery_area/SYBO3/backupset/2013_07_25/o1_mf_annnn_TAG20130725T083957_8z0wyy9n _. bkp
Tag = TAG20130725T083957 comment = NONE
Channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Piece handle =/u01/database/sybo3/flash_recovery_area/SYBO3/backupset/2013_07_25/o1_mf_nnndf_TAG20130725T083959_8z0wz06c _. bkp
Tag = TAG20130725T083959 comment = NONE
Channel ORA_DISK_1: backup set complete, elapsed time: 00:01:30
Finished backup at 2013/07/25 08:41:29

Starting Control File and SPFILE Autobackup at 2013/07/25 08:41:31
Piece handle =/u01/database/sybo3/flash_recovery_area/SYBO3/autobackup/2013_07_25/o1_mf_s_821695293478z0x1vsf _. bkp comment = NONE
Finished Control File and SPFILE Autobackup at 2013/07/25 08:41:34


B. Create the corresponding dump folder.
[Oracle @ linux3 database] $ more sybo5.sh
#! /Bin/sh
Mkdir-p/u01/database
Mkdir-p/u01/database/sybo5/adump
Mkdir-p/u01/database/sybo5/controlf
Mkdir-p/u01/database/sybo5/flash_recovery_area
Mkdir-p/u01/database/sybo5/oradata
Mkdir-p/u01/database/sybo5/redo
Mkdir-p/u01/database/sybo5/dpdump
Mkdir-p/u01/database/sybo5/pfile
[Oracle @ linux3 database] $./sybo5.sh


C. Configure the auxiliary instance parameter file
-- Generate the parameter file of the auxiliary instance under sqlplus
SQL> create pfile = '/u01/oracle/db_1/dbs/initsybo5.ora' from spfile;

-- Modify the parameter file of the secondary instance
$ Sed-I's/sybo3/sybo5/G' $ ORACLE_HOME/dbs/initsybo5.ora
$ Grep sybo3 $ ORACLE_HOME/dbs/initsybo5.ora --> check whether sybo3 characters still exist

-- The final result after modification is as follows:
[Oracle @ linux3 database] $ more $ ORACLE_HOME/dbs/initsybo5.ora
Sybo5. _ db_cache_size = 113246208
Sybo5. _ java_pool_size = 4194304
Sybo5. _ large_pool_size = 4194304
Sybo5. _ oracle_base = '/u01/oracle' # ORACLE_BASE set from environment
Sybo5. _ pga_aggregate_target = 142606336
Sybo5. _ sga_target = 234881024
Sybo5. _ shared_io_pool_size = 0
Sybo5. _ shared_pool_size = 104857600
Sybo5. _ streams_pool_size = 0
*. Audit_file_dest = '/u01/database/sybo5/adump /'
*. Audit_trail = 'db'
*. Compatible = '11. 2.0.0.0'
*. Control_files = '/u01/database/sybo5/controlf/control01.ctl', '/u01/database/sybo5/controlf/control02.ctl'
*. Db_block_size = 8192
*. Db_domain = 'orasrv. com'
*. Db_name = 'sybo5'
*. Db_recovery_file_dest = '/u01/database/sybo5/flash_recovery_area /'
*. Db_recovery_file_dest_size = 4039114752
*. Dg_broker_config_file1 = '/u01/database/sybo5/db_broker/dr1sybo5. dat'
*. Dg_broker_config_file2 = '/u01/database/sybo5/db_broker/dr2sybo5. dat'
*. Dg_broker_start = FALSE
*. Diagnostic_dest = '/u01/database/sybo5'
*. Log_archive_dest_1 = ''# The archive location is not specified here. The default flashback zone is used.
*. Memory_target = 374341632
*. Open_cursors = 300
*. Processses = 150
*. Remote_login_passwordfile = 'clusive'
*. Undo_tablespace = 'undotbs1'


D. Generate a password file for the secondary instance
-- Directly use the orapwd command
$ Orapwd file = $ ORACLE_HOME/dbs/orapwsybo5 password = oracle entries = 10


E. Configure the secondary instance listener
-- There are many ways to configure the listener for the secondary instance, such as netca, netmgr, and direct command. The script provided below
[Oracle @ linux3 ~] $ More $ ORACLE_HOME/network/admin/listener. ora
# Listener. ora Network Configuration File:/u01/oracle/db_1/network/admin/listener. ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER_SYBO5 =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = sybo5.orasrv.com)
(ORACLE_HOME =/u01/oracle/db_1)
(SID_NAME = sybo5)
)
)

SID_LIST_LISTENER_SYBO3 =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = sybo3.orasrv.com)
(ORACLE_HOME =/u01/oracle/db_1)
(SID_NAME = sybo3)
)
)

LISTENER_SYBO5 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = linux3.orasrv.com) (PORT = 1532 ))
)

ADR_BASE_LISTENER_SYBO5 =/u01/oracle

LISTENER_SYBO3 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP) (HOST = linux3.orasrv.com) (PORT = 1531 ))
)

ADR_BASE_LISTENER_SYBO3 =/u01/oracle

[Oracle @ linux3 ~] $ More $ ORACLE_HOME/network/admin/tnsnames. ora
# Tnsnames. ora Network Configuration File:/u01/oracle/db_1/network/admin/tnsnames. ora
# Generated by Oracle configuration tools.

SYBO5 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.7.25) (PORT = 1532 ))
)
(CONNECT_DATA =
(SERVICE_NAME = SYBO5.ORASRV. COM)
)
)

SYBO3 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP) (HOST = 192.168.7.25) (PORT = 1531 ))
)
(CONNECT_DATA =
(SERVICE_NAME = SYBO3.ORASRV. COM)
)
)

See the next page:

  • 1
  • 2
  • Next Page

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.