centos 6.5 部署 oracle 11G RAC+DG-------RAC-单实例部署DG部分(二)

  • 备库信息:
  • 一:备库安装数据库软件
  • 二:配置DG
    • 1.主库需要归档模式
    • 2. 主库force logging
    • 3. 主库创建 standby redo log文件
    • 4.修改RAC参数,并生成pfile与密码文件一起传输到备库
    • 5.备库创建监听
    • 6.配置 tnsnames.ora
    • 7.备库创建目录
    • 8.备库修改pfile并启动到nomount
    • 9. 备库进行duplicate
    • 10.启动备库并应用MRP
    • 11.验证同步

备库信息:

DG备库(单实例)
Hostname: Breath03
IP :10.10.10.103
Instance_name: bracdg
DB_name: Brac
Version: 11.2.0.4.0
此处搭建的是Physical Standby,生成当中多数都是Physical Standby

一:备库安装数据库软件

安装配置过程省略
PS:只安装软件不创建数据库,oracle用户环境变量要设置

二:配置DG

1.主库需要归档模式

SYS@brac1>archive log list
Database log mode          Archive Mode
Automatic archival         Enabled
Archive destination        USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     98
Next log sequence to archive   99
Current log sequence           99

SYS@brac1>show parameter db_recover

NAME                     TYPE           VALUE
------------------------------------ ---------------------- ------------------------------
db_recovery_file_dest            string         +FRA
db_recovery_file_dest_size       big integer        5727M

2. 主库force logging

SYS@brac1>alter database force logging;

Database altered.

SYS@brac1>select FORCE_LOGGING from v$database;

FORCE_
------
YES

3. 主库创建 standby redo log文件

RAC上多节点,多redo thread 。
创建规则:每个 thread 都需要创建,standby redo log 比 redo log 多一组,大小相同
查看当前redo log:

SYS@brac1>select a.thread#,a.group#,a.bytes/1024/1024,b.member from v$log a,v$logfile b where a.group#=b.group#;

   THREAD#     GROUP# A.BYTES/1024/1024 MEMBER
---------- ---------- ----------------- ---------------------------------------------------------------------------------------------------
     1      1            50 +DATA/brac/onlinelog/group_1.257.977014039
     1      1            50 +FRA/brac/onlinelog/group_1.257.977014039
     1      2            50 +DATA/brac/onlinelog/group_2.258.977014039
     1      2            50 +FRA/brac/onlinelog/group_2.258.977014041
     2      3            50 +DATA/brac/onlinelog/group_3.265.977015579
     2      3            50 +FRA/brac/onlinelog/group_3.259.977015581
     2      4            50 +DATA/brac/onlinelog/group_4.266.977015581
     2      4            50 +FRA/brac/onlinelog/group_4.260.977015581

8 rows selected.

添加standby redo (我这里位置全部选择 +FRA)

 SYS@brac1>alter database add standby logfile thread 1 group 11 ('+FRA') size 50m;

Database altered.
SYS@brac1>alter database add standby logfile thread 1 group 12 ('+FRA') size 50m;

Database altered.

SYS@brac1>alter database add standby logfile thread 1 group 13 ('+FRA') size 50m;

Database altered.

SYS@brac1>alter database add standby logfile thread 1 group 14 ('+FRA') size 50m;

Database altered.

SYS@brac1>alter database add standby logfile thread 1 group 15 ('+FRA') size 50m;

Database altered.

SYS@brac1>alter database add standby logfile thread 2 group 16 ('+FRA') size 50m;

Database altered.

SYS@brac1>alter database add standby logfile thread 2 group 17 ('+FRA') size 50m;

Database altered.

SYS@brac1>alter database add standby logfile thread 2 group 18 ('+FRA') size 50m;

Database altered.

SYS@brac1>alter database add standby logfile thread 2 group 19 ('+FRA') size 50m;

Database altered.

SYS@brac1>alter database add standby logfile thread 2 group 20 ('+FRA') size 50m;

Database altered.

SYS@brac1>select group#,type,member from v$logfile order by 2;

    GROUP# TYPE       MEMBER
