部署STANDBY資料庫

jichengjie發表於2012-07-17
這個例子是在不同主機伺服器部署
1.在備份主機建立相關目錄,保持與原資料庫相同的目錄結構。從原資料庫生成init檔案,修改例項名和服務名,但一定要保留資料庫名不變
> cat initmydb1.ora
*.aq_tm_processes=1
*.background_dump_dest='/u01/ora9/admin/mydb1/bdump'
*.compatible='9.2.0.0.0'
#*.control_files='/u01/ora9/oradata/mydb1/control01.ctl','/u01/ora9/oradata/mydb1/control02.ctl','/u01/ora9/oradata/mydb1/control03.ctl'
*.control_files='/u01/ora9/oradata/mydb1/standby.ctl'
*.core_dump_dest='/u01/ora9/admin/mydb1/cdump'
*.db_block_size=8192
*.db_cache_size=33554432
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='mydb1'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=mydb1XDB)'
*.fast_start_mttr_target=300
*.global_names=FALSE
*.hash_join_enabled=TRUE
*.instance_name='standby'
*.java_pool_size=83886080
*.job_queue_processes=10
*.large_pool_size=16777216
*.log_archive_dest_1='LOCATION=/u01/ora9/oradata/mydb1/archive'
*.log_archive_start=TRUE
*.open_cursors=300
*.pga_aggregate_target=25165824
*.processes=150
*.query_rewrite_enabled='FALSE'
*.remote_login_passwordfile='EXCLUSIVE'
*.shared_pool_size=83886080
*.sort_area_size=524288
*.star_transformation_enabled='FALSE'
*.timed_statistics=TRUE
*.undo_management='AUTO'
*.undo_retention=10800
*.undo_tablespace='UNDOTBS2'
*.service_names='standby'
*.standby_archive_dest='/u01/ora9/oradata/mydb1/archive'
*.user_dump_dest='/u01/ora9/admin/mydb1/udump'
>
2.建立口令檔案
> orapwd file=orapwSTANDBY password=sys entries=3
3.配置服務
> cat listener.ora
# LISTENER.ORA Network Configuration File: /u01/ora9/product/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.2)(PORT = 1521))
      )
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
      )
    )
  )
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (ORACLE_HOME = /u01/ora9/product)
      (SID_NAME = mydb1)
      (service_name = STANDBY)
    )
  )
>
PRIMARY =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.1)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = mydb1)
    )
  )

STANDBY =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.2)(PORT = 1521))
    )
    (CONNECT_DATA =
    (service_name = STANDBY)
)
  )
4.備份原資料庫,並將生成的檔案傳遞到備份主機,目錄與原資料庫的目錄必須一樣
run{
 allocate channel d1 type disk;
 backup  incremental level = 0
 database
 format '/backup/db_%d_%s_%p_%t.dbf'
 tag='whole_inco'
 include current controlfile for standby;
 sql "alter system archive log current";
 sql "alter system archive log current";
 backup archivelog all
 format '/backup/ar_%d_%s_%p_%t.arc';
}

5.建立STANDBY資料庫,在備份主機執行
/nolog
SQL>connect / as sysdba
SQL>startup nomount pfile='/u01/ora9/product/dbs/initmydb1.ora'
>
> ./rman
Recovery Manager: Release 9.2.0.6.0 - Production
Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.
RMAN> connect target
connected to target database: mydb1 (DBID=3061999746)
RMAN> connect auxiliary sys/sys
connected to auxiliary database: mydb1 (not mounted)

run{
   set command id to 'Standby Creation';
   allocate auxiliary channel d1 type disk;
   duplicate target database for standby dorecover nofilenamecheck;
}
6.啟動管理恢復,原資料庫自動傳遞日誌,standby資料庫自動應用日誌
SQL>recover managed standby database;
alter system set log_archive_dest_2="SERVICE=STANDBY  optional";--在原資料庫執行

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

相關文章