oracle failover primary DB physical DB




主库上的准备工作 primary DB---slow

  1. [root@slow ~]# su - oracle
  2. [oracle@slow ~]$ !sql
  3. sqlplus '/as sysdba'

  4. SQL*Plus: Release 11.2.0.4.0 Production on Sat Jan 13 20:54:25 2018

  5. Copyright (c) 1982, 2013, Oracle. All rights reserved.


  6. Connected to:
  7. Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
  8. With the Partitioning, OLAP, Data Mining and Real Application Testing options

  9. 20:54:25 SYS @ slow >
  10. 20:54:25 SYS @ slow >select status from v$instance;

  11. STATUS
  12. ------------
  13. OPEN

  14. 1 row selected.

  15. Elapsed: 00:00:00.00
  16. 20:54:37 SYS @ slow >select name,open_mode,database_role,protection_mode from v$database
  17. 20:55:07 2 ;

  18. NAME     OPEN_MODE     DATABASE_ROLE    PROTECTION_MODE
  19. --------- -------------------- ---------------- --------------------
  20. SLOW     READ WRITE     PRIMARY        MAXIMUM AVAILABILITY

  21. 1 row selected.

  22. Elapsed: 00:00:00.00
  23. 20:55:09 SYS @ slow >show parameter recover

  24. NAME                 TYPE     VALUE
  25. ------------------------------------ ----------- ------------------------------
  26. db_recovery_file_dest         string
  27. db_recovery_file_dest_size     big integer 0
  28. db_unrecoverable_scn_tracking     boolean     TRUE
  29. recovery_parallelism         integer     0
  30. 20:55:37 SYS @ slow >alter system set db_recovery_file_dest_size=4g;

  31. System altered.

  32. Elapsed: 00:00:00.00
  33. 20:56:34 SYS @ slow >alter system set db_recovery_file_dest='/dsk1/slow_recover/';

  34. System altered.

  35. Elapsed: 00:00:00.02
  36. 20:57:01 SYS @ slow >show parameter recover;

  37. NAME                 TYPE     VALUE
  38. ------------------------------------ ----------- ------------------------------
  39. db_recovery_file_dest         string     /dsk1/slow_recover/
  40. db_recovery_file_dest_size     big integer 4G
  41. db_unrecoverable_scn_tracking     boolean     TRUE
  42. recovery_parallelism         integer     0
  43. 20:57:09 SYS @ slow >show parameter dg_broker_start

  44. NAME                 TYPE     VALUE
  45. ------------------------------------ ----------- ------------------------------
  46. dg_broker_start          boolean     FALSE
  47. 21:03:02 SYS @ slow >alter system set dg_broker_start=true;

  48. System altered.

  49. Elapsed: 00:00:00.02
  50. 21:03:40 SYS @ slow >show parameter dg_broker_start

  51. NAME                 TYPE     VALUE
  52. ------------------------------------ ----------- ------------------------------
  53. dg_broker_start          boolean     TRUE
  54. 21:03:56 SYS @ slow >show parameter dg;

  55. NAME                 TYPE     VALUE
  56. ------------------------------------ ----------- ------------------------------
  57. cell_offloadgroup_name         string
  58. dg_broker_config_file1         string     /u01/app/oracle/product/11.2.0
  59.                          /dbhome_1/dbs/dr1slow.dat
  60. dg_broker_config_file2         string     /u01/app/oracle/product/11.2.0
  61.                          /dbhome_1/dbs/dr2slow.dat
  62. dg_broker_start          boolean     TRUE
  63. 21:04:07 SYS @ slow >alter system switch logfile;

  64. System altered.

  65. Elapsed: 00:00:00.02
  66. 21:21:09 SYS @ slow >select name,flashback_on from v$database;

  67. NAME     FLASHBACK_ON
  68. --------- ------------------
  69. SLOW     NO

  70. 1 row selected.

  71. Elapsed: 00:00:00.01
  72. 21:26:08 SYS @ slow >alter database flashback on;

  73. Database altered.

  74. Elapsed: 00:00:01.16
  75. 21:26:27 SYS @ slow >select status from v$instance;

  76. STATUS
  77. ------------
  78. OPEN

  79. 1 row selected.

  80. Elapsed: 00:00:00.01


