码迷,mamicode.com
首页 > 其他好文 > 详细

[terry笔记]11gR2_DataGuard搭建_拷贝数据文件

时间:2014-07-02 19:25:53      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   java   color   strong   

11gR2搭建dataguard环境:

自己做的实验,后续按照rman模式搭建、主备切换、模式调整等实验会陆续发上来。

 

primary

OS:oel 6.4

database:11.2.0.4.0

192.168.100.131

hostname=node4

ORACLE_SID=good

ORACLE_HOME=/u01/product/11.2.0

db_unique_name=good

 

standby

OS:oel 6.4

database:11.2.0.4.0

192.168.100.132

ORACLE_SID=good

ORACLE_HOME=/u01/product/11.2.0

db_unique_name=bad

 

两边oracle用户的环境变量:

export ORACLE_BASE=/u01

export ORACLE_HOME=$ORACLE_BASE/product/11.2.0

export ORACLE_SID=good

export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib

alias s=‘sqlplus / as sysdba‘ 

 

1.primary打开force logging和归档:

alter database force logging;
startup mount; 
alter database archivelog; 
alter database open; 

 

2.配置primary参数,并添加standby logfile,以用来将来主备切换

alter system set db_unique_name=good scope=spfile;

alter system set log_archive_config= DG_CONFIG=(good,bad) scope=spfile;

alter system set log_archive_dest_1= LOCATION=/u01/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=good scope=spfile;

alter system set log_archive_dest_2= SERVICE=bad LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=bad scope=spfile;

alter system set log_archive_dest_state_1 = enable;

alter system set log_archive_dest_state_2 = enable;

alter system set fal_server=bad scope=spfile;

alter system set fal_client=good scope=spfile;

alter system set standby_file_management=AUTO scope=spfile;

 

alter database add standby logfile
group 4 (/u01/oradata/good/standby04.log)size 50m,
group 5 (/u01/oradata/good/standby05.log)size 50m,
group 6 (/u01/oradata/good/standby06.log)size 50m,
group 7 (/u01/oradata/good/standby07.log)size 50m;

 

3.重启一次验证以上修改没问题:

shutdown immeidate
startup

 

4.创建standby controlfile、pfile

alter database create standby controlfile as /u01/control01.ctl;
create pfile from spfile;

 

5.关闭primary

shutdown immediate

 

6.配置primary的listener.ora、tnsname.ora,listner要用静态监听,传到standby时注意修改host

# listener.ora Network Configuration File: /u01/product/11.2.0/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
        (ORACLE_HOME = /u01/product/11.2.0)
          (PROGRAM = extproc)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = good)
        (ORACLE_HOME = /u01/product/11.2.0)
      (SID_NAME = good)
  )
)
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

ADR_BASE_LISTENER = /u01

 

# tnsnames.ora Network Configuration File: /u01/product/11.2.0/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

GOOD =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.131)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = good)
    )
  )

BAD =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.132)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = good)
    )
  )

 

 

7.copy file to standby 

监听文件:listener.ora、tnsnames.ora --$ORACLE_HOME/network/admin

参数文件:initgood.ora  --$ORACLE_HOME/dbs

密码文件:orapwgood  --$ORACLE_HOME/dbs

standby控制文件:control01.ctl  --$ORACLE_BASE/oradata/good

全库备份文件:*.dbf、*.log  --$ORACLE_BASE/oradata/good

日志目录(或直接创建文件夹):$ORACLE_BASE/admin、$ORACLE_BASE/diag、$ORACLE_BASE/flash_recovery_area

 

8.修改standby参数文件,蓝色标注的需要重点关注

good.__db_cache_size=222298112
good.__java_pool_size=4194304
good.__large_pool_size=8388608
good.__oracle_base=/u01#ORACLE_BASE set from environment
good.__pga_aggregate_target=192937984
good.__sga_target=360710144
good.__shared_io_pool_size=0
good.__shared_pool_size=113246208
good.__streams_pool_size=0
*.audit_file_dest=/u01/admin/good/adump
*.audit_trail=db
*.compatible=11.2.0.4.0
*.control_files=/u01/oradata/good/control01.ctl
*.db_block_size=8192
*.db_domain=‘‘
*.db_name=good
*.db_recovery_file_dest=/u01/fast_recovery_area
*.db_recovery_file_dest_size=4385144832
*.db_unique_name=‘bad‘
*.diagnostic_dest=/u01
*.dispatchers=(PROTOCOL=TCP) (SERVICE=goodXDB)
*.fal_client=‘bad‘
*.fal_server=‘good‘
*.log_archive_config=‘dg_config=(good,bad)‘
*.log_archive_dest_1=‘location=/u01/arch valid_for=(all_logfiles,all_roles) db_unique_name=bad‘
*.log_archive_dest_2=‘service=good lgwr sync valid_for=(online_logfiles,primary_role) db_unique_name=good‘
*.log_archive_dest_state_1=‘ENABLE‘
*.log_archive_dest_state_2=‘ENABLE‘
*.memory_target=550502400
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile=EXCLUSIVE
*.standby_file_management=‘AUTO‘
*.undo_tablespace=UNDOTBS1

 

9.启动两边监听

lsnrctl start

此时可以测试两边是否连通
sqlplus sys/xxx@good as sysdba
sqlplus sys/xxx@bad as sysdba
tnsping good
tnsping bad
select * from v$instance;

 

10.standby启动至mount并应用日志

startup mount;

alter database recover managed standby database using current logfile disconnect from session;

 

11.primary启动

startup

 

12.验证

观察primary与standby的/u01/arch,当primary切换时,standby的归档也会增加。

primary:
alter system switch logfile; SELECT STATUS,DESTINATION, ERROR FROM V$ARCHIVE_DEST; select max(sequence#) from v$archived_log; --主备结果一致

 

13.standby启动read only with apply,此时可以查询standby库同时可以从primary恢复(此为11g特性,10g如果read only打开standby库,不可以同时恢复)

alter database recover managed standby database cancel;

alter database open;

alter database recover managed standby database using current logfile disconnect from session;

select open_mode from v$database;

 

dataguard启动与关闭顺序:

启动:先standby后primary

关闭:先primary后standby

 

[terry笔记]11gR2_DataGuard搭建_拷贝数据文件,布布扣,bubuko.com

[terry笔记]11gR2_DataGuard搭建_拷贝数据文件

标签:des   style   blog   java   color   strong   

原文地址:http://www.cnblogs.com/kkterry/p/3819322.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!