单机上快速搭建一个Data Guard环境

保证主库testdatabase logging,archive状态下,并能正常运行状态。

.修改$ORACLE_HOME/dbs/inittest.ora
*.control_files='/u01/app/oracle/oradata/control01.ctl'#Restore Controlfile
*.db_cache_size=37748736
*.db_name='test'
*.db_unique_name='test'
*.local_listener='(ADDRESS=(PROTOCOL=tcp)(HOST=blliu)(PORT=1521))'
*.log_archive_dest_1='LOCATION=/u01/app/oracle/archivelogs VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=test'
*.log_archive_dest_state_1=enable
*.log_archive_format='%t_%s_%r.ARC'
*.streams_pool_size=12582912
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.log_archive_config='DG_CONFIG=(test,test222)'
*.log_archive_dest_2='SERVICE=test222 LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLES) DB_UNIQUE_NAME=test222'
*.log_archive_dest_state_2=enable
*.compatible=10.2.0.4.0
fal_server='test'
fal_client='test222'

standby_file_management=auto
db_file_name_convert=/u01/app/oracle/test222/oradata,/u01/app/oracle/oradata
log_file_name_convert=/u01/app/oracle/test222/oradata,/u01/app/oracle/oradata
db_recovery_file_dest=/u01/app/oracle/flashback_recovery_area
db_recovery_file_dest_size=2G


.修改$ORACLE_HOME/dbs/inittest222.ora
control_files='/u01/app/oracle/test222/oradata/ctlstandby.ctl'
db_cache_size=37748736
db_name='test'
db_unique_name='test222'
local_listener='(ADDRESS=(PROTOCOL=tcp)(HOST=blliu)(PORT=1521))'
log_archive_dest_1='LOCATION=/u01/app/oracle/test111/archivelogs VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=test222'
log_archive_dest_state_1=enable
log_archive_format='%t_%s_%r.ARC'
streams_pool_size=12582912
undo_management='AUTO'
undo_tablespace='UNDOTBS1'
log_archive_config='DG_CONFIG=(test,test222)'
log_archive_dest_2='SERVICE=test LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLES) DB_UNIQUE_NAME=test'
log_archive_dest_state_2=enable
db_file_name_convert=/u01/app/oracle/oradata,/u01/app/oracle/test222/oradata
log_file_name_convert=/u01/app/oracle/oradata,/u01/app/oracle/test222/oradata
background_dump_dest=/u01/app/oracle/test222/admin/bdump/
user_dump_dest=/u01/app/oracle/test222/admin/udump/
core_dump_dest=/u01/app/oracle/test222/admin/cdump/
fal_server='test222'
fal_client='test'
standby_file_management=auto
compatible=10.2.0.4.0

.创建相应目录:
mkdir -p /u01/app/oracle/test222/admin/bdump
mkdir -p /u01/app/oracle/test222/admin/cdump
mkdir -p /u01/app/oracle/test222/admin/udump
mkdir -p /u01/app/oracle/test222/oradata
mkdir -p /u01/app/oracle/test222/archivelogs
mkdir -p /u01/app/oracle/test222/rman


.创建密码文件:
orapwd file=$ORACLE_HOME/dbs/orapwtest password=oracle entries=5
orapwd file=$ORACLE_HOME/dbs/orapwtest222 password=oracle entries=5


.修改$ORACLE_HOME/network/admin/listener.ora
SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = test)
      (ORACLE_HOME = /u01/app/oracle/db_1)
      (SID_NAME = test)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = test222)
      (ORACLE_HOME = /u01/app/oracle/db_1)
      (SID_NAME = test222)
    )
  )

完成后重启监听!

.修改$ORACLE_HOME/network/admin/tnsnames.ora
TEST222 =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = test222)
    )
  )

TEST =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = test)
    )
  )

.启动standbynomount模式:
[oracle@blliu admin]$ export ORACLE_SID=test222
[oracle@blliu admin]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Thu Jan 28 23:28:29 2010

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

Connected to an idle instance.

SQL> startup nomount
ORACLE instance started.

Total System Global Area  171966464 bytes
Fixed Size                  2082496 bytes
Variable Size             125831488 bytes
Database Buffers           37748736 bytes
Redo Buffers                6303744 bytes
.利用rman工具中的duplicate进行standby控制文件、数据文件的创建:
[oracle@blliu dbs]$ echo $ORACLE_SID
test
[oracle@blliu dbs]$ rman target / auxiliarysys/oracle@test222

Recovery Manager: Release 10.2.0.4.0 - Production on Thu Jan 28 23:31:38 2010

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

connected to target database: TEST (DBID=2003741378)
connected to auxiliary database: TEST (not mounted)

RMAN> backup database include current controlfile for standby;

RMAN> duplicate target database for standby;


.启动standby管理模式(第八步完成后,standby已经是mount状态)
[oracle@blliu dbs]$ export ORACLE_SID=test222
[oracle@blliu dbs]$ sqlplus / as sysdba

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

Database altered.
.重启主数据库
[oracle@blliu dbs]$ export ORACLE_SID=test
[oracle@blliu dbs]$ sqlplus / as sysdba
SQL> shutdown immediate
SQL> startup

十一.查看/u01/app/oracle/test222/admin/bdump/alert_test222.log
如果有以下文字表示standby创建成功,并开始正常运行了:
Thu Jan 28 23:37:58 2010
Media Recovery Log /u01/app/oracle/test111/archivelogs/1_13_709083440.ARC
Media Recovery Waiting for thread 1 sequence 14 (in transit)

至此,单机上一个最简单的Data Guard环境搭建完毕。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值