一步一步搭建11gR2rac+dg之配置单实例的DG(八)-成都快上网建站

一步一步搭建11gR2rac+dg之配置单实例的DG(八)

站在用户的角度思考问题,与客户深入沟通,找到文圣网站设计与文圣网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:网站设计、成都网站制作、企业官网、英文网站、手机端网站、网站推广、域名注册、网页空间、企业邮箱。业务覆盖文圣地区。

  1. RAC主库配置单实例ActiveDataguard

本文文档结构:

一步一步搭建11gR2 rac+dg之配置单实例的DG(八)

这里配置的过程中需要注意的一项是多看看rac1和rac2以及dg的告警日志会对配置过程有更深刻的理解。。。配置oracle rac的dg环境说白了首先将主库的数据恢复到从库上,然后在主从库上配置一些DG需要用到的参数

注意:

  1. 由于DG是以DB_UNIQUE_NAME作为区分数据库标识的,因此主从库的该参数一定要不同以做区分。但是数据库名db_name必须一致以便主从切换时方便
  2. Standby库只需要安装数据库软件,不必创建数据库
  3. 主从库的数据库软件大版本必须一致,且必须是企业版数据库EE

  1. RAC主库准备工作

该步骤主要是① 将rac主库修改为归档+forcelogging模式 ② 利用rman备份db、archivelog、control file 、pfile 和口令文件

  1. ①RAC主库必须置为归档模式:

和下一步一起做

  1. ②RAC主库必须置为ForceLogging模式:

alter database force logging;

alter database archivelog; ---归档模式下修改

SQL> alter database force logging;

Database altered.

SQL> select name , open_mode, log_mode,force_logging from gv$database;

NAME     OPEN_MODE     LOG_MODE FOR

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

RACDB     READ WRITE     NOARCHIVELOG YES

RACDB     READ WRITE     NOARCHIVELOG YES

SQL> exit

[oracle@rac1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Oct 3 15:30:17 2014

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

Connected to an idle instance.

SQL> startup mount

ORACLE instance started.

Total System Global Area 784998400 bytes

Fixed Size         2232472 bytes

Variable Size         532680552 bytes

Database Buffers     247463936 bytes

Redo Buffers         2621440 bytes

Database mounted.

SQL> select name , open_mode, log_mode,force_logging from gv$database;

NAME     OPEN_MODE     LOG_MODE FOR

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

RACDB     MOUNTED     NOARCHIVELOG YES

SQL> alter database archivelog;

Database altered.

SQL> shutdown immediate;

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

SQL>

SQL> select name , open_mode, log_mode,force_logging from gv$database;

NAME     OPEN_MODE     LOG_MODE FOR

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

RACDB     READ WRITE     ARCHIVELOG YES

RACDB     READ WRITE     ARCHIVELOG YES

SQL>

  1. ③RAC主库执行RMAN全备:

run {

allocate channel c1 type disk;

allocate channel c2 type disk;

allocate channel c3 type disk;

allocate channel c4 type disk;

backup database format '/rman_backup/FULL_%U.bak';

backup archivelog all format '/rman_backup/ARC_%U.bak';

release channel c1;

release channel c2;

release channel c3;

release channel c4;

}

  1. ④RAC主库执行创建物理备库控制文件:

Rman下:backup device type disk format '/rman_backup/standby_%U.ctl' current controlfile for standby;

或:SQL>alter database create standby controlfile as '/dats/backup/standby.ctl'

  1. ⑤RAC主库创建物理备库初始化参数文件:

create pfile ='/rman_backup/initphydb.ora' from spfile;

SQL> show parameter spfile

NAME                 TYPE     VALUE

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

spfile                 string     +DATA/racdb/spfileracdb.ora

SQL>

SQL> show parameter cluster_database

NAME                 TYPE     VALUE

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

cluster_database         boolean     TRUE

cluster_database_instances     integer     2

SQL>

  1. ⑥RAC主库修改口令文件,使双节点SYS用户口令一致:

最好是将其中一个口令文件复制到另外一个节点上,最后复制到dg下,确保口令文件是一样的

  1. 物理备库准备工作

    1. ①FTP主库备份文件+备库控制文件+备库参数文件至物理备库服务器

将备份文件全部传递到dg库:

----rac1

scp /rman_backup/*.bak oracle@192.168.59.140:/rman_backup/

scp /u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwracdb1 oracle@192.168.59.140:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwphydb

  1. ②物理备库创建口令文件:

上一步已做,不需要创建了

  1. ③物理备库初始化参数文件修改:

----------dg

[oracle@dg rman_backup]$ cp initphydb.ora $ORACLE_HOME/dbs/

[oracle@dg rman_backup]$ cd $ORACLE_HOME/dbs

这个是比较重要的步骤,我把行号弄出来了,当然写的时候是没有前边的行号的

物理备库初始化参数文件修改:

  1. phydb.__db_cache_size=255852544
  2. phydb.__java_pool_size=4194304
  3. phydb.__large_pool_size=4194304
  4. phydb.__oracle_base='/u01/app/oracle'#ORACLE_BASE environment from set
  5. phydb.__pga_aggregate_target=419430400
  6. phydb.__sga_target=423624704
  7. phydb.__shared_io_pool_size=0
  8. phydb.__shared_pool_size=146800640
  9. phydb.__streams_pool_size=0
  10. *.audit_file_dest='/u01/app/oracle/admin/phydb/adump'
  11. *.audit_trail='db'
  12. *.cluster_database=false
  13. *.compatible='11.2.0.0.0'
  14. *.control_files='+DATA/phydb/controlfile/cont.ctl'
  15. *.core_dump_dest='/u01/app/oracle/diag/rdbms/phydb/cdump'
  16. *.db_block_size=8192
  17. *.db_create_file_dest='+DATA'
  18. *.db_domain=''
  19. *.db_file_name_convert='+DATA/racdb/','+DATA/phydb/'
  20. *.db_name='racdb'
  21. *.db_recovery_file_dest='+FRA'
  22. *.db_recovery_file_dest_size=4070572032
  23. *.db_unique_name='phydb'
  24. *.diagnostic_dest='/u01/app/oracle'
  25. *.dispatchers='(PROTOCOL=TCP)(SERVICE=phydbXDB)'
  26. *.fal_client='phydb'
  27. *.fal_server='racdb1','racdb2'
  28. *.log_archive_config='dg_config=(racdb,phydb)'
  29. *.log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST valid_for=(all_logfiles,all_roles) db_unique_name=phydb'
  30. *.log_archive_dest_2='service=racdb1 valid_for=(online_logfiles,primary_role) db_unique_name=racdb'
  31. *.log_archive_format='ARC_%t_%S_%r.arc'
  32. *.log_file_name_convert='+DATA/racdb/','+DATA/phydb/'
  33. *.memory_target=842006528
  34. *.open_cursors=300
  35. *.processes=150
  36. *.remote_login_passwordfile='exclusive'
  37. *.service_names='phydb'
  38. *.standby_file_management='auto'
  39. *.thread=1
  40. *.undo_management='auto'
  41. *.undo_tablespace='UNDOTBS1'

[oracle@dg dbs]$ mkdir -p /u01/app/oracle/admin/phydb/adump

[oracle@dg dbs]$ mkdir -p /u01/app/oracle/diag/rdbms/phydb/cdump

[oracle@dg dbs]$

[grid@dg ~]$ asmcmd

ASMCMD> ls

DATA/

FRA/

GRIDDG/

ASMCMD> cd DATA

ASMCMD> ls

ASMCMD> mkdir phydb

ASMCMD> ls

phydb/

ASMCMD>

  1. ④配置RAC主库,物理备库的tnsnames.ora文件:

将以下内容复制到rac1,rac2和dg库:

racdb =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = racdb.lhr.com)

)

)

racdb1 =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = racdb.lhr.com)

(INSTANCE_NAME = racdb1)

)

)

racdb2 =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = racdb.lhr.com)

(INSTANCE_NAME = racdb2)

)

)

phydb =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = phydb)

)

)

验证一下:

分别在3个库上执行:

sqlplus sys/lhr@racdb as sysdba

sqlplus sys/lhr@racdb1 as sysdba

sqlplus sys/lhr@racdb2 as sysdba

确保3个库可以连接

  1. 创建物理备库

    1. ①物理备库启动NOMOUNT状态:

startup nomount

  1. ②RMAN恢复备库控制文件:

[oracle@dg dbs]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Fri Oct 3 19:06:52 2014

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

connected to target database: RACDB (not mounted)

RMAN> restore standby controlfile from '/rman_backup/standby_0tpk53jq_1_1.ctl';

Starting restore at 2014-10-03 19:06:55

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=16 device type=DISK

channel ORA_DISK_1: restoring control file

channel ORA_DISK_1: restore complete, elapsed time: 00:00:25

output file name=+DATA/phydb/controlfile/cont.ctl

Finished restore at 2014-10-03 19:07:22

RMAN>

  1. ③MOUNT物理备库:

SQL> alter database mount;

  1. ④RMAN restore物理备库:

run {

allocate channel c1 type disk;

allocate channel c2 type disk;

allocate channel c3 type disk;

allocate channel c4 type disk;

restore database ;

release channel c1;

release channel c2;

release channel c3;

release channel c4;

}

RMAN> restore database ;

Starting restore at 2014-10-03 19:13:48

Starting implicit crosscheck backup at 2014-10-03 19:13:48

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=32 device type=DISK

Crosschecked 6 objects

Finished implicit crosscheck backup at 2014-10-03 19:13:49

Starting implicit crosscheck copy at 2014-10-03 19:13:49

using channel ORA_DISK_1

Finished implicit crosscheck copy at 2014-10-03 19:13:49

searching for all files in the recovery area

cataloging files...

no files cataloged

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore

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

channel ORA_DISK_1: restoring datafile 00001 to +DATA/phydb/datafile/system.256.859849357

channel ORA_DISK_1: restoring datafile 00004 to +DATA/phydb/datafile/users.259.859849357

channel ORA_DISK_1: restoring datafile 00005 to +DATA/phydb/datafile/example.264.859849549

channel ORA_DISK_1: reading from backup piece /rman_backup/FULL_0npk5395_1_1.bak

channel ORA_DISK_1: piece handle=/rman_backup/FULL_0npk5395_1_1.bak tag=TAG20141003T164524

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:04:23

channel ORA_DISK_1: starting datafile backup set restore

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

channel ORA_DISK_1: restoring datafile 00002 to +DATA/phydb/datafile/sysaux.257.859849357

channel ORA_DISK_1: restoring datafile 00003 to +DATA/phydb/datafile/undotbs1.258.859849357

channel ORA_DISK_1: restoring datafile 00006 to +DATA/phydb/datafile/undotbs2.265.859849971

channel ORA_DISK_1: reading from backup piece /rman_backup/FULL_0opk53c4_1_1.bak

channel ORA_DISK_1: piece handle=/rman_backup/FULL_0opk53c4_1_1.bak tag=TAG20141003T164524

channel ORA_DISK_1: restored backup piece 1

channel ORA_DISK_1: restore complete, elapsed time: 00:01:45

Finished restore at 2014-10-03 19:20:01

RMAN>

  1. ⑤备库上创建standbylogfile:

SQL> select name from v$datafile

2 union

3 select name from v$controlfile

4 union

5 select member from v$logfile;

NAME

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

+DATA/phydb/controlfile/cont.ctl

+DATA/phydb/datafile/example.258.860008433

+DATA/phydb/datafile/sysaux.260.860008695

+DATA/phydb/datafile/system.257.860008433

+DATA/phydb/datafile/undotbs1.261.860008697

+DATA/phydb/datafile/undotbs2.262.860008697

+DATA/phydb/datafile/users.259.860008435

+DATA/phydb/onlinelog/group_1.261.859849493

+DATA/phydb/onlinelog/group_2.262.859849495

+DATA/phydb/onlinelog/group_3.266.859850179

+DATA/phydb/onlinelog/group_4.267.859850183

+FRA/racdb/onlinelog/group_1.257.859849493

+FRA/racdb/onlinelog/group_2.258.859849495

+FRA/racdb/onlinelog/group_3.259.859850181

+FRA/racdb/onlinelog/group_4.260.859850187

15 rows selected.

SQL>

创建standbylogfile,这里的大小应根据主库的v$log中的bytes列来计算:

一步一步搭建11gR2 rac+dg之配置单实例的DG(八)

alter database add standby logfile thread 1 group 5 size 50M ,group 6 size 50M ,group 7 size 50M ;

alter database add standby logfile thread 2 group 8 size 50M ,group 9 size 50M ,group 10 size 50M ;

创建完成后查询:

select * from v$standby_log;

SQL> set linesize 1200

SQL> select * from v$standby_log;

GROUP# DBID                  THREAD#    SEQUENCE# BYTES BLOCKSIZE USED ARC STATUS     FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME LAST_CHANGE# LAST_TIME

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

     5 UNASSIGNED                     1        0 52428800     512      0 NO UNASSIGNED

     6 UNASSIGNED                     1        0 52428800     512      0 NO UNASSIGNED

     7 UNASSIGNED                     1        0 52428800     512      0 YES UNASSIGNED

     8 UNASSIGNED                     2        0 52428800     512      0 NO UNASSIGNED

     9 UNASSIGNED                     2        0 52428800     512      0 NO UNASSIGNED

    10 UNASSIGNED                     2        0 52428800     512      0 YES UNASSIGNED

6 rows selected.

SQL>

SQL> col member for a50

SQL> select * from v$logfile;

GROUP# STATUS TYPE MEMBER                     IS_

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

     2     ONLINE +DATA/phydb/onlinelog/group_2.270.860171617     NO

     2     ONLINE +FRA/phydb/onlinelog/group_2.294.860171767     YES

     1     ONLINE +DATA/phydb/onlinelog/group_1.269.860171391     NO

     1     ONLINE +FRA/phydb/onlinelog/group_1.293.860171601     YES

     3     ONLINE +DATA/phydb/onlinelog/group_3.271.860171811     NO

     3     ONLINE +FRA/phydb/onlinelog/group_3.295.860171893     YES

     4     ONLINE +DATA/phydb/onlinelog/group_4.272.860171905     NO

     4     ONLINE +FRA/phydb/onlinelog/group_4.296.860172007     YES

     5     STANDBY +DATA/phydb/onlinelog/group_5.263.860014755     NO

     5     STANDBY +FRA/phydb/onlinelog/group_5.256.860014769     YES

     6     STANDBY +DATA/phydb/onlinelog/group_6.264.860014775     NO

     6     STANDBY +FRA/phydb/onlinelog/group_6.257.860014789     YES

     7     STANDBY +DATA/phydb/onlinelog/group_7.265.860014795     NO

     7     STANDBY +FRA/phydb/onlinelog/group_7.258.860014811     YES

     8     STANDBY +DATA/phydb/onlinelog/group_8.266.860090543     NO

     8     STANDBY +FRA/phydb/onlinelog/group_8.259.860090581     YES

     9     STANDBY +DATA/phydb/onlinelog/group_9.267.860090607     NO

     9     STANDBY +FRA/phydb/onlinelog/group_9.260.860090659     YES

    10     STANDBY +DATA/phydb/onlinelog/group_10.268.860090669 NO

    10     STANDBY +FRA/phydb/onlinelog/group_10.261.860090715     YES

20 rows selected.

SQL>

这里可能会报一个错误:

ORA-15041: diskgroup "DATA" space exhausted

就是磁盘不足,具体大家上网搜吧,解决办法就是添加磁盘,不详解了:

alter diskgroup DATA add disk '/dev/raw/raw5';

  1. ⑥主库参数调整:

[oracle@rac2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Fri Oct 10 15:59:46 2014

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

Connected to:

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,

Data Mining and Real Application Testing options

SQL> show parameter spfile

NAME                 TYPE     VALUE

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

spfile                 string     +DATA/racdb/spfileracdb.ora

SQL>

--rac1

alter system set log_archive_dest_2='service=phydb lgwr sync valid_for=(online_logfiles,primary_role) db_unique_name=phydb' sid='*';

alter system set log_archive_config='dg_config=(racdb,phydb)' sid='*';

配置后的结果:

SQL> show parameter log_archive_dest_2

NAME                 TYPE     VALUE

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

log_archive_dest_2         string     service=phydb lgwr sync valid_

                         for=(online_logfiles,primary_r

                         ole) db_unique_name=phydb

SQL> show parameter log_archive_config

NAME                 TYPE     VALUE

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

log_archive_config         string     dg_config=(racdb,phydb)

SQL>

  1. ⑦备库接收主库日志:

SQL> select sequence#,name,applied from v$archived_log;

SEQUENCE# NAME                                                 APPLIED

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

    39 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_39.327.860599799                    NO

    40 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_40.328.860599799                    NO

    41 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_41.329.860599953                    NO

    49 +FRA/phydb/archivelog/2014_10_10/thread_1_seq_49.330.860600751                    NO

    50 +FRA/phydb/archivelog/2014_10_10/thread_1_seq_50.331.860600755                    NO

    51 +FRA/phydb/archivelog/2014_10_10/thread_1_seq_51.332.860600869                    NO

    42 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_42.333.860601127                    NO

    43 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_43.334.860601131                    NO

    44 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_44.335.860601415                    NO

9 rows selected.

SQL>

这里如果备库无法顺利接收主库日志,则主库的alert日志中有如下提示:

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

Check that the primary and standby are using a password file

and remote_login_passwordfile is set to SHARED or EXCLUSIVE,

and that the SYS password is same in the password files.

returning error ORA-16191

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

PING[ARC2]: Heartbeat failed to connect to standby 'phydb'. Error is 16191.

Process J000 died, see its trace file

kkjcre1p: unable to spawn jobq slave process

Errors in file /u01/app/oracle/diag/rdbms/racdb/racdb2/trace/racdb2_cjq0_14236.trc:

Process NSS2 died, see its trace file

Process J000 died, see its trace file

kkjcre1p: unable to spawn jobq slave process

Errors in file /u01/app/oracle/diag/rdbms/racdb/racdb2/trace/racdb2_cjq0_14236.trc:

Error 443 for archive log file 3 to 'phydb'

LGWR: Failed to archive log 3 thread 2 sequence 25 (443)

Process O000 died, see its trace file

该节点的用户口令和备库的口令不一致,最好的办法是生成一份口令文件之后,然后将该口令文件拷贝到其它节点,重新生成口令有的时候也报错的

---- 3 个节点

orapwd file=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwracdb2 password=lhr force=y

  1. ⑧备库开始应用日志:

SQL> alter database recover managed standby database using current logfile disconnect from session;

Database altered.

过几分钟后:

SQL> select sequence#,name,applied from v$archived_log;

SEQUENCE# NAME                                                                     APPLIED

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

39 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_39.327.860599799                    YES

    40 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_40.328.860599799                    YES

    41 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_41.329.860599953                    YES

    49 +FRA/phydb/archivelog/2014_10_10/thread_1_seq_49.330.860600751                    YES

    50 +FRA/phydb/archivelog/2014_10_10/thread_1_seq_50.331.860600755                    YES

    51 +FRA/phydb/archivelog/2014_10_10/thread_1_seq_51.332.860600869                    YES

    42 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_42.333.860601127                    NO

    43 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_43.334.860601131                    NO

    44 +FRA/phydb/archivelog/2014_10_10/thread_2_seq_44.335.860601415                    NO

  1. ⑨备库以READONLY方式打开:

alter database recover managed standby database cancel;

alter database open;

alter database recover managed standby database using current logfile disconnect from session;

SQL> col name for a30

SQL> select dbid,name,current_scn,protection_mode,database_role,force_logging,open_mode,switchover_status from v$database;

DBID NAME              CURRENT_SCN PROTECTION_MODE     DATABASE_ROLE FOR OPEN_MODE     SWITCHOVER_STATUS

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

857466254 RACDB             1871595 MAXIMUM PERFORMANCE PHYSICAL STANDBY YES READ ONLY WITH APPLY NOT ALLOWED

SQL>

至此,我们已经顺利的给RAC主库配置ActivePhysicalDataguard成功!

  1. 其它附加内容

    1. 11g rman duplicate命令

注意:11g以前的版本在执行复制命令dupilicate时,必须在备库上存在有备份文件,即在主库上备份完成后将文件拷到备库相同目录下

但是在11g一切都变的简单,只需要在复制命令后加上FROM ACTIVE DATABASE参数即可。

例如为实现数据库的文件回复,可以执行命令:

$ rman target / auxiliary sys/herenit@racheren_standby

RMAN>duplicate target database for standby from active database;

如果原目录下有对应文件已经删除,但是数据字典中存在,可以使用nofilenamecheck参数取消对文件名的检查

RMAN>duplicate target database for standby from active database nofilenamecheck;

恢复完成以后,检查备库状态

SQL> select status from v$instance;

STATUS$dEQ5b/C#x22494861------------ITPUB个人空间 T c:v_y!RMOUNTED

SQL> select open_mode from v$database;

OPEN_MODEITPUB个人空间FU?tN2FE5v:_wU}----------ITPUB个人空间1R_G@5k/kMOUNTED

SQL> select member from v$logfile;

SQL> select name from v$datafile;

SQL> select name from v$tempfile;

  1. 创建standby redo log 日志

DATA Guard在最大保护和最高可用性模式下,Standby数据库必须配置 Standby Redo Log

备库创建并配置 Standby Redo Log 是为了能够接收到主库传过来的日志,用作恢复.

主库创建并配置 Standby Redo Log 是为了在主备切换之后,能够接收到原备库(切换之后的主库)传过来的日志

注意:为了主备切换后能正常,主备库都必须创建standby redo log

创建原则:建议Standby Redologs日志组数量基于Primary数据库的线程数来确定(这里的线程数可以理解为RAC环境中的节点数)。

有一个推荐的公式可供参考:(每线程的日志组数+1)×最大线程数。

使用这个公式可以降低Primary数据库实例LGWR进程锁住的可能性。

创建原则和单实例一样,大小相等,但是日志组数量要比primary数据库多一组,比如在我的环境中,有2个节点,每个节点有4组redo,那么现在要创建的standby redo log组数为:(4+1)*2=10个

Standby Redologs的操作方式与Online Redologs几乎一模一样,只不过在创建或删除时需要多指定一个Standby关键字

SQL>alter database add standby logfile thread 1 group 5 '+ORAFLASH/racheren/onlinelog/group_5.log' size 50M;

SQL>alter database add standby logfile thread 2 group 6 '+ORAFLASH/racheren/onlinelog/group_6.log' size 50M;

单实例上不需要thread标识

SQL>alter database add standby logfile group 6 '/oradata/racheren/onlinelog/group_6.log' size 50M;

删除方式:

SQL>alter database drop standby logfile grop 6

查询方式:

SQL>select group#,thread#,sequence#,archived,status from v$standby_log;

ERROR at line 1:

ORA-01156: recovery or flashback in progress may need access to files

--在备库添加standby redo log需要先停MRP

SQL> alter database recover managed standby database cancel;

  1. 测试物理备库功能

    1. 测试文件同步

      1. 查看主备库的表空间信息

select tablespace_name, file_name from dba_data_files;

  1. 主库创建表空间查看备库是否同步

create tablespace dg_tbs datafile size 5m;

  1. 主库删除表空间查看备库是否同步

drop tablespace dg_tbs including contents and datafiles;

  1. 测试数据同步

①主库创建测试表:

② 备库查看测试表同步:

Create table tmp_test(id number);

Insert into tmp_test values(1);

Commit;

Select * from tmp_test;

  1. 测试DATAGUARDSWITCHOVER功能

    1. RAC主库、ActiveDataguard角色切换

即rac主库切换为物理备库,物理备库切换为rac主库。

  1. ①主库修改相关参数fal_client、fal_server:

首先需要确保主库采用spfile启动,然后

Rac1上:

alter system set fal_client='rac1' sid='rac1';

Rac2上:

alter system set fal_client='rac2' sid='rac2';

alter system set fal_server='phydb' sid='*';

  1. ②主库创建standbylogfile:

  1. ③主库修改相关参数standby_file_management、db_file_name_convert 、log_filename_convert

  1. ④停止RAC节点2:

  1. 单实例主库,RAC备库角色切换


新闻标题:一步一步搭建11gR2rac+dg之配置单实例的DG(八)
本文链接:http://kswjz.com/article/johcci.html
扫二维码与项目经理沟通

我们在微信上24小时期待你的声音

解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流