---------- -------------- ---------------------------------------------------------------------------------------------------
     1 ONLINE     +DATA/brac/onlinelog/group_1.257.977014039
     4 ONLINE     +FRA/brac/onlinelog/group_4.260.977015581
     4 ONLINE     +DATA/brac/onlinelog/group_4.266.977015581
     3 ONLINE     +FRA/brac/onlinelog/group_3.259.977015581
     3 ONLINE     +DATA/brac/onlinelog/group_3.265.977015579
     2 ONLINE     +FRA/brac/onlinelog/group_2.258.977014041
     2 ONLINE     +DATA/brac/onlinelog/group_2.258.977014039
     1 ONLINE     +FRA/brac/onlinelog/group_1.257.977014039
    19 STANDBY    +FRA/brac/onlinelog/group_19.322.978256559
    18 STANDBY    +FRA/brac/onlinelog/group_18.321.978256555
    17 STANDBY    +FRA/brac/onlinelog/group_17.320.978256549
    16 STANDBY    +FRA/brac/onlinelog/group_16.319.978256545
    15 STANDBY    +FRA/brac/onlinelog/group_15.318.978256509
    14 STANDBY    +FRA/brac/onlinelog/group_14.317.978256507
    13 STANDBY    +FRA/brac/onlinelog/group_13.316.978256501
    12 STANDBY    +FRA/brac/onlinelog/group_12.315.978256481
    20 STANDBY    +FRA/brac/onlinelog/group_20.323.978256561
    11 STANDBY    +FRA/brac/onlinelog/group_11.314.978256233

18 rows selected.

4.修改RAC参数,并生成pfile与密码文件一起传输到备库

SYS@brac1>alter system set log_archive_config='DG_CONFIG=(brac,bracdg)' scope=spfile sid='*';

System altered.

SYS@brac1>alter system set log_archive_dest_1='location=+FRA valid_for=(all_logfiles,all_roles) db_unique_name=brac' scope=spfile sid='*';

System altered.

SYS@brac1>alter system set log_archive_dest_2='service=bracdg LGWR ASYNC NOAFFIRM valid_for=(online_logfiles,primary_role) db_unique_name=bracdg' scope=spfile sid='*';

System altered.

SYS@brac1>alter system set standby_file_management=auto scope=both sid='*';

System altered.

SYS@brac1>alter system set db_file_name_convert='+DATA/brac/datafile','/u01/app/oracle/oradata/bracdg','+DATA/brac/tempfile','/u01/app/oracle/oradata/bracdg' scope=spfile sid='*';

System altered.

SYS@brac1>alter system set log_file_name_convert='+DATA/brac/onlinelog','/u01/app/oracle/oradata/bracdg','+FRA/brac/onlinelog','/u01/app/oracle/oradata/bracdg' scope=spfile sid='*';

System altered.

SYS@brac1>alter system set fal_client='brac' scope=both sid='*';

System altered.

SYS@brac1>alter system set fal_server='bracdg' scope=both sid='*';

System altered.

SYS@brac1>alter system set dg_broker_start=true scope=both sid='*';

System altered.

重启rac

[grid@breath01 ~]$ srvctl stop database -d brac -o immediate
[grid@breath01 ~]$ srvctl start database -d brac -o open

创建pfile及传到备库

SYS@brac1>create pfile='/home/oracle/pfile.ora' from spfile;

File created.
[oracle@breath01 ~]$ scp -r pfile.ora 10.10.10.103:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initbracdg.ora
[oracle@breath01 ~]$ scp -r /u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwbrac1 10.10.10.103:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwbracdg

5.备库创建监听

[oracle@breath03 ~]$ $ORACLE_HOME/bin/netca /silent /responseFile /tmp/database/response/netca.rsp
静态注册,配置listener.ora文件:
[oracle@breath03 ~]$ cat /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora 
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = breath03)(PORT = 1521))
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = bracdg)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
      (SID_NAME = bracdg)
    )
  )


ADR_BASE_LISTENER = /u01/app/oracle

[oracle@breath03 ~]$ lsnrctl reload

6.配置 tnsnames.ora

所有rac节点 和 DG备库都需要配置,添加内容一样(都是$ORACLE_HOME/network/admin目录下)

BRAC =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10.111)(PORT = 1521))
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10.112)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = brac)
    )
  )

BRACDG =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10.103)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = bracdg)
    )
  )

7.备库创建目录

[oracle@breath03 ~]$ mkdir -pv  /u01/app/oracle/oradata/bracdg/
[oracle@breath03 ~]$ mkdir -pv  /u01/app/oracle/fast_recovery_area/bracdg
[oracle@breath03 ~]$ mkdir -pv /u01/app/oracle/admin/brac/adump
[oracle@breath03 ~]$ mkdir -pv  /u01/app/oracle/archive/bracdg

8.备库修改pfile并启动到nomount

ps:注意oracle 环境变量指定的SID

修改后的pfile内容