备库上的准备工作

  1. [oracle@sink ~]$ echo $ORACLE_SID
  2. gotime
  3. [oracle@sink ~]$ !sql
  4. sqlplus / as sysdba

  5. SQL*Plus: Release 11.2.0.4.0 Production on Sat Jan 13 20:59:35 2018

  6. Copyright (c) 1982, 2013, Oracle. All rights reserved.

  7. Connected to:
  8. Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
  9. With the Partitioning, OLAP, Data Mining and Real Application Testing options

  10. 20:59:35 SYS @ gotime >select status from v$instance;

  11. STATUS
  12. ------------
  13. OPEN

  14. 1 row selected.

  15. Elapsed: 00:00:00.01
  16. 20:59:47 SYS @ gotime >select name,open_mode,database_role,protection_mode from v$database;

  17. NAME     OPEN_MODE     DATABASE_ROLE    PROTECTION_MODE
  18. --------- -------------------- ---------------- --------------------
  19. SLOW     READ ONLY     PHYSICAL STANDBY MAXIMUM AVAILABILITY

  20. 1 row selected.

  21. Elapsed: 00:00:00.00
  22. 21:01:18 SYS @ gotime >shutdown immediate;
  23. Database closed.
  24. Database dismounted.
  25. ORACLE instance shut down.
  26. 21:05:03 SYS @ gotime >startup mount;
  27. ORACLE instance started.

  28. Total System Global Area 521936896 bytes
  29. Fixed Size         2254824 bytes
  30. Variable Size         377489432 bytes
  31. Database Buffers     138412032 bytes
  32. Redo Buffers         3780608 bytes
  33. Database mounted.
  34. 21:05:18 SYS @ gotime >show parameter recover;

  35. NAME                 TYPE     VALUE
  36. ------------------------------------ ----------- ------------------------------
  37. db_recovery_file_dest         string
  38. db_recovery_file_dest_size     big integer 0
  39. db_unrecoverable_scn_tracking     boolean     TRUE
  40. recovery_parallelism         integer     0
  41. 21:08:14 SYS @ gotime >alter system set db_recovery_file_dest_size=4g scope=spfile;

  42. System altered.

  43. Elapsed: 00:00:00.01
  44. 21:09:40 SYS @ gotime >alter system set db_recovery_file_dest='/dsk1/gotime_recover/' scope=spfile;
  45. j
  46. System altered.

  47. Elapsed: 00:00:00.01
  48. 21:10:07 SYS @ gotime show parameter recover;

  49. NAME                 TYPE     VALUE
  50. ------------------------------------ ----------- ------------------------------
  51. db_recovery_file_dest         string     /dsk1/gotime_recover/
  52. db_recovery_file_dest_size     big integer 4G
  53. db_unrecoverable_scn_tracking     boolean     TRUE
  54. recovery_parallelism         integer     0
  55. 21:10:21 SYS @ gotime >show parameter dg_broker_start

  56. NAME                 TYPE     VALUE
  57. ------------------------------------ ----------- ------------------------------
  58. dg_broker_start          boolean     FALSE
  59. 21:18:49 SYS @ gotime >alter system dg_broker_start=true;
  60. alter system dg_broker_start=true
  61.              *
  62. ERROR at line 1:
  63. ORA-02065: illegal option for ALTER SYSTEM


  64. Elapsed: 00:00:00.00
  65. 21:19:07 SYS @ gotime >alter database open;

  66. Database altered.

  67. Elapsed: 00:00:00.41
  68. 21:19:44 SYS @ gotime >alter system dg_broker_start=true;
  69. alter system dg_broker_start=true
  70.              *
  71. ERROR at line 1:
  72. ORA-02065: illegal option for ALTER SYSTEM


  73. Elapsed: 00:00:00.00
  74. 21:20:01 SYS @ gotime >shutdown immediate;
  75. Database closed.
  76. Database dismounted.
  77. ORACLE instance shut down.
  78. 21:20:17 SYS @ gotime >startup mount;
  79. ORACLE instance started.

  80. Total System Global Area 521936896 bytes
  81. Fixed Size         2254824 bytes
  82. Variable Size         377489432 bytes
  83. Database Buffers     138412032 bytes
  84. Redo Buffers         3780608 bytes
  85. Database mounted.
  86. 21:21:02 SYS @ gotime >recover managed standby database disconnect;
  87. Media recovery complete.
  88. 21:21:52 SYS @ gotime >show parameter dg

  89. NAME                 TYPE     VALUE
  90. ------------------------------------ ----------- ------------------------------
  91. cell_offloadgroup_name         string
  92. dg_broker_config_file1         string     /u01/app/oracle/product/11.2.0
  93.                          /dbhome_1/dbs/dr1gotime.dat
  94. dg_broker_config_file2         string     /u01/app/oracle/product/11.2.0
  95.                          /dbhome_1/dbs/dr2gotime.dat
  96. dg_broker_start          boolean     FALSE
  97. 21:22:56 SYS @ gotime >alter system set dg_broker_start=true;

  98. System altered.

  99. Elapsed: 00:00:00.01
  100. 21:23:15 SYS @ gotime >select name,flashback_on from v$database;

  101. NAME     FLASHBACK_ON
  102. --------- ------------------
  103. SLOW     NO

  104. 1 row selected.

  105. Elapsed: 00:00:00.01
  106. 21:27:06 SYS @ gotime >alter database flashback on;
  107. alter database flashback on
  108. *
  109. ERROR at line 1:
  110. ORA-01153: an incompatible media recovery is active


  111. Elapsed: 00:00:00.01
  112. 21:27:48 SYS @ gotime >recover managed standby database cancel;
  113. Media recovery complete.
  114. 21:28:24 SYS @ gotime >alter database flashback on;

  115. Database altered.

  116. Elapsed: 00:00:01.93
  117. 21:28:42 SYS @ gotime >recover managed standby database using current logfile disconnect;
  118. Media recovery complete.
  119. 21:49:18 SYS @ gotime >select name,open_mode,database_role,protection_mode,switchover_status from v$database;

  120. NAME     OPEN_MODE     DATABASE_ROLE    PROTECTION_MODE SWITCHOVER_STATUS
  121. --------- -------------------- ---------------- -------------------- --------------------
  122. SLOW     MOUNTED     PHYSICAL STANDBY MAXIMUM AVAILABILITY NOT ALLOWED

  123. 1 row selected.

  124. Elapsed: 00:00:00.00

