《Oracle 高级复制技术介绍及应用》-HA技术-应用场景-实战演练
《Oracle高级复制技术介绍及应用》引言:Oracle高级复制技术是Oracle最早提出的HA容灾解决方案,起源于Oracle8i系统,至今在11G官方文档上依然可以找到高级复制
高级复制技术是Oracle最早提出的HA容灾解决方案,起源于Oracle 8i系统,至今在11G官方文档上依然可以找到高级复制说明文档。这个技术因为其古老我想大多数80后童靴只闻其声~未闻其形。在生产环境下可能更没有使用过。由于高级复制技术在当下已经属于非主流渐渐的退出了其历史舞台,逐步被Data Guard、Golden Gate、Streams等新技术所代替,导致其没落的原因是由于其本身机制问题,后面我们会介绍其原理和应用场景。虽说这种技术非常的原始,但可能还有一些老系统会继续使用着。一种技术我们需要知道其优点、应用场景、局限性、风险性,这样才能得心应手,有针对性的去使用,例如 原始的汇编语言现在几乎没有人在使用了,但由于其接近硬件的特点,在某些嵌入式系统中效率是最快的。所以说非主流技术我们也应该去了解一下,好的架构师就是需要具备在N种不同技术簇中,选择出最适合的。始终问自己:能不能压缩成本,能不能解决问题,能不能更易用。
《心得体会》
系统不同,架构不同,发现问题解决问题
好架构是系统演进出来的
保持简洁
易于扩展,监控,容错
一 高级复制技术应用架构
,当操作完之后马上触发->传递->应用
(4)和相关复制环境
(6)Master to Master提供节点冗余,负载均衡的复制方式
所有节点关系是对等的,数据是对等的,当其中一个Master不可用时,可以直接切换到其他Master
负载均衡,例如有三个Master相互复制,用户1&2&3可以分别连接这三个Master主节点,实现负载均衡
常用于容灾场景
(7)支持同步和异步复制
同步:可以实时推送,操作后立马触发->复制->应用,因为复制的表上就建立了trigger和package。
异步:可以设置定时job(后台进程控制),定时、批量的复制数据,使用Deferred Transaction Queue实现。
(8)事务和依赖
高级复制自动处理事务的依赖关系,如果B事务访问A事务,并且A事务有更新,称作B事务对A事务有依赖
高级复制自动解决数据的约束关系
高级复制根据分布式事务方式,解决事务的一致性问题,比GG、Streams对事务的控制力更强,对用户操作参与更多,我们应该尽量把用户操作和数据复制分离开来,不要混淆在一起,提高系统的稳定性、健壮性。
(9)基于物化视图的高级复制
对网络质量要求不高,由于非实时传递,因此可以中断
定时、批量的复制数据,直接利用解析物化视图日志的方式复制数据
原理图
------------------------------ ---------------------------------------------------------------------------------
REP LEO1.COM 源库 Y 发送主节点 Y
REP LEO2.COM 目标库 N 接收主节点 Y
目标端也应该可以查出
REPADMIN@leo2> select gname,dblink,masterdef,master from dba_repsites where gname='REP';
GNAME DBLINK MASTERDEF MASTER
------------------------------ -------------------------------------------------------------------------------------------------------------------------------- - -
REP LEO1.COM Y Y
REP LEO2.COM N Y
检查源端和目标端t表内容,应该都没有数据
源端
AR@leo1> select * from t;
no rows selected
目标端
AR@leo2> select * from t;
no rows selected
10.启动复制组rep(就可以实现高级复制了)
REPADMIN@leo1> execute ' 不能访问源库LEO1.COM
ORA-06550: line 1, column 8:
PLS-00201: identifier 'SYS@LEO1.COM' must be declared 必须声明到源库dblink
ORA-06550: line 1, column 8:
PL/SQL: Statement ignored
ORA-06550: line 1, column 7:
PLS-00352: Unable to access another database 'LEO1.COM'
ORA-06550: line 1, column 7:
PLS-00201: identifier 'SYS@LEO1.COM' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored
ORA-06512: at "SYS.DBMS_REPCAT_MAS", line 864
解决方法
目标端创建到源端dblink,因为两端有信息交互,必须相通
REPADMIN@leo2> create database link leo1.com connect to repadmin identified by oracle using 'leo1';
Database link created.
必须重启复制组rep
REPADMIN@leo1> execute dbms_repcat.suspend_master_activity('rep'); 暂停
PL/SQL procedure successfully completed.
REPADMIN@leo1> execute dbms_repcat.resume_master_activity('rep',true); 重启
PL/SQL procedure successfully completed.
直到源端和目标端的t表上都生成内部触发器、存储过程、基表才能正常复制
REPADMIN@leo1> select sname,oname,gname,status from dba_repobject where gname='REP';
SNAME ONAME GNAME STATUS
------------------------------ ------------------------------ ------------------------------ ----------
AR T REP VALID
AR T$RP REP VALID
AR T$RP REP VALID
参考官方文档地址:Database Advanced Replication Management API Reference书中的DBMS_REPCAT部分
目标端,当目标库t表上有这些东西时就可以正常复制了
REPADMIN@leo2> select sname,oname,gname,status from dba_repobject where gname='REP';
SNAME ONAME GNAME STATUS
------------------------------ ------------------------------ ------------------------------ ----------
AR T REP VALID
AR T$RP REP VALID
AR T$RP REP VALID
再次测试
源库,插入两条记录,当提交之后才会复制到目标库
AR@leo1> insert into t values(1);
1 row created.
AR@leo1> select * from t;
X
----------
1
AR@leo1> insert into t values(2);
1 row created.
AR@leo1> select * from t;
X
----------
1
2
AR@leo1> commit;
Commit complete.
目标库
AR@leo2> select * from t;
X
----------
1
2
源端,更新操作,提交之后才会传到目标库
AR@leo1> update t set x=10 where x=1;
1 row updated.
AR@leo1> update t set x=20 where x=2;
1 row updated.
AR@leo1> commit;
Commit complete.
目标端
AR@leo2> select * from t;
X
----------
10
20
DDL操作测试,上面我们说过了高级复制是不支持DDL操作的
源端
AR@leo1> truncate table t;
Table truncated.
AR@leo1> select * from t;
no rows selected
目标端并没有被清空,源端的DDL操作并不会影响到目标端的
AR@leo2> select * from t;
X
----------
10
20
自动解决数据的约束关系,GG、Streams就不会自动解决
源库
AR@leo1> insert into t values(10);
insert into t values(10)
*
ERROR at line 1:
ORA-00001: unique constraint (AR.SYS_C007046) violated 违反唯一约束
ORA-02063: preceding line from LEO2 来自于LEO2
说明:这个约束警告并不是源库t表上的有问题,而是当事务发生后高级复制会立刻自动检查两端的数据约束关系,
当发现目标库t表中有10这个值时,会立刻发出警告,,这个警告说明的是目标库上违反了约束关系~全局约束。
AR@leo2> select * from t;
X
----------
10
20
全局约束:这是由分布式事务引起的,如果发现整个分布式环境中有约束冲突的话,就会告警。
我们插入30,就没有问题,感觉比GG、streams速度还要快
AR@leo1> insert into t values(30);
1 row created.
AR@leo1> commit;
Commit complete.
AR@leo2> select * from t;
X
----------
10
20
30

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