[oracle@breath03 dbs]$ cat initbracdg.ora 
*.audit_file_dest='/u01/app/oracle/admin/brac/adump'
*.audit_trail='db'
*.compatible='11.2.0.4.0'
*.control_files='/u01/app/oracle/oradata/bracdg/control01.ctl','/u01/app/oracle/fast_recovery_area/bracdg/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_file_name_convert='+DATA/brac/datafile','/u01/app/oracle/oradata/bracdg','+DATA/brac/tempfile','/u01/app/oracle/oradata/bracdg'
*.db_name='brac'
*.db_recovery_file_dest_size=6005194752
*.dg_broker_start=TRUE
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=bracXDB)'
*.fal_client='bracdg'
*.fal_server='brac'
*.log_archive_config='DG_CONFIG=(brac,bracdg)'
*.log_archive_dest_1='location=/u01/app/oracle/archive/bracdg valid_for=(all_logfiles,all_roles) db_unique_name=bracdg'
*.log_archive_dest_2='service=brac LGWR ASYNC NOAFFIRM valid_for=(online_logfiles,primary_role) db_unique_name=brac'
*.log_archive_format='%t_%s_%r.dbf'
*.log_file_name_convert='+DATA/brac/onlinelog','/u01/app/oracle/oradata/bracdg','+FRA/brac/onlinelog','/u01/app/oracle/oradata/bracdg'
*.open_cursors=300
*.pga_aggregate_target=553648128
*.processes=150
*.remote_login_passwordfile='exclusive'
*.sga_target=1660944384
*.standby_file_management='AUTO'
*.db_unique_name='bracdg'
*.service_names='bracdg'
*.undo_tablespace='UNDOTBS1'

创建spfile 启动到nomount

[oracle@breath03 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Jun 8 16:50:50 2018

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

Connected to an idle instance.

SQL> create spfile from pfile;

File created.

SQL> startup nomount
ORACLE instance started.

Total System Global Area 1653518336 bytes
Fixed Size          2253784 bytes
Variable Size         469765160 bytes
Database Buffers     1174405120 bytes
Redo Buffers            7094272 bytes

9. 备库进行duplicate

[oracle@breath03 dbs]$ rman target sys/123456@brac auxiliary sys/123456@bracdg

Recovery Manager: Release 11.2.0.4.0 - Production on Fri Jun 8 16:56:03 2018

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

connected to target database: BRAC (DBID=3094661074)
connected to auxiliary database: BRAC (not mounted)

RMAN> duplicate target database for standby from active database nofilenamecheck;
Starting Duplicate Db at 2018:06:08 16:56:14
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:
{
   backup as copy reuse
   targetfile  '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwbrac2' auxiliary format 
 '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwbracdg'   ;
}
executing Memory Script

Starting backup at 2018:06:08 16:56:14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=158 instance=brac2 device type=DISK
Finished backup at 2018:06:08 16:56:16

contents of Memory Script:
{
   backup as copy current controlfile for standby auxiliary format  '/u01/app/oracle/oradata/bracdg/control01.ctl';
   restore clone controlfile to  '/u01/app/oracle/fast_recovery_area/bracdg/control02.ctl' from 
 '/u01/app/oracle/oradata/bracdg/control01.ctl';
}
executing Memory Script

Starting backup at 2018:06:08 16:56:16
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
copying standby control file
output file name=/u01/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_brac2.f tag=TAG20180608T165615 RECID=1 STAMP=978281776
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2018:06:08 16:56:18

Starting restore at 2018:06:08 16:56:18
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: copied control file copy
Finished restore at 2018:06:08 16:56:19

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 
 "/u01/app/oracle/oradata/bracdg/temp.262.977014053";
   switch clone tempfile all;
   set newname for datafile  1 to 
 "/u01/app/oracle/oradata/bracdg/system.259.977014041";
   set newname for datafile  2 to 
 "/u01/app/oracle/oradata/bracdg/sysaux.260.977014047";
   set newname for datafile  3 to 
 "/u01/app/oracle/oradata/bracdg/undotbs1.261.977014051";
   set newname for datafile  4 to 
 "/u01/app/oracle/oradata/bracdg/undotbs2.263.977014059";
   set newname for datafile  5 to 
 "/u01/app/oracle/oradata/bracdg/users.264.977014059";
   backup as copy reuse
   datafile  1 auxiliary format 
 "/u01/app/oracle/oradata/bracdg/system.259.977014041"   datafile 
 2 auxiliary format 
 "/u01/app/oracle/oradata/bracdg/sysaux.260.977014047"   datafile 
 3 auxiliary format 
 "/u01/app/oracle/oradata/bracdg/undotbs1.261.977014051"   datafile 
 4 auxiliary format 
 "/u01/app/oracle/oradata/bracdg/undotbs2.263.977014059"   datafile 
 5 auxiliary format 
 "/u01/app/oracle/oradata/bracdg/users.264.977014059"   ;
   sql 'alter system archive log current';
}
executing Memory Script

