oracle dataguard搭建请看如下链接 http://www.itopers.com/?p=679 switchover主要是在数据库升级,硬件升级等进行。如下将如何进行switchover: 在prmary将数据库设置为standby SQL alter database commit to switchover to physical standby;Database alte
oracle dataguard搭建请看如下链接
http://www.itopers.com/?p=679
switchover主要是在数据库升级,硬件升级等进行。如下将如何进行switchover:
在prmary将数据库设置为standby
SQL> alter database commit to switchover to physical standby; Database altered.
11g时,执行这个命令后,数据库已经关闭了,不需要手动进行关闭了
SQL> select db_unique_name,database_role,open_mode,switchover_status from v$database; select db_unique_name,database_role,open_mode,switchover_status from v$database * ERROR at line 1: ORA-01034: ORACLE not available Process ID: 2650 Session ID: 458 Serial number: 211
然后启动启动到mount状态查看:
SQL> startup mount ORACLE instance started. Total System Global Area 1.3462E+10 bytes Fixed Size 2265984 bytes Variable Size 3321891968 bytes Database Buffers 1.0133E+10 bytes Redo Buffers 4460544 bytes Database mounted. SQL> select db_unique_name,database_role,open_mode,switchover_status from v$database; DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE ------------------------------ ---------------- -------------------- SWITCHOVER_STATUS -------------------- actvdb01 PHYSICAL STANDBY MOUNTED RECOVERY NEEDED
查看已经是PHYSICAL STANDBY状态了。
打开数据库,这个时候应该是read only状态:
SQL> alter database open; Database altered. SQL> select db_unique_name,database_role,open_mode,switchover_status from v$database; DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE ------------------------------ ---------------- -------------------- SWITCHOVER_STATUS -------------------- actvdb01 PHYSICAL STANDBY READ ONLY RECOVERY NEEDED
这个时候primary已经变成了standby了。
然后连接到之前的standby服务器上:
先查看状态,确定日志应用是否完整
SQL> select db_unique_name,database_role,open_mode from v$database; DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE ------------------------------ ---------------- -------------------- actvdb02 PHYSICAL STANDBY READ ONLY WITH APPLY SQL> archive log list Database log mode Archive Mode Automatic archival Enabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 348 Next log sequence to archive 0 Current log sequence 353 SQL> alter database recover managed standby database cancel; Database altered. SQL> select db_unique_name,database_role,open_mode from v$database; DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE ------------------------------ ---------------- -------------------- actvdb02 PHYSICAL STANDBY READ ONLY
然后将standby切换成primary
SQL> alter database commit to switchover to primary; Database altered. SQL> select db_unique_name,database_role,open_mode from v$database; DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE ------------------------------ ---------------- -------------------- actvdb02 PRIMARY MOUNTED
完成后,状态已经变成的primary了,注意,在执行切换过程中,不能有任何session连接,如果有会有如下报错:
SQL> alter database commit to switchover to primary; alter database commit to switchover to primary * ERROR at line 1: ORA-01093: ALTER DATABASE CLOSE only permitted with no sessions connected
把session关闭掉,重新执行即可。
然后打开数据库,在新primary中(也就是老的standby)
SQL> alter database open; Database altered. SQL> select db_unique_name,database_role,open_mode from v$database; DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE ------------------------------ ---------------- -------------------- actvdb02 PRIMARY READ WRITE SQL> select db_unique_name,database_role,open_mode,switchover_status from v$database; DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE ------------------------------ ---------------- -------------------- SWITCHOVER_STATUS -------------------- actvdb02 PRIMARY READ WRITE TO STANDBY
查看状态已经变成了primary,且为read write了。表示已经成功从standby转成primary了
然后再登录到standby中(之前的primary中)启用mrp进程
SQL> alter database recover managed standby database using current logfile disconnect from session; Database altered. SQL> select db_unique_name,database_role,open_mode,switchover_status from v$database; DB_UNIQUE_NAME DATABASE_ROLE OPEN_MODE ------------------------------ ---------------- -------------------- SWITCHOVER_STATUS -------------------- actvdb01 PHYSICAL STANDBY READ ONLY WITH APPLY NOT ALLOWED
再查看进程已经是应用日志状态了。
到新的primary中将创建表测试是否能正常应用日志:
SQL> create table test.t11 (id number)tablespace test; Table created.
到standby中查看已经能正常传输、应用日志了:
SQL> select owner,table_name from dba_tables where owner='TEST'; OWNER TABLE_NAME ------------------------------ ------------------------------ TEST T2 TEST TEST_TABLE TEST TEST01 TEST TEST02 TEST TEST03 TEST T4 TEST T5 TEST T7 TEST T6 TEST T8 TEST T11 OWNER TABLE_NAME ------------------------------ ------------------------------ TEST T9 12 rows selected.
只要前面 的配置没有问题,switchover是很简单的,特别注意以下几点:
*.local_listener 这个配置是的自己的tnsname名字
*.fal_client=’actvdb’??? 这个配置的是自己的tnsname,不管是primary,还是standby
*.fal_server=’actvdbbak’?? 这个配置的是对方的tnsname,不管是primary,还是standby
原文地址:oracle 11g switchover, 感谢原作者分享。

