基于生产的duplicate 复制,如果事先没有手动配置pfile(设定内存,进程,dg相关配置参数,数据库相关路径参数)则会出现各种参数
基于生产的duplicate 复制,如果事先没有手动配置pfile(设定内存,进程,dg相关配置参数,数据库相关路径参数)则会出现各种参数无法转换的问题;
因为duplicate 会从生产自动拷贝pfile,控制文件,密码文件过来,如果主库和备库环境不一样(数据库软件路径,数据文件存储路径)
如果没在duplicate的命令中完整指定新环境备库的各种参数涉及路径,及转换参数,就会默认使用从主库拷贝过来的spfile中的参数设置(会忽略Oracle 自定义的的缺省配置:比如adr 缺省会放在ORACLE_BASE下,所有参数配置一切以主库拷贝过来的spfile 为准);
鉴于那些对原来主库环境,和oracle数据库参数不是特别了解的同学,就不建议使用这种配置了,折腾!
-------注意如果=备库和主库的$ORACLE_BASE/$ORACLE_HOME/数据存放路径 任意一个不同,则必须配置一下的参数
run {
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate channel prmy3 type disk;
allocate channel prmy4 type disk;
allocate auxiliary channel stby type disk;
duplicate target database for standby from active database
dorecover
spfile
parameter_value_convert 'ora11g','lixora'
set db_unique_name='orcl'
set standby_file_management='AUTO'
SET FAL_SERVER="ora11g"
SET LOG_ARCHIVE_DEST_1='LOCATION=/oracle/app/oracle/oradata/arch VALID_FOR=(ALL_LOGFILE,ALL_ROLE) DB_UNIQUE_NAME=lixora'
set log_archive_dest_2='service=ora11g ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=ora11g'
SET CONTROL_FILES '/oracle/app/oracle/oradata/control01.ctl'
set diagnostic_dest='/oracle/app/oracle'
set audit_file_dest='/oracle/app/oracle'
set DB_FILE_NAME_CONVERT='/u01/app/ora11/oradata/ORA11G/datafile/','/oracle/app/oracle/oradata/'
SET LOG_FILE_NAME_CONVERT '/u01/app/ora11/oradata/ORA11G/onlinelog/', '/oracle/app/oracle/oradata/'
set db_create_file_dest='/oracle/app/oracle/oradata/'
set db_recovery_file_dest='/oracle/app/oracle/oradata/'
#SET SGA_MAX_SIZE 200M
#SET SGA_TARGET 185M
NOFILENAMECHECK;
}
这些个存放目录:闪回区目录,adr目录,审计日志目录, Oracle-managed 数据文件目录 等等,一定要注意啊
------------这里解释使用类上述命令执行后的日子输出,来理解使用上述命令初始化备库的原理:
$rman target sys/sys@chicago auxiliary sys/sys@boston
connected to target database: CHICAGO (DBID=761464750)
connected to auxiliary database: CHICAGO (not mounted)
RMAN> run {
allocate channel prmy1 type disk;
allocate channel prmy2 type disk;
allocate channel prmy3 type disk;
allocate channel prmy4 type disk;
allocate auxiliary channel stby type disk;
duplicate target database for standby from active database
spfile
parameter_value_convert 'chicago','boston'
set db_unique_name='boston'
set db_file_name_convert='/chicago/','/boston/'
set log_file_name_convert='/chicago/','/boston/'
set control_files='/u01/app/oracle/oradata/control01.ctl'
set log_archive_max_processes='5'
set fal_client='boston'
set fal_server='chicago'
set standby_file_management='AUTO'
set log_archive_config='dg_config=(chicago,boston)'
set log_archive_dest_2='service=chicago ASYNCvalid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=chicago'
;
}
using target database control file instead of recovery catalog
allocated channel: prmy1 ---------这个就不多说了:分配通道
channel prmy1: SID=147 device type=DISK
allocated channel: prmy2
channel prmy2: SID=130 device type=DISK
allocated channel: prmy3
channel prmy3: SID=137 device type=DISK
allocated channel: prmy4
channel prmy4: SID=170 device type=DISK
allocated channel: stby
channel stby: SID=98 device type=DISK
Starting Duplicate Db at 19-MAY-08
contents of Memory Script:
{
backup as copy reuse -------------拷贝主库密码文件,spfile参数文件
file '/u02/app/oracle/product/11.1.0/db_1/dbs/orapwcore' auxiliary format'/u02/app/oracle/product/11.1.0/db_1/dbs/orapwcore1'
file'/u02/app/oracle/product/11.1.0/db_1/dbs/spfilecore.ora' auxiliary format'/u02/app/oracle/product/11.1.0/db_1/dbs/spfilecore1.ora' ;
sql clone "alter system set spfile= ''/u02/app/oracle/product/11.1.0/db_1/dbs/spfilecore1.ora''";
}
executing Memory Script ----
Starting backup at 19-MAY-08
Finished backup at 19-MAY-08
sql statement: alter system set spfile= ''/u02/app/oracle/product/11.1.0/db_1/dbs/spfilecore1.ora'' -----在修改
contents of Memory Script: -----------------------这里根据设置我们在run 脚本中spfile 标注下的一些参数设置, RMAN会自动生成以下脚本
{
sql clone "alter system set audit_file_dest =''/u02/app/oracle/admin/boston/adump'' comment='''' scope=spfile";
sql clone "alter system set dispatchers =''(PROTOCOL=TCP) (SERVICE=core1XDB)'' comment='''' scope=spfile";
sql clone "alter system set log_archive_dest_2 =''service=core11 arch async VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=boston'' comment=''''
scope=spfile";
sql clone "alter system set db_unique_name =''boston'' comment='''' scope=spfile";
sql clone "alter system set db_file_name_convert =''/chicago/'', ''/boston/'' comment='''' scope=spfile";
sql clone "alter system set log_file_name_convert =''/chicago/'', ''/boston/'' comment='''' scope=spfile";
sql clone "alter system set control_files =''/u01/app/oracle/oradata/control01.ctl'' comment='''' scope=spfile";
sql clone "alter system set log_archive_max_processes =5 comment='''' scope=spfile";
sql clone "alter system set fal_client =''boston'' comment='''' scope=spfile";
sql clone "alter system set fal_server =''chicago'' comment='''' scope=spfile";
sql clone "alter system set standby_file_management =''AUTO'' comment='''' scope=spfile";
sql clone "alter system set log_archive_config =''dg_config=(chicago,boston)'' comment='''' scope=spfile";
sql clone "alter system set log_archive_dest_2 =''service=chicago ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=chicago'' comment='''' scope=spfile";
shutdown clone immediate; ----------------因为在使用这种方式创建备库时,我们只需要配置一个包含db_name,db_unique_name,block_size 这个三个参数,并把备库启动到 nomount 状态下,,主要的目的就是为了让rman拷贝主库的spfile 和密码文件
startup clone nomount ;
}
executing Memory Script
sql statement: alter system set audit_file_dest = ''/u02/app/oracle/admin/boston/adump'' comment= '''' scope=spfile
sql statement: alter system set dispatchers = ''(PROTOCOL=TCP) (SERVICE=core1XDB)'' comment= '''' scope=spfile
sql statement: alter system set log_archive_dest_2 = ''service=core11 arch async VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=boston'' comment= ''''
scope=spfile
sql statement: alter system set db_unique_name = ''boston'' comment= '''' scope=spfile
sql statement: alter system set db_file_name_convert = ''/chicago/'', ''/boston/'' comment= '''' scope=spfile
sql statement: alter system set log_file_name_convert = ''/chicago/'', ''/boston/'' comment= '''' scope=spfile
sql statement: alter system set control_files = ''/u01/app/oracle/oradata/control01.ctl'' comment= '''' scope=spfile
sql statement: alter system set log_archive_max_processes = 5 comment= '''' scope=spfile
sql statement: alter system set fal_client = ''boston'' comment= '''' scope=spfile
sql statement: alter system set fal_server = ''chicago'' comment= '''' scope=spfile
sql statement: alter system set standby_file_management = ''AUTO'' comment= '''' scope=spfile
sql statement: alter system set log_archive_config = ''dg_config=(chicago,boston)'' comment= '''' scope=spfile
sql statement: alter system set log_archive_dest_2 = ''service=chicago ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=chicago'' comment= ''''
scope=spfile
Oracle instance shut down --------------这里重启是为了使用更新过的spfile
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 845348864 bytes
Fixed Size 1303188 bytes
Variable Size 482348396 bytes
Database Buffers 356515840 bytes
Redo Buffers 5181440 bytes
contents of Memory Script: ---------------开始拷贝standby 控制文件,并传到备库的相应位置
{
backup as copy current controlfile for standby auxiliary format '/u01/app/oracle/oradata/control01.ctl';
sql clone 'alter database mount standby database';
}
executing Memory Script
Starting backup at 19-MAY-08
channel prmy1: starting datafile copy
copying standby control file
output file name=/u02/app/oracle/product/11.1.0/db_1/dbs/snapcf_chicago.f tag=TAG20080519T173406 RECID=2 STAMP=655148053
channel prmy1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 19-MAY-08
sql statement: alter database mount standby database ----------------------mount 备库,准备修改初始化的数据文件路径,并拷贝到备库
contents of Memory Script:
{
set newname for tempfile 1 to"/u02/app/oracle/oradata/boston/temp01.dbf";
switch clone tempfile all;
set newname for datafile 1 to "/u02/app/oracle/oradata/boston/system01.dbf";
set newname for datafile 2 to "/u02/app/oracle/oradata/boston/sysaux01.dbf";
set newname for datafile 3 to "/u02/app/oracle/oradata/boston/undotbs01.dbf";
set newname for datafile 4 to "/u02/app/oracle/oradata/boston/users01.dbf";
backup as copy reuse
datafile 1 auxiliary format "/u02/app/oracle/oradata/boston/system01.dbf"
datafile 2 auxiliary format "/u02/app/oracle/oradata/boston/sysaux01.dbf"
datafile 3 auxiliary format "/u02/app/oracle/oradata/boston/undotbs01.dbf"
datafile 4 auxiliary format "/u02/app/oracle/oradata/boston/users01.dbf" ;
sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u02/app/oracle/oradata/boston/temp01.dbf in control file
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting backup at 19-MAY-08
channel prmy1: starting datafile copy
input datafile file number=00001 name=/u02/app/oracle/oradata/chicago/system01.dbf
channel prmy2: starting datafile copy
input datafile file number=00002 name=/u02/app/oracle/oradata/chicago/sysaux01.dbf
channel prmy3: starting datafile copy
input datafile file number=00003 name=/u02/app/oracle/oradata/chicago/undotbs01.dbf
channel prmy4: starting datafile copy
input datafile file number=00004 name=/u02/app/oracle/oradata/chicago/users01.dbf
output file name=/u02/app/oracle/oradata/boston/undotbs01.dbf tag=TAG20080519T173421 RECID=0 STAMP=0
channel prmy3: datafile copy complete, elapsed time: 00:00:24
output file name=/u02/app/oracle/oradata/boston/users01.dbf tag=TAG20080519T173421 RECID=0 STAMP=0
channel prmy4: datafile copy complete, elapsed time: 00:00:16
output file name=/u02/app/oracle/oradata/boston/system01.dbf tag=TAG20080519T173421 RECID=0 STAMP=0
channel prmy1: datafile copy complete, elapsed time: 00:02:32
output file name=/u02/app/oracle/oradata/boston/sysaux01.dbf tag=TAG20080519T173421 RECID=0 STAMP=0
channel prmy2: datafile copy complete, elapsed time: 00:02:32
Finished backup at 19-MAY-08
sql statement: alter system archive log current
contents of Memory Script:
{
switch clone datafile all; ---------修改standby 控制文件,更新standby 控制文件中的新数据文件路径
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=2 STAMP=655148231 file name=/u02/app/oracle/oradata/boston/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=3 STAMP=655148231 file name=/u02/app/oracle/oradata/boston/sysaux01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=4 STAMP=655148231 file name=/u02/app/oracle/oradata/boston/undotbs01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=5 STAMP=655148231 file name=/u02/app/oracle/oradata/boston/users01.dbf
Finished Duplicate Db at 19-MAY-08
released channel: prmy1
released channel: prmy2
released channel: prmy3
released channel: prmy4
到这里备库环境已经全部初始化完毕,免去了我们以前需要,手动在备库配置pfile参数文件,手动拷贝密码文件到备库,创建standby控制并拷贝到备库,拷贝数据文件备份到备库 等等步骤但是看到这里,还是有个疑惑的oracle 是怎么直接拷贝那些密码文件,参数文件,控制文件,数据文件到备库的?这里猜测应该是调用了rman 某些接口,说的直白点就是和nbu 那些第三方数据备份软件用的那一招,现在oracle自己觉得这些个接口也可以这么用,于是乎在11g(11.1.0.6 开始) 中推出了 active—database duplicate 关于这个feature oracle官方是这么讲的:
Active database duplication copies the live target database over the network to the auxiliary destination and then creates the duplicate database.
The duplication work is performed by an auxiliary channel.This channel corresponds to a server session on the auxiliary instance on the auxiliary host.
以下为 Basic Steps to ACTIVE database duplication 过程中rman干的事情 :
As part of the duplicating operation, RMAN automates the following steps:
1. Creates a control file for the duplicate database
2. Restarts the auxiliary instance and mounts the duplicate control file
3. Creates the duplicate datafiles and recovers them with incremental backups and archived redo logs.
4. Opens the duplicate database with the RESETLOGS option
--------------------------------------推荐阅读 --------------------------------------
RMAN 配置归档日志删除策略
Oracle基础教程之通过RMAN复制数据库
RMAN备份策略制定参考内容
RMAN备份学习笔记
Oracle数据库备份加密 RMAN加密
--------------------------------------分割线 --------------------------------------
本文永久更新链接地址:

本文探讨了Docker中的优化MySQL内存使用量。 它讨论了监视技术(Docker统计,性能架构,外部工具)和配置策略。 其中包括Docker内存限制,交换和cgroups

本文介绍了MySQL的“无法打开共享库”错误。 该问题源于MySQL无法找到必要的共享库(.SO/.DLL文件)。解决方案涉及通过系统软件包M验证库安装

本文讨论了使用MySQL的Alter Table语句修改表,包括添加/删除列,重命名表/列以及更改列数据类型。

本文比较使用/不使用PhpMyAdmin的Podman容器直接在Linux上安装MySQL。 它详细介绍了每种方法的安装步骤,强调了Podman在孤立,可移植性和可重复性方面的优势,还

本文提供了SQLite的全面概述,SQLite是一个独立的,无服务器的关系数据库。 它详细介绍了SQLite的优势(简单,可移植性,易用性)和缺点(并发限制,可伸缩性挑战)。 c

本指南展示了使用自制在MacOS上安装和管理多个MySQL版本。 它强调使用自制装置隔离安装,以防止冲突。 本文详细详细介绍了安装,起始/停止服务和最佳PRA

文章讨论了为MySQL配置SSL/TLS加密,包括证书生成和验证。主要问题是使用自签名证书的安全含义。[角色计数:159]

文章讨论了流行的MySQL GUI工具,例如MySQL Workbench和PhpMyAdmin,比较了它们对初学者和高级用户的功能和适合性。[159个字符]


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

SublimeText3汉化版
中文版,非常好用

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

螳螂BT
Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

Dreamweaver CS6
视觉化网页开发工具

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中