程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle教程 >> Oracle Data Guard RAC到單機ASM配置(物理standby)

Oracle Data Guard RAC到單機ASM配置(物理standby)

編輯:Oracle教程

Oracle Data Guard RAC到單機ASM配置(物理standby)


本次配置11G rac到單機ASM的dataguard配置,11G rac的安裝參考oracle 11G rac 安裝(VMware + rhel6.3),11G 單機ASM安裝參考Oracle 11G 單機asm安裝。   環境介紹: 主庫: 11203 2節點RAC   實例名:racdb1,racdb2  db_name:racdb  db_unique_name:racdb 備庫: 11203 單機 ASM   實例名:racdbstd        db_name:racdb  db_unique_name:racdbstd  整個操作過程按照以下進行 主庫操作 1.打開Forced Logging 2.配置主庫參數 3.打開主庫歸檔 4.創建主庫備份用來作為備庫恢復 5.創建standby數據庫的控制文件 6.創建配置備庫參數文件 7.拷貝所需文件到備庫   備庫操作 1.設置備庫環境變量   1.1密碼文件拷貝   1.2監聽配置   1.3創建網絡服務名 2.創建所需的目錄 3.參數文件配置 4.恢復備庫   4.1恢復參數文件   4.2恢復控制文件   4.3恢復數據庫 5.創建standby redo   5.1主庫創建   5.2備庫創建 6.網絡服務名測試   6.1主庫測試   6.2備庫測試 7.開啟實時應用 8.測試 9.啟動關閉data guard 具體操作如下所示:   主庫操作   1.打開Forced Logging   SQL> alter database force logging ;   Database altered.   SQL> select force_logging from v$database;   FOR --- YES   2.配置主庫參數 log_archive_dest_n參數的配置參數詳解參考log_archive_dest_n詳解   [root@rac1 ~]# mkdir /oradata/arch -p [root@rac1 ~]# chown oracle.oinstall /oradata/arch/   [root@rac2 ~]# mkdir /oradata/arch -p [root@rac2 ~]# chown oracle.oinstall /oradata/arch/   [oracle@rac1 ~]$ mkdir /home/oracle/standby 修改參數     SQL> alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(racdb,racdbstd)' sid='*' ;   System altered.   括號中為db_unique_name   設置主庫歸檔路徑   SQL> alter system set log_archive_dest_1='location=+datadg1' sid='racdb1' ;   System altered.   SQL> alter system set log_archive_dest_1='location=+datadg1' sid='racdb2';    System altered.    SQL> alter system set log_archive_dest_2='SERVICE=racdbstd LGWR AFFIRM ASYNC valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=racdbstd' sid='*' ;   System altered.   SQL> alter system set log_archive_max_processes=30 sid='*' ;   System altered.   SQL> alter system set fal_server='racdbstd' sid='*' ;   System altered.   SQL> alter system set STANDBY_FILE_MANAGEMENT=AUTO  sid='*';   System altered.   3.打開主庫歸檔   關閉數據庫   [root@rac1 ~]# su - oracle -c "srvctl stop instance -d racdb -i racdb1" [root@rac1 ~]# su - oracle -c "srvctl stop instance -d racdb -i racdb2"   在一個節點啟動mount狀態   [root@rac1 ~]# su - oracle [oracle@rac1 ~]$ sqlplus / as sysdba   SQL*Plus: Release 11.2.0.3.0 Production on Wed Oct 21 11:23:10 2015   Copyright (c) 1982, 2011, Oracle.  All rights reserved.   Connected to an idle instance.   SQL> startup mount ;   SQL> alter database archivelog;   Database altered.   SQL> alter database open ;   Database altered.   節點2打開數據庫   [oracle@rac2 ~]$ sqlplus / as sysdba   SQL*Plus: Release 11.2.0.3.0 Production on Wed Oct 21 11:24:39 2015   Copyright (c) 1982, 2011, Oracle.  All rights reserved.   Connected to an idle instance.   SQL> startup   4.創建主庫備份用來作為備庫恢復   使用以下腳本備份數據庫
run{
allocate channel c1 device type disk ;  
allocate channel c2 device type disk ; 
backup full database format '/home/oracle/standby/full_%U_%d_%T';
sql 'alter system archive log current';
sql 'alter system archive log current';
sql 'alter system archive log current';
backup archivelog all format '/home/oracle/standby/arch_%u_%d_%T';
release channel c1;
release channel c2; 
}

 

