一、异机复制
1、源库、目标准备静态监听
源库
listener =
(address_list=
(address=(protocol=tcp)(host=172.16.220.20)(port=1521))
(address=(protocol=ipc)(key=pnpkey)))
# sid_list_
# 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_
# 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
米乐app官网下载 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
米乐app官网下载 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
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【米乐app官网下载的版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。