In this example I'll describe steps for cloning
orcl database to new database
orcl2.
1. Create pfile from spfile from the database
orcl:
SQL> create pfile from spfile;
|
2. copy created init file for the new orcl2 database:
cp initorcl.ora initorcl2.ora
|
3. edit pfile of the database orcl2:
- remove all hidden parameters
- change orcl to orcl2 except db_name
- add new line with:
*.db_name='orcl'
*.db_unique_name='orcl2'
[oracle@localhost dbs]$ cat initorcl2.ora
*.audit_file_dest='/u01/app/oracle/admin/orcl2/adump'
*.audit_trail='db'
*.compatible='12.1.0.2.0'
*.control_files='/u01/app/oracle/oradata/orcl2/control01.ctl','/u01/app/oracle/oradata/orcl2/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='orcl'
*.db_unique_name='orcl2'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.local_listener='LISTENER_ORCL'
*.memory_target=1200m
*.open_cursors=300
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
|
4. Create directory structure:
[oracle@localhost dbs]$ mkdir -p /u01/app/oracle/admin/orcl2/adump
[oracle@localhost dbs]$ mkdir /u01/app/oracle/oradata/orcl2
[oracle@localhost dbs]$ mkdir /u01/app/oracle/fast_recovery_area/orcl2
|
5. Edit /etc/oratab:
[oracle@localhost dbs]$ cat /etc/oratab
orcl:/u01/app/oracle/product/12.1.0/dbhome_1:N
orcl2:/u01/app/oracle/product/12.1.0/dbhome_1:N
|
6. setup new environment for the database
orcl2
[oracle@localhost dbs]$ cat /etc/oratab
[oracle@localhost dbs]$ . oraenv
ORACLE_SID = [orcl] ? orcl2
The Oracle base remains unchanged with value /u01/app/oracle
|
7. startup nomount database
orcl2
SQL> startup nomount
ORACLE instance started.
Total System Global Area 524288000 bytes
Fixed Size 2926320 bytes
Variable Size 444598544 bytes
Database Buffers 71303168 bytes
Redo Buffers 5459968 bytes
|
8. copy password file from database
orcl to
orcl2 ($ORACLE_HOME/dbs)
[oracle@localhost dbs]$ ls -la orapworcl*
-rw-r----- 1 oracle oinstall 7680 Oct 10 12:42 orapworcl
[oracle@localhost dbs]$ cp orapworcl orapworcl2
|
9. update information in tnsnames.ora ($ORACLE_HOME/network/admin)
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
ORCL2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl2)
)
)
|
10. update information in listener.ora ($ORACLE_HOME/network/admin)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=orcl)
(ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1)
(SID_NAME=orcl))
(SID_DESC=
(GLOBAL_DBNAME=orcl2)
(ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1)
(SID_NAME=orcl2))
)
|
11. connect to the rman
[oracle@localhost admin]$ rman target sys/oracle@orcl auxiliary sys/oracle@orcl2
Recovery Manager: Release 12.1.0.2.0 - Production on Tue Oct 10 15:47:43 2017
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
connected to target database: ORCL (DBID=1484792494)
connected to auxiliary database: ORCL (not mounted)
|
12. run duplicate command:
run {
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate channel prmy3 type disk;
allocate channel prmy4 type disk;
allocate auxiliary channel stby type disk;
duplicate target database to orcl2 from active database
SPFILE PARAMETER_VALUE_CONVERT '/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/orcl2'
set DB_FILE_NAME_CONVERT 'orcl','orcl2'
set log_file_name_convert '/u01/app/oracle/oradata/orcl','/u01/app/oracle/oradata/orcl2'
set DB_UNIQUE_NAME 'orcl2'
set control_files='/u01/app/oracle/oradata/orcl2/control01.ctl',
'/u01/app/oracle/fast_recovery_area/orcl2/control02.ctl';
}
|
Comments
Post a Comment