首页 > 其他分享 >物理备库在切换为主库时报错ORA-01577—主库已切换为备库

物理备库在切换为主库时报错ORA-01577—主库已切换为备库

时间:2023-06-10 23:01:55浏览次数:62  
标签:主库 备库 log app oradata 切换 oracle group u01

问题描述:物理备库在切换为主库时报错ORA-01577,如下所示:
数据库:oracle 11.2.0.4
系统架构:rac(2节点)+dg
1、异常重现
SYS@orcldg> alter database commit to switchover to primary with session shutdown;
alter database commit to switchover to primary with session shutdown
*
ERROR at line 1:
ORA-01577: cannot add log file '/u01/app/oracle/oradata/group_1.257.1132745547' - file already part of database
2、异常原因
主库端redo文件分别存放在+data/orcl/onlinelog和+fra/orcl/onlinelog目录下,存放在+data和+fra日志组1的两个成员文件名却相同,都是group_1.257.1132745547,日志组2也存在相同问题.
此种情况下搭建的ADG就会出现同个目录下有两个相同文件名的redo日志,在进行主备切换时便会出现ORA-01577告警.
3、redo文件相关查询
主库
ASMCMD> pwd
+data/orcl/onlinelog
ASMCMD> ls
group_1.257.1132745547
group_10.268.1132751451
group_11.269.1132751473
group_12.270.1132751475
group_13.271.1132751475
group_14.272.1132751475
group_15.273.1132751475
group_2.258.1132745547
group_3.265.1132747513
group_4.266.1132747513
standby10.log
standby11.log
standby12.log
standby13.log
standby14.log
standby15.log
ASMCMD> pwd
+fra/orcl/onlinelog
ASMCMD> ls
group_1.257.1132745547
group_10.267.1132751451
group_11.268.1132751473
group_12.269.1132751475
group_13.270.1132751475
group_14.271.1132751475
group_15.272.1132751475
group_2.258.1132745547
group_3.259.1132747513
group_4.260.1132747515
standby10B.log
standby11B.log
standby12B.log
standby13B.log
standby14B.log
standby15B.log

注意:日志组1和2的两个成员文件名相同,分别是group_1.257.1132745547和group_2.258.1132745547.
备库
SYS@orcldg> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/group_1.257.1132745547
/u01/app/oracle/oradata/group_1.257.1132745547
/u01/app/oracle/oradata/group_2.258.1132745547
/u01/app/oracle/oradata/group_2.258.1132745547
/u01/app/oracle/oradata/group_3.265.1132747513
/u01/app/oracle/oradata/group_3.259.1132747513
/u01/app/oracle/oradata/group_4.266.1132747513
/u01/app/oracle/oradata/group_4.260.1132747515
/u01/app/oracle/oradata/standby10.log
/u01/app/oracle/oradata/standby10b.log
/u01/app/oracle/oradata/standby11.log
/u01/app/oracle/oradata/standby11b.log
/u01/app/oracle/oradata/standby12.log
/u01/app/oracle/oradata/standby12b.log
/u01/app/oracle/oradata/standby13.log
/u01/app/oracle/oradata/standby13b.log
/u01/app/oracle/oradata/standby14.log
/u01/app/oracle/oradata/standby14b.log
/u01/app/oracle/oradata/standby15.log
/u01/app/oracle/oradata/standby15b.log

20 rows selected.

