Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

[DG] Data Guard master / slave library Switchover switch

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

First, check before switching. Standby library check that manager recovery is running

SQL > SELECT PROCESS FROM V$MANAGED_STANDBY WHERE PROCESS LIKE 'MRP%'

two。 The main library checks that database is in real-time application state.

SQL > SELECT RECOVERY_MODE FROM V$ARCHIVE_DEST_STATUS WHERE DEST_ID=2

RECOVERY_MODE

MANAGED REAL TIME APPLY

If the slave database is not in the state of real-time application, you need to restart the real-time application

SQL > ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL

SQL > ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT

3. Ensure that the temporary files of the main library and the standby library match

For temporary files, a temporary file repository that ensures that the main library exists should also exist. After the initial standby library is created, the temporary files newly created by the primary library will not be transferred to the standby library. The master and slave libraries execute the following SQL:

SQL > SELECT TMP.NAME FILENAME, BYTES, TS.NAME TABLESPACE

FROM V$TEMPFILE TMP, V$TABLESPACE TS WHERE TMP.TS#=TS.TS#

If the query does not match, the mismatch needs to be corrected immediately.

4. Ensure that all data files are in online state

SQL > SELECT NAME FROM V$DATAFILE WHERE STATUS='OFFLINE'

If there is a data file in the offline state, you need to offline the data file before switchover.

5. Make sure there is no GAP in the repository.

Prepare for database execution

SQL > SELECT THREAD#, LOW_SEQUENCE#, HIGH_SEQUENCE# FROM V$ARCHIVE_GAP

THREAD# LOW_SEQUENCE# HIGH_SEQUENCE#

1 8 0 82

If no result is returned, there is no GAP; if there is a result, there is a GAP. The above results show that the GAP content contains the archive log sequence80,81,82. You need the master database to copy the above archive log, transfer it to the standby database, and register it in the standby database, as follows

SQl > ALTER DATABASE REGISTER PHYSICAL LOGFILE 'filespec1'

Second, clear thinking

Step1: cleanup parameters and jobs

Step2: ensure that the switching status of the main database is normal

Step3: the main library executes switchover

Step4: check that the slave database switch status is normal.

Step5: prepare the database to execute switchover

Step6: open the new main library and standby library

Step7: real-time application log of new repository

Step8: check the status of master and slave libraries

Third, switchover switch 1. Clean up parameters and jobs that may block handover

1) View the currently executed JOBS

SQL > SELECT * FROM DBA_JOBS_RUNNING

SQL > SELECT OWNER, JOB_NAME, START_DATE, END_DATE, ENABLED FROM DBA_SCHEDULER_JOBS WHERE ENABLED='TRUE' AND OWNER 'SYS'

If you have a running job, terminate the job if necessary.

2) terminate the current job

SQL > EXECUTE DBMS_SCHEDULER.DISABLE (job_name)

two。 Make sure that the main library switchover_status is normal.

SQL > select switchover_status from v$database

SWITCHOVER_STATUS

-

SESSIONS ACTIVE

Note: the status of the main library should be to primary or session active. If the state of the main library is session active, you need to append the with session shutdown option when switching. If the primary library is RAC, stop the second node before switching.

3. The main library executes switchover to the standby library.

SQL > ALTER DATABASE COMMIT TO SWITCHOVER TO STANDBY WITH SESSION SHUTDOWN

4. Check that the standby database switchover_status is normal

SQL > select switchover_status from v$database

SWITCHOVER_STATUS

-

To primary

5. Standby library switchover as the main library

SQL > ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN

At this point, the new master database is in Mount state, and the new standby database is in shutdown state.

6. Open the new main library

SQL > alter database open

7. Open the new library

SQL > startup

At this point, the new slave library mode is read only

8. Real-time application log of new library

SQL > ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT

9. Check the status of the master and standby libraries

SQL > select db_unique_name,open_mode,database_role,switchover_status from v$database

-end

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report