cp資料檔案方式搭建 11g 物理standby

哎呀我的天吶發表於2015-06-03



1.主庫設定強制歸檔

點選( 此處 )摺疊或開啟

  1. SQL > alter database force logging ;


  2. SQL > select force_logging from v$database ;


  3. FOR

  4. - - -

  5. YES


2.建立口令檔案並複製到備庫

點選( 此處 )摺疊或開啟

  1. orapwd file = $ ORACLE_HOME/dbs/orapwbeijing password = oracle entries = 3

  2. scp orapwbeijing ...


  3. 備庫上重新命名一下

  4. mv orapwbeijing orapwshanghai


3.主庫確定為歸檔模式

點選( 此處 )摺疊或開啟

  1. archive log list ;

  2. shutdown immediate ;

  3. startup mount ;

  4. alter database archivelog ;

  5. alter system set log_archvie_dest_1 =' location = / arch/' scope = spfile;

4.主備庫上新增監聽和Oracle Net Service(tnsnames.ora)

主庫tnsnames.ora

點選( 此處 )摺疊或開啟

  1. sh =

  2.    ( DESCRIPTION =

  3.      ( ADDRESS = ( PROTOCOL = TCP ) ( HOST = 192.168.6.31 ) ( PORT = 9521 ) )

  4.      ( CONNECT_DATA =

  5.        ( SERVER = DEDICATED )

  6.        ( SERVICE_NAME = shanghai )

  7.      )

  8.    )

備庫tnsnames.ora

點選( 此處 )摺疊或開啟

  1. bj =

  2.    ( DESCRIPTION =

  3.      ( ADDRESS_LIST =

  4.        ( ADDRESS = ( PROTOCOL = TCP ) ( HOST = 192 . 168 . 6 . 21 ) ( PORT = 9521 ) )

  5.      )

  6.      ( CONNECT_DATA =

  7.        ( SERVICE_NAME = beijing )

  8.      )

  9.    )


  10. sh =

  11.    ( DESCRIPTION =

  12.      ( ADDRESS_LIST =

  13.        ( ADDRESS = ( PROTOCOL = TCP ) ( HOST = 192 . 168 . 6 . 31 ) ( PORT = 9521 ) )

  14.      )

  15.      ( CONNECT_DATA =

  16.        ( SERVICE_NAME = shanghai )

  17.      )

  18.    )

5.主庫上建立standby Control file

點選( 此處 )摺疊或開啟

  1. alter database create standby controlfile as '/u01/control01.ctl' ;


  2. Database altered .

6.修改主備庫引數檔案
主庫pfile

點選( 此處 )摺疊或開啟

  1. beijing . __db_cache_size = 314572800

  2. beijing . __java_pool_size = 4194304

  3. beijing . __large_pool_size = 4194304

  4. beijing . __oracle_base = '/u01/app/oracle' # ORACLE_BASE set from environment

  5. beijing . __pga_aggregate_target = 339738624

  6. beijing . __sga_target = 503316480

  7. beijing . __shared_io_pool_size =

  8. beijing . __shared_pool_size = 167772160

  9. beijing . __streams_pool_size = 4194304

  10. * . audit_file_dest = '/u01/app/oracle/admin/beijing/adump'

  11. * . audit_trail = 'db'

  12. * . compatible = '11.2.0.0.0'

  13. * . control_files = '/u01/app/oracle/oradata/beijing/control01.ctl' , '/u01/app/oracle/fast_recovery_area/beijing/control02.ctl'

  14. * . db_block_size = 8192

  15. * . db_domain = ''

  16. * . db_name = 'beijing'

  17. * . db_recovery_file_dest = '/u01/app/oracle/fast_recovery_area'

  18. * . db_recovery_file_dest_size = 4294967296

  19. * . diagnostic_dest = '/u01/app/oracle'

  20. * . dispatchers = '(PROTOCOL=TCP) (SERVICE=beijingXDB)'

  21. # * . local_listener = 'LISTENER_BEIJING'

  22. * . memory_target = 842006528

  23. * . open_cursors = 300

  24. * . processes = 200

  25. * . remote_login_passwordfile = 'EXCLUSIVE'

  26. * . sessions = 225

  27. * . undo_tablespace = 'UNDOTBS1'


  28. # add for primary_dg

  29. * . db_unique_name = 'beijing'

  30. * . log_archive_config = 'dg_config=(beijing,shanghai)'

  31. * . log_archive_dest_1 = 'location=/arch valid_for=(all_logfiles,all_roles) db_unique_name=beijing'

  32. * . log_archive_dest_2 = 'service=sh reopen=120 lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=shanghai'

  33. * . log_archive_dest_state_1 = enable

  34. * . log_archive_dest_state_2 = enable

  35. * . standby_file_management = 'auto'

  36. * . fal_server = 'shanghai'

  37. * . db_file_name_convert = '/u01/app/oracle/oradata/shanghai' , '/u01/app/oracle/oradata/bejing'

  38. * . log_file_name_convert = '/u01/app/oracle/oradata/shanghai' , '/u01/app/oracle/oradata/beijing'

