oracle 11g switchover

WBOY
풀어 주다: 2016-06-07 16:36:38
원래의
1115명이 탐색했습니다.

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

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