ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 11gR2 RAC+DG配置

11gR2 RAC+DG配置

原创 Linux操作系统 作者:DBA_oracle_java 时间:2013-07-22 20:39:15 0 删除 编辑

DATAGRUAD配置


目录

 环境准备

1.1        主备库的配置信息

 确认主库设置

2.1 启动监听

2.2 查看归档模式是否开启

2.3 更改主库为force logging模式

2.4 创建主库的密码文件

2.5 配置主库的监听和TNS

2.6 修改主库的参数文件

2.7传输密码文件,tns文件到其他节点和备库

 备库设置

3.1修改备库的参数文件

3.2 建立参数文件相关的目录

 主库做全备并恢复备库

4.1 全备主库

4.2 传输备份到备库

4.3 备库启动到nomount

4.4 主库 duplicate target database for standby;

4.5 执行备库恢复模式

4.6 查看日志同步情况

4.7 创建STANDBY LOGFILE

 SWITCHOVER AND FAILOVER

5.1 switchover

5.2 FAILOVER

 PROTECTION MODE

6.1 修改DG的保护模式

 

 

 

 

 

 

 


 环境准备

1.1    主备库的配置信息

 

PRIMARY

STANDBY

OS

OEL5.6

OEL5.6

HOSTNAME

Jxdb1/jxdb2

jxstb

RELEASE

11.2.0.3

11.2.0.3

RAC

YES

NO

DB_NAME

Jxdb

Jxdb

DB_UNIQUE_NAME

jxpdb

Jxstb

LISTENER

LISTENER/1521

LISTENER/1521

SCAN_LISTENER

LISTENER_SCAN1/1521

 

TNSNAME

jxstb

Jxpdb

SID

Jxdb1/jxdb2

jxdb

 

#RACSTANDBY主机的IP设置

#public

192.168.56.10   jxdb1

192.168.56.11   jxdb2

 

#private

10.0.0.10   jxdb1-priv

10.0.0.11   jxdb2-priv

 

#vip

192.168.56.20   jxdb1-vip

192.168.56.21   jxdb2-vip

 

#scan

192.168.56.50   jxdb-scan

 

#jxstb

192.168.56.40   jxstb

 

 确认主库设置

2.1 启动监听

#JXDB2

grid@jxdb2:/home/grid>>lsnrctl status

 

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 16-MAR-2013 10:49:10

 

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

 

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))

STATUS of the LISTENER

------------------------

Alias                     LISTENER

Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production

Start Date                16-MAR-2013 10:19:27

Uptime                    0 days 0 hr. 29 min. 43 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/app/11.2.0/grid/network/admin/listener.ora

Listener Log File         /u01/app/grid/diag/tnslsnr/jxdb2/listener/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.11)(PORT=1521)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.21)(PORT=1521)))

Services Summary...

Service "+ASM" has 1 instance(s).

  Instance "+ASM2", status READY, has 1 handler(s) for this service...

Service "jxdbXDB" has 1 instance(s).

  Instance "jxdb2", status READY, has 1 handler(s) for this service...

Service "jxpdb" has 2 instance(s).

  Instance "jxdb2", status UNKNOWN, has 1 handler(s) for this service...

  Instance "jxdb2", status READY, has 1 handler(s) for this service...

The command completed successfully

 

 

 

grid@jxdb2:/home/grid>lsnrctl status LISTENER_SCAN1

 

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 16-MAR-2013 10:52:55

 

Copyright (c) 1991, 2011, Oracle.  All rights reserved.

 

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1)))

STATUS of the LISTENER

------------------------

Alias                     LISTENER_SCAN1

Version                   TNSLSNR for Linux: Version 11.2.0.3.0 - Production

Start Date                16-MAR-2013 10:19:27

Uptime                    0 days 0 hr. 33 min. 29 sec

Trace Level               off

Security                  ON: Local OS Authentication

SNMP                      OFF

Listener Parameter File   /u01/app/11.2.0/grid/network/admin/listener.ora

Listener Log File        /u01/app/grid/diag/tnslsnr/jxdb2/listener_scan1/alert/log.xml

