Oracle单实例数据库迁移到Oracle RAC 环境之(3)--主备库Switchover

简介:

系统环境:

操作系统:RedHat EL55

Oracle : Oracle 11.2.0.1.0

集群软件:Oracle GI 11.2.0.1.0

本案例采用的是基于DataGuard的迁移方式

wKioL1N9ovKhMVJ1AAGFVMkanCc961.jpg

主备库实施切换,将RAC database切换成主库,既可以完成数据的迁移。

主库:

8:18:00 SYS@ cuug>select name,dbid,database_role,protection_mode,switchover_status from v$database;

NAME            DBID DATABASE_ROLE    PROTECTION_MODE      SWITCHOVER_STATUS

--------- ---------- ---------------- -------------------- --------------------

CUUG      1329392875 PRIMARY          MAXIMUM PERFORMANCE  TO STANDBY

备库:

SQL> select name,dbid,database_role,protection_mode,switchover_status from v$database;

NAME            DBID DATABASE_ROLE    PROTECTION_MODE      SWITCHOVER_STATUS

--------- ---------- ---------------- -------------------- --------------------

CUUG      1329392875 PHYSICAL STANDBY MAXIMUM PERFORMANCE  NOT ALLOWED



1、首先将主库(单实例)切换成备库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
18 : 20 : 51  SYS@ cuug>alter database commit to switchover to standby with session shutdown ;
Database altered.
 
18 : 21 : 25  SYS@ cuug>shutdown
ORA- 01507 : database not mounted
ORACLE instance shut down.
 
18 : 21 : 55  SYS@ cuug>startup mount;
ORACLE instance started.
Total System Global Area   418484224  bytes
Fixed Size                   1336932  bytes
Variable Size              264243612  bytes
Database Buffers           146800640  bytes
Redo Buffers                 6103040  bytes
Database mounted.
 
18 : 22 : 03  SYS@ cuug>select name,dbid,database_role,protection_mode,switchover_status from v$database;
NAME            DBID DATABASE_ROLE    PROTECTION_MODE      SWITCHOVER_STATUS
--------- ---------- ---------------- -------------------- --------------------
CUUG       1329392875  PHYSICAL STANDBY MAXIMUM PERFORMANCE  TO PRIMARY
Elapsed:  00 : 00 : 00.01
18 : 22 : 08  SYS@ cuug>recover managed standby database disconnect from session;
Media recovery complete.

2、将备库(RAC)切换成主库

SQL> alter database commit to switchover to primary;

Database altered.

SQL> alter database open;

Database altered.

SQL> select name,dbid,database_role,protection_mode,switchover_status from v$database;

NAME            DBID DATABASE_ROLE    PROTECTION_MODE      SWITCHOVER_STATUS

--------- ---------- ---------------- -------------------- --------------------

CUUG      1329392875 PRIMARY          MAXIMUM PERFORMANCE  RESOLVABLE GAP

SQL> alter system switch logfile;

System altered.

SQL> select name,dbid,database_role,protection_mode,switchover_status from v$database;

NAME            DBID DATABASE_ROLE    PROTECTION_MODE      SWITCHOVER_STATUS

--------- ---------- ---------------- -------------------- --------------------

CUUG      1329392875 PRIMARY          MAXIMUM PERFORMANCE  TO STANDBY

@至此,DG切换成功


3、启动node2上的Instnace(stddb2)

1
2
3
4
5
6
7
SQL> startup
ORACLE instance started.
Total System Global Area   418484224  bytes
Fixed Size                   1336932  bytes
Variable Size              318769564  bytes
Database Buffers            92274688  bytes
Redo Buffers                 6103040  bytes

ORA-01618: redo thread 2 is not enabled - cannot mount

启动失败,解决方法:

1)查看实例1的redo日志

SQL> select group#,thread#,sequence#,status,bytes from v$log;

    GROUP#    THREAD#  SEQUENCE# STATUS                BYTES

---------- ---------- ---------- ---------------- ----------

         1          1         31 CURRENT            52428800

         2          1         29 INACTIVE           52428800

         3          1         30 ACTIVE             52428800

缺少thread 2的日志,对于RAC应该有两个thread !

2)添加thread 2日志组

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
SQL> alter database add logfile thread  2  ( '+dg1' , '+rcy1' ) size 50m;
Database altered.
 
SQL> alter database add logfile thread  2  ( '+dg1' , '+rcy1' ) size 50m;
Database altered.
 
SQL> alter database add logfile thread  2  ( '+dg1' , '+rcy1' ) size 50m;
Database altered.
 
SQL> select group#,member  from  v$logfile order by  1 ;
     GROUP# MEMBER
---------- --------------------------------------------------
          1  +DG1/stddb/onlinelog/redo01a.log
          1  +RCY1/stddb/onlinelog/redo01b.log
          2  +RCY1/stddb/onlinelog/redo02b.log
          2  +DG1/stddb/onlinelog/redo02a.log
          3  +DG1/stddb/onlinelog/redo03a.log
          3  +RCY1/stddb/onlinelog/redo03b.log
          4  +DG1/stddb/onlinelog/group_4 .280.848169735
          4  +RCY1/stddb/onlinelog/group_4 .287.848169817
          5  +DG1/stddb/onlinelog/group_5 .281.848169749
          5  +RCY1/stddb/onlinelog/group_5 .288.848169827
          6  +DG1/stddb/onlinelog/group_6 .282.848169759
     GROUP# MEMBER
