一、异机复制
1、源库、目标准备静态监听
源库
LISTENER =
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=172.16.220.20)(PORT=1521))
(ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)))
# SID_LIST_<lsnr>
# List of services the listener knows about and can connect
# clients to. There is no default. See the Net8 Administrator's
# Guide for more information.
#
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=cy)
(SID_NAME=cy)
(ORACLE_HOME=/u01/app/oracle/product/19.3/dbhome_1)
)
)
目标库
LISTENER =
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=172.16.220.21)(PORT=1521))
(ADDRESS=(PROTOCOL=ipc)(KEY=PNPKEY)))
# SID_LIST_<lsnr>
# List of services the listener knows about and can connect
# clients to. There is no default. See the Net8 Administrator's
# Guide for more information.
#
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=cy)
(SID_NAME=cy)
(ORACLE_HOME=/u01/app/oracle/product/19.3/dbhome_1)
)
)
复制源库sample下的模板,修改即可,修改完成复制至目标库只需要修改ip地址即可
2、准备源库、目标库tnsnames.ora
源库、目标库一样
cy =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.220.20)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = cy)
)
)
cydp =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.220.21)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = cy)
)
)
3、准备密码文件
因为需要用sys用户登录,必须准备,只是一次使用,使用本地密码文件即可
[oracle@19c01 dbs]$ scp orapwcy oracle@172.16.220.21://u01/app/oracle/product/19.3/dbhome_1/dbs/
4、启动
目标库随便准备一个参数文件
[oracle@19c02 ~]$ cat dp.ora
db_name=aaa
[oracle@19c02 ~]$ export ORACLE_SID=cy
SQL> startup nomount pfile='/home/oracle/dp.ora';
ORACLE instance started.
Total System Global Area 268434280 bytes
Fixed Size 8895336 bytes
Variable Size 201326592 bytes
Database Buffers 50331648 bytes
Redo Buffers 7880704 bytes
5、复制
[oracle@19c02 ~]$ rman target sys/oracle@cy auxiliary sys/oracle@cydp
Recovery Manager: Release 19.0.0.0.0 - Production on Tue May 23 06:18:59 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: CY (DBID=3276910691)
connected to auxiliary database: AAA (not mounted)
RMAN> duplicate target database to cy from active database spfile nofilenamecheck;
Starting Duplicate Db at 23-MAY-23
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=20 device type=DISK
current log archived
contents of Memory Script:
{
restore clone from service 'cy' spfile to
'/u01/app/oracle/product/19.3/dbhome_1/dbs/spfilecy.ora';
sql clone "alter system set spfile= ''/u01/app/oracle/product/19.3/dbhome_1/dbs/spfilecy.ora''";
}
...
input datafile copy RECID=3 STAMP=1137565404 file name=/u01/app/oracle/oradata/CY/datafile/o1_mf_users_l6qtsyxo_.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 23-MAY-23
SQL> select status from v$instance;
STATUS
------------------------
OPEN
二、本机复制
1、调整实例
使用新的实例名
[oracle@19c01 ~]$ export ORACLE_SID=dp
2、准备参数文件
参数文件随便写个db_name就行
[oracle@19c01 ~]$ vi 1.ora
db_name=aaa
3、启动实例
SQL> startup nomount pfile='1.ora';
ORACLE instance started.
Total System Global Area 268434280 bytes
Fixed Size 8895336 bytes
Variable Size 201326592 bytes
Database Buffers 50331648 bytes
Redo Buffers 7880704 bytes
4、连接实例
源库使用密码连接,新实例使用操作系统认证
[oracle@19c01 ~]$ rman target sys/oracle@cy auxiliary sys/oracle
Recovery Manager: Release 19.0.0.0.0 - Production on Tue May 23 06:38:32 2023
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
connected to target database: CY (DBID=3276910691)
connected to auxiliary database: AAA (not mounted)
5、复制数据库
必须设置日志文件、数据文件转换,负责文件名重名会报错如下
Oracle instance shut down
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 05/23/2023 06:47:20
RMAN-05501: aborting duplication of target database
RMAN-03015: error occurred in stored script Memory Script
ORA-19660: some files in the backup set could not be verified
ORA-19661: datafile 0 could not be verified
ORA-19849: error while reading backup piece from service cy
ORA-19504: failed to create file "/u01/app/oracle/oradata/CY/controlfile/o1_mf_ktd8x3op_.ctl"
ORA-27086: unable to lock file - already in use
Linux-x86_64 Error: 11: Resource temporarily unavailable
Additional information: 8
Additional information: 4592
启动复制
RMAN> DUPLICATE TARGET DATABASE
2> TO DP
FROM ACTIVE DATABASE
SPFILE
SET DB_NAME 'DP'
SET CONTROL_FILES=
'/u01/app/oracle/oradata/DP/control01.ctl'
SET DB_FILE_NAME_CONVERT '/u01/app/oracle/oradata/CY','/u01/app/oracle/oradata/DP'
SET LOG_FILE_NAME_CONVERT '/u01/app/oracle/oradata/CY','/u01/app/oracle/oradata/DP'
3> 4> NOFILENAMECHECK;5> 6> 7> 8> 9> 10>
Starting Duplicate Db at 23-MAY-23
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=20 device type=DISK
current log archived
...
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 23-MAY-23
6、验证
[oracle@19c01 ~]$ ps -ef|grep pmon
oracle 4552 1 0 05:21 ? 00:00:00 ora_pmon_cy
oracle 9118 1 0 06:52 ? 00:00:00 ora_pmon_dp
oracle 9939 3181 0 06:56 pts/0 00:00:00 grep --color=auto pmon
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