Listening Endpoints Summary...

  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN1)))

  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.56.50)(PORT=1521)))

Services Summary...

Service "jxdbXDB" has 1 instance(s).

  Instance "jxdb2", status READY, has 1 handler(s) for this service...

Service "jxpdb" has 2 instance(s).

  Instance "jxdb2", status UNKNOWN, has 1 handler(s) for this service...

  Instance "jxdb2", status READY, has 1 handler(s) for this service...

The command completed successfully

2.2 查看归档模式是否开启

SQL> archive log list;

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            +RECO/arch/jxdb/

Oldest online log sequence     8

Next log sequence to archive   9

Current log sequence           9

SQL>

2.3 更改主库为force logging模式

SQL> alter database force logging;

 

Database altered.

 

2.4 创建主库的密码文件

密码文件的命名格式和操作系统有关。如果命名不正确会导致ORA-01031错误。

Linux/Unixorapw$ORACLE_SID

Windows  PWD$ORACLE_SID.ora

 

oracle@jxpdb:/u01/app/oracle/products/11.2.0/dbs>orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=oracle entries=30;

将创建的密码文件发送到其他节点和备库,并修改文件名称。格式为:orapw$ORACLE_SID

2.5 查看相关文件位置

SQL> show parameter spfile

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

spfile                               string      +DATA/jxpdb/spfilejxdb.ora

 

SQL> select name from v$datafile;

 

NAME

--------------------------------------------------------------------------------

+DATA/jxpdb/system01.dbf

+DATA/jxpdb/sysaux01.dbf

+DATA/jxpdb/undotbs01.dbf

+DATA/jxpdb/users01.dbf

+DATA/jxpdb/undotbs02.dbf

 

SQL> select name from v$controlfile;

 

NAME

--------------------------------------------------------------------------------

+DATA/jxpdb/control01.ctl

+DATA/jxpdb/control02.ctl

 

2.5 配置主库的监听和TNS

11gR2 RAC环境中配置监听的动态注册貌似收到去编辑listener.ora文件不太可行。而且监听是受到grid用户管理的。所以配置监听需要在grid用户下。下面给出配置的过程截图,和配置结束后的配置文件的情况。

 

2.5.1 配置监听

grid@jxdb2:/home/grid >netmgr


2.5.2查看动态注册结果

 grid@jxdb1:/u01/app/11.2.0/grid/network/admin>cat listener.ora      

# listener.ora Network Configuration File: /u01/app/11.2.0/grid/network/admin/listener.ora

# Generated by Oracle configuration tools.

 

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1 = ON

 

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = jxpdb)

      (ORACLE_HOME = /u01/app/11.2.0/grid)

      (SID_NAME = jxdb1)

    )

  )

 

SID_LIST_LISTENER_SCAN1 =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = jxpdb)

      (ORACLE_HOME = /u01/app/11.2.0/grid)

      (SID_NAME = jxdb1)

    )

  )

 

LISTENER =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER))

  )

 

ADR_BASE_LISTENER = /u01/app/grid

 

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER = ON

 

LISTENER_SCAN1 =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER_SCAN1))

  )

 

ADR_BASE_LISTENER_SCAN1 = /u01/app/grid

2.5.3 配置TNSNAME

下面配置TNS,配置文件的位置在$ORACLE_HOME/NETWORK/ADMIN/下的tnsname.ora.该文件需要在oracle用户下配置,因为DG是通过oracle传输日志的。

oracle@jxstb:/u01/app/oracle/products/11.2.0/network/admin>cat tnsnames.ora

# tnsnames.ora Network Configuration File: /u02/app/oracle/products/11.2.0/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

 

JXSTB =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = jxstb)(PORT = 1521))

    )

    (CONNECT_DATA =

      (SERVER = DEDICATED) 

      (SERVICE_NAME = jxstb)

    )

  )

 

JXPDB =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = jxdb-scan)(PORT = 1521))

    )

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = jxpdb)

    )

  )

 

2.5.4 配置其他节点监听及TNS设置

