搭建rac+DataGuard的測試環境

suifeng2316發表於2013-07-05
搭建rac+DataGuard的測試環境
--1.配置網路
主備庫的監聽,修改tnsnames.ora 和 listener.ora  檔案
--主備庫的tnsnames.ora 檔案是一致的。 修改成如下:
racdb2=
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac2-vip)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = racdb)
      (INSTANCE_NAME = racdb2)
    )
  ) 
racdb1=
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = rac1-vip)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = racdb)
      (INSTANCE_NAME = racdb1)
    )
  ) 
orcl_st =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.13.4)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SID = dgrac)
    )
  )
--備庫配置監聽
SID_LIST_LISTENER_RAC2 =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
   (SID_DESC =
      (SID_NAME = orcl)
      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
    )
  ) 
LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.13.4)(PORT = 1521))
  )
--拷貝密碼檔案到備庫或者使用orapwd生成密碼檔案,一定要保持主備密碼一致
預設情況下,win下口令檔案的格式是pwdsid.ora,unix下的格式是orapwSID(大小寫敏感)
--生成standby控制檔案
alter database create standby controlfile as '/oracle/backup/control01.ctl';
--修改主庫引數檔案
create pfile='/oracle/backup/pfile.txt' from spfile;
*.log_archive_config='dg_config=(racdb,dgrac)'
*.log_archive_dest_3='service=orcl_st VALID_FOR=(ALL_LOGFILES,ALL_ROLES) db_unique_name=dgrac'
*.db_file_name_convert='/home/oracle/oradata','+ASM_DISK/RACDB/DATAFILE','/home/oracle/tempfile','+ASM_DISK/RACDB/tempfile'
*.log_file_name_convert='/home/oracle/oradata', '+ASM_DISK/RACDB/DATAFILE'
*.standby_file_management=auto
*.fal_server='orcl_st'
orcl1.fal_client='racdb1'
orcl2.fal_client='racdb2'
對應命令如下:
alter system set log_archive_config='dg_config=(racdb,dgrac)' scope=both sid='*';      
alter system set log_archive_dest_3='service=orcl_st lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=dgrac' scope=both sid='*';
alter system set db_file_name_convert='/home/oracle/oradata','+ASM_DISK/RACDB/DATAFILE','/home/oracle/tempfile','+ASM_DISK/RACDB/tempfile' scope=spfile sid='*';
alter system set log_file_name_convert='/home/oracle/oradata', '+ASM_DISK/RACDB/DATAFILE' scope=spfile sid='*';
alter system set standby_file_management=auto scope=both sid='*';
alter system set fal_server='orcl_st' scope=both sid='*';
alter system set fal_client='racdb1' scope=both sid='racdb1';
alter system set fal_client='racdb2' scope=both sid='racdb2';
--備庫的引數檔案
*.db_unique_name=dgrac  
-- 注意,這個值要和主庫參log_archive_dest_n裡設定的一致,不然會報錯誤:
ORA-16047: DGID mismatch between destination
*.log_archive_config='dg_config=(racdb,dgrac)'
*.log_archive_dest_2='service=racdb1 valid_for=(online_logfiles,primary_role) db_unique_name=racdb'
*.db_file_name_convert='+ASM_DISK/RACDB/DATAFILE','/home/oracle/oradata/','+ASM_DISK/RACDB/tempfile','/home/oracle/tempfile'
*.log_file_name_convert='+ASM_DISK/RACDB/onlinelog','/home/oracle/oradata'
*.standby_file_management=auto
*.fal_server='racdb1','racdb2'
*.fal_client='orcl_st'
--將主庫備份的目錄掛載到本地備庫
mount -t nfs -o rw,hard,nointr,tcp,noac,vers=3,timeo=600,rsize=32768,wsize=32768 192.168.13.201:/oracle/backup  /oracle/backup 
--備庫節點上
startup pfile='/home/oracle/node1.pfile' nomount;
rman target sys/zhong@racdb1 auxiliary /
duplicate target database for standby;
alter database add standby logfile group 10 '/home/oracle/oradata/standby10_a.log' size 50m;
alter database add standby logfile group 11 '/home/oracle/oradata/standby11_a.log' size 50m;
alter database add standby logfile group 12 '/home/oracle/oradata/standby12_a.log' size 50m;
alter database add standby logfile group 13 '/home/oracle/oradata/standby13_a.log' size 50m;
--開啟日誌應用
alter database recover managed standby database disconnect from session;
搭建Oracle DataGuard還是相對比較簡單,主要要注意在於
1,網路通暢
2,引數設定

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23073818/viewspace-765609/,如需轉載,請註明出處,否則將追究法律責任。

相關文章