Data guard 配置之搭建物理備庫

YallonKing發表於2011-08-17
知識獲得不易,轉載請註明出處!
Data guard 配置之物理備庫
1.規劃
1.1 主備機資訊
OS:centos4.8
DB:oracle10.2
1.2 主備庫配置資訊
 
ip                             db_name             db_unique_name                  Net service name
 
Primary db
192.168.241.5      node1                   node1                                       node1
 
Standby db       
192.168.241.6      node1/2                node2                                       node2
 
保護模式:預設最大效能模式
2. 主庫操作
2.1 設定日誌模式
注:若已處於logging模式,此步驟可省略
2.2 建立密碼檔案
orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=oracle entries=5 force=y
2.3 配置備庫日誌
注:此步驟可省略
2.4 設定主庫引數檔案
SQL> alter system set db_unique_name=node1 scope=spfile;
SQL> alter system set log_archive_config='dg_config=(node1,node2)' scope=spfile;
SQL> alter system set log_archive_dest_1='location=/u01/app/oracle/oradata/node1/archive1/ valid_for=(all_logfiles,all_roles) db_unique_name=node1' scope=spfile;
SQL> alter system set log_archive_dest_2='service=node2 lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=node2' scope=spfile;
SQL> alter system set log_archive_dest_state_1=enable scope=spfile;
SQL> alter system set log_archive_dest_state_2=enable scope=spfile;
SQL> alter system set remote_login_passwordfile=exclusive scope=spfile;
SQL> alter system set log_archive_max_processes=5 scope=spfile;
*******************************************************************************
以下引數可省略
SQL> alter system set fal_server=node2 scope=spfile;
SQL> alter system set fal_client=node1 scope=spfile;
SQL> alter system set db_file_name_convert='node2','node1' scope=spfile;
SQL> alter system set log_file_name_convert='node2','node1' scope=spfile;
SQL> alter system set standby_file_management=auto scope=spfile;
2.5 設定主庫歸檔模式
SQL> shutdown immediate
3. 建立物理備庫
**************以下均在主庫操作************
3.1 建立主庫的備份
[oracle@xlong01 dbs]$ rman target /
RMAN> backup full database format '/tmp/dg/backup_%T_%s_%p.bak';
RMAN> sql 'alter system archive log current';
RMAN> backup archivelog all format='/tmp/dg/arch_%T_%s_%p.bak';
3.2 為備庫建立控制檔案
SQL> startup mount
SQL> alter database create standby controlfile as '/tmp/dg/staby_control01.ctl';
SQL> alter database open;
3.3 設定備庫引數檔案
SQL> create pfile='/tmp/dg/initnode2.ora' from spfile;
修改此引數檔案(具體修改後內容參見後邊相關檔案)
3.4 複製主庫備份至備庫
將3.1中的備份移動(藉助ftp軟體)至備庫的相同目錄下,將3.2中的控制檔案備份移動至備庫的相關目錄下並複用,將3.3中的引數檔案(initnode2.ora)移動至備庫相關檔案下
[oracle@xlong01 node2]$ pwd
/u01/app/oracle/oradata/node2
[oracle@xlong01 node2]$ cp staby_control01.ctl staby_control02.ctl
[oracle@xlong01 node2]$ cp staby_control01.ctl staby_control03.ctl
3.5 設定主備庫網路環境
①通過netmgr設定主備庫listener.ora與tnsnames.ora
②重新啟動主備庫監聽
[oracle@xlong01 ~]$ lsnrctl stop
[oracle@xlong01 ~]$ lsnrctl start
③檢查主備庫連線串解析情況
[oracle@xlong01 ~]$ tnsping node2    (主庫操作)
[oracle@xlong01 node2]$ tnsping node1(備庫操作)
3.6 啟動備庫
①將主庫的密碼檔案拷貝至備庫相關目錄下(也可建立和主庫一致的密碼檔案)
②修改備庫的os配置檔案(.bash_profile)(可能)
③由pfile生成spfile
SQL> create spfile from pfile;
④將備庫nomount後執行rman下的restore和recover
[oracle@xlong01 ~]$ rman target /
RMAN> restore database;
RMAN> recover database;
SQL> startup mount
SQL> alter database recover managed standby database disconnect from session;
4. 驗證物理備庫是否成功
4.1 檢視主備庫之間的歸檔日誌是否正常傳遞
 
 
4.2 檢視主備庫的歸檔檔案是否已經歸檔到指定位置