步骤同2.5.1~2.5.2

 

2.6 修改主库的参数文件

SQL> create pfile='/home/oracle/initjxdb.ora' from spfile;

oracle@jxdb2:/home/oracle>vi initjxdb.ora

#DG CONFIG

*.log_archive_config='dg_config=(jxpdb,jxstb)'

*.log_archive_dest_1='LOCATION=+RECO/arch/jxdb/ LGWR VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=jxpdb'

*.log_archive_dest_2='SERVICE=jxstb ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=jxstb'

*.standby_file_management='AUTO'

*.DB_FILE_NAME_CONVERT='/ORADATA/jxstb/','+DATA/jxpdb/'

*.LOG_FILE_NAME_CONVERT='/ORADATA/jxstb/','+DATA/jxpdb'

*.log_archive_dest_state_1=enable

*.log_archive_dest_state_2=enable

*.fal_server=jxstb

*.fal_client=jxpdb

*.db_unique_name=jxpdb

 

#生产新的spfile文件

SQL> shutdown immediate;

SQL> create spfile='+DATA/jxpdb/spfilejxdb.ora' from pfile='/home/oracle/initjxdb.ora';

SQL> startup

 

2.6.1 部分DG参数说明

LOG_ARCHIVE_CONFIG

Verify that the LOG_ARCHIVE_CONFIG database initialization parameter has been defined on the primary database and on each standby database, and that its value includes a DG_CONFIG list that includes the DB_UNIQUE_NAME of the primary database and each standby database.

DB_UNIQUE_NAME

Verify that the DB_UNIQUE_NAME database initialization parameter has been set to a unique value on the primary database and on each standby database.

LOG_ARCHIVE_DEST_1

LOG_ARCHIVE_DEST_1 archives redo data received from the primary

database to archived redo log files in /arch1/boston/.

LOG_ARCHIVE_DEST_2

LOG_ARCHIVE_DEST_2 is currently ignored because this destination is

valid only for the primary role. If a switchover occurs and this instance

becomes the primary database, then it will transmit redo data to the remote

Chicago destination.

FAL_SERVER

Specify the Oracle Net service name of the FAL server (typically this is the database running in the primary role). When the Boston database is running in the standby role, it uses the Chicago database as the FAL server from which to fetch (request) missing archived redo log files if Chicago is unable to automatically send the missing log files.

STANDBY_FILE_MANAGEMENT

Set to AUTO so when datafiles are added to or dropped from the primary

database, corresponding changes are made automatically to the standby

database

DB_FILE_NAME_CONVERT

Specify the path name and filename location of the primary database datafiles followed by the standby location. This parameter converts the path names of the primary database datafiles to the standby datafile path names. If the standby database is on the same system as the primary database or if the directory structure where the datafiles are located on the standby site is different from the primary site, then this parameter is required. Note that this parameter is used only to convert path names for physical standby databases. Multiple pairs of paths may be specified by this parameter.

 

LOG_FILE_NAME_CONVERT

Specify the location of the primary database online redo log files followed by the standby location. This parameter converts the path names of the primary database log files to the path names on the standby database. If the standby database is on the same system as the primary database or if the directory structure where the log files are located on the standby system is different from the primary system, then this parameter is required. Multiple pairs of paths may be specified by this parameter.

 

 

2.7传输密码文件,tns文件到其他节点和备库

oracle@jxdb1:/u02/app/oracle/products/11.2.0/dbs>orapwd file=orapwjxdb1 password=oracle entries=5

oracle@jxdb1:/u02/app/oracle/products/11.2.0/dbs>scp orapwjxdb1 jxdb2: /u02/app/oracle/products/11.2.0/dbs

oracle@jxdb1:/u02/app/oracle/products/11.2.0/dbs>scp orapwjxdb1 jxstb:/u01/app/oracle/products/11.2.0/dbs

oracle@jxdb2:/u02/app/oracle/products/11.2.0/dbs>mv orapwjxdb1 orapwjxdb2

oracle@jxstb: /u01/app/oracle/products/11.2.0/dbs> mv orapwjxdb1 orapwjxdb

 

 备库设置

