Step1:搭建oracle dataguard

之前很多次搭建oracle dg都是通过duplicate方式,今天用rman的备份集来手动恢复搭建dg.

Enable Forced Logging
Create a Password File
Configure a Standby Redo Log
Set Primary Database Initialization Parameters
Enable Archiving

上面的这些步骤我就不说啦,

1.initparmeter

primary database:

[oracle@dg1 dbs]$ more initprimary.ora
db_name=DG
control_files=/u01/app/oradata/cntl.ctl
db_block_size=8192
undo_tablespace=UNDOTBS1


#add lance
DB_UNIQUE_NAME=primary
LOG_ARCHIVE_CONFIG=’DG_CONFIG=(primary,standby)’
LOG_ARCHIVE_DEST_1=’LOCATION=/u01/app/oracle/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=primary’
LOG_ARCHIVE_DEST_2=’SERVICE=dg2 LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=standby’
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=enable
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
*.fal_server=dg2
*.fal_client=dg1
*.STANDBY_FILE_MANAGEMENT=AUTO
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
LOG_ARCHIVE_MAX_PROCESSES=30

Standby database:

db_name=DG
control_files=/u01/app/oradata/con.ctl
DB_UNIQUE_NAME=standby
LOG_ARCHIVE_CONFIG=’DG_CONFIG=(standby,primary)’
LOG_ARCHIVE_DEST_1=’LOCATION=/u01/app/oracle/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=standby’
LOG_ARCHIVE_DEST_2=’SERVICE=dg1 LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=primary’
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=enable
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
*.fal_server=dg1
*.fal_client=dg2
*.STANDBY_FILE_MANAGEMENT=AUTO
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
#LOG_ARCHIVE_MAX_PROCESSES=30
log_file_name_convert=’/u01/app/oracle/arch’,'/u01/app/oracle/arch’

2.listener&tnsnames file

primary database:

[oracle@dg1 admin]$ more listener.ora
SID_LIST_dg1 =
 (SID_LIST =
   (SID_DESC =
     (SID_NAME = primary)
     (ORACLE_HOME = /u01/app/oracle/11.2.0)
   )
 )

dg1 =
 (DESCRIPTION_LIST =
   (DESCRIPTION =
     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.120)(PORT = 1521))
   )
 )

[oracle@dg1 admin]$ more tnsnames.ora
dg1 =
 (DESCRIPTION =
   (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.120)(PORT = 1521))
   (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = primary)
   )
 )

dg2 =
 (DESCRIPTION =
   (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.110)(PORT = 1521))
   (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = standby)
   )
 )

Standby database:

[oracle@dg2 admin]$ more listener.ora
SID_LIST_dg2 =
 (SID_LIST =
   (SID_DESC =
     (SID_NAME = standby)
     (ORACLE_HOME = /u01/app/oracle/11.2.0)
   )
 )

dg2 =
 (DESCRIPTION_LIST =
   (DESCRIPTION =
     (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.110)(PORT = 1521))
   )
 )

[oracle@dg2 admin]$ more tnsnames.ora
dg1 =
 (DESCRIPTION =
   (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.120)(PORT = 1521))
   (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = primary)
   )
 )

dg2 =
 (DESCRIPTION =
   (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.110)(PORT = 1521))
   (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = standby)
   )
 )

上面配置的db_unique_name=primary,standby

tnsnames=dg1,dg2

listeners=dg1,dg2

db_name=dg,虽然比较乱,但是能清晰的知道哪个参数是什么意思.注意initparmeter里面有几个是静态参数.


3.rman backup on primary database and scp to standby database

[oracle@dg1 backupbk]$ rman target /

Recovery Manager: Release 11.2.0.2.0 �C Production on Tue Jul 30 00:17:53 2013

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

connected to target database: DG (DBID=1735397445)

RMAN> backup format ‘/u01/backupbk/full_%U’ database plus archivelog delete input;
Starting backup at 30-JUL-13
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=40 RECID=46 STAMP=822097135
input archived log thread=1 sequence=41 RECID=47 STAMP=822097177
input archived log thread=1 sequence=42 RECID=49 STAMP=822097337
input archived log thread=1 sequence=43 RECID=51 STAMP=822097500
channel ORA_DISK_1: starting piece 1 at 30-JUL-13
channel ORA_DISK_1: finished piece 1 at 30-JUL-13
piece handle=/u01/backupbk/full_1cog0dis_1_1 tag=TAG20130730T002500 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process
archived log file name=/u01/app/oracle/arch/1_40_822066437.arc thread=1 sequence=40
RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process
archived log file name=/u01/app/oracle/arch/1_41_822066437.arc thread=1 sequence=41
RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process
archived log file name=/u01/app/oracle/arch/1_42_822066437.arc thread=1 sequence=42
RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process
archived log file name=/u01/app/oracle/arch/1_43_822066437.arc thread=1 sequence=43
Finished backup at 30-JUL-13

Starting backup at 30-JUL-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oradata/system.dbf
input datafile file number=00003 name=/u01/app/oradata/undotbs1.dbf
input datafile file number=00002 name=/u01/app/oradata/sysaux.dbf
channel ORA_DISK_1: starting piece 1 at 30-JUL-13
channel ORA_DISK_1: finished piece 1 at 30-JUL-13
piece handle=/u01/backupbk/full_1dog0diu_1_1 tag=TAG20130730T002501 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 30-JUL-13
channel ORA_DISK_1: finished piece 1 at 30-JUL-13
piece handle=/u01/backupbk/full_1eog0dk1_1_1 tag=TAG20130730T002501 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 30-JUL-13

