-------------------------------------------------------------------------------
主数据库:
  操作系统:windows 2012
  IP地址:192.168.160.122
  数据库:Oracle 11.2.0.2.0
  ORACLE_SID:orcl
  Global_name:orcl

  从数据库:
  操作系统:windows 2012
  IP地址:192.168.160.123
  数据库:Oracle 11.2.0.2.0
  ORACLE_SID:orcl
  Global_name:orcl

alter system set deferred_segment_creation=false scope=both;
alter system set sec_case_sensitive_logon=false scope=both;
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;

主数据库配置
archive log list;
select supplemental_log_data_min from v$database;
shutdown immediate;
startup mount;
alter database archivelog;
alter database add supplemental log data;
archive log list;
select supplemental_log_data_min from v$database;
alter database open;

设置参数
alter system set aq_tm_processes=2 scope=both;
  alter system set global_names=true scope=both;
  alter system set job_queue_processes=10 scope=both;
  alter system set parallel_max_servers=20 scope=both;
  alter system set undo_retention=3600 scope=both;
  alter system set nls_date_format='YYYY-MM-DD HH24:MI:SS' scope=spfile;
  alter system set streams_pool_size=100M scope=spfile;
  alter system set utl_file_dir='*' scope=spfile;
  alter system set open_links=4 scope=spfile;
alter system set statistics_level='TYPICAL' scope=both;
alter system set utl_file_dir='*' scope=spfile;
alter system set "_job_queue_interval"=1 scope=spfile;
alter system set global_names=false scope=both;

shutdown immediate;
startup;

create user hytera identified by hytera account unlock;
grant connect to hytera;
grant RESOURCE to hytera;
grant dba to hytera;

--alter system set logmnr_max_persistent_sessions=1 scope=spfile;

create tablespace streams_tbs datafile 'D:\app\Administrator\oradata\orcl\streams_tbs.dbf' size 100M autoextend on maxsize unlimited;

create user strmadmin identified by strmadmin default tablespace streams_tbs account unlock quota unlimited on streams_tbs;
grant dba to strmadmin;
grant connect to strmadmin;
exec dbms_streams_auth.grant_admin_privilege('strmadmin');

begin
dbms_streams_auth.grant_admin_privilege(
grantee=>'strmadmin',
grant_privileges=>TRUE);
end;
/

tnsnames.ora
SZXTDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.160.123)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)

conn strmadmin/strmadmin;
create database link SZXTDB connect to strmadmin identified by strmadmin using 'SZXTDB';

创建Master流队列
#以strmadmin身份,登录主数据库。
connect strmadmin/strmadmin;
begin
dbms_streams_adm.set_up_queue(
queue_table => 'source_queue_table',--队列表
queue_name => 'source_queue',--队列
queue_user =>'strmadmin'); --队列用户
end;
/
select owner,queue_table,name from dba_queues where owner='STRMADMIN';

创建数据捕获进程,捕获redo的改变

connect strmadmin/strmadmin;
begin
dbms_streams_adm.add_schema_rules(
schema_name => 'hytera', --捕获用户名 非sys或者system
streams_type => 'capture',
streams_name => 'capture_stream',
queue_name => 'strmadmin.source_queue',
include_dml => true,
include_ddl => true,
include_tagged_lcr => false,
source_database => 'ORCL',
inclusion_rule => true);
end;
/

select capture_name,queue_name,start_scn,status,capture_type from dba_capture;

在源数据库上创建传播进程 相当于ogg里面的datapump数据传递
传播进程需要对应捕获规则分别创建table/schema/global的传播进程。
connect strmadmin/strmadmin;
begin
dbms_streams_adm.add_schema_propagation_rules(
schema_name => 'hytera',
streams_name => 'source_to_target',
source_queue_name => 'strmadmin.SOURCE_QUEUE',
destination_queue_name => 'strmadmin.TARGET_QUEUE@szxtdb',
include_dml => true,
include_ddl => true,
source_database => 'ORCL',
inclusion_rule => true,
queue_to_queue => true);
end;
/

select propagation_name,status from all_propagation;

