Benjamin Zhang

目前就职于中科院计算机网络信息中心,主要兴趣集中在数据库,操作系统,中间件。

【DATAGUARD】创建Active Data Guard Physical Standby

26 Mar 2019 » Oracle

创建Active Data Guard Physical Standby

0.环境准备情况

Primary数据库:
Platform          : Linux 86_64
Server Name       : db01.zsd.com, IP: 172.17.4.201
DB Version        : Oracle 11.2.0.4, File system: Normal
DB Name           : arpdb, DB_UNIQUE_NAME: arp_primary
Oracle Home Path  : /u01/app/oracle/product/11.2.0/db_1
data file Path    : /u01/app/oracle/oradata/arpdb
archive log Path  : /u01/app/oracle/oradata/arpdb/archive

Standby数据库:
Platform          : Linux 86_64
Server Name       : db02.zsd.com, IP: 172.17.4.202
DB Version        : Oracle 11.2.0.4, , File system: Normal
DB Name           : arpdb, DB_UNIQUE_NAME: arp_standby
Oracle Home Path  : /u01/app/oracle/product/11.2.0/db_1
data file Path    : /u01/app/oracle/oradata/arpdb
archive log Path  : /u01/app/oracle/oradata/arpdb/archive

1.确认Primary主库为归档模式

如何开启归档,参考Oracle开启归档

SQL> archive log list; 
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u01/app/oracle/oradata/arpdb/archive
Oldest online log sequence     3
Next log sequence to archive   5
Current log sequence           5

2.将Primary数据库置为Force Logging模式

SQL> alter database force logging 

SQL> select force_logging from v$database;

FORCE_LOG
---------
YES

3.在Primary数据库创建密钥文件

[root@db dbs]# su - oracle
[oracle@db ~]$ cd /u01/app/oracle/product/11.2.0/db_1/dbs
[oracle@db dbs]$ orapwd file=orapwarpdb password=oracle force=y

4.在Primary数据库创建Standby Redologs

SQL> set lines 180
SQL> col MEMBER for a50
SQL> select b.thread#, a.group#, a.member, b.bytes FROM v$logfile a, v$log b WHERE a.group# = b.group#;

   THREAD#     GROUP# MEMBER                                                  BYTES
---------- ---------- -------------------------------------------------- ----------
         1          3 /u01/app/oracle/oradata/arpdb/redo03.log             52428800
         1          2 /u01/app/oracle/oradata/arpdb/redo02.log             52428800
         1          1 /u01/app/oracle/oradata/arpdb/redo01.log             52428800

ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 ('/u01/app/oracle/oradata/arpdb/std01.log') SIZE 200M;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 ('/u01/app/oracle/oradata/arpdb/std02.log') SIZE 200M;
ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 ('/u01/app/oracle/oradata/arpdb/std03.log') SIZE 200M;

SQL> select a.group#, a.member, b.bytes FROM v$logfile a, v$standby_log b WHERE a.group# = b.group#;

    GROUP# MEMBER                                                  BYTES
---------- -------------------------------------------------- ----------
         4 /u01/app/oracle/oradata/arpdb/std01.log             209715200
         5 /u01/app/oracle/oradata/arpdb/std02.log             209715200
         6 /u01/app/oracle/oradata/arpdb/std03.log             209715200

删除命令(知识点扩展):

SQL>ALTER DATABASE ADD STANDBY LOGFILE GROUP 7 ('/u01/app/oracle/oradata/arpdb/std04.log') SIZE 200M;
SQL>alter database drop standby logfile group 7; 

未完,待更新。

5.