3.1修改备库的参数文件

oracle@jxstb:/u01/app/oracle/products/11.2.0/dbs>vi initjxdb.ora

#DG CONFIG

*.log_archive_config='dg_config=(jxpdb,jxstb)'

*.log_archive_dest_1='LOCATION=/RECO/arch/jxdb/ LGWR VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=jxstb'

*.log_archive_dest_2='SERVICE=jxpdb ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=jxpdb'

*.standby_file_management='AUTO'

*.DB_FILE_NAME_CONVERT='+DATA/jxpdb/','/ORADATA/jxstb/'

*.LOG_FILE_NAME_CONVERT='+DATA/jxpdb/','/ORADATA/jxstb/'

*.log_archive_dest_state_1=enable

*.log_archive_dest_state_2=enable

*.fal_server=jxpdb

*.fal_client=jxstb

*.db_unique_name=jxstb

3.2 建立参数文件相关的目录

audit_file_dest

control_files

 

 

 主库做全备并恢复备库

4.1 全备主库

RMAN> backup device type disk format '/home/oracle/backup/%U' database plus archivelog;

4.2 传输备份到备库

传输备份到备库的相应位置

oracle@jxdb2:/home/oracle/backup>scp * jxstb:/home/oracle/backup/

4.3 备库启动到nomount

oracle@jxstb:/home/oracle>sqlplus  '/ as sysdba'

SQL> startup nomount;

 

4.4 主库 duplicate target database for standby;

racle@jxdb2:/u02/app/oracle/products/11.2.0/dbs>rman target /

 

Recovery Manager: Release 11.2.0.3.0 - Production on Thu Mar 14 19:19:35 2013

 

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

 

connected to target database: JXDB (DBID=581150047)

 

RMAN> connect auxiliary sys/oracle@jxstb

 

connected to auxiliary database: JXPDB (not mounted)

 

 

RMAN> duplicate target database for standby;

 

Starting Duplicate Db at 14-MAR-13

using target database control file instead of recovery catalog

allocated channel: ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: SID=10 device type=DISK

 

contents of Memory Script.:

{

   restore clone standby controlfile;

}

executing Memory Script

 

Starting restore at 14-MAR-13

using channel ORA_AUX_DISK_1

 

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: restoring control file

channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/backup/03o4hb7m_1_1

channel ORA_AUX_DISK_1: piece handle=/home/oracle/backup/03o4hb7m_1_1 tag=TAG20130314T191012

channel ORA_AUX_DISK_1: restored backup piece 1

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07

output file name=/ORADATA/jxstb/control01.ctl

output file name=/ORADATA/jxstb/control02.ctl

Finished restore at 14-MAR-13

 

contents of Memory Script.:

{

   sql clone 'alter database mount standby database';

}

executing Memory Script

 

sql statement: alter database mount standby database

 

contents of Memory Script.:

{

   set newname for tempfile  1 to

 "/ORADATA/jxstb/temp01.dbf";

   switch clone tempfile all;

   set newname for datafile  1 to

 "/ORADATA/jxstb/system01.dbf";

   set newname for datafile  2 to

 "/ORADATA/jxstb/sysaux01.dbf";

   set newname for datafile  3 to

 "/ORADATA/jxstb/undotbs01.dbf";

   set newname for datafile  4 to

 "/ORADATA/jxstb/users01.dbf";

   set newname for datafile  5 to

 "/ORADATA/jxstb/undotbs02.dbf";

   restore

   clone database

   ;

}

executing Memory Script

 

executing command: SET NEWNAME

 

renamed tempfile 1 to /ORADATA/jxstb/temp01.dbf in control file

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

executing command: SET NEWNAME

 

Starting restore at 14-MAR-13

using channel ORA_AUX_DISK_1

 

channel ORA_AUX_DISK_1: starting datafile backup set restore

channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set

channel ORA_AUX_DISK_1: restoring datafile 00001 to /ORADATA/jxstb/system01.dbf

