Oracle通过rman进行克隆,你知道如何做吗?
发表于:2024-11-26 作者:千家信息网编辑
千家信息网最后更新 2024年11月26日,一. 安装规划IPROLE192.168.1.235克隆对象192.168.1.221克隆库二. 备库创建相应的dump文件夹# 在主库查询对应的dump目录select name, value f
千家信息网最后更新 2024年11月26日Oracle通过rman进行克隆,你知道如何做吗?一. 安装规划
二. 备库创建相应的dump文件夹
IP | ROLE |
192.168.1.235 | 克隆对象 |
192.168.1.221 | 克隆库 |
# 在主库查询对应的dump目录
select name, value from v$parameter where name in ('audit_file_dest', 'background_dump_dest', 'control_files', 'core_dump_dest', 'user_dump_dest', 'db_recovery_file_dest' ) ORDER BY name ASC;
# 备库用Oracle用户执行创建目录
mkdir -p $value三. 创建实例密钥文件
- 主库生成密钥文件
orapwd FILE=/u01/app/oracle/dbs/orapwora235 password=li0924 entries=5;
- 将密钥文件传输到备库
scp /u01/app/oracle/dbs/orapwora235 oracle@192.168.1.221:/u01/app/oracle/dbs四. 创建参数文件
- 主库通过spfile生成pfile文件
create pfile from spfile;
- 复制参数文件到Standby库
scp /u01/app/oracle/dbs/initora235.ora oracle@192.168.1.221:/u01/app/oracle/dbs
- 将Standby端启动到nomount状态
[oracle@oracle221 ~]$ sqlplus / as sysdbaSQL*Plus: Release 11.2.0.4.0 Production on Thu Aug 9 22:56:49 2018Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to an idle instance.SQL> startup nomount pfile='/u01/app/oracle/dbs/initora235.ora';ORACLE instance started.Total System Global Area 780824576 bytesFixed Size 2257312 bytesVariable Size 511708768 bytesDatabase Buffers 264241152 bytesRedo Buffers 2617344 bytes五. 配置主备库的监听文件和网络文件 设置Primary库和Standby库的service_name
SQL> show parameter service_name;NAME TYPE VALUE------------------------------------ ----------- ---------------service_names string lottuSQL> alter system set service_names='db_primary' scope=both;System altered.SQL> show parameter service_name;NAME TYPE VALUE------------------------------------ ----------- ----------------service_names string db_primary
备库的service_name设置为db_standby;需要到参数文件修改。
*.service_names='db_standby'Primary库配置listener.ora
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.235)(PORT = 1521)(IP = FIRST))) (ADDRESS_LIST = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC)) ) ) )SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = ora235) (GLOBAL_DBNAME = db_primary) (ORACLE_HOME =/u01/app/oracle) ) )Standby库配置listener.ora
(DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.221)(PORT = 1521)(IP = FIRST))) (ADDRESS_LIST = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC)) ) ) )SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = ora235) (GLOBAL_DBNAME = db_standby) (ORACLE_HOME =/u01/app/oracle) ) )Primary库和Standby库设置tnsname.ora
tns_primary= (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.235)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = db_primary) ) (HS = OK) ) tns_standby= (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.221)(PORT = 1521)) (CONNECT_DATA = (SERVICE_NAME = db_standby) ) (HS = OK) )
六. 克隆Oracle
在Standby库执行:DUPLICATE TARGET DATABASE TO ORA235 FROM ACTIVE DATABASE SPFILE NOFILENAMECHECK;
[oracle@oracle221 ~]$ rlwrap rman target sys/li0924@tns_primary auxiliary sys/li0924@tns_standbyRecovery Manager: Release 11.2.0.4.0 - Production on Thu Aug 16 23:21:27 2018Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.connected to target database: ORA235 (DBID=2047494122)connected to auxiliary database: ORA235 (not mounted)RMAN> DUPLICATE TARGET DATABASE TO ORA235 FROM ACTIVE DATABASE SPFILE NOFILENAMECHECK;Starting Duplicate Db at 16-AUG-18using target database control file instead of recovery catalogallocated channel: ORA_AUX_DISK_1channel ORA_AUX_DISK_1: SID=19 device type=DISKcontents of Memory Script:{backup as copy reusetargetfile '/u01/app/oracle/dbs/spfileora235.ora' auxiliary format'/u01/app/oracle/dbs/spfileora235.ora' ;sql clone "alter system set spfile= ''/u01/app/oracle/dbs/spfileora235.ora''";}executing Memory ScriptStarting backup at 16-AUG-18allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=27 device type=DISKFinished backup at 16-AUG-18sql statement: alter system set spfile= ''/u01/app/oracle/dbs/spfileora235.ora''contents of Memory Script:{sql clone "alter system set db_name =''ORA235'' comment=''duplicate'' scope=spfile";sql clone "alter system set db_unique_name =''ORA235'' comment=''duplicate'' scope=spfile";shutdown clone immediate;startup clone nomount;}executing Memory Scriptsql statement: alter system set db_name = ''ORA235'' comment= ''duplicate'' scope=spfilesql statement: alter system set db_unique_name = ''ORA235'' comment= ''duplicate'' scope=spfileOracle instance shut downconnected to auxiliary database (not started)Oracle instance startedTotal System Global Area 780824576 bytesFixed Size 2257312 bytesVariable Size 511708768 bytesDatabase Buffers 264241152 bytesRedo Buffers 2617344 bytescontents of Memory Script:{sql clone "alter system set db_name =''ORA235'' comment=''Modified by RMAN duplicate'' scope=spfile";sql clone "alter system set db_unique_name =''ORA235'' comment=''Modified by RMAN duplicate'' scope=spfile";shutdown clone immediate;startup clone force nomountbackup as copy current controlfile auxiliary format '/u01/app/oradata/ora235/control01.ctl';restore clone controlfile to '/u01/app/oradata/ora235/control02.ctl' from'/u01/app/oradata/ora235/control01.ctl';alter clone database mount;}executing Memory Scriptsql statement: alter system set db_name = ''ORA235'' comment= ''Modified by RMAN duplicate'' scope=spfilesql statement: alter system set db_unique_name = ''ORA235'' comment= ''Modified by RMAN duplicate'' scope=spfileOracle instance shut downOracle instance startedTotal System Global Area 780824576 bytesFixed Size 2257312 bytesVariable Size 511708768 bytesDatabase Buffers 264241152 bytesRedo Buffers 2617344 bytesStarting backup at 16-AUG-18using channel ORA_DISK_1channel ORA_DISK_1: starting datafile copycopying current control fileoutput file name=/u01/app/oracle/dbs/snapcf_ora235.f tag=TAG20180816T232148 RECID=6 STAMP=984352909channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03Finished backup at 16-AUG-18Starting restore at 16-AUG-18allocated channel: ORA_AUX_DISK_1channel ORA_AUX_DISK_1: SID=18 device type=DISKchannel ORA_AUX_DISK_1: copied control file copyFinished restore at 16-AUG-18database mountedRMAN-05538: WARNING: implicitly using DB_FILE_NAME_CONVERTcontents of Memory Script:{sql clone 'alter database flashback off';set newname for datafile 1 to"/u01/app/oradata/ora235/system01.dbf";set newname for datafile 2 to"/u01/app/oradata/ora235/sysaux01.dbf";set newname for datafile 3 to"/u01/app/oradata/ora235/undotbs01.dbf";set newname for datafile 4 to"/u01/app/oradata/ora235/users01.dbf";set newname for datafile 5 to"/data/oracle/data/lottu01.dbf";backup as copy reusedatafile 1 auxiliary format"/u01/app/oradata/ora235/system01.dbf" datafile2 auxiliary format"/u01/app/oradata/ora235/sysaux01.dbf" datafile3 auxiliary format"/u01/app/oradata/ora235/undotbs01.dbf" datafile4 auxiliary format"/u01/app/oradata/ora235/users01.dbf" datafile5 auxiliary format"/data/oracle/data/lottu01.dbf" ;sql 'alter system archive log current';}executing Memory Scriptsql statement: alter database flashback offexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEStarting backup at 16-AUG-18using channel ORA_DISK_1channel ORA_DISK_1: starting datafile copyinput datafile file number=00005 name=/data/oracle/data/lottu01.dbfoutput file name=/data/oracle/data/lottu01.dbf tag=TAG20180816T232159channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:45channel ORA_DISK_1: starting datafile copyinput datafile file number=00001 name=/u01/app/oradata/ora235/system01.dbfoutput file name=/u01/app/oradata/ora235/system01.dbf tag=TAG20180816T232159channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45channel ORA_DISK_1: starting datafile copyinput datafile file number=00002 name=/u01/app/oradata/ora235/sysaux01.dbfoutput file name=/u01/app/oradata/ora235/sysaux01.dbf tag=TAG20180816T232159channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35channel ORA_DISK_1: starting datafile copyinput datafile file number=00003 name=/u01/app/oradata/ora235/undotbs01.dbfoutput file name=/u01/app/oradata/ora235/undotbs01.dbf tag=TAG20180816T232159channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35channel ORA_DISK_1: starting datafile copyinput datafile file number=00004 name=/u01/app/oradata/ora235/users01.dbfoutput file name=/u01/app/oradata/ora235/users01.dbf tag=TAG20180816T232159channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01Finished backup at 16-AUG-18sql statement: alter system archive log currentcontents of Memory Script:{backup as copy reusearchivelog like "/data/arch/1_7_984178575.dbf" auxiliary format"/data/arch/1_7_984178575.dbf" ;catalog clone archivelog "/data/arch/1_7_984178575.dbf";switch clone datafile all;}executing Memory ScriptStarting backup at 16-AUG-18using channel ORA_DISK_1channel ORA_DISK_1: starting archived log copyinput archived log thread=1 sequence=7 RECID=45 STAMP=984353140output file name=/data/arch/1_7_984178575.dbf RECID=0 STAMP=0channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01Finished backup at 16-AUG-18cataloged archived logarchived log file name=/data/arch/1_7_984178575.dbf RECID=45 STAMP=984353142datafile 1 switched to datafile copyinput datafile copy RECID=6 STAMP=984353142 file name=/u01/app/oradata/ora235/system01.dbfdatafile 2 switched to datafile copyinput datafile copy RECID=7 STAMP=984353142 file name=/u01/app/oradata/ora235/sysaux01.dbfdatafile 3 switched to datafile copyinput datafile copy RECID=8 STAMP=984353142 file name=/u01/app/oradata/ora235/undotbs01.dbfdatafile 4 switched to datafile copyinput datafile copy RECID=9 STAMP=984353142 file name=/u01/app/oradata/ora235/users01.dbfdatafile 5 switched to datafile copyinput datafile copy RECID=10 STAMP=984353142 file name=/data/oracle/data/lottu01.dbfcontents of Memory Script:{set until scn 1190640;recoverclone databasedelete archivelog;}executing Memory Scriptexecuting command: SET until clauseStarting recover at 16-AUG-18using channel ORA_AUX_DISK_1starting media recoveryarchived log for thread 1 with sequence 7 is already on disk as file /data/arch/1_7_984178575.dbfarchived log file name=/data/arch/1_7_984178575.dbf thread=1 sequence=7media recovery complete, elapsed time: 00:00:00Finished recover at 16-AUG-18Oracle instance startedTotal System Global Area 780824576 bytesFixed Size 2257312 bytesVariable Size 511708768 bytesDatabase Buffers 264241152 bytesRedo Buffers 2617344 bytescontents of Memory Script:{sql clone "alter system set db_name =''ORA235'' comment=''Reset to original value by RMAN'' scope=spfile";sql clone "alter system reset db_unique_name scope=spfile";shutdown clone immediate;startup clone nomount;}executing Memory Scriptsql statement: alter system set db_name = ''ORA235'' comment= ''Reset to original value by RMAN'' scope=spfilesql statement: alter system reset db_unique_name scope=spfileOracle instance shut downconnected to auxiliary database (not started)Oracle instance startedTotal System Global Area 780824576 bytesFixed Size 2257312 bytesVariable Size 511708768 bytesDatabase Buffers 264241152 bytesRedo Buffers 2617344 bytessql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORA235" RESETLOGS ARCHIVELOGMAXLOGFILES 16MAXLOGMEMBERS 3MAXDATAFILES 100MAXINSTANCES 8MAXLOGHISTORY 292LOGFILEGROUP 1 ( '/u01/app/oradata/ora235/redo01.log' ) SIZE 50 M REUSE,GROUP 2 ( '/u01/app/oradata/ora235/redo02.log' ) SIZE 50 M REUSE,GROUP 3 ( '/u01/app/oradata/ora235/redo03.log' ) SIZE 50 M REUSEDATAFILE'/u01/app/oradata/ora235/system01.dbf'CHARACTER SET UTF8contents of Memory Script:{set newname for tempfile 1 to"/u01/app/oradata/ora235/temp01.dbf";switch clone tempfile all;catalog clone datafilecopy "/u01/app/oradata/ora235/sysaux01.dbf","/u01/app/oradata/ora235/undotbs01.dbf","/u01/app/oradata/ora235/users01.dbf","/data/oracle/data/lottu01.dbf";switch clone datafile all;}executing Memory Scriptexecuting command: SET NEWNAMErenamed tempfile 1 to /u01/app/oradata/ora235/temp01.dbf in control filecataloged datafile copydatafile copy file name=/u01/app/oradata/ora235/sysaux01.dbf RECID=1 STAMP=984353151cataloged datafile copydatafile copy file name=/u01/app/oradata/ora235/undotbs01.dbf RECID=2 STAMP=984353151cataloged datafile copydatafile copy file name=/u01/app/oradata/ora235/users01.dbf RECID=3 STAMP=984353151cataloged datafile copydatafile copy file name=/data/oracle/data/lottu01.dbf RECID=4 STAMP=984353151datafile 2 switched to datafile copyinput datafile copy RECID=1 STAMP=984353151 file name=/u01/app/oradata/ora235/sysaux01.dbfdatafile 3 switched to datafile copyinput datafile copy RECID=2 STAMP=984353151 file name=/u01/app/oradata/ora235/undotbs01.dbfdatafile 4 switched to datafile copyinput datafile copy RECID=3 STAMP=984353151 file name=/u01/app/oradata/ora235/users01.dbfdatafile 5 switched to datafile copyinput datafile copy RECID=4 STAMP=984353151 file name=/data/oracle/data/lottu01.dbfReenabling controlfile options for auxiliary databaseExecuting: alter database force loggingcontents of Memory Script:{Alter clone database open resetlogs;}executing Memory Scriptdatabase openedExecuting: alter database flashback onFinished Duplicate Db at 16-AUG-18
原文地址: https://www.linuxprobe.com/oracle-how-rman.html
文件
参数
密钥
配置
目录
生成
原文
地址
实例
对象
文件夹
状态
用户
网络
端启
传输
查询
监听
规划
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
美国大学网络安全专业发展
网络安全法规定人民政府
网络安全隐患整改落实记录
男士学习软件开发
计算机网络技术学习app
香港软件开发靠谱吗
潍坊数据库安全审计系统
手机代理服务器怎么申请
绿色医疗产业大数据库
危害网络安全由什么机关处罚
智能理财软件开发
边防数据库
c 往mysql写入数据库
mc如何查看服务器IP
服务器机房管理办法
数据库有哪些常用参数
怎么看服务器日志内容
esim办理服务器数据出现问题
网络技术负载均衡
网络安全人人有责吗
cbm数据库怎么查近义词
新颖有创意的软件开发
网络安全视频mp4
车载网络技术发展历史的认识
大数据网络安全专家招聘
网络安全相关法律法规问题
安全宣传周主题是网络安全
计算机网络技术诞生的基础
服务器安装不了驱动
网络安全保护和