Starting backup at 30-JUL-13
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=44 RECID=52 STAMP=822097540
channel ORA_DISK_1: starting piece 1 at 30-JUL-13
channel ORA_DISK_1: finished piece 1 at 30-JUL-13
piece handle=/u01/backupbk/full_1fog0dk4_1_1 tag=TAG20130730T002540 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
RMAN-08137: WARNING: archived log not deleted, needed for standby or upstream capture process
archived log file name=/u01/app/oracle/arch/1_44_822066437.arc thread=1 sequence=44
Finished backup at 30-JUL-13
[oracle@dg1 backupbk]$ ls
full_1cog0dis_1_1  full_1dog0diu_1_1  full_1eog0dk1_1_1  full_1fog0dk4_1_1  standby.ctl
[oracle@dg1 backupbk]$ scp * dg2:/u01/backupbk
oracle@dg2′s password:
full_1cog0dis_1_1                                                                                 100%  763KB 762.5KB/s   00:00  
full_1dog0diu_1_1                                                                                 100%  326MB   5.8MB/s   00:56  
full_1eog0dk1_1_1                                                                                 100% 9856KB   9.6MB/s   00:01  
full_1fog0dk4_1_1                                                                                 100%   26KB  26.0KB/s   00:00  
standby.ctl                                                                                       100% 9808KB   4.8MB/s   00:02

4.startup mount using standby controlfile(standby)

5.restore datafile(standby database)

RMAN> restore database;

Starting restore at 30-JUL-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=28 device type=DISK

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 /u01/app/oradata/system.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oradata/sysaux.dbf
channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oradata/undotbs1.dbf
channel ORA_DISK_1: reading from backup piece /u01/backupbk/full_1dog0diu_1_1
channel ORA_DISK_1: piece handle=/u01/backupbk/full_1dog0diu_1_1 tag=TAG20130730T002501
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25


[root@dg2 oradata]# ls
con.ctl  sysaux.dbf  system.dbf  temp01.dbf  undotbs1.dbf


但是如果你用duplicate做过的话会生成redo logfile的啊 .接着往下走.

6.restart standby database
RMAN> startup

connected to target database (not started)
Oracle instance started
database mounted
database opened

Total System Global Area     217157632 bytes

Fixed Size                     2225064 bytes
Variable Size                159386712 bytes
Database Buffers              50331648 bytes
Redo Buffers                   5214208 bytes

SQL> select open_mode from v$database;

OPEN_MODE
――――――�C
READ ONLY

SQL> select member from v$logfile;

MEMBER
――――――――――――――――――――――――――�C
/u01/app/oradata/redo1.log
/u01/app/oradata/redo2.log
/u01/app/oradata/redo3.log

现在到这个目录下面看还是没有redo logfile,但是数据库已经打开啦.

然后我去primary database 切换几次log,就发现redo log已经有啦

[root@dg2 oradata]# ls
con.ctl  redo1.log  redo2.log  redo3.log  sysaux.dbf  system.dbf  temp01.dbf  undotbs1.dbf

alert里面的记录相关log

ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: ‘/u01/app/oradata/redo1.log’
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Clearing online redo logfile 1 /u01/app/oradata/redo1.log
Clearing online log 1 of thread 1 sequence number 46
Errors in file /u01/app/diag/rdbms/standby/standby/trace/standby_mrp0_5864.trc:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: ‘/u01/app/oradata/redo1.log’
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/diag/rdbms/standby/standby/trace/standby_mrp0_5864.trc:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1: ‘/u01/app/oradata/redo1.log’
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Completed: alter database recover managed standby database disconnect from session
Clearing online redo logfile 1 complete
Errors in file /u01/app/diag/rdbms/standby/standby/trace/standby_mrp0_5864.trc:
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: ‘/u01/app/oradata/redo2.log’
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Clearing online redo logfile 2 /u01/app/oradata/redo2.log
Clearing online log 2 of thread 1 sequence number 47
Errors in file /u01/app/diag/rdbms/standby/standby/trace/standby_mrp0_5864.trc:
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: ‘/u01/app/oradata/redo2.log’
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/diag/rdbms/standby/standby/trace/standby_mrp0_5864.trc:
ORA-00313: open failed for members of log group 2 of thread 1
ORA-00312: online log 2 thread 1: ‘/u01/app/oradata/redo2.log’
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Clearing online redo logfile 2 complete
Errors in file /u01/app/diag/rdbms/standby/standby/trace/standby_mrp0_5864.trc:
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1: ‘/u01/app/oradata/redo3.log’
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Clearing online redo logfile 3 /u01/app/oradata/redo3.log
Clearing online log 3 of thread 1 sequence number 48
Errors in file /u01/app/diag/rdbms/standby/standby/trace/standby_mrp0_5864.trc:
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1: ‘/u01/app/oradata/redo3.log’
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Errors in file /u01/app/diag/rdbms/standby/standby/trace/standby_mrp0_5864.trc:
ORA-00313: open failed for members of log group 3 of thread 1
ORA-00312: online log 3 thread 1: ‘/u01/app/oradata/redo3.log’
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
Tue Jul 30 00:31:56 2013
Clearing online redo logfile 3 complete

7.check dataguard ok.

8.备库有一个log_file_name_convert这个参数一定要注意.

9.总结

  • 先配置了init parameter然后再用rman去做的恢复,能否先做rman的备份在配置init parameter呢?

  • 通过rman不需要recover.但是如果有archivelog gap呢?


你可能感兴趣的:(oracle,dataguard,Step1)