[oracle@hisdbdg oradata]$ ls -ltr
total 5390480
-rw-r----- 1 oracle oinstall   52429312 May  5 19:31 group_1.257.1132745547
-rw-r----- 1 oracle oinstall   52429312 May  5 19:31 group_2.258.1132745547
-rw-r----- 1 oracle oinstall   52429312 May  5 19:31 group_3.265.1132747513
-rw-r----- 1 oracle oinstall   52429312 May  5 19:31 group_3.259.1132747513
-rw-r----- 1 oracle oinstall   52429312 May  5 19:31 group_4.266.1132747513
-rw-r----- 1 oracle oinstall   52429312 May  5 19:31 group_4.260.1132747515
-rw-r----- 1 oracle oinstall   69214208 May  5 19:33 temp.262.1132745555
-rw-r----- 1 oracle oinstall  471867392 May  6 11:40 tbs_tst_idx_bak.286.1134752063
-rw-r----- 1 oracle oinstall   52429312 Jun  6 21:26 standby12.log
-rw-r----- 1 oracle oinstall   52429312 Jun  6 21:26 standby12b.log
-rw-r----- 1 oracle oinstall   52429312 Jun  7 18:42 standby15.log
-rw-r----- 1 oracle oinstall   52429312 Jun  7 18:42 standby15b.log
-rw-r----- 1 oracle oinstall   52429312 Jun  9 19:52 standby14.log
-rw-r----- 1 oracle oinstall   52429312 Jun  9 19:52 standby14b.log
-rw-r----- 1 oracle oinstall   52429312 Jun  9 21:23 standby10.log
-rw-r----- 1 oracle oinstall   52429312 Jun  9 21:23 standby10b.log
-rw-r----- 1 oracle oinstall   52429312 Jun  9 21:23 standby13.log
-rw-r----- 1 oracle oinstall   52429312 Jun  9 21:23 standby13b.log
-rw-r----- 1 oracle oinstall   52429312 Jun  9 21:48 standby11.log
-rw-r----- 1 oracle oinstall   52429312 Jun  9 21:48 standby11b.log
-rw-r----- 1 oracle oinstall 1111498752 Jun  9 21:48 system.259.1132745549
-rw-r----- 1 oracle oinstall   52436992 Jun  9 21:48 users.285.1133862437
-rw-r----- 1 oracle oinstall   52436992 Jun  9 21:48 users.284.1133862457
-rw-r----- 1 oracle oinstall   52436992 Jun  9 21:48 users.283.1133862473
-rw-r----- 1 oracle oinstall    5251072 Jun  9 21:48 users.264.1132745567
-rw-r----- 1 oracle oinstall  209723392 Jun  9 21:48 undotbs2.263.1132745567
-rw-r----- 1 oracle oinstall  880812032 Jun  9 21:48 undotbs1.261.1132745553
-rw-r----- 1 oracle oinstall  671096832 Jun  9 21:48 sysaux.260.1132745551
-rw-r----- 1 oracle oinstall   52436992 Jun  9 21:48 users.282.1133862489
-rw-r----- 1 oracle oinstall   52436992 Jun  9 21:48 users.281.1133862509
-rw-r----- 1 oracle oinstall   52436992 Jun  9 21:48 users.280.1133862525
-rw-r----- 1 oracle oinstall  104865792 Jun  9 21:48 users.279.1133862553
-rw-r----- 1 oracle oinstall  104865792 Jun  9 21:48 users.278.1133862571
-rw-r----- 1 oracle oinstall   52436992 Jun  9 21:48 users.277.1133862585
-rw-r----- 1 oracle oinstall   52436992 Jun  9 21:48 users.276.1133862603
-rw-r----- 1 oracle oinstall   52436992 Jun  9 21:48 users.275.1133862625
-rw-r----- 1 oracle oinstall   52436992 Jun  9 21:48 users.274.1133862645
-rw-r----- 1 oracle oinstall  471867392 Jun  9 21:48 tbs_tst_idx.286.1134752063
-rw-r----- 1 oracle oinstall   18792448 Jun  9 22:38 control01.ctl

说明:如上所示,搭建好的ADG视图v$logfile中记录的日志组1为两个相同的文件名group_1.257.1132745547,而系统层面却只有1个,日志组2也是相同的问题.
4、解决方案:
将日志组1和2的两个成员分别放到不同目录,同时修改ADG的log_file_name_convert参数.
[oracle@hisdbdg oradata]$ pwd
/u01/app/oracle/oradata
[oracle@hisdbdg oradata]$ mkdir redo01
SYS@orcldg> select open_mode from v$database;

OPEN_MODE
--------------------
MOUNTED

SYS@orcldg> alter system set standby_file_management=manual;

System altered.

SYS@orcldg> alter database rename file '/u01/app/oracle/oradata/group_1.257.1132745547' to '/u01/app/oracle/oradata/redo01/group_1.257.1132745547';

Database altered.

SYS@orcldg> alter database rename file '/u01/app/oracle/oradata/group_2.258.1132745547' to '/u01/app/oracle/oradata/redo01/group_2.258.1132745547';

Database altered.

SYS@orcldg> alter database rename file '/u01/app/oracle/oradata/group_3.259.1132747513' to '/u01/app/oracle/oradata/redo01/group_3.259.1132747513';

Database altered.

SYS@orcldg> alter database rename file '/u01/app/oracle/oradata/group_4.260.1132747515' to '/u01/app/oracle/oradata/redo01/group_4.260.1132747515';

Database altered.

SYS@orcldg> alter database rename file '/u01/app/oracle/oradata/standby10b.log' to '/u01/app/oracle/oradata/redo01/standby10b.log';

Database altered.

SYS@orcldg> alter database rename file '/u01/app/oracle/oradata/standby11b.log' to '/u01/app/oracle/oradata/redo01/standby11b.log';