直接设置SCN的方式进行实例化
查询源端的scn号
select DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER() FROM dual;

启动捕获进程 相当于OGG里面的ext1
BEGIN
DBMS_CAPTURE_ADM.START_CAPTURE(
capture_name => 'capture_stream');
END;
/

停止捕获进程
BEGIN
DBMS_CAPTURE_ADM.STOP_CAPTURE(
capture_name => 'capture_stream');
END;
/

查看捕获进程状态
select capture_name,status from dba_capture;

表示实时传播lcr实时复制
begin
dbms_aqadm.alter_propagation_schedule(
queue_name => 'strmadmin.SOURCE_QUEUE',
destination => 'szxtdb',
destination_queue => 'TARGET_QUEUE',
latency => 0);
end;
/
-------------------------------------------------------------------------------------------------------------------------
备数据库配置
archive log list;
select supplemental_log_data_min from v$database;
shutdown immediate;
startup mount;
alter database archivelog;
alter database add supplemental log data;
archive log list;
select supplemental_log_data_min from v$database;
alter database open;

设置参数
alter system set aq_tm_processes=2 scope=both;
  alter system set global_names=true scope=both;
  alter system set job_queue_processes=10 scope=both;
  alter system set parallel_max_servers=20 scope=both;
  alter system set undo_retention=3600 scope=both;
  alter system set nls_date_format='YYYY-MM-DD HH24:MI:SS' scope=spfile;
  alter system set streams_pool_size=100M scope=spfile;
  alter system set utl_file_dir='*' scope=spfile;
  alter system set open_links=4 scope=spfile;
alter system set statistics_level='TYPICAL' scope=both;
alter system set utl_file_dir='*' scope=spfile;
alter system set "_job_queue_interval"=1 scope=spfile;
alter system set global_names=false scope=both;

shutdown immediate;
startup;

--alter system set logmnr_max_persistent_sessions=1 scope=spfile;

create user hytera identified by hytera account unlock;
grant connect to hytera;
grant RESOURCE to hytera;
grant dba to hytera;

create tablespace streams_tbs datafile 'D:\app\Administrator\oradata\orcl\streams_tbs.dbf' size 100M autoextend on maxsize unlimited;

create user strmadmin identified by strmadmin default tablespace streams_tbs account unlock quota unlimited on streams_tbs;
grant dba to strmadmin;
grant connect to strmadmin;
exec dbms_streams_auth.grant_admin_privilege('strmadmin');

begin
dbms_streams_auth.grant_admin_privilege(
grantee=>'strmadmin',
grant_privileges=>TRUE);
end;
/

tnsnames.ora
SZXTDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.160.122)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)

conn strmadmin/strmadmin;
create database link SZXTDB connect to strmadmin identified by strmadmin using 'SZXTDB';

创建备库流队列
#以strmadmin身份,登录主数据库。
connect strmadmin/strmadmin;
begin
dbms_streams_adm.set_up_queue(
queue_table => 'target_queue_table',--队列表
queue_name => 'target_queue',--队列
queue_user =>'strmadmin'); --队列用户
end;
/
select owner,queue_table,name from dba_queues where owner='STRMADMIN';

目标端数据库上创建Apply队列应用进程 相当于OGG中的rep1进程
connect strmadmin/strmadmin;
begin
dbms_streams_adm.add_schema_rules(
schema_name => 'hytera', --捕获用户名 非sys或者system
streams_type => 'apply',
streams_name => 'target_apply_stream',
queue_name => 'strmadmin.TARGET_QUEUE',
include_dml => true,
include_ddl => true,
include_tagged_lcr => false,
source_database => 'ORCL',
inclusion_rule => true);
end;
/

select apply_name,queue_name,status from dba_apply;

设置成跟源端一致的SCN号
源端查
select DBMS_FLASHBACK.GET_SYSTEM_CHANGE_NUMBER() FROM dual;
conn strmadmin/strmadmin;
BEGIN
DBMS_APPLY_ADM.SET_SCHEMA_INSTANTIATION_SCN(
source_schema_name => 'hytera',
source_database_name => 'ORCL',
instantiation_scn => 1097715);
END;
/

