Home > Database > Mysql Tutorial > oracle 11g switchover

oracle 11g switchover

WBOY
Release: 2016-06-07 16:36:38
Original
1134 people have browsed it

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.
Copy after login

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
Copy after login

然后启动启动到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
Copy after login

查看已经是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
Copy after login

这个时候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
Copy after login

然后将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
Copy after login

完成后,状态已经变成的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
Copy after login

把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
Copy after login

查看状态已经变成了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
Copy after login

再查看进程已经是应用日志状态了。

到新的primary中将创建表测试是否能正常应用日志:

SQL> create table test.t11 (id number)tablespace test;
Table created.
Copy after login

到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.
Copy after login

只要前面 的配置没有问题,switchover是很简单的,特别注意以下几点:

*.local_listener 这个配置是的自己的tnsname名字

*.fal_client=’actvdb’??? 这个配置的是自己的tnsname,不管是primary,还是standby
*.fal_server=’actvdbbak’?? 这个配置的是对方的tnsname,不管是primary,还是standby

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template