channel ORA_AUX_DISK_1: restoring datafile 00002 to /ORADATA/jxstb/sysaux01.dbf

channel ORA_AUX_DISK_1: restoring datafile 00003 to /ORADATA/jxstb/undotbs01.dbf

channel ORA_AUX_DISK_1: restoring datafile 00004 to /ORADATA/jxstb/users01.dbf

channel ORA_AUX_DISK_1: restoring datafile 00005 to /ORADATA/jxstb/undotbs02.dbf

channel ORA_AUX_DISK_1: reading from backup piece /home/oracle/backup/02o4hb0k_1_1

channel ORA_AUX_DISK_1: piece handle=/home/oracle/backup/02o4hb0k_1_1 tag=TAG20130314T191012

channel ORA_AUX_DISK_1: restored backup piece 1

channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:07:49

Finished restore at 14-MAR-13

 

contents of Memory Script.:

{

   switch clone datafile all;

}

executing Memory Script

 

datafile 1 switched to datafile copy

input datafile copy RECID=1 STAMP=810073147 file name=/ORADATA/jxstb/system01.dbf

datafile 2 switched to datafile copy

input datafile copy RECID=2 STAMP=810073147 file name=/ORADATA/jxstb/sysaux01.dbf

datafile 3 switched to datafile copy

input datafile copy RECID=3 STAMP=810073147 file name=/ORADATA/jxstb/undotbs01.dbf

datafile 4 switched to datafile copy

input datafile copy RECID=4 STAMP=810073147 file name=/ORADATA/jxstb/users01.dbf

datafile 5 switched to datafile copy

input datafile copy RECID=5 STAMP=810073147 file name=/ORADATA/jxstb/undotbs02.dbf

Finished Duplicate Db at 14-MAR-13

4.5 执行备库恢复模式

SQL> select instance_name,status from v$instance;

 

INSTANCE_NAME    STATUS

---------------- ------------

jxdb               MOUNTED

 

SQL> alter database recover managed standby database disconnect from session;

 

Database altered.

4.6 查看日志同步情况

SQL> SELECT SEQUENCE#, REGISTRAR, FIRST_TIME, NEXT_TIME, APPLIED

     FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;

4.7 创建STANDBY LOGFILE

建议比online redo 至少多一组

A standby redo log is used to store redo Configuring Redo Transport Services received from another Oracle database.

SQL>SELECT GROUP#, BYTES FROM V$LOG;

SQL>SELECT GROUP#, BYTES FROM V$STANDBY_LOG;

 

#FOR PRIMARY

SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 1  GROUP 5 '+DATA/jxpdb/sredo05.log' size 50M;

 

SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 1  GROUP 6 '+DATA/jxpdb/sredo06.log' size 50M;

 

SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 1  GROUP 7 '+DATA/jxpdb/sredo07.log' size 50M;

 

SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 2  GROUP 8 '+DATA/jxpdb/sredo08.log' size 50M;

 

SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 2  GROUP 9 '+DATA/jxpdb/sredo09.log' size 50M;

 

SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 2  GROUP 10 '+DATA/jxpdb/sredo10.log' size 50M;

 

#FOR STANDBY

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL; 

 

SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 1  GROUP 5 '/ORADATA/jxstb/sredo05.log' size 50M;

 

SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 1  GROUP 6 '/ORADATA/jxstb/sredo06.log' size 50M;

 

SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 1  GROUP 7 '/ORADATA/jxstb/sredo07.log' size 50M;

 

SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 2  GROUP 8 '/ORADATA/jxstb/sredo08.log' size 50M;

 

SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 2  GROUP 9 '/ORADATA/jxstb/sredo09.log' size 50M;

 

SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 2  GROUP 10 '/ORADATA/jxstb/sredo10.log' size 50M;

 

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

 SWITCHOVER AND FAILOVER

5.1 switchover

5.1.1 Verify that the primary database

SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;

 

SWITCHOVER_STATUS

--------------------

TO STANDBY

 

**A value of TO STANDBY or SESSIONS ACTIVE indicates that the primary database can be switched to the standby role.**当值为TO STANDBYSESSION ACTIVE的时候可以切换。