主库操作系统上,主库设置dg_broker_start=true后,进程ora_dmon_slow,启动

  1. [root@slow ~]# ps -ef|grep ora_|grep -v grep
  2. oracle 5629 1 0 18:57 ? 00:00:00 ora_pmon_slow
  3. oracle 5633 1 0 18:57 ? 00:00:01 ora_psp0_slow
  4. oracle 5637 1 0 18:57 ? 00:01:10 ora_vktm_slow
  5. oracle 5643 1 0 18:57 ? 00:00:00 ora_gen0_slow
  6. oracle 5647 1 0 18:57 ? 00:00:00 ora_diag_slow
  7. oracle 5651 1 0 18:57 ? 00:00:00 ora_dbrm_slow
  8. oracle 5655 1 0 18:57 ? 00:00:02 ora_dia0_slow
  9. oracle 5659 1 0 18:57 ? 00:00:00 ora_mman_slow
  10. oracle 5663 1 0 18:57 ? 00:00:00 ora_dbw0_slow
  11. oracle 5667 1 0 18:57 ? 00:00:02 ora_lgwr_slow
  12. oracle 5671 1 0 18:57 ? 00:00:02 ora_ckpt_slow
  13. oracle 5675 1 0 18:57 ? 00:00:00 ora_smon_slow
  14. oracle 5679 1 0 18:57 ? 00:00:00 ora_reco_slow
  15. oracle 5683 1 0 18:57 ? 00:00:01 ora_mmon_slow
  16. oracle 5687 1 0 18:57 ? 00:00:01 ora_mmnl_slow
  17. oracle 5691 1 0 18:57 ? 00:00:00 ora_d000_slow
  18. oracle 5695 1 0 18:57 ? 00:00:00 ora_s000_slow
  19. oracle 5726 1 0 19:00 ? 00:00:00 ora_arc0_slow
  20. oracle 5730 1 0 19:00 ? 00:00:00 ora_arc1_slow
  21. oracle 5734 1 0 19:00 ? 00:00:00 ora_arc2_slow
  22. oracle 5738 1 0 19:00 ? 00:00:00 ora_arc3_slow
  23. oracle 5742 1 0 19:00 ? 00:00:00 ora_qmnc_slow
  24. oracle 5770 1 0 19:00 ? 00:00:01 ora_cjq0_slow
  25. oracle 5774 1 0 19:00 ? 00:00:09 ora_vkrm_slow
  26. oracle 5778 1 0 19:00 ? 00:00:00 ora_q000_slow
  27. oracle 5782 1 0 19:00 ? 00:00:00 ora_q001_slow
  28. oracle 5809 1 0 19:05 ? 00:00:00 ora_smco_slow
  29. oracle 6338 1 0 20:55 ? 00:00:00 ora_w000_slow
  30. oracle 6344 1 0 20:56 ? 00:00:00 ora_nss2_slow
  31. oracle 6411 1 0 21:03 ? 00:00:00 ora_dmon_slow
  32. oracle 6415 1 0 21:03 ? 00:00:00 ora_insv_slow
  33. oracle 6421 1 0 21:05 ? 00:00:00 ora_w001_slow
  34. oracle 6426 1 0 21:05 ? 00:00:00 ora_w002_slow
  35. [root@slow ~]#

