当前位置:网站首页>New feature of Oracle 19C: automatic DML redirection of ADG, enhanced read-write separation -- ADG_ REDIRECT_ DML
New feature of Oracle 19C: automatic DML redirection of ADG, enhanced read-write separation -- ADG_ REDIRECT_ DML
2022-07-07 00:47:00 【Wheat seedling DB treasure】
Oracle 19c New characteristics :ADG Automatic DML Redirection enhances read-write separation --ADG_REDIRECT_DML
Oracle 19c One of the new features ,adg Automatic dml Redirect . Is in the ADG In the environment , Connect to standby Database execution dml.
This feature is available in 18c As an implicit parameter _enable_proxy_adg_redirect Adjusted ,
But in 19c in , Through explicit parameters ADG_REDIRECT_DML Parameter adjustment .
SQL> show parameter adg_redirect_dml;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
adg_redirect_dml boolean FALSE
The default is false
stay primary and standby All open
SQL> alter system set adg_redirect_dml = true scope = both sid = '*';
After the test, it was found that dblink The way to primay perform dml, So we need to monitor standby Of 2pc It's abnormal .
Reference resources :
explain
stay 19c In the version ,ADG Backup library support in DML operation , The principle is : It's through DML Redirect to the main library to execute , Then the standby application DML Change data , So far, the standby database is completed DML operation .
notes : Avoid executing too much... On the standby database DML operation , It is actually executed on the main library .
I won't support it XA In the transaction DML operation .
To configure
Automatic redirection DML Operations support session level and system level , Session level overrides system level configuration .
Enable... On all standby databases DML Redirect
Will initialize parameters ADG_REDIRECT_DML Set to true
ALTER SYSTEM SET ADG_REDIRECT_DML=true SCOPE=BOTH;
The current session is enabled DML Redirect
ALTER SESSION ENABLE ADG_REDIRECT_DML;
Specific examples
Conversation level DML Redirect
Confirm the current database role
SQL> select open_mode,database_role from v$database;
OPEN_MODE DATABASE_ROLE
---------------------------------------- --------------------------------
READ ONLY WITH APPLY PHYSICAL STANDBY
Enable session level... On the standby DML Redirect
SQL> conn system/oracle -- Not sys user
Connected.
SQL> ALTER SESSION ENABLE ADG_REDIRECT_DML;
Session altered.
Confirm table data
SQL> select * from test;
no rows selected
Execute... On the standby database DML operation
SQL> insert into test values(1);
1 row created.
SQL> select * from test;
ID
----------
1
Be careful : I won't support it sys User session enable :ORA-16397: statement redirection from Oracle Active Data Guard standby database to primary database failed
Possible causes of the error :
[[email protected]_p admin]$ oerr ORA 16397
16397, 00000, "statement redirection from Oracle Active Data Guard standby database to primary database failed"
// *Cause: The statement redirection failed because of one of the following reasons:
// 1. The primary database connect string was not established.
// 2. The primary database could not be reached.
// 3. The undo-mode or incarnation were not the same.
// 4. The current user and logged-in user were not the same.
// 5. Redirecting CREATE TABLE AS SELECT (CTAS) of the global temporary
// table was not supported.
// 6. Redirecting PL/SQL execution having bind variable was not supported.
// *Action: Run the statement after fixing the condition that caused the failure.
System level enable DML Redirect
see ADG_REDIRECT_DML Parameter values
SQL> SHOW PARAMETER ADG_REDIRECT_DML;
NAME TYPE
------------------------------------ ----------------------
VALUE
------------------------------
adg_redirect_dml boolean
FALSE
Set to... On the standby database true
SQL> ALTER SYSTEM SET ADG_REDIRECT_DML=true SCOPE=BOTH;
System altered.
perform DML
SQL> conn system/oracle
Connected.
SQL> insert into system.test values(2);
1 row created.
SQL> COMMIT;
Commit complete.
Validation data
SQL> select * from system.test;
ID
----------
1
2
That's about ADG Medium backup Library DML Redirect feature test ,
In the previous article 《 Oracle 19c A list of ten new features 》 in , We have mentioned Oracle 19c An important enhancement of , Namely ADG Automatic DML forward :

The function of this new feature is : Will be sent to ADG Upper DML operation , Automatically forward to the main library for execution , Then, it is transferred to the backup database real-time application through the main database log , It's guaranteed ACID Under the premise of , Greatly enhance the practicality of the backup library , This is known as DML Redirection .
In fact, this feature is Oracle 18c We have already provided , So we don't have to wait for 19c You can experience this feature .
In both versions , The only difference is :
stay 18c in , This feature is through implicit parameters _enable_proxy_adg_redirect To enable this feature , This means that the feature tends to be internal ;
stay 19c in , Explicit parameters ADG_REDIRECT_DML Parameters control the switch of this feature , It shows that this feature becomes external and mature ;
Take a look at the test , Experience the convenience of this new feature . First, create a test table in the main database , Insert test data :
[[email protected]]$ export ORACLE_SID=DB18C
[[email protected]]$ sqlplus / as sysdba
Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
SQL> create user eygle identified by eygle;
User created.
SQL> grant connect,resource,dba to eygle;
Grant succeeded.
SQL> connect eygle/eygle
Connected.
SQL> create table enmotech (id number,name varchar2(20));
Table created.
SQL> insert into enmotech values(1,'EYGLE');
1 row created.
SQL> commit;
Commit complete.
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ WRITE
Next, after setting the parameters in the standby database , It can be executed against the table DML Operation , Note that the backup library needs to be placed in Real time application status :
[[email protected]]$ export ORACLE_SID=DB18C_S
[[email protected]]$ sqlplus eygle/eygle
Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY WITH APPLY
SQL> select * from enmotech;
ID NAME
---------- --------------------
1 EYGLE
SQL> alter session set "_enable_proxy_adg_redirect"=true;
Session altered.
SQL> show parameter redirect
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
_adg_redirect_flags integer 1
_enable_proxy_adg_redirect boolean TRUE
-- Trace is enabled here , Can be analyzed ADG How redirection works
SQL> alter session set events '10046 trace name context forever ,level 12';
Session altered.
-- Here DML The operation can be carried out smoothly
SQL> insert into enmotech values(2,'YANGTINGKUN');
1 row created.
SQL> select * from enmotech;
ID NAME
---------- --------------------
1 EYGLE
2 YANGTINGKUN
SQL> commit;
Commit complete.
In the above test , Can be set by 10046 track , To get recursive execution in the background , Study how this feature works .
You can also set the terminal output time , Evaluate redirection latency , My test environment is built on the same host , Basically DML The delay of the operation is 1 About seconds , It's totally acceptable in case of accident :
SQL> set timing on
SQL> insert into enmotech values(2,'KAMUS');
1 row created.
Elapsed: 00:00:01.05
SQL> select * from enmotech;
ID NAME
---------- --------------------
1 EYGLE
2 YANGTINGKUN
2 KAMUS
Elapsed: 00:00:00.00
SQL> commit;
Commit complete.
Elapsed: 00:00:01.05
Through the tracking log in the background , You can see ,DML The operation is through DB Link To redirect to the main library , This DB Link It's internal , Under the normal configuration of service name and so on ,Oracle Can automatically complete internal operations , If the configuration is wrong, there will be an error :
=====================
PARSING IN CURSOR #139880746795960 len=44 dep=0 uid=107 oct=2 lid=107 tim=45368825051292 hv=3193100945 ad='674870e8' sqlid='3bg4wy2z55qnj'
insert into enmotech values(2,'YANGTINGKUN')
END OF STMT
PARSE #139880746795960:c=44993,e=1721825,p=1,cr=28,cu=6,mis=1,r=0,dep=0,og=1,plh=0
WAIT #139880746795960: nam='SQL*Net message to dblink' ela= 2
WAIT #139880746795960: nam='SQL*Net message from dblink' ela= 1164
EXEC #139880746795960:c=1000,e=1297,p=0,cr=0,cu=0,mis=0,r=1,dep=0,og=1,plh=0
WAIT #139880746795960: nam='SQL*Net message to dblink' ela= 1
WAIT #139880746795960: nam='SQL*Net vector data to dblink' ela= 82
WAIT #139880746795960: nam='SQL*Net message from dblink' ela= 1280
*** 2019-01-10T21:08:37.292860+08:00
WAIT #139880746795960: nam='standby query scn advance' ela= 850283
WAIT #139880746795960: nam='PGA memory operation' ela= 98 p1=0 p2=0
WAIT #139880746795960: nam='SQL*Net message to client' ela= 2 d
=====================
PARSING IN CURSOR #139880746795960 len=6 dep=0 uid=107 oct=44 lid=107 tim=45368881823728 hv=3480936638 ad='0' sqlid='23wm3kz7rps5y'
commit
END OF STMT
PARSE #139880746795960:c=0,e=150,p=0,cr=0,cu=0,mis=0,r=0,dep=0,og=0,plh=0
XCTEND rlbk=0, rd_only=1, tim=45368881823795
WAIT #139880746795960: nam='SQL*Net message to dblink' ela= 2
WAIT #139880746795960: nam='SQL*Net message from dblink' ela= 1598
*** 2019-01-10T21:09:34.259699+08:00
WAIT #139880746795960: nam='standby query scn advance' ela= 1045191
EXEC #139880746795960:c=1000,e=1047570,p=0,cr=0,cu=4,mis=0,r=0,dep=0,og=0,plh=0
WAIT #139880746795960: nam='SQL*Net message to client' ela= 3
In addition to the regular tables ,Oracle It also supports the creation of global temporary tables in the standby database , stay 19c in , Implied parameters _alter_adg_redirect_behavior Can be used to define the level of redirection allowed , For example, when setting disallow_gtt Redirection of global temporary tables will not be allowed .
ADG in DML Another problem with redirecting new features , Later deployment ADG when , We must pay attention to the safety control of the backup warehouse , Otherwise, it will be distributed to the backup database DML May damage the consistency of the main library .
About Me
........................................................................................................................ ● The author of this article : Wheat seedling , Some content is organized from the network , In case of infringement, please contact wheat seedling to delete ● QQ Group number : 230161599、618766405 ● tiny Xinqun : Can add me micro Letter , I'll get everyone in , If you are the one ● The content of the article comes from the study notes of Wheat Seedling , Partially collated from the network , If there is any infringement or improper place, please understand ● copyright , Welcome to share this article , Reprint please keep the source |
| |
边栏推荐
- 学习使用代码生成美观的接口文档!!!
- Leecode brush question record sword finger offer 58 - ii Rotate string left
- Data analysis course notes (V) common statistical methods, data and spelling, index and composite index
- Article management system based on SSM framework
- Testers, how to prepare test data
- 集合(泛型 & List & Set & 自定义排序)
- String comparison in batch file - string comparison in batch file
- Data processing of deep learning
- Matlab learning notes
- Lombok makes ⽤ @data and @builder's pit at the same time. Are you hit?
猜你喜欢

