8. Oracle通过rman进行克隆
一. 安装规划
IP | ROLE |
192.168.1.235 | 克隆对象 |
192.168.1.221 | 克隆库 |
二. 备库创建相应的dump文件夹
# 在主库查询对应的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=;
- 将密钥文件传输到备库
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 sysdba SQL*Plus: Release 11.2.0.4. Production on Thu Aug :: Copyright (c) , , 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 bytes
Fixed Size bytes
Variable Size bytes
Database Buffers bytes
Redo Buffers bytes
五. 配置主备库的监听文件和网络文件
设置Primary库和Standby库的service_name
SQL> show parameter service_name; NAME TYPE VALUE
------------------------------------ ----------- ---------------
service_names string lottu
SQL> 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 = )(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
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.221)(PORT = )(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 = ))
(CONNECT_DATA =
(SERVICE_NAME = db_primary)
)
(HS = OK)
) tns_standby=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.221)(PORT = ))
(CONNECT_DATA =
(SERVICE_NAME = db_standby)
)
(HS = OK)
)
重启监听lsnrctl restart
六. 克隆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_standby Recovery Manager: Release 11.2.0.4. - Production on Thu Aug :: Copyright (c) , , Oracle and/or its affiliates. All rights reserved. connected to target database: ORA235 (DBID=)
connected to auxiliary database: ORA235 (not mounted) RMAN> DUPLICATE TARGET DATABASE TO ORA235 FROM ACTIVE DATABASE SPFILE NOFILENAMECHECK; Starting Duplicate Db at -AUG-
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID= device type=DISK contents of Memory Script:
{
backup as copy reuse
targetfile '/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 Script Starting backup at -AUG-
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID= device type=DISK
Finished backup at -AUG- sql 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 Script sql statement: alter system set db_name = ''ORA235'' comment= ''duplicate'' scope=spfile sql statement: alter system set db_unique_name = ''ORA235'' comment= ''duplicate'' scope=spfile Oracle instance shut down connected to auxiliary database (not started)
Oracle instance started Total System Global Area bytes Fixed Size bytes
Variable Size bytes
Database Buffers bytes
Redo Buffers bytes contents 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 nomount
backup 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 Script sql statement: alter system set db_name = ''ORA235'' comment= ''Modified by RMAN duplicate'' scope=spfile sql statement: alter system set db_unique_name = ''ORA235'' comment= ''Modified by RMAN duplicate'' scope=spfile Oracle instance shut down Oracle instance started Total System Global Area bytes Fixed Size bytes
Variable Size bytes
Database Buffers bytes
Redo Buffers bytes Starting backup at -AUG-
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/u01/app/oracle/dbs/snapcf_ora235.f tag=TAG20180816T232148 RECID= STAMP=
channel ORA_DISK_1: datafile copy complete, elapsed time: ::
Finished backup at -AUG- Starting restore at -AUG-
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID= device type=DISK channel ORA_AUX_DISK_1: copied control file copy
Finished restore at -AUG- database mounted
RMAN-: WARNING: implicitly using DB_FILE_NAME_CONVERT contents of Memory Script:
{
sql clone 'alter database flashback off';
set newname for datafile to
"/u01/app/oradata/ora235/system01.dbf";
set newname for datafile to
"/u01/app/oradata/ora235/sysaux01.dbf";
set newname for datafile to
"/u01/app/oradata/ora235/undotbs01.dbf";
set newname for datafile to
"/u01/app/oradata/ora235/users01.dbf";
set newname for datafile to
"/data/oracle/data/lottu01.dbf";
backup as copy reuse
datafile auxiliary format
"/u01/app/oradata/ora235/system01.dbf" datafile
auxiliary format
"/u01/app/oradata/ora235/sysaux01.dbf" datafile
auxiliary format
"/u01/app/oradata/ora235/undotbs01.dbf" datafile
auxiliary format
"/u01/app/oradata/ora235/users01.dbf" datafile
auxiliary format
"/data/oracle/data/lottu01.dbf" ;
sql 'alter system archive log current';
}
executing Memory Script sql statement: alter database flashback off executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME Starting backup at -AUG-
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number= name=/data/oracle/data/lottu01.dbf
output file name=/data/oracle/data/lottu01.dbf tag=TAG20180816T232159
channel ORA_DISK_1: datafile copy complete, elapsed time: ::
channel ORA_DISK_1: starting datafile copy
input datafile file number= name=/u01/app/oradata/ora235/system01.dbf
output file name=/u01/app/oradata/ora235/system01.dbf tag=TAG20180816T232159
channel ORA_DISK_1: datafile copy complete, elapsed time: ::
channel ORA_DISK_1: starting datafile copy
input datafile file number= name=/u01/app/oradata/ora235/sysaux01.dbf
output file name=/u01/app/oradata/ora235/sysaux01.dbf tag=TAG20180816T232159
channel ORA_DISK_1: datafile copy complete, elapsed time: ::
channel ORA_DISK_1: starting datafile copy
input datafile file number= name=/u01/app/oradata/ora235/undotbs01.dbf
output file name=/u01/app/oradata/ora235/undotbs01.dbf tag=TAG20180816T232159
channel ORA_DISK_1: datafile copy complete, elapsed time: ::
channel ORA_DISK_1: starting datafile copy
input datafile file number= name=/u01/app/oradata/ora235/users01.dbf
output file name=/u01/app/oradata/ora235/users01.dbf tag=TAG20180816T232159
channel ORA_DISK_1: datafile copy complete, elapsed time: ::
Finished backup at -AUG- sql statement: alter system archive log current contents of Memory Script:
{
backup as copy reuse
archivelog 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 Script Starting backup at -AUG-
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log copy
input archived log thread= sequence= RECID= STAMP=
output file name=/data/arch/1_7_984178575.dbf RECID= STAMP=
channel ORA_DISK_1: archived log copy complete, elapsed time: ::
Finished backup at -AUG- cataloged archived log
archived log file name=/data/arch/1_7_984178575.dbf RECID= STAMP= datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oradata/ora235/system01.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oradata/ora235/sysaux01.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oradata/ora235/undotbs01.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oradata/ora235/users01.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/data/oracle/data/lottu01.dbf contents of Memory Script:
{
set until scn ;
recover
clone database
delete archivelog
;
}
executing Memory Script executing command: SET until clause Starting recover at -AUG-
using channel ORA_AUX_DISK_1 starting media recovery archived log for thread with sequence is already on disk as file /data/arch/1_7_984178575.dbf
archived log file name=/data/arch/1_7_984178575.dbf thread= sequence=
media recovery complete, elapsed time: ::
Finished recover at -AUG-
Oracle instance started Total System Global Area bytes Fixed Size bytes
Variable Size bytes
Database Buffers bytes
Redo Buffers bytes contents 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 Script sql statement: alter system set db_name = ''ORA235'' comment= ''Reset to original value by RMAN'' scope=spfile sql statement: alter system reset db_unique_name scope=spfile Oracle instance shut down connected to auxiliary database (not started)
Oracle instance started Total System Global Area bytes Fixed Size bytes
Variable Size bytes
Database Buffers bytes
Redo Buffers bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORA235" RESETLOGS ARCHIVELOG
MAXLOGFILES
MAXLOGMEMBERS
MAXDATAFILES
MAXINSTANCES
MAXLOGHISTORY
LOGFILE
GROUP ( '/u01/app/oradata/ora235/redo01.log' ) SIZE M REUSE,
GROUP ( '/u01/app/oradata/ora235/redo02.log' ) SIZE M REUSE,
GROUP ( '/u01/app/oradata/ora235/redo03.log' ) SIZE M REUSE
DATAFILE
'/u01/app/oradata/ora235/system01.dbf'
CHARACTER SET UTF8 contents of Memory Script:
{
set newname for tempfile 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 Script executing command: SET NEWNAME renamed tempfile to /u01/app/oradata/ora235/temp01.dbf in control file cataloged datafile copy
datafile copy file name=/u01/app/oradata/ora235/sysaux01.dbf RECID= STAMP=
cataloged datafile copy
datafile copy file name=/u01/app/oradata/ora235/undotbs01.dbf RECID= STAMP=
cataloged datafile copy
datafile copy file name=/u01/app/oradata/ora235/users01.dbf RECID= STAMP=
cataloged datafile copy
datafile copy file name=/data/oracle/data/lottu01.dbf RECID= STAMP= datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oradata/ora235/sysaux01.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oradata/ora235/undotbs01.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/u01/app/oradata/ora235/users01.dbf
datafile switched to datafile copy
input datafile copy RECID= STAMP= file name=/data/oracle/data/lottu01.dbf
Reenabling controlfile options for auxiliary database
Executing: alter database force logging contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script database opened
Executing: alter database flashback on
Finished Duplicate Db at -AUG-
8. Oracle通过rman进行克隆的更多相关文章
- RMAN 数据库克隆文件位置转换方法
在使用RMAN克隆数据库时,如果辅助数据库(新数据库)使用了与目标数据库(原数据库)使用了不同的路径,那么就存在位置转换的问题.在Oracle中,控制文件用于定位数据文件以及联机重做日志文件,如果没有 ...
- Oracle19c 如何用rman duplicate 克隆一个数据库。(Backup-Based, achive log)
Oracle19c 如何用rman duplicate 克隆一个数据库.(Backup-Based, achive log) 首先克隆有两种方法,一种是Backup-Based,一种是Active方式 ...
- Oracle19c 如何用rman duplicate 克隆一个数据库。(Backup-Based, no achive log)
Oracle19c 如何用rman duplicate 克隆一个数据库. 首先克隆有两种方法,一种是Backup-Based,一种是Active方式.官网文档链接https://docs.oracle ...
- Oracle19c 如何用rman duplicate 克隆一个数据库。(Active方式)
Oracle19c 如何用rman duplicate 克隆一个数据库. 首先克隆有两种方法,一种是Backup-Based,一种是Active方式.官网文档链接https://docs.oracle ...
- ORACLE 查看RMAN的备份信息总结
关于Oracle数据库的RMAN备份,除了邮件外,是否能通过其它方式检查RMAN备份的成功与失败呢?其实我们可以通过下面SQL脚本来检查某个时间段备份失败的记录: SELECT * FROM V$RM ...
- ORACLE的RMAN
1.什么是RMAN? RMAN可以用来备份和还原数据库文件.归档日志和控制文件.它也可以用来执行完全或不完全的数据库恢复. 注意:RMAN不能用于备份初始化参数文件和口令文件. RMAN启动数据库上的 ...
- Oracle 基于 RMAN 的不完全恢复(incomplete recovery by RMAN)
Oracle 数据库可以实现数据库不完全恢复与完全恢复.完全恢复是将数据库恢复到最新时刻,也就是无损恢复,保证数据库无丢失的恢复.而不完全恢复则是根据需要特意将数据库恢复到某个过去的特定时间点或特定的 ...
- Oracle单机Rman笔记[5]---脱机异地还原
脱机异地还原(安装一个原环境相同的linux,并安装数据库,注意不要配置安装实例) .检查/home/oracle下的.bashrc .bash_profile内容是否与原环境一致(具体看情况而定), ...
- Oracle 12c RMAN备份文档
创建备份目录,查看剩余空间 [cistest@cistest ~]$ df -h df: '/home/oratest/.gvfs': Permission denied Filesystem Siz ...
随机推荐
- [Visual studio] Visual studio 2017添加引用时报错未能正确加载ReferenceManagerPackage包的解决方法
转载原文:http://www.ynpxrz.com/n1806804c2023.aspx 1.打开VS2017下的Developer Command Prompt for VS 2017 2.然后在 ...
- 标 题: [心得]传统IT转互联网面试经验分享
发信人: lgonnet (逃之夭夭), 信区: Java标 题: [心得]传统IT转互联网面试经验分享发信站: 水木社区 (Wed Jul 1 10:18:38 2015), 站内 统一回复一下 ...
- TCP/IP协议随笔
今天翻博客的时候看到了TCP/IP协议相关的几篇文章,写的非常好,LZ打算把其中的重点整理一下,虽然都是一些概念性的东西,平时编码的时候可能用不到,但是起码我们应该知道自己是在哪一层编码,又有哪些协议 ...
- Windows DIB文件操作具体解释-4.使用DIB Section
前面讲了为了提高DIB的显示性能和效率,我们将DIB转换成DDB.可是这又遇到一个问题.假设我想操作DIB的数据的话,显然是不能使用DDB:一是由于DIB转DDB时发生了颜色转换.再就是DDB无法直接 ...
- mysql从库Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'报错处理
年后回来查看mysql运行状况与备份情况,登录mysql从库查看主从同步状态 mysql> show slave status\G; *************************** . ...
- .net里Release的pdb文件有什么用 是否可以删除
程序数据库 (PDB) 文件保存着调试和项目状态信息,使用这些信息可以对程序的调试配置进行增量链接. 在使用 /debug 生成时,会创建一个 PDB 文件. 可以使用 /debug:full 或 / ...
- Android典型界面设计(7) ——DrawerLayout+Fragement+ViewPager+PagerTabStrip实现双导航
一.问题描述 在Android典型界面设计(3)的我们实现了双导航效果,即外层底部导航和内部区域的头部导航,如网易新闻等很多应用采用了这种导航,但Google提供DrawerLayout可实现抽屉式导 ...
- 【CSS Demo】纯 CSS 打造 Flow-Steps 导航
low-Steps 导航效果常用于需要表示执行步骤的交互页面,效果如下: 步骤一 步骤二 步骤三 通常使用图片来实现 Flow-Steps 效果,但此方法的灵活性不足,当内容变化较大时就可能需要重 ...
- git的使用笔记
1.git下载:https://git-scm.com/downloads 安装git 2.在github.com网站上注册账号 网址:https://github.com/ 3.使用gi ...
- JS代码把JSON字符串转换为对象,计算对象的长度并把它转换为数字类型,把转换的值相加减
Number(JSON.parse(rowObject.RenewalProperty).length)-1