备库操作系统上,备库设置dg_broker_start=true后,进程ora_dmon_gotime,启动

  1. [root@sink ~]# ps -ef|grep ora_|grep -v grep
  2. oracle 10913 1 0 21:20 ? 00:00:00 ora_pmon_gotime
  3. oracle 10917 1 0 21:20 ? 00:00:00 ora_psp0_gotime
  4. oracle 10922 1 0 21:20 ? 00:00:01 ora_vktm_gotime
  5. oracle 10928 1 0 21:20 ? 00:00:00 ora_gen0_gotime
  6. oracle 10932 1 0 21:20 ? 00:00:00 ora_diag_gotime
  7. oracle 10936 1 0 21:20 ? 00:00:00 ora_dbrm_gotime
  8. oracle 10940 1 0 21:20 ? 00:00:00 ora_dia0_gotime
  9. oracle 10944 1 0 21:20 ? 00:00:00 ora_mman_gotime
  10. oracle 10948 1 0 21:20 ? 00:00:00 ora_dbw0_gotime
  11. oracle 10952 1 0 21:20 ? 00:00:00 ora_lgwr_gotime
  12. oracle 10956 1 0 21:20 ? 00:00:00 ora_ckpt_gotime
  13. oracle 10960 1 0 21:20 ? 00:00:00 ora_smon_gotime
  14. oracle 10964 1 0 21:20 ? 00:00:00 ora_reco_gotime
  15. oracle 10968 1 0 21:20 ? 00:00:00 ora_mmon_gotime
  16. oracle 10972 1 0 21:20 ? 00:00:00 ora_mmnl_gotime
  17. oracle 10976 1 0 21:20 ? 00:00:00 ora_d000_gotime
  18. oracle 10980 1 0 21:20 ? 00:00:00 ora_s000_gotime
  19. oracle 10995 1 0 21:20 ? 00:00:00 ora_nss2_gotime
  20. oracle 11003 1 0 21:21 ? 00:00:00 ora_arc0_gotime
  21. oracle 11007 1 0 21:21 ? 00:00:00 ora_arc1_gotime
  22. oracle 11011 1 0 21:21 ? 00:00:00 ora_arc2_gotime
  23. oracle 11016 1 0 21:21 ? 00:00:00 ora_arc3_gotime
  24. oracle 11044 1 0 21:21 ? 00:00:00 ora_mrp0_gotime
  25. oracle 11064 1 0 21:23 ? 00:00:00 ora_dmon_gotime
  26. [root@sink ~]#

