环境搭建
1.修改sid
192.168.5.240 orcl
192.168.5.241 orcltest
2.创建副本数据库密码文件
cd /opt/oracle/product/18c/dbhome_1/dbs/
[oracle@oracle dbs]$ orapwd file=orapwORCLTEST password="19961216wpp" entries=20 format=12;
3.创建副本数据库所需要目录
[oracle@oracle dbs]$ mkdir /opt/oracle/admin/ORCLTEST -p
[oracle@oracle dbs]$ cd /opt/oracle/admin/ORCLTEST
[oracle@oracle admin]$ mkdir adump dpdump pfile
[oracle@oracle admin]$ mkdir /opt/oracle/oradata/ORCLTEST/controlfile -p
[oracle@oracle admin]$ cd /opt/oracle/
[oracle@oracle oracle]$ mkdir fast_recovery_are/archivelog -p
4.创建副本数据库初始化文件
vi initORCLTEST.ora
db_name='ORCLTEST'
audit_file_dest='/opt/oracle/admin/ORCLTEST/adump'
db_block_size=8192
remote_login_passwordfile='EXCLUSIVE'
memory_target=2g
log_archive_dest='/opt/oracle/fast_recovery_are/archivelog'
log_archive_format='%t_%s_%r.arc'
undo_management='AUTO'
undo_tablespace='UNDOTBS1'
control_files = ('/opt/oracle/oradata/ORCLTEST/controlfile/control01.ctl', '/opt/oracle/oradata/ORCLTEST/controlfile/control02.ctl')
compatible ='12.2.0'
db_file_name_convert=('/opt/oracle/oradata/ORCL','/opt/oracle/oradata/ORCLTEST')
log_file_name_convert=('/opt/oracle/oradata/ORCL','/opt/oracle/oradata/ORCLTEST')
5.nomount启动副本数据库
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 1073740616 bytes
Fixed Size 8665928 bytes
Variable Size 641728512 bytes
Database Buffers 415236096 bytes
Redo Buffers 8110080 bytes
6.配置目标库静态监听
listener.ora
[oracle@oracle admin]$ cat listener.ora
# listener.ora Network Configuration File: /opt/oracle/product/18c/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = ORCLTEST)
(ORACLE_HOME = /opt/oracle/product/18c/dbhome_1)
(SID_NAME = ORCLTEST)
)
)
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.5.241)(PORT = 1521))
)
ADR_BASE_LISTENER = /opt/oracle
[oracle@oracle admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /opt/oracle/product/18c/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCLTEST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.5.241)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = ORCLTEST)
)
)
7.启动源数据库和监听
8.测试副本数据库监听
sqlplus sys/19961216wpp@192.168.5.241:1521/ORCLTEST as sysdba
9.创建副本数据库
1.从活动实例创建
rman target sys/19961216wpp@192.168.5.11:1521/orcl auxiliary sys/19961216wpp@192.168
.5.12:1521/orcltest
duplicate target database to ORCLTEST from active database nofilenamecheck;
-----------------------------------------------------------------------------------------
压缩传输到目标库
duplicate target database to ORCLTEST from active database
password file using compressed backupset nofilenamecheck;
----------------------------------------------------------------
设置目标库表空间大小
duplicate target database to ORCLTEST from active database
password file section 500M nofilenamecheck;
2.从源库rman备份集创建
源库
configure backup optimization on;
backup database;
rman target sys/19961216wpp@192.168.5.11:1521/orcl auxiliary sys/19961216wpp@192.168
.5.12:1521/orcltest
duplicate target database to ORCLTEST;
3.从目录备份集恢复
cp 归档日志,数据文件和controlfile 备份集到/opt/oracle/backup
rman auxiliary sys/19961216wpp@192.168.5.12:1521/orcltest
duplicate target database to ORCLTESTbackup location '/opt/oracle/backup' NOFILENAMECHECK;
10.错误提示
rman 版本不一致
ORA-19690: backup piece release 18.0.0.0.0 incompatible with Oracle release 12.2.0.0.0
RMAN-05001,主备库oracle目录相同的情况下,如果没有nofilenamecheck参数,则复制库的时候会报这个错。
channel ORA_AUX_DISK_1: SID=433 device type=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 10/12/2019 04:49:27
RMAN-05501: aborting duplication of target database
RMAN-05001: auxiliary file name /opt/oracle/fast_recovery_area/ORCL/onlinelog/o1_mf_3_gswm7phr_.log conflic
ts with a file used by the target database
RMAN-05001: auxiliary file name /opt/oracle/fast_recovery_area/ORCL/onlinelog/o1_mf_2_gswm7phh_.log conflic
ts with a file used by the target database
RMAN-05001: auxiliary file name /opt/oracle/fast_recovery_area/ORCL/onlinelog/o1_mf_1_gswm7ph8_.log conflic
ts with a file used by the target database
ORA-17628:问题解决,原因是备库缺少日志目录、数据文件目录,创建相应的目录,即可解决问题