Oracle21.3 active data guard(ADG)配置

Oracle21.3 active data guard(ADG)配置

环境介绍:

OS :centos8.3

oracle: 21.3

此次文档搭建的是CDB级别的ADG。Oracle从21.7版本开始支持PDB级别的ADG,不在这篇文章中测试验证,后续有时间再安排更新。

以下是主要的配置步骤:

1、主备开启归档模式

SQL>shutdown immediate
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup mount;
ORACLE 例程已经启动。

Total System Global Area 5301599856 bytes
Fixed Size                  9698928 bytes
Variable Size            1006632960 bytes
Database Buffers         4278190080 bytes
Redo Buffers                7077888 bytes
数据库装载完毕。
SQL> alter database archivelog;

数据库已更改。

SQL> alter database open;

数据库已更改。

SQL> show pdbs;
SQL> archive log list;
数据库日志模式            存档模式
自动存档             启用
存档终点            USE_DB_RECOVERY_FILE_DEST
最早的联机日志序列     1
下一个存档日志序列   3
当前日志序列           3

2、主备配置TNS

itsm_pri =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.xx.xx)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = itsmsrv)
    )
  )

itsm_std =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.xx.xx)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = itsmsrv)
    )
  )

3、配置静态监听

vi listener.ora

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC = 
      (GLOBAL_DBNAME = ITSMPROD)
      (ORACLE_HOME = /OSdata/oracle/app/product/21.3.0/db_1)
      (SID_NAME = ITSMPROD)
    )
  )
# lsnrctl reload
# lsnrctl status

4、主备开启强制日志和闪回

SQL> alter database force logging;
SQL> shutdown immediate
SQL> startup mount;
SQL> alter database flashback on;
SQL> alter database open;

SQL> select flashback_on,FORCE_LOGGING from v$database;
FLASHBACK_ON       FORCE_LOGGING
------------------ ---------------------------------------
YES                YES

5、主库添加standb redolog

添加standby日志组
alter database add standby logfile group 4 '/OSdata/oradata/ITSM/std_redo04.log' size 200m;
alter database add standby logfile group 5 '/OSdata/oradata/ITSM/std_redo05.log' size 200m;
alter database add standby logfile group 6 '/OSdata/oradata/ITSM/std_redo06.log' size 200m;
alter database add standby logfile group 7 '/OSdata/oradata/ITSM/std_redo07.log' size 200m; 

select group#,sequence#,status, bytes/1024/1024 from v$standby_log;

6、配置主备库参数文件

主库配置参数文件

主库配置参数文件1:
alter system set db_unique_name=PRODITSM sid='*' scope=spfile; 
alter system set log_file_name_convert= '/OSdata/oradata/ITSM','/OSdata/oradata/ITSM' sid='*' scope=spfile;
alter system set db_file_name_convert= '/OSdata/oradata/ITSM/ITSMPROD','/OSdata/oradata/ITSM/ITSMPROD','/OSdata/oradata/ITSM/pdbseed','/OSdata/oradata/ITSM/pdbseed','/OSdata/oradata/ITSM','/OSdata/oradata/ITSM' sid='*' scope=spfile;
alter system set service_names=itsmsrv sid='*' scope=spfile;

主库开启闪回:
alter system set db_recovery_file_dest_size=100G sid='*' scope=both;  (生产环境根据实际情况调整大小)
--alter system set db_recovery_file_dest='D:\flashbackon' sid='*' scope=both;
shutdown immediate
startup mount;
alter database flashback on;
alter database open;
检查flashback结果:
select flashback_on,FORCE_LOGGING from v$database;

主库配置参数文件2:
alter system set log_archive_config='DG_CONFIG=(PRODITSM,STDITSM)' sid='*' scope=both;
alter system set log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=PRODITSM' sid='*' scope=both;
alter system set log_archive_dest_2='SERVICE=itsm_std LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=STDITSM' sid='*' scope=both;
alter system set log_archive_dest_state_1=ENABLE sid='*' scope=both;
alter system set log_archive_dest_state_2=ENABLE sid='*' scope=both;
--# Standby role Parameters
alter system set FAL_SERVER=STDITSM sid='*' scope=both;
alter system set FAL_CLIENT=PRODITSM sid='*' scope=both;
alter system set STANDBY_FILE_MANAGEMENT=AUTO sid='*' scope=both;

备库配置参数文件

备库参数文件修改
alter system set db_unique_name=STDITSM sid='*' scope=spfile;
alter system set log_file_name_convert= '/OSdata/oradata/ITSM','/OSdata/oradata/ITSM' sid='*' scope=spfile;
alter system set db_file_name_convert= '/OSdata/oradata/ITSM/ITSMPROD','/OSdata/oradata/ITSM/ITSMPROD','/OSdata/oradata/ITSM/pdbseed','/OSdata/oradata/ITSM/pdbseed','/OSdata/oradata/ITSM','/OSdata/oradata/ITSM' sid='*' scope=spfile;
alter system set service_names=itsmsrv sid='*' scope=spfile;