启动目的端的Apply应用进程相当于启动OGG里面的rep1
BEGIN
DBMS_APPLY_ADM.START_APPLY(
apply_name => 'target_apply_stream');
END;
/

停止apply
BEGIN
DBMS_APPLY_ADM.STOP_APPLY(
apply_name => 'target_apply_stream');
END;
/

查看apply进程状态
select apply_name,queue_name,status from dba_apply;
--------------------------------------------------------------

查看捕获进程状态
select capture_name,status from dba_capture;

查看apply进程状态
select apply_name,queue_name,status from dba_apply;

在源数据库上创建传播进程 相当于ogg里面的datapump数据传递
select propagation_name,status from all_propagation;

select capture_name,status from dba_capture;
select apply_name,queue_name,status from dba_apply;
select capture_name,status from dba_capture;
select error_message from DBA_APPLY_ERROR;

源端查询 抓取进程和应用进程的SCN号是否一致,流复制是基于redolog 的scn号的
select capture_name,queue_name,status,captured_scn,applied_scn from dba_capture;

查看应用进程是否有错误
select apply_name,error_number,apply_captured,status from dba_apply;

------------------------------------------------------------------------------

启动捕获进程 相当于OGG里面的ext1
BEGIN
DBMS_CAPTURE_ADM.START_CAPTURE(
capture_name => 'capture_stream');
END;
/

停止捕获进程
BEGIN
DBMS_CAPTURE_ADM.STOP_CAPTURE(
capture_name => 'capture_stream');
END;
/

启动目的端的Apply应用进程相当于启动OGG里面的rep1
BEGIN
DBMS_APPLY_ADM.START_APPLY(
apply_name => 'target_apply_stream');
END;
/

停止apply
BEGIN
DBMS_APPLY_ADM.STOP_APPLY(
apply_name => 'target_apply_stream');
END;
/

--------------------------------------------------------------------------------

create tablespace hytera datafile 'D:\app\Administrator\oradata\orcl\hytera.dbf' size 100M autoextend on maxsize unlimited;
alter user hytera default tablespace hytera;

--------------------------------------------------------------------------------
配置双向流复制

源端执行
解决ORA-26687问题

SELECT * FROM DBA_CAPTURE_PREPARED_TABLES;

BEGIN
DBMS_APPLY_ADM.SET_TABLE_INSTANTIATION_SCN (
source_object_name => 'hytera.t',
source_database_name => 'ORCL',
instantiation_scn => 1094239);
END;
/

select error_message from DBA_APPLY_ERROR;--流复制错误信息

PURGE recyclebin;

解决 ORA-00942 问题
BEGIN
DBMS_APPLY_ADM.SET_PARAMETER(
apply_name => 'target_apply_stream',
parameter => 'disable_on_error',
value => 'n');
END;
/
--------------------------------------------------------------------------------

drop user hytera cascade;
create user hytera identified by hytera account unlock default tablespace hytera;
grant connect to hytera;
grant RESOURCE to hytera;
grant dba to hytera;