備庫pfile

點選( 此處 )摺疊或開啟

  1. [ oracle@standby dbs ] $ cat initshanghai . ora

  2. shanghai . __db_cache_size = 314572800

  3. shanghai . __java_pool_size = 4194304

  4. shanghai . __large_pool_size = 4194304

  5. shanghai . __oracle_base = '/u01/app/oracle\' # ORACLE_BASE set from environment

  6. shanghai . __pga_aggregate_target = 339738624

  7. shanghai . __sga_target = 503316480

  8. shanghai . __shared_io_pool_size =

  9. shanghai . __shared_pool_size = 167772160

  10. shanghai . __streams_pool_size = 4194304

  11. * . audit_file_dest = \ '/u01/app/oracle/admin/shanghai/adump\'

  12. * . audit_trail = \ 'db\'

  13. * . compatible = \ '11.2.0.0.0\'

  14. * . control_files = '/u01/app/oracle/oradata/shanghai/control01.ctl' , '/u01/app/oracle/fast_recovery_area/shanghai/control02.ctl\'

  15. * . db_block_size = 8192

  16. * . db_domain = ''

  17. * . db_name = 'beijing'

  18. * . db_recovery_file_dest = '/u01/app/oracle/fast_recovery_area'

  19. * . db_recovery_file_dest_size = 4294967296

  20. * . diagnostic_dest = '/u01/app/oracle\'

  21. * . dispatchers = '(PROTOCOL=TCP) (SERVICE=shanghaiXDB)'

  22. # * . local_listener = 'LISTENER_SHANGHAI'

  23. * . memory_target = 842006528

  24. * . open_cursors = 300

  25. * . processes = 200

  26. * . remote_login_passwordfile = 'EXCLUSIVE'

  27. * . sessions = 225

  28. * . undo_tablespace = 'UNDOTBS1'


  29. # add for primary_dg

  30. * . db_unique_name = 'shanghai'

  31. * . log_archive_config = 'dg_config=(shanghai,beijing)'

  32. * . log_archive_dest_1 = 'location=/arch valid_for=(all_logfiles,all_roles) db_unique_name=shanghai'

  33. * . log_archive_dest_2 = 'service=sh reopen=120 lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=shanghai'

  34. * . log_archive_dest_state_1 = enable

  35. * . log_archive_dest_state_2 = enable

  36. * . fal_server = 'beijing'

  37. * . db_file_name_convert = '/u01/app/oracle/oradata/beijing' , '/u01/app/oracle/oradata/shanghai'

  38. * . log_file_name_convert = '/u01/app/oracle/oradata/beijing' , '/u01/app/oracle/oradata/shanghai'

  39. * . standby_file_management = 'auto'

7.將主備庫open並檢查DG是否有錯誤

點選( 此處 )摺疊或開啟

  1. SQL > startup pfile = '/u01/app/oracle/product/11.2.0/db_1/dbs/initshanghai.ora' ;

  2. ORACLE instance started .


  3. Total System Global Area  839282688 bytes

  4. Fixed Size             2233000 bytes

  5. Variable Size           520097112 bytes

  6. Database Buffers      314572800 bytes

  7. Redo Buffers            2379776 bytes

  8. Database mounted .

  9. Database opened .

  10. SQL > select open_mode from v$database ;


  11. OPEN_MODE

  12. - - - - - - - - - - - - - - - - - - - -

  13. READ ONLY

