windows和linux平台可以实现跨平台的异构Dataguard,配置方法和同平台没有太大区别,注意目录的格式。
1、环境准备
1.1 主库开启归档
-----开启归档
alter system set LOG_ARCHIVE_DEST_1='LOCATION=/archivelog' scope=both;
shutdown immediate
start mount
alter database archivelog;
1.2 配置监听
--备库监听
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db/)
(SID_NAME = orcl_dr1)
)
)
主备库tns
ORCL_DR=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.x)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl_dr)
)
)
ORCL =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.x.x)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
1.3 密码文件
orapwd file=$ORACLE_HOME/dbs/orapworcl_dr1 password=oracle
2、Dupalicate 方式配置Dataguard
rman target sys/oracle@orcl auxiliary sys/oracle@orcl_dr
rman target sys/oracle@orcl auxiliary sys/oracle@orcl_dr
set newname for datafile 1 to '+DATA/orcl_dr/system01.dbf';
set newname for datafile 2 to '+DATA/orcl_dr/sysaux01.dbf';
set newname for datafile 3 to '+DATA/orcl_dr/undotbs01.dbf';
set newname for datafile 4 to '+DATA/orcl_dr/users01.dbf';
set newname for datafile 5 to '+FLASH/orcl_dr/testtbs01.dbf';
run{
set newname for tempfile 1 to '+DATA/orcl_dr/temp01.dbf';
set newname for datafile 1 to '+DATA/orcl_dr/system01.dbf';
set newname for datafile 2 to '+DATA/orcl_dr/sysaux01.dbf';
set newname for datafile 3 to '+DATA/orcl_dr/undotbs01.dbf';
set newname for datafile 4 to '+DATA/orcl_dr/users01.dbf';
set newname for datafile 5 to '+FLASH/orcl_dr/testtbs01.dbf';
DUPLICATE TARGET DATABASE
FOR STANDBY
FROM ACTIVE DATABASE
nofilenamecheck
dorecover
SPFILE
SET DB_UNIQUE_NAME="orcl_dr"
SET AUDIT_FILE_DEST="/u01/app/oracle/admin/orcl_dr/adump"
SET DIAGNOSTIC_DEST="/u01/app/oracle"
set log_archive_config='dg_config=(orcl,orcl_dr)'
set log_archive_dest_1='location=+FLASH '
SET LOG_ARCHIVE_DEST_2="service=orcl LGWR SYNC REGISTER VALID_FOR=(online_logfile,primary_role) "
SET FAL_SERVER="orcl"
SET FAL_CLIENT="orcl_dr"
SET CONTROL_FILES='+DATA/orcl_dr/control01.ctl','+DATA/orcl_dr/control02.ctl'
SET DB_FILE_NAME_CONVERT='C:\app\Administrator\oradata\orcl\','+DATA'
SET LOG_FILE_NAME_CONVERT='C:\app\Administrator\oradata\orcl\','+DATA'
SET DB_RECOVERY_FILE_DEST='+FLASH'
SET DB_RECOVERY_FILE_DEST_SIZE='1G';
}
部分输出:duplicate会输出它执行的命令和结果
复制过程中,可以通过sql命令查看通道进度
--rman进度查询
select sid,context,sofar,totalwork,round(sofar/totalwork*100,2) from v$session_longops where opname like 'RMAN%' and opname not like '%aggregate%' and totalwork<>0 and round(sofar/totalwork*100,2)<>100;
--复制过程中,主库做了添加数据文件的操作,以及复制暂停,只需要把脚本重新跑一下,根据复制的记录会重用已复制的数据文件
总结一下duplicate的过程:
1)连接目标库(主库)、辅助数据库(需要dbname即可)
2)进行参数配置
3)实例重启到mount
4)备份传输控制文件
5)复制数据文件:数据文件和临时数据文件分脚本进行
6)完成copy,编制文件目录
7)设置scn号,使用归档进行恢复
8)完成配置
3、主库参数配置
主库
alter system set standby_file_management=AUTO scope=both;
alter system set fal_server=orcl scope=both;
alter system set fal_client=orcl_dr scope=both;
alter system set LOG_ARCHIVE_DEST_2='SERVICE=orcl_dr LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) NET_TIMEOUT=60 DB_UNIQUE_NAME=orcl_dr' scope=both;
alter system set log_archive_config='dg_config=(orcl,orcl_dr)' scope=both;
4、开启实时同步
--启用归档2
alter system set log_archive_dest_state_2='DEFER' scope=both sid='*';
alter system set log_archive_dest_state_2='ENABLE' scope=both sid='*';
alter database recover managed standby database disconnect from session;
--开启实时同步
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE using current logfile disconnect from session;
取消同步
alter database recover managed standby database cancel;