主库上的listener.ora

  1. [oracle@slow ~]$ vim /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora

  2. # listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  3. # Generated by Oracle configuration tools.

  4. LISTENER =
  5.   (DESCRIPTION_LIST =
  6.     (DESCRIPTION =
  7.       (ADDRESS = (PROTOCOL = TCP)(HOST = slow)(PORT = 1521))
  8.     )
  9.   )

  10. ADR_BASE_LISTENER = /u01/app/oracle


  11. SID_LIST_LISTENER=
  12.    (SID_DESC=
  13.     (SID_NAME=slow)
  14.     (SDU=32767)
  15.         (ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
  16.         (GLOBAL_DBNAME=slow_dgmgrl)
  17.    )

主库上的tnsname.ora

  1. [oracle@slow ~]$ vim /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora

  2. # tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
  3. # Generated by Oracle configuration tools.

  4. GOTIME =
  5.   (DESCRIPTION =
  6.     (ADDRESS_LIST =
  7.       (ADDRESS = (PROTOCOL = TCP)(HOST = sink)(PORT = 1521))
  8.     )
  9.     (CONNECT_DATA =
  10.       (SERVICE_NAME = gotime)
  11.     )
  12.   )

  13. SLOW =
  14.   (DESCRIPTION =
  15.     (ADDRESS_LIST =
  16.       (ADDRESS = (PROTOCOL = TCP)(HOST = slow)(PORT = 1521))
  17.     )
  18.     (CONNECT_DATA =
  19.       (SERVICE_NAME = slow)
  20.     )
  21.   )

备库上的listener.ora

  1. [grid@sink ~]$ vim /u01/11.2.0/grid/network/admin/listener.ora

  2. # listener.ora Network Configuration File: /u01/11.2.0/grid/network/admin/listener.ora
  3. # Generated by Oracle configuration tools.

  4. LISTENER =
  5.   (DESCRIPTION_LIST =
  6.     (DESCRIPTION =
  7.       (ADDRESS = (PROTOCOL = TCP)(HOST = sink)(PORT = 1521))
  8.     )
  9.   )

  10. ADR_BASE_LISTENER = /u01/app/grid

  11. ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON # line added by Agent

  12. SID_LIST_LISTENER=
  13.  (SID_LIST=
  14.   (SID_DESC=
  15.     (SID_NAME=gotime)
  16.     (SDU=32767)
  17.       (ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
  18.       (GLOBAL_DBNAME=gotime_dgmgrl)
  19.    )
  20.  )

备库上的tnsname.ora

  1. [grid@sink ~]$ su - oracle
  2. Password:
  3. [oracle@sink ~]$ vim /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora

  4. # tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
  5. # Generated by Oracle configuration tools.
  6. SLOW =
  7.   (DESCRIPTION =
  8.     (ADDRESS_LIST =
  9.       (ADDRESS = (PROTOCOL = TCP)(HOST = slow)(PORT = 1521))
  10.     )
  11.     (CONNECT_DATA =
  12.       (SERVICE_NAME = slow)
  13.     )
  14.   )

  15. GOTIME =
  16.   (DESCRIPTION =
  17.     (ADDRESS_LIST =
  18.       (ADDRESS = (PROTOCOL = TCP)(HOST = sink)(PORT = 1521))
  19.     )
  20.     (CONNECT_DATA =
  21.       (SERVICE_NAME = gotime)
  22.     )
  23.   )


主库上的网络状态

  1. [oracle@slow ~]$ lsnrctl stop

  2. LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 13-JAN-2018 21:15:40

  3. Copyright (c) 1991, 2013, Oracle. All rights reserved.

  4. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=slow)(PORT=1521)))
  5. TNS-12541: TNS:no listener
  6.  TNS-12560: TNS:protocol adapter error
  7.   TNS-00511: No listener
  8.    Linux Error: 111: Connection refused
  9. [oracle@slow ~]$ lsnrctl start

  10. LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 13-JAN-2018 21:15:43

  11. Copyright (c) 1991, 2013, Oracle. All rights reserved.

  12. Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...

  13. TNSLSNR for Linux: Version 11.2.0.4.0 - Production
  14. System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  15. Log messages written to /u01/app/oracle/diag/tnslsnr/slow/listener/alert/log.xml
  16. Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=slow)(PORT=1521)))

  17. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=slow)(PORT=1521)))
  18. STATUS of the LISTENER
  19. ------------------------
  20. Alias LISTENER
  21. Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
  22. Start Date 13-JAN-2018 21:15:43
  23. Uptime 0 days 0 hr. 0 min. 0 sec
  24. Trace Level off
  25. Security ON: Local OS Authentication
  26. SNMP OFF
  27. Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
  28. Listener Log File /u01/app/oracle/diag/tnslsnr/slow/listener/alert/log.xml
  29. Listening Endpoints Summary...
  30.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=slow)(PORT=1521)))
  31. Services Summary...
  32. Service "slow_dgmgrl" has 1 instance(s).
  33.   Instance "slow", status UNKNOWN, has 1 handler(s) for this service...
  34. The command completed successfully



备库上的网络状态

  1. [grid@sink ~]$ lsnrctl stop

  2. LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 13-JAN-2018 21:14:56

  3. Copyright (c) 1991, 2013, Oracle. All rights reserved.

  4. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=sink)(PORT=1521)))
  5. The command completed successfully
  6. [grid@sink ~]$ lsnrctl start

  7. LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 13-JAN-2018 21:14:59

  8. Copyright (c) 1991, 2013, Oracle. All rights reserved.

  9. Starting /u01/11.2.0/grid/bin/tnslsnr: please wait...

  10. TNSLSNR for Linux: Version 11.2.0.4.0 - Production
  11. System parameter file is /u01/11.2.0/grid/network/admin/listener.ora
  12. Log messages written to /u01/app/grid/diag/tnslsnr/sink/listener/alert/log.xml
  13. Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=sink)(PORT=1521)))

  14. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=sink)(PORT=1521)))
  15. STATUS of the LISTENER
  16. ------------------------
  17. Alias LISTENER
  18. Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
  19. Start Date 13-JAN-2018 21:14:59
  20. Uptime 0 days 0 hr. 0 min. 0 sec
  21. Trace Level off
  22. Security ON: Local OS Authentication
  23. SNMP OFF
  24. Listener Parameter File /u01/11.2.0/grid/network/admin/listener.ora
  25. Listener Log File /u01/app/grid/diag/tnslsnr/sink/listener/alert/log.xml
  26. Listening Endpoints Summary...
  27.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=sink)(PORT=1521)))
  28. Services Summary...
  29. Service "gotime_dgmgrl" has 1 instance(s).
  30.   Instance "gotime", status UNKNOWN, has 1 handler(s) for this service...
  31. The command completed successfully
  32. [grid@sink ~]$
  33. [grid@sink ~]$ lsnrctl status

  34. LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 13-JAN-2018 21:15:03

  35. Copyright (c) 1991, 2013, Oracle. All rights reserved.

  36. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=sink)(PORT=1521)))
  37. STATUS of the LISTENER
  38. ------------------------
  39. Alias LISTENER
  40. Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
  41. Start Date 13-JAN-2018 21:14:59
  42. Uptime 0 days 0 hr. 0 min. 4 sec
  43. Trace Level off
  44. Security ON: Local OS Authentication
  45. SNMP OFF
  46. Listener Parameter File /u01/11.2.0/grid/network/admin/listener.ora
  47. Listener Log File /u01/app/grid/diag/tnslsnr/sink/listener/alert/log.xml
  48. Listening Endpoints Summary...
  49.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=sink)(PORT=1521)))
  50.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1522)))
  51. Services Summary...
  52. Service "gotime_dgmgrl" has 1 instance(s).
  53.   Instance "gotime", status UNKNOWN, has 1 handler(s) for this service...
  54. The command completed successfully

