Home  >  Article  >  Database  >  RACArchivelog写入错误的节点

RACArchivelog写入错误的节点

WBOY
WBOYOriginal
2016-06-07 14:55:301352browse

由于多个客户几次问到,RAC环境中,node2的归档日志,写入到node1的archive路径中。 这个问题导致一些客户在使用OGG的情况下,有时无法正确读取日志的问题。 那是什么原因导致的这个问题呢? 对此,进行查找和测试。发现了下面的情况会导致archive log没有记

     由于多个客户几次问到,RAC环境中,node2的归档日志,写入到node1的archive路径中。

这个问题导致一些客户在使用OGG的情况下,有时无法正确读取日志的问题。

     那是什么原因导致的这个问题呢?

     对此,进行查找和测试。发现了下面的情况会导致archive log没有记录到正确的节点位置。

测试环境

Linux + 11.2.0.4 RAC
node1
  ALTER SYSTEM SET log_archive_dest_1='location=/home/oracle/archive_log/ valid_for=(all_logfiles,all_roles)' sid='orcl1' scope=spfile; 
 node2
   ALTER SYSTEM SET log_archive_dest_1='location=/home/oracle/archive_log/ valid_for=(all_logfiles,all_roles)' sid='orcl2' scope=spfile;


情况1


在node2 instance关闭的情况下,node1上执行alter system archive log current;

会将node2的archive log写入到node1的路径

-----------10.2.0.5版本测试--------------

注:nascds14是节点1,nascds15是节点2

[oracle@nascds14 ~]$ ls -l /u01/app/database/dbs/ 
-rw-r----- 1 oracle oinstall 9897472 Dec  1 09:47 arch1_66_827745338.dbf
-rw-r----- 1 oracle oinstall    2048 Dec  1 09:47 arch1_67_827745338.dbf
-rw-r----- 1 oracle oinstall    1024 Dec  1 09:50 arch1_68_827745338.dbf
[oracle@nascds14 ~]$ sqlplus / as sysdba
SQL>  alter system archive log current;
System altered.
[oracle@nascds14 ~]$ ls -l /u01/app/database/dbs/ 
-rw-r----- 1 oracle oinstall 9897472 Dec  1 09:47 arch1_66_827745338.dbf
-rw-r----- 1 oracle oinstall    2048 Dec  1 09:47 arch1_67_827745338.dbf
-rw-r----- 1 oracle oinstall    1024 Dec  1 09:50 arch1_68_827745338.dbf
-rw-r----- 1 oracle oinstall   11776 Dec  1 09:55 arch1_69_827745338.dbf
-rw-r----- 1 oracle oinstall  128512 Dec  1 09:55 arch2_101_827745338.dbf    <<<<<<<<<<<<<<node2的日志,产生在node1上
[oracle@nascds14 ~]$ date
Mon Dec  1 09:56:01 CST 2014
$ sqlplus / as sysdba
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production 
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
[oracle@nascds15 ~]$ ls -l /u01/app/database/dbs/ 
-rw-r----- 1 oracle oinstall     6144 Dec  1 09:50 arch2_100_827745338.dbf
-rw-r----- 1 oracle oinstall 17412608 Dec  1 09:46 arch2_98_827745338.dbf
-rw-r----- 1 oracle oinstall     1536 Dec  1 09:47 arch2_99_827745338.dbf 
[oracle@nascds15 ~]$ ls -l /u01/app/database/dbs/ 
-rw-r----- 1 oracle oinstall     6144 Dec  1 09:50 arch2_100_827745338.dbf
-rw-r----- 1 oracle oinstall 17412608 Dec  1 09:46 arch2_98_827745338.dbf
-rw-r----- 1 oracle oinstall     1536 Dec  1 09:47 arch2_99_827745338.dbf


-----------11.2.0.4版本测试--------------

node2 instance关闭,日志产生结果

在node2 instance关闭的情况下,node1上执行alter system archive log current;

同样会将node2的archive log写入到node1的路径

---node2---

SQL> create table test1 as select * from dba_users;
create table test1 as select * from dba_users;
SQL> shutdown abort 
shutdown abort
ORACLE instance shut down.

 

---node1---

SQL> alter system archive log current;

---node1---