AI超清修复出黄家驹眼里的光、LeCun大佬《深度学习》课程生还报告、绝美画作只需一行代码、AI最新论文 | ShowMeAI资讯日报 #07.06

How engineers treat open source -- the heartfelt words of an old engineer

uniapp实现从本地上传头像并显示,同时将头像转化为base64格式存储在mysql数据库中

Data sharing of the 835 postgraduate entrance examination of software engineering in Hainan University in 23

C9 colleges and universities, doctoral students make a statement of nature!

Understand the misunderstanding of programmers: Chinese programmers in the eyes of Western programmers

File and image comparison tool kaleidoscope latest download

Set (generic & list & Set & custom sort)

深度学习之数据处理

Hero League | King | cross the line of fire BGM AI score competition sharing
随机推荐
基于GO语言实现的X.509证书
Learn self 3D representation like ray tracing ego3rt
PXE server configuration
【JokerのZYNQ7020】AXI_EMC。
Sword finger offer 26 Substructure of tree
一图看懂对程序员的误解:西方程序员眼中的中国程序员
Learn to use code to generate beautiful interface documents!!!
浅谈测试开发怎么入门,如何提升?
Leetcode (547) - number of provinces
Devops can help reduce technology debt in ten ways
Attention SLAM:一种从人类注意中学习的视觉单目SLAM
Data analysis course notes (V) common statistical methods, data and spelling, index and composite index
Lombok 同时使⽤ @Data 和 @Builder 的坑,你中招没?
QT tutorial: creating the first QT program
【vulnhub】presidential1
Idea automatically imports and deletes package settings
Leecode brush questions record sword finger offer 43 The number of occurrences of 1 in integers 1 to n
工程师如何对待开源 --- 一个老工程师的肺腑之言
ZYNQ移植uCOSIII
Everyone is always talking about EQ, so what is EQ?