Database altered.

SYS@orcldg> alter database rename file '/u01/app/oracle/oradata/standby12b.log' to '/u01/app/oracle/oradata/redo01/standby12b.log';

Database altered.

SYS@orcldg> alter database rename file '/u01/app/oracle/oradata/standby13b.log' to '/u01/app/oracle/oradata/redo01/standby13b.log';

Database altered.

SYS@orcldg> alter database rename file '/u01/app/oracle/oradata/standby14b.log' to '/u01/app/oracle/oradata/redo01/standby14b.log';

Database altered.

SYS@orcldg> alter database rename file '/u01/app/oracle/oradata/standby15b.log' to '/u01/app/oracle/oradata/redo01/standby15b.log';

Database altered.

--修改备库log_file_name_convert,将主库的+FRA/orcl/onlinelog/路径指向备库的/u01/app/oracle/oradata/redo01/路径.
SYS@orcldg> alter system set log_file_name_convert='+DATA/orcl/onlinelog/','/u01/app/oracle/oradata/','+FRA/orcl/onlinelog/','/u01/app/oracle/oradata/redo01/','+DATA/orcl/controlfile/','/u01/app/oracle/oradata/','+FRA/orcl/controlfile/','/u01/app/oracle/oradata/' scope=spfile;

System altered.

--重启生效
SYS@orcldg> shutdown immediate;
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SYS@orcldg> startup mount;
ORACLE instance started.

Total System Global Area 2455228416 bytes
Fixed Size                  2255712 bytes
Variable Size             620758176 bytes
Database Buffers         1811939328 bytes
Redo Buffers               20275200 bytes
Database mounted.

SYS@orcldg> select group#,thread#,sequence#,members,status,archived from v$log;

    GROUP#    THREAD#  SEQUENCE#    MEMBERS STATUS           ARC
---------- ---------- ---------- ---------- ---------------- ---
         1          1          0          2 CLEARING_CURRENT YES
         2          1          0          2 UNUSED           YES
         3          2          0          2 CURRENT          YES
         4          2          0          2 UNUSED           YES

SYS@orcldg> select group#,bytes/1024/1024 from v$log;                                     

    GROUP# BYTES/1024/1024
---------- ---------------
         1              50
         2              50
         3              50
         4              50

SYS@orcldg> alter database add logfile thread 1 group 5 ('/u01/app/oracle/oradata/group_1.log','/u01/app/oracle/oradata/redo01/group_1.log') size 50M;

Database altered.	
	 
SYS@orcldg> alter database drop logfile group 2;

Database altered.
--系统层面删除日志组2的redo文件
[oracle@hisdbdg redo01]$ rm -f group_2.258.1132745547
[oracle@hisdbdg redo01]$ cd ..
[oracle@hisdbdg oradata]$ pwd
/u01/app/oracle/oradata
[oracle@hisdbdg oradata]$ rm -f group_2.258.1132745547

--添加日志组2文件
SYS@orcldg> alter database add logfile group 2 ('/u01/app/oracle/oradata/group_2.258.1132745547','/u01/app/oracle/oradata/redo01/group_2.258.1132745547') size 50M;

Database altered.

[oracle@hisdbdg oradata]$ mv standby10b.log redo01 
[oracle@hisdbdg oradata]$ mv standby11b.log redo01 
[oracle@hisdbdg oradata]$ mv standby12b.log redo01 
[oracle@hisdbdg oradata]$ mv standby13b.log redo01 
[oracle@hisdbdg oradata]$ mv standby14b.log redo01 
[oracle@hisdbdg oradata]$ mv standby15b.log redo01 
[oracle@hisdbdg oradata]$ ll redo01
total 563244
-rw-r----- 1 oracle oinstall 52429312 Jun  9 23:58 group_1.257.1132745547
-rw-r----- 1 oracle oinstall 52429312 Jun  9 23:51 group_1.log
-rw-r----- 1 oracle oinstall 52429312 Jun  9 23:55 group_2.258.1132745547
-rw-r----- 1 oracle oinstall 52429312 May  5 19:31 group_3.259.1132747513
-rw-r----- 1 oracle oinstall 52429312 Jun  9 23:32 group_4.260.1132747515
-rw-r----- 1 oracle oinstall 52429312 Jun  9 21:23 standby10b.log
-rw-r----- 1 oracle oinstall 52429312 Jun  9 21:48 standby11b.log
-rw-r----- 1 oracle oinstall 52429312 Jun  6 21:26 standby12b.log
-rw-r----- 1 oracle oinstall 52429312 Jun  9 21:23 standby13b.log
-rw-r----- 1 oracle oinstall 52429312 Jun  9 19:52 standby14b.log
-rw-r----- 1 oracle oinstall 52429312 Jun  7 18:42 standby15b.log