开启强制日志功能
alter database force logging;

备库开启闪回:
alter system set db_recovery_file_dest_size=100G sid='*' scope=both;  (生产环境根据实际情况调整大小)
--alter system set db_recovery_file_dest='D:\flashbackon' sid='*' scope=both;
shutdown immediate
startup mount;
alter database flashback on;
alter database open;
--检查flashback结果:
select flashback_on,FORCE_LOGGING from v$database;

备库参数修改2
alter system set log_archive_config='DG_CONFIG=(PRODITSM,STDITSM)' sid='*' scope=both;
alter system set log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=STANDBY' sid='*' scope=both;
alter system set log_archive_dest_2='SERVICE=itsm_pri LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=PRODUCTION' sid='*' scope=both;
alter system set log_archive_dest_state_1=ENABLE sid='*' scope=both;
alter system set log_archive_dest_state_2=DEFER sid='*' scope=both;
--# #Standby Database Standby role parameters
alter system set FAL_SERVER=PRODITSM sid='*' scope=both;
alter system set FAL_CLIENT=STDITSM sid='*' scope=both;
alter system set STANDBY_FILE_MANAGEMENT=AUTO sid='*' scope=both;

7、备库启动到nomount状态进行搭建

备库启动到nomount状态

shutdown immediate;
startup nomount;
在线搭建DG
rman target sys/xxx@itsm_pri auxiliary sys/xxx@itsm_std
duplicate target database for standby from active database nofilenamecheck dorecover;

8、启动备库到只读状态

SQL> show pdbs;

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       MOUNTED
         3 ITSMPROD                       MOUNTED

SQL> alter database open;

数据库已更改。

SQL> show pdbs;

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 ITSMPROD                       MOUNTED
SQL> select database_role from v$database;

DATABASE_ROLE
----------------
PHYSICAL STANDBY

SQL> alter pluggable database ITSMPROD open read only;

插接式数据库已变更。

SQL> show pdbs;

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 ITSMPROD                       READ ONLY  NO

9、检查状态

主库:
SQL> select process,status,sequence# from v$managed_standby;

PROCESS   STATUS        SEQUENCE#
--------- ------------ ----------
DGRD      ALLOCATED             0
ARCH      CONNECTED             0
DGRD      ALLOCATED             0
ARCH      CONNECTED             0
ARCH      CONNECTED             0
ARCH      CLOSING               3
DGRD      ALLOCATED             0
LNS       CONNECTED             0
LNS       WRITING               7

备库:
SQL> select process,status,sequence# from v$managed_standby;

PROCESS   STATUS        SEQUENCE#
--------- ------------ ----------
ARCH      CONNECTED             0
DGRD      ALLOCATED             0
DGRD      ALLOCATED             0
ARCH      CONNECTED             0
ARCH      CONNECTED             0
ARCH      CONNECTED             0
RFS       IDLE                  0
RFS       IDLE                  7

--启动实时应用
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

SQL> select process,status,sequence# from v$managed_standby;

PROCESS   STATUS        SEQUENCE#
--------- ------------ ----------
ARCH      CONNECTED             0
DGRD      ALLOCATED             0
DGRD      ALLOCATED             0
ARCH      CONNECTED             0
ARCH      CONNECTED             0
ARCH      CLOSING              12
RFS       IDLE                  0
RFS       IDLE                 13
MRP0      APPLYING_LOG         13

问题处理

RMAN

-04006: 来自辅助数据库的错误: ORA-01017: invalid username/password; logon denied

该问题主要是由于TNS的服务名配置错误导致。

相关推荐
指尖上跳动的旋律16 分钟前
shell脚本定义特殊字符导致执行mysql文件错误的问题
数据库·mysql
一勺菠萝丶27 分钟前
MongoDB 常用操作指南(Docker 环境下)
数据库·mongodb·docker
m0_748244831 小时前
StarRocks 排查单副本表
大数据·数据库·python
C++忠实粉丝1 小时前
Redis 介绍和安装
数据库·redis·缓存
wmd131643067122 小时前
将微信配置信息存到数据库并进行调用
数据库·微信
是阿建吖!2 小时前
【Linux】基础IO(磁盘文件)
linux·服务器·数据库
凡人的AI工具箱2 小时前
每天40分玩转Django:Django国际化
数据库·人工智能·后端·python·django·sqlite
ClouGence2 小时前
Redis 到 Redis 数据迁移同步
数据库·redis·缓存
m0_748236582 小时前
《Web 应用项目开发:从构思到上线的全过程》
服务器·前端·数据库
苏三说技术2 小时前
Redis 性能优化的18招
数据库·redis·性能优化