电脑技术学习

Oracle数据库9i DataGuard的安装与维护

dn001
一、安装

环境:

Primary 数据库:sun01

Standby 数据库:sun02

Oracle_Sid:bnet

1. 拷贝$ORACLE_BASE 到新机器上

2. 让Primary数据库处于归档模式,对Primary数据库做一个Rman热备份

startup mount

alter database archivelog;

archive log list;

rman target sys/oracle

backup database format "/....";

3.创建Data Guard数据库控制文件

alter database create standby controlfile as '/....ctl';

4.设置监听

Primary:

bnetguard =

( (DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = sun02)(PORT = 1522))

)

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = bnet)

)

)

Standby:

listener.ora

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))

)

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = sun01)(PORT = 1522))

)

)

)

tnsname.ora

bnet =

( (DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = sun02)(PORT = 1522))

)

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = bnet)

)

)

5. 设置主机参数

alter database force logging;

主库强制归档

主机参数:

fal_client=bnetguard

fal_server=bnet

standby_file_management=auto

remote_login_passwordfile=exclusive

备机参数:

db_file_name_convert

log_file_name_convert

standby_file_management='AUTO'

standby_archive_dest=/export/home/oracle/oradata/bnet/arch

6.创建standby 数据库

orapwd

sqlplus "sys/oracle as sysdba"

startup nomount pfile='''

alter database mount standby database;

exit

rman target sys/oracle nocatalog

restore database

7.设置自动归档

alter system set log_archive_dest_2='server=bnetguard reopen=200'

8.启动Data Guard自动恢复状态

sqlplus "sys/oracle as sysdba"<

recover managed standby database;

exit

EOF

9.测试

alter system archive log current;

二、维护:

使Standby 数据库处与 read-only状态

reover cancel/recover managed standby database cancel;

取消恢复模式

alter database open read only;

启动数据库到只读状态

recover standby database;

使数据库切换到恢复模式

recover managed standby database time out 15;

如果超过15分钟没有传日志

Restarting dead background process QMN0

"Restarting dead background process QMN" message can continually

appear in the alert log during startup in RAC environment.

Workaround:

Set aq_tm_processes=0 in the init.ora.

It can be set to desired value through

"alter system set aq_tm_processes=n" once the database is open completely.

alter database activate standby database;