--此时在来处理日志组1,因为日志组1状态为current,所以留在最后来处理.
说明:当时主库已执行alter database commit to switchover to physical standby with session shutdown;主切备语句,后来有将其重新切回主库后操作.
[oracle@hisdbdg oradata]$ ll group_1.257.1132745547
-rw-r----- 1 oracle oinstall 52429312 May  5 19:31 group_1.257.1132745547
[oracle@hisdbdg oradata]$ ll group_2.258.1132745547
-rw-r----- 1 oracle oinstall 52429312 Jun  9 23:55 group_2.258.1132745547
--在主库多次进行日志切换,直到备库日志组1为CLEARING或为UNUSED状态.
SYS@orcldg> select group#,thread#,sequence#,members,status,archived from v$log;

    GROUP#    THREAD#  SEQUENCE#    MEMBERS STATUS           ARC
---------- ---------- ---------- ---------- ---------------- ---
         1          1        299          2 CLEARING         YES
         2          1        301          2 CURRENT          YES
         3          2        153          2 CURRENT          YES
         4          2        152          2 CLEARING         YES
         5          1        300          2 CLEARING         YES
		 
SYS@orcldg> alter database clear logfile group 1;

Database altered.

SYS@orcldg> select group#,thread#,sequence#,members,status,archived from v$log;

    GROUP#    THREAD#  SEQUENCE#    MEMBERS STATUS           ARC
---------- ---------- ---------- ---------- ---------------- ---
         1          1          0          2 UNUSED           YES
         2          1        301          2 CURRENT          YES
         3          2        153          2 CURRENT          YES
         4          2        152          2 CLEARING         YES
         5          1        300          2 CLEARING         YES

SYS@orcldg> alter database drop logfile group 1;

Database altered.
		 
[oracle@hisdbdg oradata]$ rm -f group_1.257.1132745547
[oracle@hisdbdg oradata]$ cd redo01
[oracle@hisdbdg redo01]$ rm -f group_1.257.1132745547

SYS@orcldg> alter database add logfile thread 1 group 1 ('/u01/app/oracle/oradata/group_1.257.1132745547','/u01/app/oracle/oradata/redo01/group_1.257.1132745547') size 50M;

Database altered.		 

--日志组1成功处理OK,此时同样在主库多次切换日志.
SYS@orcldg> select group#,thread#,sequence#,members,status,archived from v$log;

    GROUP#    THREAD#  SEQUENCE#    MEMBERS STATUS           ARC
---------- ---------- ---------- ---------- ---------------- ---
         1          1        302          2 CURRENT          YES
         2          1        301          2 CLEARING         YES
         3          2        153          2 CLEARING         YES
         4          2        154          2 CURRENT          YES
         5          1        300          2 CLEARING         YES

SYS@orcldg> alter database clear logfile group 5;

Database altered.

SYS@orcldg> select group#,thread#,sequence#,members,status,archived from v$log;

    GROUP#    THREAD#  SEQUENCE#    MEMBERS STATUS           ARC
---------- ---------- ---------- ---------- ---------------- ---
         1          1        302          2 CURRENT          YES
         2          1        301          2 CLEARING         YES
         3          2        153          2 CLEARING         YES
         4          2        154          2 CURRENT          YES
         5          1          0          2 UNUSED           YES

SYS@orcldg> alter database drop logfile group 5;

Database altered.
		 
SYS@orcldg> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/group_1.257.1132745547
/u01/app/oracle/oradata/redo01/group_1.257.1132745547
/u01/app/oracle/oradata/group_2.258.1132745547
/u01/app/oracle/oradata/redo01/group_2.258.1132745547
/u01/app/oracle/oradata/group_3.265.1132747513
/u01/app/oracle/oradata/redo01/group_3.259.1132747513
/u01/app/oracle/oradata/group_4.266.1132747513
/u01/app/oracle/oradata/redo01/group_4.260.1132747515
/u01/app/oracle/oradata/standby10.log
/u01/app/oracle/oradata/redo01/standby10b.log
/u01/app/oracle/oradata/standby11.log

MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/redo01/standby11b.log
/u01/app/oracle/oradata/standby12.log
/u01/app/oracle/oradata/redo01/standby12b.log
/u01/app/oracle/oradata/standby13.log
/u01/app/oracle/oradata/redo01/standby13b.log
/u01/app/oracle/oradata/standby14.log
/u01/app/oracle/oradata/redo01/standby14b.log
/u01/app/oracle/oradata/standby15.log
/u01/app/oracle/oradata/redo01/standby15b.log

20 rows selected.		 

SYS@orcldg> alter system set standby_file_management=auto;

System altered.

说明:目前日志组两个成员文件名相同,但在不同目录下,此后备库成功切换为主库.

标签:主库,备库,log,app,oradata,切换,oracle,group,u01
From: https://blog.51cto.com/u_12991611/6456063

相关文章

  • 物理备库在open数据库时报错ORA-01190
    问题描述:物理备库在open数据库时报错ORA-01190,如下所示:数据库:oracle11.2.0.41、异常重现SYS@orcldg>alterdatabaseopen;alterdatabaseopen*ERRORatline1:ORA-10458:standbydatabaserequiresrecoveryORA-01190:controlfileordatafile1isfrombeforeth......
  • Windows下Rust toolchain的切换
    在用运行命令cargoinstallcargo-eval的过程中,总是提示链接器错误。因为原先使用的rusttoolchain是GNU的,怀疑是GNU的链接器有问题,毕竟Windows下实际上还是MSVC最稳,所以尝试切换成MSVC,果然问题就解决了,cargo-eval成功安装。以下是步骤:下载VisualStudio。在VisualStudioIns......
  • vuex使用,Router使用(做两个主页面的跳转),路由守卫(对路由进行权限控制),路由的工作模式
    vuex使用使用的流程文件中的代码前端页面<template><div><h1>使用vuex</h1>购物车商品数量:{{num}}购物车的数量:{{$store.state.num}}<br><button@click="yjx">加数量</button></div></template><sc......
  • prefers-color-scheme与color-scheme自由切换网站主题背景色变化
    部分转自:布依前端和前端侦探prefers-color-schemeprefers-color-scheme这个新的css特性,想必大家并不陌生,写文章的目的就是分享给大家怎么正确用好它以及提升网站用户体验。prefers-color-scheme是CSS 媒体特性【@media】用于检测用户是否有将操作系统的主题色设置为亮色【light】......
  • qt按钮切换互斥功能
    有这样一种功能:一组按钮,点击其中一个,该按钮被选中,其他按钮取消选中。  我这里简单说一下方法。创建一个继承自QFrame的窗口类,在上面放几个按钮,按钮属性设置如下:然后设置按钮的qss,下面是其中一个的按钮(其他按钮类似):data文件夹和exe所在的文件夹在同一目录,下面有几个图片......
  • mycat读写分离方式下强制指定select从主库查数据的方法
    在程序代码的sql语句前,如mybatis中指定select前加入/mycat:db_type=master/这个注释标识,select语句就会直接在主库查询数据,如下:/mycat:db_type=master/SELECT*FROMtb_table;上面的注释中:/!mycat:db_type=master//#mycat:db_type=master//mycat:db_type=master/使用哪一......
  • QT桌面(实现界面的滑动切换)
    (文章目录)前言在ARMLinux中使用QT如何实现滑动翻页切换界面的效果呢?在ARM中是没有自带的鼠标的,那么我们如何实现滑动翻页呢?经过测试发现在ARM中运行QT程序也是可以通过重写鼠标事件来捕获触屏动作的,在ARM中滑动屏幕被定义成了鼠标左键事件,那么这样就有思路了,重写鼠标事件。一......
  • 某个页面的菜单在切换页面时,菜单展开状态恢复关闭
    使用局部刷新解决在需要刷新的组件写一个变量,自己在data里面简历变量哦:isReloadData:truemethods里面写一个方法methods:{reloadPart(){this.isReloadData=false;this.$nextTick(()=>{this.isReloadData=true;});},在......
  • Flexslider图片轮播、文字图片相结合滑动切换效果
    Flexslider是一款基于的jQuery内容滚动插件。它能让你轻松的创建内容滚动的效果,具有非常高的可定制性。开发者可以使用Flexslider轻松创建各种图片轮播效果、焦点图效果、图文混排滚动效果。查看演示DEMO下载源码Flexslider具有以下特性:支持滑动和淡入淡出效果。支持水平、......
  • 多数据源切换
    多数据源解决方案mybatis-plus动态切换数据源该方法简单便捷,直接通过注解@DS("xxx")就可以切换数据源但是这边官方建议只添加在方法上或类上,所以在同一个方法中只能使用一种数据源依赖配置1.添加依赖<dependency> <groupId>com.baomidou</groupId> <artifact......