==================  配置FSF(fast_start failover ==============================


在主库主机上配置configuration

  1. [root@slow ~]# su - oracle
  2. [oracle@slow ~]$ dgmgrl
  3. DGMGRL for Linux: Version 11.2.0.4.0 - 64bit Production

  4. Copyright (c) 2000, 2009, Oracle. All rights reserved.

  5. Welcome to DGMGRL, type "help" for information.
  6. DGMGRL> connect
  7. Username: sys
  8. Password:
  9. Connected.
  10. DGMGRL> create configuration 'slow_cfg1' as primary database is 'slow' connect identifier is 'slow';
  11. #################最后面这个slow是tnsname.ora里面的名称#########################
  12. Configuration "slow_cfg1" created with primary database "slow"
  13. DGMGRL> show configuration

  14. Configuration - slow_cfg1

  15.   Protection Mode: MaxAvailability
  16.   Databases:
  17.     slow - Primary database

  18. Fast-Start Failover: DISABLED

  19. Configuration Status:
  20. DISABLED

  21. DGMGRL> add database 'gotime' as connect identifier is 'gotime' maintained as physical;

    1. #################最后面这个gotime是tnsname.ora里面的名称#########################

  22. Database "gotime" added
  23. DGMGRL> show configuration;

  24. Configuration - slow_cfg1

  25.   Protection Mode: MaxAvailability
  26.   Databases:
  27.     slow - Primary database
  28.     gotime - Physical standby database

  29. Fast-Start Failover: DISABLED

  30. Configuration Status:
  31. DISABLED

  32. DGMGRL> enable configuration;
  33. Enabled.
  34. DGMGRL> show configuration;

  35. Configuration - slow_cfg1

  36.   Protection Mode: MaxAvailability
  37.   Databases:
  38.     slow - Primary database
  39.     gotime - Physical standby database

  40. Fast-Start Failover: DISABLED

  41. Configuration Status:
  42. SUCCESS

  43. DGMGRL> start observer;
  44. Observer started
  45. ...
  46. 至此不能继续进行,需要新建一个连接窗口继续配置

此为新建窗口,继续配置...

  1. [oracle@slow ~]$ export ORACLE_SID=gotime
  2. [oracle@slow ~]$ echo $ORACLE_SID
  3. gotime
  4. [oracle@slow ~]$ dgmgrl
  5. DGMGRL for Linux: Version 11.2.0.4.0 - 64bit Production

  6. Copyright (c) 2000, 2009, Oracle. All rights reserved.

  7. Welcome to DGMGRL, type "help" for information.
  8. DGMGRL> connect
  9. Username: sys
  10. Password:
  11. Connected.
  12. DGMGRL> show database verbose slow
  13. ORA-01034: ORACLE not available
  14. Process ID: 0
  15. Session ID: 0 Serial number: 0

  16. Configuration details cannot be determined by DGMGRL
  17. DGMGRL> exit
  18. [oracle@slow ~]$ export ORACLE_SID=slow
  19. [oracle@slow ~]$ echo $ORACLE_SID
  20. slow
  21. [oracle@slow ~]$ dgmgrl
  22. DGMGRL for Linux: Version 11.2.0.4.0 - 64bit Production

  23. Copyright (c) 2000, 2009, Oracle. All rights reserved.

  24. Welcome to DGMGRL, type "help" for information.
  25. DGMGRL> connect
  26. Username: sys
  27. Password:
  28. Connected.
  29. DGMGRL> show database verbose slow

  30. Database - slow

  31.   Role: PRIMARY
  32.   Intended State: TRANSPORT-ON
  33.   Instance(s):
  34.     slow

  35.   Properties:
  36.     DGConnectIdentifier = 'slow'
  37.     ObserverConnectIdentifier = ''
  38.     LogXptMode = 'SYNC'
  39.     DelayMins = '0'
  40.     Binding = 'optional'
  41.     MaxFailure = '0'
  42.     MaxConnections = '1'
  43.     ReopenSecs = '300'
  44.     NetTimeout = '30'
  45.     RedoCompression = 'DISABLE'
  46.     LogShipping = 'ON'
  47.     PreferredApplyInstance = ''
  48.     ApplyInstanceTimeout = '0'
  49.     ApplyParallel = 'AUTO'
  50.     StandbyFileManagement = 'AUTO'
  51.     ArchiveLagTarget = '0'
  52.     LogArchiveMaxProcesses = '4'
  53.     LogArchiveMinSucceedDest = '1'
  54.     DbFileNameConvert = '/u01/app/oracle/oradata/slow/, /u01/app/oracle/oradata/gotime/'
  55.     LogFileNameConvert = '/u01/app/oracle/oradata/slow/, /u01/app/oracle/oradata/gotime/'
  56.     FastStartFailoverTarget = ''
  57.     InconsistentProperties = '(monitor)'
  58.     InconsistentLogXptProps = '(monitor)'
  59.     SendQEntries = '(monitor)'
  60.     LogXptStatus = '(monitor)'
  61.     RecvQEntries = '(monitor)'
  62.     ApplyLagThreshold = '0'
  63.     TransportLagThreshold = '0'
  64.     TransportDisconnectedThreshold = '30'
  65.     SidName = 'slow'
  66.     StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=slow)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=slow_DGMGRL)(INSTANCE_NAME=slow)(SERVER=DEDICATED)))'
  67.     StandbyArchiveLocation = '/dsk1/arch_slow/'
  68.     AlternateLocation = ''
  69.     LogArchiveTrace = '0'
  70.     LogArchiveFormat = '%t_%s_%r.arc'
  71.     TopWaitEvents = '(monitor)'

  72. Database Status:
  73. SUCCESS

  74. DGMGRL> show database verbose gotime;

  75. Database - gotime

  76.   Role: PHYSICAL STANDBY
  77.   Intended State: APPLY-ON
  78.   Transport Lag: 0 seconds (computed 1 second ago)
  79.   Apply Lag: 0 seconds (computed 1 second ago)
  80.   Apply Rate: 0 Byte/s
  81.   Real Time Query: OFF
  82.   Instance(s):
  83.     gotime

  84.   Properties:
  85.     DGConnectIdentifier = 'gotime'
  86.     ObserverConnectIdentifier = ''
  87.     LogXptMode = 'SYNC'
  88.     DelayMins = '0'
  89.     Binding = 'OPTIONAL'
  90.     MaxFailure = '0'
  91.     MaxConnections = '1'
  92.     ReopenSecs = '300'
  93.     NetTimeout = '30'
  94.     RedoCompression = 'DISABLE'
  95.     LogShipping = 'ON'
  96.     PreferredApplyInstance = ''
  97.     ApplyInstanceTimeout = '0'
  98.     ApplyParallel = 'AUTO'
  99.     StandbyFileManagement = 'AUTO'
  100.     ArchiveLagTarget = '0'
  101.     LogArchiveMaxProcesses = '4'
  102.     LogArchiveMinSucceedDest = '1'
  103.     DbFileNameConvert = '/u01/app/oracle/oradata/slow/, /u01/app/oracle/oradata/gotime/'
  104.     LogFileNameConvert = '/u01/app/oracle/oradata/slow/, /u01/app/oracle/oradata/gotime/'
  105.     FastStartFailoverTarget = ''
  106.     InconsistentProperties = '(monitor)'
  107.     InconsistentLogXptProps = '(monitor)'
  108.     SendQEntries = '(monitor)'
  109.     LogXptStatus = '(monitor)'
  110.     RecvQEntries = '(monitor)'
  111.     ApplyLagThreshold = '0'
  112.     TransportLagThreshold = '0'
  113.     TransportDisconnectedThreshold = '30'
  114.     SidName = 'gotime'
  115.     StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=sink)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=gotime_DGMGRL)(INSTANCE_NAME=gotime)(SERVER=DEDICATED)))'
  116.     StandbyArchiveLocation = '/dsk1/arch_gotime/'
  117.     AlternateLocation = ''
  118.     LogArchiveTrace = '0'
  119.     LogArchiveFormat = '%t_%s_%r.arc'
  120.     TopWaitEvents = '(monitor)'

  121. Database Status:
  122. SUCCESS

  123. DGMGRL> show configuration;

  124. Configuration - slow_cfg1

  125.   Protection Mode: MaxAvailability
  126.   Databases:
  127.     slow - Primary database
  128.     gotime - Physical standby database

  129. Fast-Start Failover: DISABLED

  130. Configuration Status:
  131. SUCCESS

  132. DGMGRL> enable fast_start failover;
  133. Enabled.
  134. DGMGRL> show configuration;

  135. Configuration - slow_cfg1

  136.   Protection Mode: MaxAvailability
  137.   Databases:
  138.     slow - Primary database
  139.     gotime - (*) Physical standby database

  140. Fast-Start Failover: ENABLED

  141. Configuration Status:
  142. SUCCESS

  143. DGMGRL>