executing command: SET NEWNAME

renamed tempfile 1 to /u01/app/oracle/oradata/bracdg/temp.262.977014053 in control file

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting backup at 2018:06:08 16:56:25
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=+DATA/brac/datafile/undotbs1.261.977014051
output file name=/u01/app/oracle/oradata/bracdg/undotbs1.261.977014051 tag=TAG20180608T165624
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=+DATA/brac/datafile/system.259.977014041
output file name=/u01/app/oracle/oradata/bracdg/system.259.977014041 tag=TAG20180608T165624
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=+DATA/brac/datafile/sysaux.260.977014047
output file name=/u01/app/oracle/oradata/bracdg/sysaux.260.977014047 tag=TAG20180608T165624
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=+DATA/brac/datafile/undotbs2.263.977014059
output file name=/u01/app/oracle/oradata/bracdg/undotbs2.263.977014059 tag=TAG20180608T165624
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=+DATA/brac/datafile/users.264.977014059
output file name=/u01/app/oracle/oradata/bracdg/users.264.977014059 tag=TAG20180608T165624
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 2018:06:08 16:57:28

sql statement: alter system archive log current

contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=1 STAMP=978281851 file name=/u01/app/oracle/oradata/bracdg/system.259.977014041
datafile 2 switched to datafile copy
input datafile copy RECID=2 STAMP=978281851 file name=/u01/app/oracle/oradata/bracdg/sysaux.260.977014047
datafile 3 switched to datafile copy
input datafile copy RECID=3 STAMP=978281851 file name=/u01/app/oracle/oradata/bracdg/undotbs1.261.977014051
datafile 4 switched to datafile copy
input datafile copy RECID=4 STAMP=978281851 file name=/u01/app/oracle/oradata/bracdg/undotbs2.263.977014059
datafile 5 switched to datafile copy
input datafile copy RECID=5 STAMP=978281851 file name=/u01/app/oracle/oradata/bracdg/users.264.977014059
Finished Duplicate Db at 2018:06:08 16:57:35

RMAN> 

10.启动备库并应用MRP

SQL> select DBID,NAME,OPEN_MODE,DATABASE_ROLE from v$database;

      DBID NAME           OPEN_MODE                    DATABASE_ROLE
---------- ------------------ ---------------------------------------- --------------------------------
3094661074 BRAC           MOUNTED                      PHYSICAL STANDBY

SQL> alter database open;

Database altered.

SQL> select DBID,NAME,OPEN_MODE,DATABASE_ROLE from v$database;

      DBID NAME           OPEN_MODE                    DATABASE_ROLE
---------- ------------------ ---------------------------------------- --------------------------------
3094661074 BRAC           READ ONLY                    PHYSICAL STANDBY

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

Database altered.

SQL> select DBID,NAME,OPEN_MODE,DATABASE_ROLE from v$database;

      DBID NAME           OPEN_MODE                    DATABASE_ROLE
---------- ------------------ ---------------------------------------- --------------------------------
3094661074 BRAC           READ ONLY WITH APPLY             PHYSICAL STANDBY

11.验证同步

SYS@brac1>create table dg_test1 as select * from dba_objects;

Table created.


SYS@brac2>create table dg_test2 as select * from dba_objects;

Table created.

SYS@brac2>create tablespace dg_test_tablespace datafile '+DATA' size 100m;

Tablespace created.

SYS@brac2>select TABLESPACE_NAME,FILE_NAME from dba_data_files where tablespace_name='DG_TEST_TABLESPACE';

TABLESPACE_NAME      FILE_NAME
-------------------- ---------------------------------------------------------------------------------------------------
DG_TEST_TABLESPACE   +DATA/brac/datafile/dg_test_tablespace.268.978282989


备库查看
SQL> show parameter db_unique

NAME                     TYPE           VALUE
------------------------------------ ---------------------- ------------------------------
db_unique_name               string         bracdg
SQL> select count(*) from dg_test1;

  COUNT(*)
----------
     86297

SQL> select count(*) from dg_test2;

  COUNT(*)
----------
     86298

SQL> select TABLESPACE_NAME,FILE_NAME from dba_data_files where tablespace_name='DG_TEST_TABLESPACE';

TABLESPACE_NAME              FILE_NAME
---------------------------------------- ---------------------------------------------------------------------------------------------------
DG_TEST_TABLESPACE           /u01/app/oracle/oradata/bracdg/dg_test_tablespace.268.978282989

你可能感兴趣的:(Oracle,RAC)