Simulate a failover

Source: Internet
Author: User

Simulate a failover

1. Stop the listener of the standby database [oracle @ rhel132 ~] $ Lsnrctl stop2. the master database needs to be restarted. (If the listener is disabled in the slave database, the communication between the master database and the slave database is still not broken. It is a persistent connection ), after that, perform the switch logfile several times: SQL> shutdown immediate; Database closed. databasedismounted. ORACLE instanceshut down. SQL> startupORACLE instancestarted. total SystemGlobal Area 281018368 bytesFixed Size 1218944 bytesVariableSize 100664960 bytesDatabaseBuffers 171966464 bytesRedoBuffers 7168000 bytesDatabasemounted. databaseopened. SQL> altersyst Em switch logfile; System altered. SQL> altersystem switch logfile; System altered. SQL> altersystem switch logfile; System altered.3. view the archive information in the master database: SQL> select sequence #, standby_dest, archived, applied from v $ archived_log; SEQUENCE # staarc app ---------- ------ --- 122 YES 122 no yes 123 no yes no 124 no yes no 125 no yes 126 no yes NO215 rows selected. check the archive information of the slave Database: SQL> select sequence #, standby_dest, Archived, applied from v $ archived_log; SEQUENCE # staarc app ---------- ------ --- 116 no yes 117 no yes 118 no yes 119 no yes 120 no yes 121 no yes 122 NO YES128 rowsselected. four archivelog files are not synchronized. The alert information of the master database is as follows: Thread 1 advanced to log sequence 127 Current log #3 seq #127 mem #0:/u01/app/oracle/oradata/orcl/redo03.log4. now the master database is simulated to have an exception and perform the failover operation. check whether there is a gap in the standby database query: SQL> select * from v $ archive_gap; no rowsselected. If there is a gap, copy the missing log and register it to the standby database. 5. Compare the archivelog of the master database and slave database, and copy the missing log to the slave database. [Oracle @ rhel1_archivelog] $ scp limit 172.17.61.132:/tmporacle@172.17.61.132 'spassword: Limit 100% 1024 1.0KB/s 00:00 [oracle @ rhel1_archivelog] $ scp limit 172.17.61.132:/tmporacle@172.17.61.132' spassword: 2017124_794505797.dbf 100% 57KB 56.5KB/s 00:00 [oracle @ rhel1_archivelog] $ scp 0000125_791_5797.dbf 172.17.61.132:/tmporacle@172.17.61.132 'spassword: Limit 125_79380 5797. dbf 100% 1024 1.0KB/s [oracle @ rhel1_archivelog] $ scp limit 172.17.61.132:/tmporacle@172.17.61.132 'spassword: Limit 100% 2048 2.0KB/s apply the above four logs to the database in the slave database: SQL> alterdatabase register logfile '/tmp/FIG; Databasealtered. SQL> alterdatabase register logfile '/tmp/FIG; Databasealtered. SQL> alterdatabase register logfile '/tmp/limit 125 _ 793805797. dbf'; Databasealtered. SQL> alter database register logfile '/tmp/FIG; Databasealtered. 6. after all archive logs are applied to the standby database, you must copy the redo log to the standby database for recover [oracle @ rhel1_orcl] $ scp redo * 172.17.61.132: /tmp the status of the application log to be terminated before recover: SQL> alterdatabase recover managed standby database cancel; Databasealtered. SQL> recoverstandby database until cancel; ORA-00279: change 603271 generated at 08/06/2013 13:52:08 needed for thread 1ORA-00289: suggestion:/u01/app/oracle/oradata/orcl/archivelog/1_127_794505797.dbfora-00280: change 603271 for thread 1 is in sequence #127 Specify log: {<RET> = suggested | filename | AUTO | CANCEL}/tmp/redo03.logLog applied. media recoverycomplete. because log no. 127th is generated by redo03.log from the alert log of the master database, you need to restore the redo03.log information. 7. Change the role of the standby database to the master database and open it normally. SQL> alterdatabase activate standby database; Databasealtered. SQL> alterdatabase open; Databasealtered. SQL> selectdatabase_role, open_mode from v $ database; DATABASE_ROLE OPEN_MODE--------------------------PRIMARY READ WRITESQL> archivelog list; database logmode Archive ModeAutomaticarchival EnabledArchivedestination/u01/app/oracle/oradata/orcl/archivelog/Oldest onlinelog sequence 1 Next logsequence to archive 2 Current logsequence 2

 

Now this database has nothing to do with the previous master database, and the redo log is also compiled from No. 1.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.