=============== 开始测试==========  前面是准备工作很重要,否则失败 =================

此时主库的状态,是,primary

  1. 21:26:27 SYS @ slow >select status from v$instance;

  2. STATUS
  3. ------------
  4. OPEN

  5. 1 row selected.

  6. Elapsed: 00:00:00.01
  7. 21:41:31 SYS @ slow >select name,open_mode,database_role,protection_mode,switchover_status from v$database;

  8. NAME     OPEN_MODE     DATABASE_ROLE    PROTECTION_MODE SWITCHOVER_STATUS
  9. --------- -------------------- ---------------- -------------------- --------------------
  10. SLOW     READ WRITE     PRIMARY        MAXIMUM AVAILABILITY SESSIONS ACTIVE

  11. 1 row selected.

  12. Elapsed: 00:00:00.00

此时备库的状态,是,physical standby

  1. 21:50:41 SYS @ gotime >select status from v$instance;

  2. STATUS
  3. ------------
  4. MOUNTED

  5. 1 row selected.

  6. Elapsed: 00:00:00.01
  7. 21:53:15 SYS @ gotime >alter database open;

  8. Database altered.

  9. Elapsed: 00:00:01.26
  10. 21:53:37 SYS @ gotime >select name,open_mode,database_role,protection_mode,switchover_status from v$database;

  11. NAME     OPEN_MODE     DATABASE_ROLE    PROTECTION_MODE SWITCHOVER_STATUS
  12. --------- -------------------- ---------------- -------------------- --------------------
  13. SLOW     READ ONLY WITH APPLY PHYSICAL STANDBY MAXIMUM AVAILABILITY NOT ALLOWED

  14. 1 row selected.

  15. Elapsed: 00:00:00.03

