Oracle 10g使用RMAN创建physical standby(二)

日期: 2008-11-03 作者:Anna 来源:TechTarget中国 英文

主库:


  listener.ora


  SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(SID_NAME = PLSExtProc)

(ORACLE_HOME = /u01/oracle/product/10.2.0)

(PROGRAM = extproc)

)

)


  LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = s1.gti.com)(PORT = 1521))

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))

)

)

tnsnames.ora


  dbprimary =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.131)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = orcl)

)

)


  dbstandby =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.132)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = orcl)

)

)

备库:


  listener.ora


  SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(SID_NAME = orcl)

(ORACLE_HOME = /u01/oracle/product/10.2.0)

)

)


  LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.132)(PORT = 1521))

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))

)

)
  tnsnames.ora


  dbprimary =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.131)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = orcl)

)

)


  dbstandby =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.132)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = orcl)

)

)


  7.使用rman备份主库


  [oracle@s1 ~]$ rman target /


  Recovery Manager: Release 10.2.0.1.0 – Production on Thu May 29 19:52:37 2008


  Copyright (c) 1982, 2005, Oracle. All rights reserved.


  connected to target database: ORCL (DBID=1171867028)


  RMAN> backup full format=’/u02/db_%U’

database include current controlfile for standby;


  ……………….


  8.归档主库当前日志

SQL> alter system archive log current;

System altered.

9.启动备库到nomount

sqlplus “/ as sysdba”

Connected to an idle instance.

SQL> startup nomount


  Total System Global Area 285212672 bytes

Fixed Size 1218992 bytes

Variable Size 96470608 bytes

Database Buffers 184549376 bytes

Redo Buffers 2973696 bytes

10.利用rman恢复备库

[oracle@s1 ~]$ rman target /


  Recovery Manager: Release 10.2.0.1.0 – Production on Thu May 29 19:53:21 2008


  Copyright (c) 1982, 2005, Oracle. All rights reserved.


  connected to target database: ORCL (DBID=1171867028)


  RMAN> connect auxiliary sys/a@dbstandby


  connected to auxiliary database: ORCL (DBID=1171867028, not mount)


  RMAN> duplicate target database for standby nofilenamecheck;


  ………………………..

如果第8步没有归档当前日志,duplicate时可能出现错误:

RMAN-05507: standby controlfile checkpoint (710256) is more recent than duplicat

ion point in time (709530)

至此,备库创建成功。

11.将备库置于自动恢复状态

SQL> conn / as sysdba

Connected.

SQL>alter database recover managed standby database disconnect from session;

Media recovery complete.

12.switchover


  物理STANDBY的SWITCHOVER切换会把当前的一个物理STANDBY切换为PRIMARY数据库,而PRIMARY数据库且变成物理STNADBY数据库。


  一般SWITCHOVER切换都是计划中的切换,特点是在切换后,不会丢失任何的数据,而且这个过程是可逆的,整个DATA GUARD环境不会被破坏,原来DATA GUARD环境中的所有物理和逻辑STANDBY都可以继续工作。


  在进行DATA GUARD的物理STANDBY切换前需要注意:


  确认主库和从库间网络连接通畅;


  确认没有活动的会话连接在数据库中;


  PRIMARY数据库处于打开的状态,STANDBY数据库处于MOUNT状态;


  确保STANDBY数据库处于ARCHIVELOG模式;


  如果设置了REDO应用的延迟,那么将这个设置去掉;


  确保配置了主库和从库的初始化参数,使得切换完成后,DATA GUARD机制可以顺利的运行。

主库:


  [oracle@s1 ~]$ sqlplus “/ as sysdba”


  SQL*Plus: Release 10.2.0.1.0 – Production on Thu May 29 19:55:02 2008


  Copyright (c) 1982, 2005, Oracle. All rights reserved.

Connected to:

Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 – Production

With the Partitioning, OLAP and Data Mining options


  SQL> alter database commit to switchover to physical standby;


  Database altered.


  SQL> shutdown immediate;

ORA-01507: database not mounted

ORACLE instance shut down.

SQL> startup nomount

ORACLE instance started.


  Total System Global Area 285212672 bytes

Fixed Size 1218992 bytes

Variable Size 96470608 bytes

Database Buffers 184549376 bytes

Redo Buffers 2973696 bytes

SQL> alter database mount standby database;


  Database altered.


  SQL> alter database recover managed standby database disconnect from session;


  Database altered.

备库:


  SQL> alter database commit to switchover to primary;


  Database altered.


  SQL> shutdown immediate;

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

SQL> startup

ORACLE instance started.


  Total System Global Area 285212672 bytes

Fixed Size 1218992 bytes

Variable Size 96470608 bytes

Database Buffers 184549376 bytes

Redo Buffers 2973696 bytes

Database mounted.

Database opened.

SQL>


  至此完成自由切换。

我们一直都在努力坚持原创.......请不要一声不吭,就悄悄拿走。

我原创,你原创,我们的内容世界才会更加精彩!

【所有原创内容版权均属TechTarget,欢迎大家转发分享。但未经授权,严禁任何媒体(平面媒体、网络媒体、自媒体等)以及微信公众号复制、转载、摘编或以其他方式进行使用。】

微信公众号

TechTarget微信公众号二维码

TechTarget

官方微博

TechTarget中国官方微博二维码

TechTarget中国

电子邮件地址不会被公开。 必填项已用*标注

敬请读者发表评论,本站保留删除与本文无关和不雅评论的权力。

相关推荐

  • DBA必须掌握的数据库恢复管理技术

    如果没有备份副本,数据库管理员就无法还原数据库,所以DBA在恢复之前倾向于考虑备份是合乎逻辑的。 但是,对我来说,这种逻辑一直是错误的。

  • Oracle备份和恢复简史

    这些年来,Oracle数据库备份和恢复方式已经发生了重大变化,特别是在Recovery Manager(RMAN)功能有了进一步改善之后。

  • Oracle 数据库12c新特性总结(一)

    本系列文章是Oracle ACE总监Syed Jaffer Hussain对Oracle数据库12c的一些新特性总结,包括数据库管理、RMAN、高可用性以及性能调优等内容。

  • Oracle 10g/11g Latch机制的变化

    Oracle的Latch机制采用spin来进行持有CPU的不断尝试,虽然通常Latch的获取会非常快(一般在微秒级),但是很多时候Latch竞争还是会引发极为严重的CPU争用。