oracle数据库基于(streams流复制)的双机热备配置手册的更多相关文章

  1. SQLServer 2005 数据库定阅复制实现双机热备(主要是sharepoint 内容数据库)

    原文:SQLServer 2005 数据库定阅复制实现双机热备(主要是sharepoint 内容数据库) 场景 公司最近的sharepoint的数据库服务器老是出问题,并且在一旦出现问题,就导致无法正 ...

  2. CentOS系统MySQL双机热备配置

    1  概述 在集成项目中需要应对不同环境下的安装配置,主流操作系统大致可以分为三种:Linux.Windows以及UNIX.其中Linux备受青睐的主要原因有两个: 首先,Linux作为自由软件有两个 ...

  3. Mysql双机热备配置(超详细多图版)

    一.双击热备介绍 1.基本概念 双机热备特指基于高可用系统中的两台服务器的热备(或高可用),双机高可用按工作中的切换方式分为:主-备方式(Active-Standby方式)和双主机方式(Active- ...

  4. 基于防火墙的VRRP技术--华为防火墙双机热备--VGMP

    目录 主备备份双机热备配置 负载分担双机热备配置 为了解决多个VRRP备份组状态不一致的问题,华为防火墙引入VGMP(VRRP Group Management Protocol)来实现对VRRP备份 ...

  5. windows下使用mysql双机热备功能

    一. 准备工作 1. 准备两台服务器(电脑),接入局域网中,使互相ping得通对方 2. 两台服务器都安装mysql-server-5.1,必须保证mysql的版本一致 3. 假设,服务器A:192. ...

  6. mysql双机热备的实现

    转:http://blog.csdn.net/qq394829044/article/details/53203645 Mysql数据库没有增量备份的机制,当数据量太大的时候备份是一个很大的问题.还好 ...

  7. (转)mysql双机热备的实现

    mysql双机热备的实现 原文:http://www.zjian.me/web/php/mysql%E5%8F%8C%E6%9C%BA%E7%83%AD%E5%A4%87%E7%9A%84%E5%AE ...

  8. mysql 主从复制(mysql双机热备的实现)

    转:http://blog.csdn.net/qq394829044/article/details/53203645 Mysql数据库没有增量备份的机制,当数据量太大的时候备份是一个很大的问题.还好 ...

  9. Centos7 Mysql主从双机热备的实战记录

    操作系统:centos7 服务器:主:172.19.242.69   从:172.19.242.70 1. 服务器 由于Mysql不同版本之间的(二进制日志)binlog格式可能会不太一样,因此最好的 ...

随机推荐

  1. Java进阶知识10 Hibernate一对多_多对一双向关联(Annotation+XML实现)

    本文知识点(目录): 1.Annotation 注解版(只是测试建表)    2.XML版 的实现(只是测试建表)    3.附录(Annotation 注解版CRUD操作)[注解版有个问题:插入值时 ...

  2. CentOS7部署tomcat

    首先检查是否安装了jdk,然后再查看是否配置了JAVA_HOME 配置JAVA_HOME的方法: 我的是jdk已经安装好了是1.8 我需要找到它的安装目录 [root@bogon xwg]# java ...

  3. Java 面试题 四

    1.序列化 File 类的介绍:http://www.cnblogs.com/ysocean/p/6851878.html Java IO 流的分类介绍:http://www.cnblogs.com/ ...

  4. Linux 系统设置命令之ulimit

    定义 ulimit 用于限制 shell 启动进程所占用的资源,支持以下各种类型的限制:所创建的内核文件的大小.进程数据块的大小.Shell 进程创建文件的大小.内存锁住的大小.常驻内存集的大小.打开 ...

  5. 【java设计模式】-13代理模式

    代理模式(Proxy Pattern) 定义: 给某一个对象提供一个代理,并由代理对象控制对原对象的引用.在一些情况下,一个客户不想或者不能够直接引用一个对象,而代理对象可以在客户端和目标对象之间起到 ...

  6. [pytorch] PyTorch Hook

      PyTorch Hook¶ 为什么要引入hook? -> hook可以做什么? 都有哪些hook? 如何使用hook?   1. 为什么引入hook?¶ 参考:Pytorch中autogra ...

  7. Java String和hadoop的Text差异性比较

    Text类似于String,UTF-8编码.采用整型储存长度,最大长度为2GB. 补充编码知识: ASCII码 英语字母标点符号等256个字符,一个字节储存,取值0x00-0x7F; UNICODE编 ...

  8. java按某个字段对数据分组

    import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; i ...

  9. 20175329&20175313&20175318 2019-2020 《信息安全系统设计基础》实验三

    20175329&20175313&20175318 2019-2020 <信息安全系统设计基础>实验三

  10. 快速解决设置Android 23.0以上版本对SD卡的读写权限无效的问题

    快速解决设置Android 23.0以上版本对SD卡的读写权限无效的问题 转 https://www.jb51.net/article/144939.htm 今天小编就为大家分享一篇快速解决设置And ...