日期:2014-05-16  浏览次数:20483 次

Oracle Data Guard (二) Physical Standby

1. 检查Primary数据库是否是archivelog模式

SQL> select log_mode from v$database;


如果结果不是"ARCHIVELOG",执行以下命令:

SQL> shutdown immediate;

SQL> startup mount;

SQL> alter database archivelog;

SQL> alter database open;


2. 检查Primary数据库是否是force logging模式

SQL> select force_logging from v$database;


如果结果不是"YES",执行以下命令:

SQL> alter database force logging;

3. 在Primary数据库上创建Standby logfile

SQL> select group#,thread#,bytes/1024/1024 from v$log;


根据得到的group数目和log大小,为Standby实例创建对应的logfile,默认情况下是三个Group,且每个大小为50M。

SQL> alter database add standby logfile ‘/home/oracle/app/oracle/oradata/sungoin/stby_redo01.log’ size 50m;

SQL> alter database add standby logfile ‘/home/oracle/app/oracle/oradata/sungoin/stby_redo02.log’ size 50m;

SQL> alter database add standby logfile ‘/home/oracle/app/oracle/oradata/sungoin/stby_redo03.log’ size 50m;


4. 在Primary数据库上配置Standby相关系统参数

SQL> alter system set log_archive_config=’DG_CONFIG=(test,standby)’;

SQL> alter system set log_archive_dest_1=’LOCATION=/home/oracle/app/oracle/flash_recovery_area/test/archivelog VALID_FOR=(ALL_LOGFILES,ALL_ROLES)  DB_UNIQUE_NAME=test’;

SQL> alter system set log_archive_dest_2=’service=standby ASYNC valid_for=(ONLINE_LOGFILE,PRIMARY_ROLE) db_unique_name=standby’;

SQL> alter system set fal_server=test;

SQL> alter system set fal_client=standby;

SQL> alter system set standby_file_management=auto;

SQL> alter system set remote_login_passwordfile=exclusive;


5. 在Primary服务器上配置监听器和TNS变量

在Primary服务器的监听器中静态注册test实例,添加下面行到文件 /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora中:

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC = 
      (SID_NAME = test)
      (ORACLE_HOME = /home/oracle/app/oracle/product/11.2.0/dbhome_1)
    )

  )


在Primary服务器的TNS中注册test和standby,添加下面行到文件 /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora中:


TEST=
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = testdb)(PORT = 1521))
    (CONNECT_DATA =
    &nb