4.3 檢視主備庫歸檔日誌檔案最大序號是否相同
5. 相關檔案
5.1 主庫資訊
[oracle@xlong01 dbs]$ strings spfilenode1.ora
node1.__db_cache_size=197132288
node1.__java_pool_size=4194304
node1.__large_pool_size=4194304
node1.__shared_pool_size=75497472
node1.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/node1/adump'
*.background_dump_dest='/u01/app/oracle/admin/node1/bdump'
*.compatible=' 10.2.0.1.0'
*.control_files='/u01/app/oracle/oradata/node1/control01.ctl','/u01/app/oracle/oradata/node1/control02.ctl','/u01/app/oracle/oradata/node1/control03.ctl'
*.core_dump_dest='/u01/app/oracle/admin/node1/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_file_name_convert='node2','node1'
*.db_name='node1'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.db_unique_name='NODE1'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=node1XDB)'
*.fal_client='NODE1'
*.fal_server='NODE2'
*.job_queue_processes=10
*.log_archive_config='dg_config=(node1,node2)'
*.log_archive_dest_1='location=/u01/app/oracle/oradata/node1/archive1/ valid_for=(all_logfiles,all_roles) db_unique_name=node1'
*.log_archive_dest_2='service=NODE2 lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=node2'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_format='%t_%s_%r.dbf'
*.log_archive_max_processes=5
*.log_file_name_convert='node2','node1'
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=285212672
*.standby_file_management='AUTO'
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/node1/udump'
**************************************************
[oracle@xlong01 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
 
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = node1)
      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
      (SID_NAME = node1)
    )
  )
 
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = xlong01)(PORT = 1521))
    )
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )
**************************************************
 [oracle@xlong01 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
 
NODE2 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.241.6)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = node2)
    )
  )
 
NODE1 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.241.5)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = node1)
    )
  )
 
EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )
 
5.2 備庫資訊
[oracle@xlong01 dbs]$ strings spfilenode2.ora
node2.__db_cache_size=197132288
node2.__java_pool_size=4194304
node2.__large_pool_size=4194304
node2.__shared_pool_size=75497472
node2.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/node2/adump'
*.background_dump_dest='/u01/app/oracle/admin/node2/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/u01/app/oracle/oradata/node2/staby_control01.ctl','/u01/app/oracle/oradata/node2/staby_control02.ctl','/u01/app/oracle/oradata/node2/staby_control03.ctl'
*.core_dump_dest='/u01/app/oracle/admin/node2/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_file_name_convert='node1','node2'
*.db_name='node1'
*.db_recovery_file_dest='/u01/app/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.db_unique_name='NODE2'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=node1XDB)'
*.fal_client='NODE2'
*.fal_server='NODE1'
*.job_queue_processes=10
*.log_archive_config='dg_config=(node2,node1)'
*.log_archive_dest_1='location=/u01/app/oracle/oradata/node2/archive1/ valid_for=(all_logfiles,all_roles) db_unique_name=node2'
*.log_archive_dest_2='service=NODE1 lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=node1'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.log_archive_format='%t_%s_%r.dbf'
*.log_archive_max_processes=5
*.log_file_name_convert='node1','node2'
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=285212672
*.standby_file_management='AUTO'
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/node2/udump'
**************************************************
 [oracle@xlong01 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
 
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = node2)
      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)
      (SID_NAME = node2)
    )
  )
 
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = xlong01)(PORT = 1521))
    )
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
  )
**************************************************
[oracle@xlong01 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
 
NODE2 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.241.6)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = node2)
    )
  )
 
NODE1 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.241.5)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = node1)
    )
  )
 
EXTPROC_CONNECTION_DATA =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
    )
    (CONNECT_DATA =
      (SID = PLSExtProc)
      (PRESENTATION = RO)
    )
  )
6. 注意事項
6.1 下邊的問題主要是listener.ora和tnsnames.ora設定不當引起,建議使用netmgr進行相關設定
 
6.2 下邊問題可能通過設定一致的主備庫密碼檔案解決
 
6.3 注意網路服務名在引數檔案中的大小寫以及檔案目錄許可權

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

相關文章