5.1.2  Initiate the switchover on the primary database

Issue the following SQL statement on the primary database to switch it to the standby

role:

SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH -

> SESSION SHUTDOWN;

 

This statement converts the primary database into a physical standby database. The

current control file is backed up to the current SQL session trace file before the

switchover. This makes it possible to reconstruct a current control file, if necessary

**这个语句将primary数据库转化成physical standby数据库。在switchover之前,当前的控制文件将被备份到当前SQL SESSION会话的trace文件中。**

 

Note: The WITH SESSION SHUTDOWN clause can be omitted from

the switchover statement if the query performed in the previous step

returned a value of TO STANDBY

**如果之前查询出来的结果是“TO STANDBY",则这句话可以被省略**

5.1.3  Shut down and then mount the former primary database

SQL> SHUTDOWN ABORT;

SQL> STARTUP MOUNT;

5.1.4  Verify that the switchover target

SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;

 

SWITCHOVER_STATUS

--------------------

SWITCHOVER PENDING     

 

SQL> alter database recover managed standby database disconnect from session;

 

SQL>  SELECT SWITCHOVER_STATUS FROM V$DATABASE;

 

SWITCHOVER_STATUS

--------------------

TO PRIMARY

**当查询的值为TO PRIMARY的时候可以切换**

5.1.5 Switch the target physical standby database

SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;

 

Note: The WITH SESSION SHUTDOWN clause can be omitted from

the switchover statement if the query performed in the previous step

returned a value of TO PRIMARY

**WITH SESSION SHUTDOWN子句可以省略,当之前查询的结果为TO PRIMARYAD的时候**

5.1.6 Open the new primary database.

SQL> ALTER DATABASE OPEN;

5.1.7  Start Redo Apply on the new physical standby database

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE -

> DISCONNECT FROM SESSION;

5.1.8  Restart Redo Apply if it has stopped

Restart Redo Apply if it has stopped at any of the other physical standby

databases in your Data Guard configuration.

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE -

> DISCONNECT FROM SESSION;

 

5.2 FAILOVER

Changes a standby database to the primary role in response to a primary database

failure. If the primary database was not operating in either maximum protection

mode or maximum availability mode before the failure, some data loss may occur.

**当主库损坏的时候将备库转换成主库。如果主库在损坏前不是运行在maximum protection或者maximum availability mode,将会出现一些数据库的丢失。

5.2.1 Preparing for a Failover

If a standby database currently running in maximum protection mode will be

involved in the failover, first place it in maximum performance mode by issuing

the following statement on the standby database:

SQL> ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE;

 

**如果你的standby database 当前运行在maximum protection模式,你需要首先将其置入maximum performance模式。**

5.2.2  Performing a Failover to a Physical Standby Database

Step 1  Flush any unsent redo from the primary database to the target standby database

If the primary database can be mounted, it may be possible to flush any unsent

archived and current redo from the primary database to the standby database. If this

operation is successful, a zero data loss failover is possible even if the primary

database is not in a zero data loss data protection mode.

**如果你的主库可以被mount,你可以刷新主库的归档和当前的reodo log到备库。如果这个操作可以成功,那么你可以实现0数据库丢失的failover,即使你的主库没有运行在0数据丢失的保护模式下**

 

Ensure that Redo Apply is active at the target standby database.

Mount, but do not open the primary database. If the primary database cannot be mounted, go to Step 2.

Issue the following SQL statement at the primary database:

SQL> ALTER SYSTEM FLUSH REDO TO target_db_name;

For target_db_name, specify the DB_UNIQUE_NAME of the standby database that is

to receive the redo flushed from the primary database.

 

**使用这句SQL,完成FLUSH,其中的target_db_name的值为standby databaseDB_UNIQUE_NAME的值,如果你的主库不能被mount上,则执行Step 2**

 

If this statement completes without any errors, go to Step 5. If the statement completes with any error, or if it must be stopped because you cannot wait any longer for the statement to complete, continue with Step 2.

