环境描述(两台机器中oracle版本均为10.0.2.1):
目标端(待复制数据库ORCL)
IP:10.37.100.100
DB_NAME:ORCL
SID:ORCL
辅助端:
IP:10.37.100.101
DB_NAME:ORCL_DUP
SID:ORCL_DUP
创建秘钥文件
[oracle@localhost ~]$ orapwd file=/u01/app/oracle/10.2.0/db_1/dbs/ora
pworcl password=oracle entries=30 force=y
创建PFILE
SQL> create pfile='/u01/pfile.ora' from spfile;
File created.
[oracle@localhost ~]$ scp 10.37.100.100:/u01/pfile.ora /u01/
oracle@10.37.100.100's password:
pfile.ora 100% 1058 1.0KB/s 00:00
[oracle@localhost ~]$ scp 10.37.100.100:/u01/app/oracle/10.2.0/db_1/dbs/orapworcl /u01/app/oracle/10.2.0/d
b_1/dbs/orapworcl_dup
oracle@10.37.100.100's password:
orapworcl 100% 5120 5.0KB/s 00:00
配置辅助端监听
[oracle@localhost ~]$ echo O$ORACLE_SID
orcl_dup
[oracle@localhost ~]$ cd $ORACLE_HOME/network/admin
[oracle@localhost admin]$ vi listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = orcl_dup)
(ORACLE_HOME = /u01/app/oracle/10.2.0/db_1)
(GLOBAL_NAME = orcl_dup)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.37.100.101)(PORT = 1521))
)
)
重启监听:
[oracle@localhost ~]$ lsnrctl stop
[oracle@localhost ~]$ lsnrctl start
配置目标端tns
[oracle@localhost ~]$ cd $ORACLE_HOME/network/admin
[oracle@localhost admin]$ vi tnsnames.ora
添加如下内容:
RMAN_DUP =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.37.100.101)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl_dup)
)
)
测试TNS:
[oracle@localhost admin]$ tnsping rman_dup
TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 11-APR-2014 09:00:40
Copyright (c) 1997, 2005, Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/10.2.0/db_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.37.100.101)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl_dup)))
OK (10 msec)
创建辅助端相关目录
[oracle@localhost admin]$ vi tnsnames.ora
[oracle@localhost ~]$ mkdir -p /u01/FRA/orcl_dup
[oracle@localhost ~]$ mkdir -p /u01/orcl_dup_arch
[oracle@localhost ~]$ mkdir -p /u01/app/oracle/admin/orcl_dup/{a,b,c,u}dump
[oracle@localhost ~]$ mkdir -p /u01/app/oracle/oradata/orcl_dup
修改辅助端参数文件
[oracle@localhost ~]$ vi /u01/pfile.ora
orcl.__db_cache_size=88080384
orcl.__java_pool_size=4194304
orcl.__large_pool_size=8388608
orcl.__shared_pool_size=58720256
orcl.__streams_pool_size=4194304
*.audit_file_dest='/u01/app/oracle/admin/orcl_dup/adump'
*.background_dump_dest='/u01/app/oracle/admin/orcl_dup/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/u01/app/oracle/oradata/orcl_dup/control01.ctl','/u01/app/oracle/oradata/orcl_dup/control02.ctl','/u01/app/oracle/oradata/orcl_dup/control03.ctl'
*.core_dump_dest='/u01/app/oracle/admin/orcl_dup/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='orcl_dup'
*.db_recovery_file_dest='/u01/FRA/orcl_dup'
*.db_recovery_file_dest_size=5368709120
*.dbwr_io_slaves=2
*.disk_asynch_io=FALSE
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='location=/u01/orcl_dup_arch'
*.open_cursors=300
*.pga_aggregate_target=16777216
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=167772160
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS'
*.user_dump_dest='/u01/app/oracle/admin/orcl_dup/udump'
启动辅助实例
SQL> create spfile from pfile='/u01/pfile.ora';
File created.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 167772160 bytes
Fixed Size 1218316 bytes
Variable Size 62916852 bytes
Database Buffers 100663296 bytes
Redo Buffers 2973696 bytes
目标端启动数据库到mount或open,登入rman查看有无数据库备份,没有备份需做一次整库备份:
RMAN> list backup of database;
List of Backup Sets
===================
BS Key Type LV Size Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
2 Full 1.07G DISK 00:03:38 08-APR-14
BP Key: 2 Status: AVAILABLE Compressed: NO Tag: TAG20140408T090232
Piece Name: /u01/FRA/ORCL/backupset/2014_04_08/o1_mf_nnndf_TAG20140408T090232_9n6looxp_.bkp
List of Datafiles in backup set 2
File LV Type Ckp SCN Ckp Time Name
---- -- ---- ---------- --------- ----
1 Full 1678073 08-APR-14 /u01/app/oracle/oradata/orcl/system01.dbf
2 Full 1678073 08-APR-14
3 Full 1678073 08-APR-14 /u01/app/oracle/oradata/orcl/sysaux01.dbf
4 Full 1678073 08-APR-14 /u01/app/oracle/oradata/orcl/users01.dbf
5 Full 1678073 08-APR-14 /u01/app/oracle/oradata/orcl/example01.dbf
6 Full 1678073 08-APR-14 /u01/app/oracle/oradata/orcl/tts01.dbf
7 Full 1678073 08-APR-14 /u01/app/oracle/oradata/orcl/tts02.dbf
rman连接数据库和辅助实例
[oracle@localhost admin]$ rman target sys/oracle auxiliary sys/oracle@rman_dup
Recovery Manager: Release 10.2.0.1.0 - Production on Fri Apr 11 09:08:48 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: ORCL (DBID=1370299695)
connected to auxiliary database: ORCL_DUP (not mounted)
RMAN> list backup;
查看备份集,将备份集copy至目标端的相应路径下
[oracle@localhost backupset]$ scp 10.37.100.100:/u01/FRA/ORCL/backupset/2014_04_11/* /u01/FRA/ORCL/backupset/2014_04_11/
oracle@10.37.100.100's password:
o1_mf_annnn_TAG20140411T092418_9ngk2cpl_.bkp 100% 2416MB 10.1MB/s 03:59
o1_mf_annnn_TAG20140411T093218_9ngkk4fo_.bkp 100% 142KB 142.0KB/s 00:01
o1_mf_ncsnf_TAG20140411T092904_9ngkjv89_.bkp 100% 7008KB 6.8MB/s 00:01
o1_mf_nnndf_TAG20140411T092904_9ngkc1fm_.bkp 100% 857MB 13.0MB/s 01:06
开始复制
RMAN> run{
2> allocate auxiliary channel c1 device type disk;
3> allocate auxiliary channel c2 device type disk;
4> duplicate target database to orcl_dup
5> db_file_name_convert='/u01/app/oracle/oradata/orcl', '/u01/app/oracle/oradata/orcl_dup'
6> logfile
7> '/u01/app/oracle/oradata/orcl_dup/redo01.log' size 20m,
8> '/u01/app/oracle/oradata/orcl_dup/redo03.log' size 20m,
9> '/u01/app/oracle/oradata/orcl_dup/redo02.log' size 20m;
10> }
.
.
.
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 11-APR-14
复制完成,验证结果
辅助端登入数据库:
[oracle@localhost backupset]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Apr 11 09:58:53 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select status from v$instance;
STATUS
------------
OPEN
SQL> conn scott/oracle
Connected.
SQL> select tname from tab;
TNAME
------------------------------
DEPT
EMP
BONUS
SALGRADE
TEST
DUPLICATE复制数据库成功。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29320885/viewspace-1139947/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29320885/viewspace-1139947/