As web applications continue to develop, we need to handle a large number of tasks to maintain the stability and availability of the application. Using a queuing system is one solution. ThinkPHP6 provides a built-in queue system to manage tasks. However, handling a large number of tasks requires better queue management, which can be achieved using Supervisor. This article will introduce how to use Supervisor to manage ThinkPHP6 queues. Before that, we need to understand some basic concepts: queue system queue system is

deque in Python is a low-level, highly optimized deque useful for implementing elegant and efficient Pythonic queues and stacks, which are the most common list-based data types in computing. In this article, Mr. Yun Duo will learn the following together with you: Start using deque to effectively pop up and append elements. Access any element in deque. Use deque to build an efficient queue. Start using deque to append elements to the right end of a Python list and pop up elements. The operations are generally very Efficient. If time complexity is expressed in Big O, then we can say that they are O(1). And when Python needs to reallocate memory to increase the underlying list to accept new elements, these

Application summary of queue technology in message delay and message retry in PHP and MySQL: With the continuous development of web applications, the demand for high concurrency processing and system reliability is getting higher and higher. As a solution, queue technology is widely used in PHP and MySQL to implement message delay and message retry functions. This article will introduce the application of queue technology in PHP and MySQL, including the basic principles of queues, methods of using queues to implement message delay, and methods of using queues to implement message retries, and give

Performance Analysis and Optimization Strategy of JavaQueue Queue Summary: Queue (Queue) is one of the commonly used data structures in Java and is widely used in various scenarios. This article will discuss the performance issues of JavaQueue queues from two aspects: performance analysis and optimization strategies, and give specific code examples. Introduction Queue is a first-in-first-out (FIFO) data structure that can be used to implement producer-consumer mode, thread pool task queue and other scenarios. Java provides a variety of queue implementations, such as Arr

Implementation of queue task monitoring and task scheduling in PHP and MySQL Introduction In modern web application development, task queue is a very important technology. Through queues, we can queue some tasks that need to be executed in the background, and control the execution time and order of tasks through task scheduling. This article will introduce how to implement task monitoring and scheduling in PHP and MySQL, and provide specific code examples. 1. Working principle of queue Queue is a first-in-first-out (FIFO) data structure that can be used to

What is the principle and implementation of the PHP mail queue system? With the development of the Internet, email has become one of the indispensable communication methods in people's daily life and work. However, as the business grows and the number of users increases, sending emails directly may lead to server performance degradation, email delivery failure and other problems. To solve this problem, you can use a mail queue system to send and manage emails through a serial queue. The implementation principle of the mail queue system is as follows: when the mail is put into the queue, when it is necessary to send the mail, it is no longer directly

Queue in Java is a linear data structure with multiple functions. A queue has two endpoints and it follows the first-in-first-out (FIFO) principle for inserting and deleting its elements. In this tutorial, we will learn about two important functions of queues in Java, which are add() and Offer(). What is a queue? Queue in Java is an interface that extends the util and collection packages. Elements are inserted in the backend and removed from the frontend. Queues in Java can be implemented using classes such as linked lists, DeQueue, and priority queues. A priority queue is an extended form of a normal queue, where each element has a priority. The add() method of the queue is used to insert elements into the queue. It will define the element (as

Implementation Methods of Queue Producer and Consumer Patterns in PHP and MySQL With the rapid development of Internet business, the need to handle a large number of tasks in the system has become more and more urgent. Queues are a common solution to handle tasks efficiently. The implementation of the queue's producer-consumer pattern (Producer-ConsumerPattern) in PHP and MySQL is a common solution. This article will introduce the specific implementation method and provide code examples. producer-consumer pattern