5.創建standby數據庫的控制文件   SQL>  alter database create standby controlfile as '/home/oracle/standby/standby.ctl';   Database altered. 6.創建配置備庫參數文件   SQL> create pfile='/home/oracle/standby/a.txt' from spfile ;   File created.   7.拷貝所需文件到備庫
[oracle@rac1 ~]$ scp -r /home/oracle/standby/ 192.168.10.30:/home/oracle/
full_15qk946n_1_1_RACDB_20151021          100%  507MB  16.9MB/s   00:30 arch_0vqk9379_RACDB_20151021              100%   20KB  19.5KB/s   00:00
arch_19qk94al_RACDB_20151021            100% 8960KB   8.8MB/s   00:00 
arch_18qk94al_RACDB_20151021            100%   15MB  15.2MB/s   00:01 
standby.ctl                                             100%   18MB  17.9MB/s   00:00    
arch_0tqk9377_RACDB_20151021                            100% 1898KB   1.9MB/s   00:00    
full_16qk946n_1_1_RACDB_20151021                        100%  312MB  11.1MB/s   00:28    
full_13qk93vj_1_1_RACDB_20151021                        100%  506MB  11.8MB/s   00:43    
full_0rqk9346_1_1_RACDB_20151021                        100%  310MB  11.1MB/s   00:28    
a.txt                                                   100% 1196     1.2KB/s   00:00    
full_11qk93jb_1_1_RACDB_20151021                        100%  505MB  13.3MB/s   00:38    
arch_0uqk9377_RACDB_20151021                            100% 1367KB   1.3MB/s   00:00

 

  備庫操作   1.設置備庫環境變量   1.1密碼文件拷貝   [oracle@dg dbs]$ scp 192.168.10.10:/oracle/db/product/11.2/dbs/orapwracdb1 $ORACLE_HOME/dbs/orapw$ORACLE_SID   1.2監聽配置   為備庫創建監聽,主庫的監聽已經創建,當前創建備庫的監聽,11G ASM使用grid用戶管理監聽,使用netmgr命令操作,創建完畢之後,grid用戶下的$ORACLE_HOME/network/admin下的listener.ora文件如下所示:
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = racdbstd)
      (ORACLE_HOME = /oracle/asm)
      (SID_NAME = racdbstd)
    )
  )

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

ADR_BASE_LISTENER = /oracle/grid

ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER = ON

 

  1.3創建網絡服務名   使用oracle用戶登錄,在/oracle/db/product/11.2/network/admin的tnsnames.ora中加入以下內容,同樣,rac的兩個節點需需要添加   RACDBSTD =   (DESCRIPTION =     (ADDRESS_LIST =       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.10.30)(PORT = 1521))     )     (CONNECT_DATA =       (SERVICE_NAME = racdbstd)     )   )   2.創建所需的目錄   [oracle@dg ~]$ mkdir -p /oracle/db/admin/racdbstd/adump   3.參數文件配置   修改完畢之後,參數如下所示:  
[oracle@dg ~]$ vi standby/a.txt
*.audit_file_dest='/oracle/db/admin/racdbstd/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='+DATADG1/racdbstd/controlfile/control01.ctl'
*.db_block_size=8192
*.db_create_file_dest='+DATADG1'
*.db_domain=''
*.db_name='racdb'
*.diagnostic_dest='/oracle/db'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=racdbXDB)'
*.open_cursors=300
*.pga_aggregate_target=301989888
*.processes=150
*.remote_login_passwordfile='exclusive'
*.sga_target=905969664
*.db_unique_name=racdbstd
*.log_archive_config='dg_config=(racdb,racdbstd)'
*.log_archive_dest_2='location=+datadg1'
*.log_archive_dest_2='service=racdb LGWR AFFIRM ASYNC valid_for=(ONLINE_LOGFILES,PRIMARY_ROLE) db_unique_name=racdb'
*.log_archive_max_processes=30
*.fal_server=racdb
*.standby_file_management=auto

 

  4.恢復備庫   4.1恢復參數文件  