檢查DG是否有錯誤

點選( 此處 )摺疊或開啟

  1. select dest_name , status , process , error , transmit_mode from v$archive_dest where target = 'STANDBY'


  2. DEST_NAME              STATUS     PROCESS     ERROR    TRANSMIT_MODE

  3. - - - - - - - - - - - -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ---

  4. LOG_ARCHIVE_DEST_2           VALID      LGWR                 ASYNCHRONOUS

8.主備庫上新增standby redo log

點選( 此處 )摺疊或開啟

  1. alter database add standby logfile group 4 ( '/u01/app/oracle/oradata/beijing/redo04.log' ) size 100M ;

  2. alter database add standby logfile group 5 ( '/u01/app/oracle/oradata/beijing/redo05.log' ) size 100M ;

  3. alter database add standby logfile group 6 ( '/u01/app/oracle/oradata/beijing/redo06.log' ) size 100M ;

  4. alter database add standby logfile group 7 ( '/u01/app/oracle/oradata/beijing/redo07.log' ) size 100M ;


  5. SQL > col member for a60

  6. SQL > select group# , type , member from v$logfile ;


  7. GROUP# TYPE     MEMBER

  8. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  9.      3 ONLINE  /u01/app/oracle/oradata/beijing/redo03 . log

  10.      2 ONLINE  /u01/app/oracle/oradata/beijing/redo02 . log

  11.      1 ONLINE  /u01/app/oracle/oradata/beijing/redo01 . log

  12.      4 STANDBY /u01/app/oracle/oradata/beijing/redo04 . log

  13.      5 STANDBY /u01/app/oracle/oradata/beijing/redo05 . log

  14.      6 STANDBY /u01/app/oracle/oradata/beijing/redo06 . log

  15.      7 STANDBY /u01/app/oracle/oradata/beijing/redo07 . log


  16. 7 rows selected .

備庫同上

9.備庫啟動MRP程式

點選( 此處 )摺疊或開啟

  1. alter database recover managed standby database disconnect from session;

點選( 此處 )摺疊或開啟

  1. SQL > select open_mode from v$database ;


  2. OPEN_MODE

  3. - - - - - - - - - - - - - - - - - - - -

  4. READ ONLY WITH APPLY


點選( 此處 )摺疊或開啟

  1. 1 * select * from v$managed_standby


  2. PROCESS  PID STATUS CLIENT_PROCESS CLIENT_PID CLIENT_DBID     GROUP#   RESETLOG_ID    THREAD#  SEQUENCE#   BLOCK#     BLOCKS DELAY_MINS KNOWN_AGENTS ACTIVE_AGENTS

  3. - - - - - - -   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   - - - - - - -   - - - - - - -   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

  4. ARCH   11245 CLOSING       ARCH       11245       845781194        5           881314188      1          10        1       6        0           0         0

  5. ARCH   11247 CLOSING       ARCH       11247       845781194        5           881314188      1           8        1   926        0           0         0

  6. ARCH   11249 CONNECTED      ARCH       11249       845781194        N/A           0      0           0        0       0        0           0         0

  7. ARCH   11251 CLOSING       ARCH       11251       845781194        4           881314188      1           9        1       2        0           0         0

  8. RFS    12009 IDLE          ARCH       28837       845781194        N/A           0      0           0        0       0        0           0         0

  9. RFS    12003 IDLE       UNKNOWN     28835       845781194        N/A           0      0           0        0       0        0           0         0

  10. RFS    12005 IDLE       UNKNOWN     28839       845781194        N/A           0      0           0        0       0        0           0         0

  11. RFS    12007 IDLE          LGWR       28841       845781194        2           881314188      1          11       33       1        0           0         0

  12. MRP0   12058 WAIT_FOR_LOG   N/A       N/A             N/A     N/A   881314188      1          11        0       0        0           0         0






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

相關文章