Oracle DataGuard是一种数据库级别的HA方案,最主要功能是冗灾、数据保护、故障恢复等。
在生产数据库的"事务一致性"时,使用生产库的物理全备份(或物理COPY)创建备库,备库会通过生产库传输过来的归档日志(或重做条目)自动维护备用数据库。将重做数据应用到备用库。本文介绍使用RMAN备份创建备库(dataguard).
一:Oracle DataGuard环境概述
1.软件环境
操作系统Red Linux Enterprise as 5
数据库版本Oracle 10g release 2
2.primary databae
IP:192.168.18.1
ORACLE_SID=db1
db_unique_name=db1
3.standby database
IP:192.168.18.2
ORACLE_SID=standby
db_unique_name=standby
二,主数据库(db1)做准备
1.设置主数据库为Force logging
SQL> alter database force logging;
2.创建密码文件
cd $ORACLE_HOME/dbs/
orapwdfile=orapwdb1 password=123456 force=y
3.修改主库的初始化参数
alter
system
set
log_archive_config=
'dg_config=(db1,standby)'
scope=both;
alter system set log_archive_dest_1='location=/u01/db1/arch' scope=both;
alter system set db_unique_name='db1' scope=both;
4.生成数据库备份
RMAN>
connect
target sys/123456
RMAN> backup database format='/oracle/rmanback/%d_%s.dbf' plus archivelog;
[oracle@oracle rmanback]$ ls
DB1_1.dbfDB1_2.dbf
5.生成备库的control file
SQL> alter database create standby controlfile as '/oracle/rmanback/ctontrl01
6.配置listener.ora 和tnsnames.ora文件
启动lintener.ora,
[oracle@oracle dbs]$ lsnrctl status
LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 14-JUN-2009 02:54:29
Service "db1" has 1 instance(s).
Instance "db1", status READY, has 1 handler(s) for this service...
Service "db1_XPT" has 1 instance(s).
Instance "db1", status READY, has 1 handler(s) for this service...
The command completed successfully
配置rnsnames.ora
vi $ORACLE_HOME/network/admin/tnsnames.ora
db1 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.18.1)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = db1)
standby =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.18.2)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = standby)
)
)