[oracle@node111g archive_log]$ ls -al 2*
 
-rw------- 1 oracle asmadmin 148992 12月 19 11:22 2_176_864642458.dbf
-rw------- 1 oracle asmadmin 1024 12月 19 11:22 2_177_864642458.dbf <<<<<<<<<<<<<<node2的日志,产生在node1上

---node2---
[oracle@node211g archive_log]$ ls -ctrl
-rw------- 1 oracle asmadmin 1024 12月 19 10:44 2_173_864642458.dbf
-rw------- 1 oracle asmadmin 1872896 12月 19 11:18 2_174_864642458.dbf
-rw------- 1 oracle asmadmin 15360 12月 19 11:18 2_175_864642458.dbf

 下面是测试结果截图,同时开启4个窗口

spacer.gifwKiom1STq-bQ0-pjAA3qlGN7Y9w173.jpg


情景2

如果node2正常运行情况下,是不是也会出现日志写入到node1的情况呢?

经过多次测试,alter system archive log current; 

node1和node2都是正常的将各自的archive log写入到各自正确的位置。

这时考虑,如果给node2点运行压力呢?

在node2上运行下面脚本,让node2处于高CPU运行状态

DECLARE
n NUMBER;
BEGIN
WHILE (TRUE)
LOOP
n:= dbms_random.random();
END LOOP;
END;

在CPU使用率超过90%的情况下,在node1上多次执行alter system archive log current; 

就会出现node2的归档,写入node1的路径的情况

node1查看archive log生成结果

[oracle@node111g archive_log]$ pwd
/home/oracle/archive_log 
[oracle@node111g archive_log]$ ls -al 2*
-rw------- 1 oracle asmadmin 1024 12月 19 10:32 2_103_864642458.dbf
-rw------- 1 oracle asmadmin 1024 12月 19 10:37 2_131_864642458.dbf

node2查看archive log生成结果

[oracle@node211g archive_log]$ ls -ctrl
 
-rw------- 1 oracle asmadmin 1024 12月 19 10:32 2_101_864642458.dbf
-rw------- 1 oracle asmadmin 1024 12月 19 10:32 2_102_864642458.dbf
-rw------- 1 oracle asmadmin 1024 12月 19 10:32 2_104_864642458.dbf <<<<<<<<<<<<<<archive log 103产生在node1上
-rw------- 1 oracle asmadmin 269824 12月 19 10:33 2_105_864642458.dbf
-rw------- 1 oracle asmadmin 5120 12月 19 10:33 2_106_864642458.dbf
......
-rw------- 1 oracle asmadmin 1024 12月 19 10:37 2_129_864642458.dbf
-rw------- 1 oracle asmadmin 1024 12月 19 10:37 2_130_864642458.dbf
-rw------- 1 oracle asmadmin 1024 12月 19 10:37 2_132_864642458.dbf <<<<<<<<<<<<<<archive log 131
-rw------- 1 oracle asmadmin 1024 12月 19 10:37 2_133_864642458.dbf

同时开启4个窗口,开始测试

spacer.gif

wKioL1STrK2Qdn3fAA3qlGN7Y9w211.jpg


   总结,首先要先了解 alter system switch logfile;和alter system archive log current;的区别。

主要的区别在于:
ALTER SYSTEM SWITCH LOGFILE对单实例数据库或RAC中的当前实例执行日志切换;
而ALTER SYSTEM ARCHIVE LOG CURRENT会对数据库中的所有实例执行日志切换。


所以在使用ALTER SYSTEM SWITCH LOGFILE的情况下,就不会遇到archive写错节点的问题。

RAC中archive log写错节点的问题,在使用日志挖掘的应用的时候,可能会遇到问题,如OGG。

这里,我们可以理解为,这是一个oracle expected behaviour。

那么,我们需要考虑下面几种情况来规避这个问题

1. 和应用的开发人员讨论,是不是一定要使用ALTER SYSTEM ARCHIVE LOG CURRENT。

2. 让两个节点的log_archive_dest_*是可以互相访问的,这样在日志挖掘的情况下,control file会告诉你去哪里找到需要的日志,并且可以读取,就不会报错。

3. 将RAC中的多个节点的归档路径设置为相同的共享路径下,也就没有这些问题了。





Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn