RMAN duplicate database, rmanduplicate
Use the RMAN duplicate command to create a secondary database. Once the secondary database is created successfully, it is out of the source database. You can use the secondary database for some experiments.
This document uses the source database to create a secondary database in other directories of the local machine.
Source database:
SID = ORCL
Secondary database:
SID = DUP
For the physical file directories of the source and secondary databases, see initDUP. ora.
Step 1. Create a key file for the secondary database.
Execute the orapwd command to create the key file. When logging on to the database remotely, you need to save the password in the key file.
Command:
$: Orapwd file = orapwDUP password = oracle entries = 30
The format of the key file is orapwSID, And the SID of our auxiliary database is DUP.
Step 2. Create the parameter file initDUP. ora of the secondary Database
DB_NAME='DUP'shared_pool_size=163577856control_files='/u01/app/oracle/oradata/DUP/controlfile/o1_mf_blt7js24_.ctl','/u01/app/oracle/oradata/DUP/controlfile/o1_mf_blt7js9b_.ctl'db_block_size=8192DB_FILE_NAME_CONVERT=('/u01/app/oracle/oradata/ORCL/datafile','/u01/app/oracle/oradata/DUP/datafile')LOG_FILE_NAME_CONVERT=('/u01/app/oracle/oradata/ORCL/onlinelog','/u01/app/oracle/oradata/DUP/onlinelog')
Our secondary database only has the required six parameters. Because we create a secondary database on the same machine, the data file directories of the secondary database and the source database must be different from those of the On-premises log files. Therefore, we need to convert the directories, the last two parameters are the directory conversion of the source database and auxiliary database data files and On-line log files.
Then, sqlplus connects to the secondary database and changes the environment variable $ ORACLE_SID. (Use the export ORACLE_SID = DUP command for conversion)
Use initDUP. ora to create spfile:
SQL> create spfile from pfile.
Step 3. Start the secondary Database
At this time, the auxiliary database does not have control files, so it only starts the database to the nomount state.
SQL> startup nomount;
Step 4. Configure the listener and Network Service name
Create a LISTENER for the secondary database DUP, and add the database DUP in the existing LISTENER. You can use the netca and netmgr tools in Linux, you can also go to $ ORACLE_HOME/netwaork/admin/listener. create the following text in ora:
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = ORCL) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1) (SID_NAME = ORCL) ) (SID_DESC = (GLOBAL_DBNAME = DUP) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1) (SID_NAME = DUP) ) )LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.159.155)(PORT = 1521)) )
Modify $ ORACLE_HOME/network/admin/tnsnames. ora
ORCL = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.159.155)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = ORCL) ) )DUP = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.159.155)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = DUP) ) )
After configuring the above two files, remember to start the LISTENER process LISTENER.
$ Lsnrctl start
Step 5. Start the source database to the mount or open state
Because we want to use rman to connect to the source database, we must start the source database to the mount or open state.
Switch ORACLE_SID to ORCL
SQL> startup
Step 6. Verify the backup of the source database
You need to use the backup of the source database to create a secondary database, use rman to connect to the ORCL database, and use list backup to check whether there is a backup. For the sake of security, you can perform a full backup again.
Step 7. Perform Replication
Connect to the source and secondary databases using rman
$ Rman target sys/xxxxx @ orcl auxiliary sys/orcl @ dup
Run the following command to copy
Run {
Allocate channel c1 device type disk;
Duplicate target database to dup;
}
After the command is executed, you can connect to the secondary database for operations.
References:
Apply Oracle