主库意外宕机。。。

  1. 21:48:16 SYS @ slow >shutdown abort;
  2. ORACLE instance shut down.
  3. 21:56:45 SYS @ slow >

几秒钟后。。。之前配置configuration时候,不能继续进行的窗口,弹出,显示failover successful!!!

  1. DGMGRL> start observer;
  2. Observer started
  3. ...

  4. 21:57:17.41 Saturday, January 13, 2018
  5. Initiating Fast-Start Failover to database "gotime"...
  6. Performing failover NOW, please wait...
  7. Failover succeeded, new primary is "gotime"
  8. 21:57:22.68 Saturday, January 13, 2018

那么此时备库(physical standby)应该成主库(primary)了,瞅一下,对了,那么成功!!!

  1. 21:53:51 SYS @ gotime >select status from v$instance;
  2. select status from v$instance
  3. *
  4. ERROR at line 1:
  5. ORA-03135: connection lost contact
  6. Process ID: 11015
  7. Session ID: 18 Serial number: 7


  8. ERROR:
  9. ORA-03114: not connected to ORACLE


  10. Elapsed: 00:00:00.00
  11. 21:57:25 SYS @ gotime >conn / as sysdba
  12. Connected.
  13. 21:57:42 SYS @ gotime >select status from v$instance;

  14. STATUS
  15. ------------
  16. OPEN

  17. 1 row selected.

  18. Elapsed: 00:00:00.01
  19. 21:57:50 SYS @ gotime >select name,database_role,protection_mode,switchover_status from v$database;

  20. NAME     DATABASE_ROLE PROTECTION_MODE    SWITCHOVER_STATUS
  21. --------- ---------------- -------------------- --------------------
  22. SLOW     PRIMARY     MAXIMUM AVAILABILITY NOT ALLOWED

  23. 1 row selected.

  24. Elapsed: 00:00:00.01
  25. 21:58:27 SYS @ gotime >



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31405474/viewspace-2150128/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/31405474/viewspace-2150128/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值