[oracle@dg ~]$ mv standby/a.txt $ORACLE_HOME/dbs/init$ORACLE_SID.ora
[oracle@dg ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Wed Oct 21 15:39:21 2015

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

Connected to an idle instance.

SQL> startup nomount ;
ORACLE instance started.

Total System Global Area  901914624 bytes
Fixed Size         2233600 bytes
Variable Size        243272448 bytes
Database Buffers     650117120 bytes
Redo Buffers           6291456 bytes
SQL>

 

  4.2恢復控制文件  
[oracle@dg ~]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Wed Oct 21 15:43:55 2015

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

connected to target database: RACDB (not mounted)

RMAN> restore standby controlfile from '/home/oracle/standby/standby.ctl';

Starting restore at 21-OCT-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=24 device type=DISK

channel ORA_DISK_1: copied control file copy
output file name=+DATADG1/racdbstd/controlfile/control01.ctl
Finished restore at 21-OCT-15

SQL> alter database mount standby database ;

Database altered.

SQL> select controlfile_type from v$database ;

CONTROL
-------
STANDBY

SQL>

 

  4.3恢復數據庫  
RMAN> restore database ;

Starting restore at 21-OCT-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=57 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 00002 to +DATADG1/racdb/datafile/sysaux.260.892746071
channel ORA_DISK_1: restoring datafile 00004 to +DATADG1/racdb/datafile/undotbs2.263.892746151
channel ORA_DISK_1: reading from backup piece /home/oracle/standby/full_16qk946n_1_1_RACDB_20151021
channel ORA_DISK_1: piece handle=/home/oracle/standby/full_16qk946n_1_1_RACDB_20151021 tag=TAG20151021T140614
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
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 +DATADG1/racdb/datafile/system.259.892746035
channel ORA_DISK_1: restoring datafile 00003 to +DATADG1/racdb/datafile/undotbs1.261.892746097
channel ORA_DISK_1: restoring datafile 00005 to +DATADG1/racdb/datafile/users.264.892746163
channel ORA_DISK_1: reading from backup piece /home/oracle/standby/full_15qk946n_1_1_RACDB_20151021
channel ORA_DISK_1: piece handle=/home/oracle/standby/full_15qk946n_1_1_RACDB_20151021 tag=TAG20151021T140614
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:56
Finished restore at 21-OCT-15

RMAN> recover database ;

Starting recover at 21-OCT-15
using channel ORA_DISK_1

starting media recovery

channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=75
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=30
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=76
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=31
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=32
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=77
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=78
channel ORA_DISK_1: restoring archived log
archived log thread=2 sequence=33
channel ORA_DISK_1: reading from backup piece /home/oracle/standby/arch_19qk94al_RACDB_20151021
channel ORA_DISK_1: piece handle=/home/oracle/standby/arch_19qk94al_RACDB_20151021 tag=TAG20151021T140820
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/oracle/db/product/11.2.0/dbhome_1/dbs/arch1_75_892746023.dbf thread=1 sequence=75
archived log file name=/oracle/db/product/11.2.0/dbhome_1/dbs/arch2_30_892746023.dbf thread=2 sequence=30
archived log file name=/oracle/db/product/11.2.0/dbhome_1/dbs/arch1_76_892746023.dbf thread=1 sequence=76
archived log file name=/oracle/db/product/11.2.0/dbhome_1/dbs/arch2_31_892746023.dbf thread=2 sequence=31
archived log file name=/oracle/db/product/11.2.0/dbhome_1/dbs/arch2_32_892746023.dbf thread=2 sequence=32
archived log file name=/oracle/db/product/11.2.0/dbhome_1/dbs/arch1_77_892746023.dbf thread=1 sequence=77
archived log file name=/oracle/db/product/11.2.0/dbhome_1/dbs/arch1_78_892746023.dbf thread=1 sequence=78
archived log file name=/oracle/db/product/11.2.0/dbhome_1/dbs/arch2_33_892746023.dbf thread=2 sequence=33
archived log file name=/oracle/db/product/11.2.0/dbhome_1/dbs/arch1_79_892746023.dbf thread=1 sequence=79
archived log file name=/oracle/db/product/11.2.0/dbhome_1/dbs/arch2_34_892746023.dbf thread=2 sequence=34
archived log file name=/oracle/db/product/11.2.0/dbhome_1/dbs/arch1_80_892746023.dbf thread=1 sequence=80
archived log file name=/oracle/db/product/11.2.0/dbhome_1/dbs/arch2_35_892746023.dbf thread=2 sequence=35
archived log file name=/oracle/db/product/11.2.0/dbhome_1/dbs/arch2_36_892746023.dbf thread=2 sequence=36
unable to find archived log
archived log thread=2 sequence=37
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 10/21/2015 16:17:16
RMAN-06054: media recovery requesting unknown archived log for thread 2 with sequence 37 and starting SCN of 1033093

RMAN>

 

  5.創建standby redo   注意:如果主庫已經提前創建好了standby redo log file,備庫會根據LOG_FILE_NAME_CONVERT參數轉換後自動創建與之對應的standby redo log file日志組。因此此步驟可省略。   如有主庫未創建standby redo logfile,則備庫必須手工創建日志文件組 公式如下:   如果主庫是單實例數據庫:Standby Redo Log組數=主庫日志組總數+1 如果主庫是RAC數據庫:StandbyRedo Log組數=(所有節點中日志組數最大值 + 1) * RAC節點數   5.1主庫創建   5.2備庫創建   SQL> alter database add standby logfile thread 1 ('+datadg1') size 50m ;   Database altered.   SQL> /   Database altered.   SQL> /   Database altered.   SQL> l   1* alter database add standby logfile thread 1 ('+datadg1') size 50m SQL> c/1/2   1* alter database add standby logfile thread 2 ('+datadg1') size 50m SQL> /   Database altered.   SQL> /   Database altered.   SQL> /   Database altered.   SQL>   6.網絡服務名測試   6.1主庫測試   如果成功連接,說明正常 [oracle@rac1 ~]$ sqlplus system/oracle@racdbstd [oracle@rac1 ~]$ sqlplus system/oracle@racdbstd
6.2備庫測試   [oracle@dg ~]$ sqlplus system/oracle@racdb   7.開啟實時應用   啟動redo apply,在此過程中注意監控備庫日志的變化     SQL> alter database recover managed standby database using current logfile disconnect from session ;   Database altered. 8.測試 9.啟動關閉data guard 以上參照Oracle Data Guard 單實例到單實例配置(物理standby)

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved