暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

修改Standby DB的rman配置

原创 楚枫默寒 2025-12-05
199

 

一、直接在standbydb上修改:保留2次有效备份

        提示:RMAN-05021: this configuration cannot be changed for a BACKUP or STANDBY control file

[oracle@testrac01:/home/oracle]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Fri Dec 5 10:59:25 2025

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: TEST (DBID=2507982056)

RMAN> show  RETENTION POLICY;

RMAN configuration parameters for database with db_unique_name TESTDG are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1;


RMAN> configure retention policy to redundancy 2;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of configure command at 12/05/2025 10:59:53
RMAN-05021: this configuration cannot be changed for a BACKUP or STANDBY control file

RMAN> 

RMAN> exit


Recovery Manager complete.

二、sqlplus登录Standbydb

        查看rman配置:

        set line 900 COLSEP '|' pagesize 50
        col name for a60
        col value for a100
        select * from v$rman_configuration;

[oracle@testrac01:/home/oracle]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Dec 5 11:00:15 2025

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SYS@TESTDG1 2025/12/05 11:00:15>set line 900 COLSEP '|' pagesize 50
SYS@TESTDG1 2025/12/05 11:00:27>col name for a60
SYS@TESTDG1 2025/12/05 11:00:27>col value for a100
SYS@TESTDG1 2025/12/05 11:00:27>select * from v$rman_configuration;

     CONF#|NAME                                                        |VALUE
----------|------------------------------------------------------------|----------------------------------------------------------------------------------------------------
         1|CONTROLFILE AUTOBACKUP                                      |ON
         2|CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE               |DISK TO '/rman/20250904_rman/%F'

        此时standbydb中没有相关配置信息。


三、添加配置信息

DECLARE 
   x NUMBER; 
  BEGIN 
    x := dbms_backup_restore.setconfig('RETENTION POLICY','TO REDUNDANCY 2'); 
    dbms_output.put_line('setconfig returned ' || x); 
  END; 
/


SYS@TESTDG1 2025/12/05 11:00:27>DECLARE 
  2     x NUMBER; 
  3    BEGIN 
  4      x := dbms_backup_restore.setconfig('RETENTION POLICY','TO REDUNDANCY 2'); 
  5      dbms_output.put_line('setconfig returned ' || x); 
  6    END; 
  7  /
setconfig returned 3

PL/SQL procedure successfully completed.

SYS@TESTDG1 2025/12/05 11:01:18>
SYS@TESTDG1 2025/12/05 11:01:19>
SYS@TESTDG1 2025/12/05 11:01:20>set line 900 COLSEP '|' pagesize 50
SYS@TESTDG1 2025/12/05 11:01:21>col name for a60
SYS@TESTDG1 2025/12/05 11:01:21>col value for a100
SYS@TESTDG1 2025/12/05 11:01:21>select * from v$rman_configuration;

     CONF#|NAME                                                        |VALUE
----------|------------------------------------------------------------|----------------------------------------------------------------------------------------------------
         1|CONTROLFILE AUTOBACKUP                                      |ON
         2|CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE               |DISK TO '/rman/20250904_rman/%F'
         3|RETENTION POLICY                                            |TO REDUNDANCY 2

SYS@TESTDG1 2025/12/05 11:01:21>exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
[oracle@testrac01:/home/oracle]$ 

        可以看到信息已添加到stangbydb中。

        如果想继续修改可执行上面的命令添加,或用以下命令删除,() 内的值为CONF# 号        

exec DBMS_BACKUP_RESTORE.DELETECONFIG(3);

        注:同一项不要配置重复如下:

SYS@xxx999dg2> select * from v$rman_configuration;
     CONF# NAME                 VALUE
---------- -------------------- ----------------------------
         1 RETENTION POLICY     TO RECOVERY WINDOW OF 7 DAYS
         2 RETENTION POLICY     TO RECOVERY WINDOW OF 8 DAYS


RMAN> show  RETENTION POLICY;
RMAN configuration parameters for database with db_unique_name xxx999DG2 are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 7 DAYS;
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 8 DAYS;

四、配置完成,检查

[oracle@testrac01:/home/oracle]$ rman target /

Recovery Manager: Release 11.2.0.4.0 - Production on Fri Dec 5 11:01:28 2025

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: TEST (DBID=2507982056)

RMAN> show  RETENTION POLICY;

RMAN configuration parameters for database with db_unique_name TESTDG are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;


RMAN> 

参考:https://blog.itpub.net/267265/viewspace-2838396/
https://mdinh.wordpress.com/2021/10/12/how-to-change-rman-config-for-standby-db/

 

  

最后修改时间:2025-12-05 11:25:06
文章转载自楚枫默寒,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论