---------- --------------------------------------------------
          6  +RCY1/stddb/onlinelog/group_6 .289.848169831
12  rows selected.

3)激活thread 2

SQL> alter database enable thread 2;

Database altered.

4)再从node 2 open database

SQL> alter database open;

alter database open

*

ERROR at line 1:

ORA-01092: ORACLE instance terminated. Disconnection forced

ORA-30012: undo tablespace 'UNDOTBS2' does not exist or of wrong type

Process ID: 10707

Session ID: 1 Serial number: 3

看来是缺少undo tablespace;


回到node 1添加表空间:

SQL> alter system set db_create_file_dest='+dg1';

System altered.

SQL> create undo tablespace undotbs2;

Tablespace created.

重新在node2上启动Instance:

1
2
3
4
5
6
7
8
9
SQL> startup 
ORACLE instance started.
Total System Global Area   418484224  bytes
Fixed Size                   1336932  bytes
Variable Size              318769564  bytes
Database Buffers            92274688  bytes
Redo Buffers                 6103040  bytes
Database mounted.
Database opened.

SQL> show parameter undo

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

undo_management                      string      AUTO

undo_retention                       integer     900

undo_tablespace                      string      UNDOTBS2

SQL> 

@至此,node2上的Instance 启动完毕,数据迁移完成。


4、将RAC上的database和Instance注册到CRS

由于RAC是基于CRS管理的,需要把database和instance注册到CRS里进行管理

1)注册数据库

[oracle@node1 ~]$ srvctl add database -d stddb -o $ORACLE_HOME -n cuug

2)注册实例

[oracle@node1 ~]$ srvctl add instance -d stddb -i stddb1 -n node1

[oracle@node1 ~]$ srvctl add instance -d stddb -i stddb2 -n node2

3)启动数据库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[oracle @node1  ~]$ srvctl start database -d stddb
通过node1连接:
[oracle @node1  ~]$ sqlplus  '/as sysdba'
SQL*Plus: Release  11.2 . 0.1 . 0  Production on Wed May  21  19 : 18 : 37  2014
Copyright (c)  1982 2009 , Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release  11.2 . 0.1 . 0  - Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
 
SQL> select instance_name,status from gv$instance;
INSTANCE_NAME    STATUS
---------------- ------------
stddb1           OPEN
stddb2           OPEN

通过node2连接:

1
2
3
4
5
6
7
8
[oracle @node2  admin]$ export ORACLE_SID=stddb2
[oracle @node2  admin]$ sqlplus  '/as sysdba'
SQL*Plus: Release  11.2 . 0.1 . 0  Production on Wed May  21  19 : 19 : 53  2014
Copyright (c)  1982 2009 , Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release  11.2 . 0.1 . 0  - Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

@至此,整个数据迁移的工作全部完成,对于单实例的原来的主库,可以继续作为备库构建容灾的环境,保护数据安全!










本文转自 客居天涯 51CTO博客,原文链接:http://blog.51cto.com/tiany/1415383,如需转载请自行联系原作者
目录
相关文章
|
运维 Oracle 前端开发
Oracle 11g RAC集群日常运维命令总结
Oracle 11g RAC集群日常运维命令总结
630 2
|
存储 Oracle 关系型数据库
|
SQL Oracle 关系型数据库
关系型数据库Oracle设置 RMAN 环境:
【7月更文挑战第25天】
318 2
|
存储 负载均衡 Oracle
|
Oracle 关系型数据库
分布式锁设计问题之Oracle RAC保证多个节点写入内存Page的一致性如何解决
分布式锁设计问题之Oracle RAC保证多个节点写入内存Page的一致性如何解决
344 0
|
5月前
|
缓存 关系型数据库 BI
使用MYSQL Report分析数据库性能(下)
使用MYSQL Report分析数据库性能
444 158
|
5月前
|
关系型数据库 MySQL 数据库
自建数据库如何迁移至RDS MySQL实例
数据库迁移是一项复杂且耗时的工程,需考虑数据安全、完整性及业务中断影响。使用阿里云数据传输服务DTS,可快速、平滑完成迁移任务,将应用停机时间降至分钟级。您还可通过全量备份自建数据库并恢复至RDS MySQL实例,实现间接迁移上云。
|
5月前
|
关系型数据库 MySQL 数据库
阿里云数据库RDS费用价格:MySQL、SQL Server、PostgreSQL和MariaDB引擎收费标准
阿里云RDS数据库支持MySQL、SQL Server、PostgreSQL、MariaDB,多种引擎优惠上线!MySQL倚天版88元/年,SQL Server 2核4G仅299元/年,PostgreSQL 227元/年起。高可用、可弹性伸缩,安全稳定。详情见官网活动页。
1038 152
|
5月前
|
关系型数据库 MySQL 数据库
阿里云数据库RDS支持MySQL、SQL Server、PostgreSQL和MariaDB引擎
阿里云数据库RDS支持MySQL、SQL Server、PostgreSQL和MariaDB引擎,提供高性价比、稳定安全的云数据库服务,适用于多种行业与业务场景。
814 156

推荐镜像

更多