**如果这句话执行没有任何问题,那么你可以直接执行Step 5,,如果语句执行失败,则继续执行Step 2**

 

Step 2  Verify that the standby database has the most recently archived redo log file for each primary database redo thread.

 

Query the V$ARCHIVED_LOG view on the target standby database to obtain the

highest log sequence number for each redo thread.

For example:

SQL> SELECT UNIQUE THREAD# AS THREAD, MAX(SEQUENCE#) OVER (PARTITION BY thread#) AS LAST from V$ARCHIVED_LOG;

    THREAD       LAST

---------- ----------

         1         13

 

**查询动态性能视图V$ARCHIVED_LOG,获得highest log sequence**

 

If possible, copy the most recently archived redo log file for each primary database redo thread to the standby database if it does not exist there, and register it. This must be done for each redo thread.

**如果可以,复制主库的归档日志文件到备库,然后在备库注册**

 

For example:

SQL> ALTER DATABASE REGISTER PHYSICAL LOGFILE 'filespec1';

**filespec1,是复制过来的归档文件的名字**

 

Step 3  Identify and resolve any archived redo log gaps

 

SQL> SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM V$ARCHIVE_GAP;

 

Step 4  Repeat Step 3 until all gaps are resolved.

 

Step 5  Stop Redo Apply.

Issue the following SQL statement on the target standby database:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

 

Step 6  Finish applying all received redo data.

Issue the following SQL statement on the target standby database:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;

 

Step 7  Verify that the target standby database is ready to become a primary database.

SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;

SWITCHOVER_STATUS

-----------------

TO PRIMARY

1 row selected

 

Step 8  Switch the physical standby database to the primary role.

Issue the following SQL statement on the target standby database:

SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY [WITH SESSION SHUTDOWN];

 

Step 9  Open the new primary database.

 

SQL> ALTER DATABASE OPEN;

 

Step 10  Back up the new primary database.

 

 

 PROTECTION MODE

 DATA DUARD有三种保护模式,分别是Maximum AvailabilityMaximum Performancedefault protection mode.),Maximum Protection

查看当前DG的保护模式

SQL> SELECT PROTECTION_MODE FROM V$DATABASE;

6.1 修改DG的保护模式

6.1.1 修改参数

The LOG_ARCHIVE_DEST_n 参数必须设置为如下表的中值才可以使用保护模式。STANDBY DATABASE必须有STANDBY REDO日志。

 

Table 6–1 Required Redo Transport Attributes for Data Protection Modes

Maximum Availability

Maximum Performance

Maximum Protection

AFFIRM

NOAFFIRM

AFFIRM

SYNC

SYNC

SYNC

DB_UNIQUE_NAME

DB_UNIQUE_NAME

DB_UNIQUE_NAME

 

SQL> show parameter LOG_ARCHIVE_DEST_2

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

log_archive_dest_2                   string      SERVICE=jxstb ASYNC VALID_FOR=

                                                 (ONLINE_LOGFILES,PRIMARY_ROLE)

                                                  DB_UNIQUE_NAME=jxstb

6.1.2 确定 DB_UNIQUE_NAME

SQL> show parameter DB_UNIQUE

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

db_unique_name                       string      jxpdb

6.1.3 确定 LOG_ARCHIVE_CONFIG

SQL> show parameter LOG_ARCHIVE_CONFIG   

 

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

log_archive_config                   string      dg_config=(jxpdb,jxstb)

6.1.4 更改保护模式

SQL> ALTER DATABASE  SET STANDBY DATABASE TO MAXIMIZE {AVAILABILITY | PERFORMANCE | PROTECTION};

 

SQL> ALTER DATABASE  SET STANDBY DATABASE TO MAXIMIZE AVAILABILITY;

 

Database altered.

6.1.5 查看新的保护模式

SQL> SELECT PROTECTION_MODE FROM V$DATABASE;

 

 

dg1.jpg

dg2.jpg

dg3.jpg

dg4.jpg

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/26169542/viewspace-766878/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2013-07-02

  • 博文量
    31
  • 访问量
    117117