环境搭建
    1.修改sid

    1. 192.168.5.240 orcl
    2. 192.168.5.241 orcltest

    2.创建副本数据库密码文件

    1. cd /opt/oracle/product/18c/dbhome_1/dbs/
    2. [oracle@oracle dbs]$ orapwd file=orapwORCLTEST password="19961216wpp" entries=20 format=12;

    3.创建副本数据库所需要目录

    1. [oracle@oracle dbs]$ mkdir /opt/oracle/admin/ORCLTEST -p
    2. [oracle@oracle dbs]$ cd /opt/oracle/admin/ORCLTEST
    3. [oracle@oracle admin]$ mkdir adump dpdump pfile
    4. [oracle@oracle admin]$ mkdir /opt/oracle/oradata/ORCLTEST/controlfile -p
    5. [oracle@oracle admin]$ cd /opt/oracle/
    6. [oracle@oracle oracle]$ mkdir fast_recovery_are/archivelog -p

    4.创建副本数据库初始化文件

    1. vi initORCLTEST.ora
    2. db_name='ORCLTEST'
    3. audit_file_dest='/opt/oracle/admin/ORCLTEST/adump'
    4. db_block_size=8192
    5. remote_login_passwordfile='EXCLUSIVE'
    6. memory_target=2g
    7. log_archive_dest='/opt/oracle/fast_recovery_are/archivelog'
    8. log_archive_format='%t_%s_%r.arc'
    9. undo_management='AUTO'
    10. undo_tablespace='UNDOTBS1'
    11. control_files = ('/opt/oracle/oradata/ORCLTEST/controlfile/control01.ctl', '/opt/oracle/oradata/ORCLTEST/controlfile/control02.ctl')
    12. compatible ='12.2.0'
    13. db_file_name_convert=('/opt/oracle/oradata/ORCL','/opt/oracle/oradata/ORCLTEST')
    14. log_file_name_convert=('/opt/oracle/oradata/ORCL','/opt/oracle/oradata/ORCLTEST')

    5.nomount启动副本数据库

    1. SQL> startup nomount;
    2. ORACLE instance started.
    3. Total System Global Area 1073740616 bytes
    4. Fixed Size 8665928 bytes
    5. Variable Size 641728512 bytes
    6. Database Buffers 415236096 bytes
    7. Redo Buffers 8110080 bytes

    6.配置目标库静态监听
    listener.ora

    1. [oracle@oracle admin]$ cat listener.ora
    2. # listener.ora Network Configuration File: /opt/oracle/product/18c/dbhome_1/network/admin/listener.ora
    3. # Generated by Oracle configuration tools.
    4. SID_LIST_LISTENER =
    5. (SID_LIST =
    6. (SID_DESC =
    7. (GLOBAL_DBNAME = ORCLTEST)
    8. (ORACLE_HOME = /opt/oracle/product/18c/dbhome_1)
    9. (SID_NAME = ORCLTEST)
    10. )
    11. )
    12. LISTENER =
    13. (DESCRIPTION =
    14. (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.5.241)(PORT = 1521))
    15. )
    16. ADR_BASE_LISTENER = /opt/oracle
    1. [oracle@oracle admin]$ cat tnsnames.ora
    2. # tnsnames.ora Network Configuration File: /opt/oracle/product/18c/dbhome_1/network/admin/tnsnames.ora
    3. # Generated by Oracle configuration tools.
    4. ORCLTEST =
    5. (DESCRIPTION =
    6. (ADDRESS_LIST =
    7. (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.5.241)(PORT = 1521))
    8. )
    9. (CONNECT_DATA =
    10. (SERVICE_NAME = ORCLTEST)
    11. )
    12. )

    7.启动源数据库和监听
    8.测试副本数据库监听

    1. sqlplus sys/19961216wpp@192.168.5.241:1521/ORCLTEST as sysdba

    9.创建副本数据库
    1.从活动实例创建

    1. rman target sys/19961216wpp@192.168.5.11:1521/orcl auxiliary sys/19961216wpp@192.168
    2. .5.12:1521/orcltest
    3. duplicate target database to ORCLTEST from active database nofilenamecheck;
    4. -----------------------------------------------------------------------------------------
    5. 压缩传输到目标库
    6. duplicate target database to ORCLTEST from active database
    7. password file using compressed backupset nofilenamecheck;
    8. ----------------------------------------------------------------
    9. 设置目标库表空间大小
    10. duplicate target database to ORCLTEST from active database
    11. password file section 500M nofilenamecheck;

    2.从源库rman备份集创建

    1. 源库
    2. configure backup optimization on;
    3. backup database;
    4. rman target sys/19961216wpp@192.168.5.11:1521/orcl auxiliary sys/19961216wpp@192.168
    5. .5.12:1521/orcltest
    6. duplicate target database to ORCLTEST;

    3.从目录备份集恢复

    1. cp 归档日志,数据文件和controlfile 备份集到/opt/oracle/backup
    2. rman auxiliary sys/19961216wpp@192.168.5.12:1521/orcltest
    3. duplicate target database to ORCLTESTbackup location '/opt/oracle/backup' NOFILENAMECHECK;

    10.错误提示
    rman 版本不一致

    1. ORA-19690: backup piece release 18.0.0.0.0 incompatible with Oracle release 12.2.0.0.0

    RMAN-05001,主备库oracle目录相同的情况下,如果没有nofilenamecheck参数,则复制库的时候会报这个错。

    1. channel ORA_AUX_DISK_1: SID=433 device type=DISK
    2. RMAN-00571: ===========================================================
    3. RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    4. RMAN-00571: ===========================================================
    5. RMAN-03002: failure of Duplicate Db command at 10/12/2019 04:49:27
    6. RMAN-05501: aborting duplication of target database
    7. RMAN-05001: auxiliary file name /opt/oracle/fast_recovery_area/ORCL/onlinelog/o1_mf_3_gswm7phr_.log conflic
    8. ts with a file used by the target database
    9. RMAN-05001: auxiliary file name /opt/oracle/fast_recovery_area/ORCL/onlinelog/o1_mf_2_gswm7phh_.log conflic
    10. ts with a file used by the target database
    11. RMAN-05001: auxiliary file name /opt/oracle/fast_recovery_area/ORCL/onlinelog/o1_mf_1_gswm7ph8_.log conflic
    12. ts with a file used by the target database

    ORA-17628:问题解决,原因是备库缺少日志目录、数据文件目录,创建相应的目录,即可解决问题