duplicate database
关于复制数据库的几点总结:
1、Starting with Oracle Database 12c, the version of the RMAN client, target database, and auxiliary database must be the same.
也就是说不能在不同的版本上使用复制数据库的方式
2、测试过程中,在线复制的方式在连接辅助实例时报错,建议以后用备份集的复制方式。
操作过程:
从测试数据库服务器6.80上orcl复制数据库到5.10上
1、复制口令文件到目标服务器
scp oracle@10.10.6.80:/u01/app/oracle/product/12.1.0/dbhome_1/dbs/orapworcl1 orapwdupdb
2、手动创建一个参数文件
Create an initialization parameter file manually
db_name='dupdb'
db_block_size=8192
control_files = (/u01/app/oracle/product/12.1.0/db_1/dbs/ctl01_.ctl,/u01/app/oracle/product/12.1.0/db_1/dbs/ctl02_.ctl)
db_file_name_convert=('+DATA/ORCL/DATAFILE/','/u01/app/oracle/dupdbdata/datafile/','+DATA/ORCL/TEMPFILE/','/u01/app/oracle/dupdbdata/datafile/')
log_file_name_convert=('+DATA/ORCL/ONLINELOG/','/u01/app/oracle/dupdbdata/datafile/')
compatible=12.1.0.2.0)
3、建立网络连接
在目标服务器上配置静态listener,将复制数据库静态注册到监听器。静态注册后,重启监听后监听会对将该实例立即监听。其他动态的监听实例会等大约1分钟。
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = DOCTEST)
(ORACLE_HOME =/u01/app/oracle/product/12.2.0/dbhome_1)
)
)
配置tnsnames.ora,将
10.10.5.10dupdb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = tcp)(HOST = 10.10.5.10)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = dupdb)
(INSTANCE_NAME = dupdb)
)
)
10.10.6.80orcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = tcp)(HOST = 10.10.6.80)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = orcl)
(INSTANCE_NAME = orcl1)
)
)
4\重启10.10.5.10的监听
5、 采用数据备份集的方式复制数据库,舍弃active复制方式
备份源数据库 10.10.6.80orcl库
RUN {
BACKUP full DATABASE format '/u01/dbbackup/duporcl/full_%d_%s_%p_%u.bak'
tag='full' include current controlfile;
backup spfile tag='spfile' format='/u01/dbbackup/duporcl/spfile_%d_%U_%T';
sql 'alter system archive log current';
backup archivelog all format='/u01/dbbackup/duporcl/archive_%d_%U_%T' delete input;
crosscheck backup;
crosscheck archivelog all;
delete expired backup;
delete expired archivelog all;
}
7、 备份完毕后,在目标服务器上建立和源服务器上备份目录相同的目录,将备份的文件拷贝到目标服务器。
6、 复制数据库
SQL> startup nomount pfile='/u01/app/oracle/product/12.1.0/db_1/dbs/initdupdb.ora';
ORACLE instance started.
Total System Global Area 520093696 bytes
Fixed Size 2926176 bytes
Variable Size 444598688 bytes
Database Buffers 67108864 bytes
Redo Buffers 5459968 bytes
SQL> create spfile from pfile;
File created.
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 520093696 bytes
Fixed Size 2926176 bytes
Variable Size 444598688 bytes
Database Buffers 67108864 bytes
Redo Buffers 5459968 bytes
SQL> show parameter compatible
NAME TYPE
------------------------------------ ---------------------------------
VALUE
------------------------------
compatible string
12.1.0.2.0
noncdb_compatible boolean
FALSE
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
[oracle@enfidbcl dbs]$ rman auxiliary /
Recovery Manager: Release 12.1.0.2.0 - Production on Tue Mar 24 16:46:40 2020
Copyright (c) 1982, 2014, Oracle and/or its affiliates. All rights reserved.
connected to auxiliary database: DUPDB (not mounted)
RMAN> duplicate database to dupdb backup location='/u01/dbbackup/duporcl/';
Starting Duplicate Db at 24-MAR-20
contents of Memory S