Mastering the method of adding MySQL users is crucial for database administrators and developers because it ensures the security and access control of the database. 1) Create a new user using the CREATEUSER command, 2) Assign permissions through the GRANT command, 3) Use FLUSHPRIVILEGES to ensure permissions take effect, 4) Regularly audit and clean user accounts to maintain performance and security.

ChooseCHARforfixed-lengthdata,VARCHARforvariable-lengthdata,andTEXTforlargetextfields.1)CHARisefficientforconsistent-lengthdatalikecodes.2)VARCHARsuitsvariable-lengthdatalikenames,balancingflexibilityandperformance.3)TEXTisidealforlargetextslikeartic

Best practices for handling string data types and indexes in MySQL include: 1) Selecting the appropriate string type, such as CHAR for fixed length, VARCHAR for variable length, and TEXT for large text; 2) Be cautious in indexing, avoid over-indexing, and create indexes for common queries; 3) Use prefix indexes and full-text indexes to optimize long string searches; 4) Regularly monitor and optimize indexes to keep indexes small and efficient. Through these methods, we can balance read and write performance and improve database efficiency.

ToaddauserremotelytoMySQL,followthesesteps:1)ConnecttoMySQLasroot,2)Createanewuserwithremoteaccess,3)Grantnecessaryprivileges,and4)Flushprivileges.BecautiousofsecurityrisksbylimitingprivilegesandaccesstospecificIPs,ensuringstrongpasswords,andmonitori

TostorestringsefficientlyinMySQL,choosetherightdatatypebasedonyourneeds:1)UseCHARforfixed-lengthstringslikecountrycodes.2)UseVARCHARforvariable-lengthstringslikenames.3)UseTEXTforlong-formtextcontent.4)UseBLOBforbinarydatalikeimages.Considerstorageov

When selecting MySQL's BLOB and TEXT data types, BLOB is suitable for storing binary data, and TEXT is suitable for storing text data. 1) BLOB is suitable for binary data such as pictures and audio, 2) TEXT is suitable for text data such as articles and comments. When choosing, data properties and performance optimization must be considered.

No,youshouldnotusetherootuserinMySQLforyourproduct.Instead,createspecificuserswithlimitedprivilegestoenhancesecurityandperformance:1)Createanewuserwithastrongpassword,2)Grantonlynecessarypermissionstothisuser,3)Regularlyreviewandupdateuserpermissions

MySQLstringdatatypesshouldbechosenbasedondatacharacteristicsandusecases:1)UseCHARforfixed-lengthstringslikecountrycodes.2)UseVARCHARforvariable-lengthstringslikenames.3)UseBINARYorVARBINARYforbinarydatalikecryptographickeys.4)UseBLOBorTEXTforlargeuns


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1
Easy-to-use and free code editor

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool
