DataGuard - Physical Standby简明配置步骤

Physical Standby配置

修改控制文件,修改最大日志组为10

alter database backup controlfile to trace;

 

ORACLE_HOME/opt/oracle/app/oracle/product/ 9.2.0

190作为primary185作为Standby

 

创建StandbyOracle软件

打包Primary上的oracle软件

cd /opt/oracle/app/oracle/product

tar cvf db.tar 9.2.0

ftpStandby服务器相应目录

 

创建Standby上的Oracle软件目录结构

mkdir -p /opt/oracle/app/oracle/product

cd /opt/oracle/app/oracle/product

tar xvf db.tar

 

cd /opt/oracle/app/oracle

mkdir -p admin/ctsdb/bdump

mkdir -p admin/ctsdb/cdump

mkdir -p admin/ctsdb/udump

 

创建Standby上的dbaoracle用户修改oracle用户的环境变量修改/etc/system文件

 

1。设置Primary强制Logging

ALTER DATABASE FORCE LOGGING;

 

2。设置Primary为归档模式

 

3。检查Primary中所有数据文件

 

4。关闭Primary,关闭应用服务器,停止监听

 

5cp所有数据文件到本地备份路径

 

6。启动Primary,保持监听和应用服务器处于停止状态

 

7。生成Standby控制文件

ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/tmp/stdby.ctl';

 

8。生成初始化参数文件

CREATE PFILE='/tmp/initctsdb.ora' FROM SPFILE;

 

9。将5,7,8中生成的所有文件以及密码文件cpStandby服务器

 

10。修改Standby的初始化参数文件

添加下面行:

*.standby_archive_dest='/export/spare/oradata/ctsdb/archive'

*.fal_server='ctsdb.primary'

*.fal_client='ctsdb.standby'

*.standby_file_management=auto

*.remote_archive_enable=TRUE

 

11。修改PrimaryStandbylisener.oratnsnames.ora文件

# LISTENER.ORA Network Configuration File: /opt/oracle/app/oracle/product/ 9.2.0 /

network/admin/listener.ora

# Generated by Oracle configuration tools.

 

SID_LIST_LISTENER_DG =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = ctsdb)

      (ORACLE_HOME = /opt/oracle/app/oracle/product/ 9.2.0 )

      (SID_NAME = ctsdb)

    )

  )

 

LISTENER_DG =

  (DESCRIPTION =

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

  )

 

 

# TNSNAMES.ORA Network Configuration File: /opt/oracle/app/oracle/product/ 9.2.0 /

network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

 

CTSDB.STANDBY =

  (DESCRIPTION =

    (ADDRESS_LIST =

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

    )

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SID = ctsdb)

    )

  )

 

CTSDB.PRIMARY =

  (DESCRIPTION =

    (ADDRESS_LIST =

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

    )

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SID = ctsdb)

    )

  )

 

12。设置StandbySQLNET.ORA文件

添加SQLNET.EXPIRE_TIME=2,该配置表示在Standby由于故障不可用时,Primary将持续检测2分钟,如果仍然不可用,则返回网络连接错误。

 

13。创建Standbyspfile

CREATE SPFILE FROM PFILE='/tmp/initctsdb.ora';

 

14。启动Standby

STARTUP NOMOUNT;

ALTER DATABASE MOUNT STANDBY DATABASE;

 

添加standby redolog

alter database add standby logfile group 4 ('/export/spare/oradata/ctsdb/stdby_redo04.log') size 10240K;

alter database add standby logfile group 5 ('/export/spare/oradata/ctsdb/stdby_redo05.log') size 10240K;

alter database add standby logfile group 6 ('/export/spare/oradata/ctsdb/stdby_redo06.log') size 10240K;

alter database add standby logfile group 7 ('/export/spare/oradata/ctsdb/stdby_redo07.log') size 10240K;

 

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

 

为了防止以后primarystandby切换,可以在primary上也建立相应的standby redolog

 

15。设置Primary的归档地址

ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=CTSDB.STANDBY LGWR' SCOPE=BOTH;

ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE SCOPE=BOTH;

 

16。测试Primary的归档能否应用到Standby

ALTER SYSTEM ARCHIVE LOG CURRENT;

 

17。停止Standby

alter database recover managed standby database finish;

shutdown immediate;

 

18。切换到只读模式

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

ALTER DATABASE OPEN READ ONLY;

 

19。切换回管理恢复模式

ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

 

以上为MAX PERFORMANCE模式的DataGuard

如果要改为MAX AVAILABILITY,进行如下操作:

检查当前Primary库的保护模式

select protection_mode from v$database;

 

转换:

shutdown immediate;

startup mount;

alter database set standby database to maximize availability;

alter database open;

 

如果要强制Primary一分种归档一次,那么设置Primary的初始化参数ARCHIVE_LAG_TARGET

alter system set ARCHIVE_LAG_TARGET=60 scope=both;

 

如果想要自动在Standby上应用Primary中创建数据文件等操作,需要在Standby上设置:

alter system set STANDBY_FILE_MANAGEMENT=AUTO scope=both;

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值