CentOS 5.11下Oracle 11G R2 DataGuard搭建

Datagard算是Oracle企业版的一种容灾方案,在企业中广泛应用,我就将搭建过程记录下来以作备用。
主机名    数据库版本    实例名    IP
db1    Oracle 11G R2    member    172.16.1.250
db2    Oracle 11G R2    member    172.16.1.251
默认情况下以上都已经安装好了Oracle数据库,但是只在db1上建立了数据库和监听,db2只安装Oracle软件不建库,不建监听。

目录:

打开强制归档日志

增加standby日志组

修改主备启动参数

密码文件的处理

修改监听

复制监听文件、参数文件、密码文件到备库

创建备库控制文件

复制主库数据文件和日志文件到备库

初始化及配置备库做standby

DataGuard测试

主备切换测试

基础工作:
    a.安装CentOS 5.11 x86_64,关闭selinux,iptables,自动对时
    b.安装Oracle 11G R2,db1安装软件、监听及建库,db2只安装软件不建库
    可以参考:  与

在db1的/etc/hosts里增加
127.0.0.1      db1
172.16.1.251    db2
在db2的/etc/hosts里增加
127.0.0.1      db2
172.16.1.250    db1

打开强制归档(db1)

(db1)SQL >shutdown immediate;

(db1)SQL >startup mount;
(db1)SQL >alter database force logging;
(db1)SQL >alter database archivelog;
2.创建重做日志组(必须要比原来的redo log多一组或多组,standby redo log是使用Real Time Apply的必要条件)
(db1)SQL> select group#,member from v$logfile;
    GROUP#    MEMBER
-------------  -----------------------------------------------------------------
    3    /opt/oracle/oradata/member/redo03.log
    2    /opt/oracle/oradata/member/redo02.log
    1    /opt/oracle/oradata/member/redo01.log
从上面可以看出现在已经有3组redo log.
(db1)SQL >alter database add standby logfile ('/opt/oracle/oradata/member/standby04.log') size 50m;
(db1)SQL >alter database add standby logfile ('/opt/oracle/oradata/member/standby05.log') size 50m;
(db1)SQL >alter database add standby logfile ('/opt/oracle/oradata/member/standby06.log') size 50m;
(db1)SQL >alter database add standby logfile ('/opt/oracle/oradata/member/standby07.log') size 50m;
再查下日志组是否创建成功
(db1)SQL> select group#,member from v$logfile;
    GROUP#    MEMBER
-------------  -----------------------------------------------------------------
    3    /opt/oracle/oradata/member/redo03.log
    2    /opt/oracle/oradata/member/redo02.log
    1    /opt/oracle/oradata/member/redo01.log
    4    /opt/oracle/oradata/member/standby04.log
    5    /opt/oracle/oradata/member/standby05.log
    6    /opt/oracle/oradata/member/standby06.log
    7    /opt/oracle/oradata/member/standby07.log
可以看到我们创建的4组日志

3.修改主备库的启动参数

生成参数文件
(db1)SQL> create pfile='/tmp/member.pfile' from spfile;
退出sqlplus,用编辑器打开/tmp/member.pfile
[oracle@db1 ~]$ vi /tmp/member.pfile
member.__db_cache_size=331350016
member.__java_pool_size=4194304
member.__large_pool_size=4194304
member.__oracle_base='/opt/oracle'#ORACLE_BASE set from environment
member.__pga_aggregate_target=339738624
member.__sga_target=503316480
member.__shared_io_pool_size=0
member.__shared_pool_size=150994944
member.__streams_pool_size=0
*.audit_file_dest='/opt/oracle/admin/member/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/opt/oracle/oradata/member/control01.ctl','/opt/oracle/flash_recovery_area/member/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='member'
*.db_recovery_file_dest='/opt/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=4070572032
*.diagnostic_dest='/opt/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=memberXDB)'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=839909376
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
#增加一下部分
*.db_unique_name='db1'
*.archive_lag_target=1800
*.fal_client='db1'
*.fal_server='db2'
*.log_archive_config='DG_CONFIG=(db1,db2)'
*.log_archive_dest_1='location=/opt/oracle/flash_recovery_area/ VALID_FOR=(all_logfiles,all_roles) db_unique_name=db1'
*.log_archive_dest_2='service=db2 lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=db2'
*.log_archive_dest_state_1='enable'
*.log_archive_dest_state_2='enable'
*.log_archive_format='%t_%s_%r.dbf'
*.standby_file_management='auto'
*.db_file_name_convert='/opt/oracle/flash_recovery_area',' /opt/oracle/flash_recovery_area'
*.log_file_name_convert='/opt/oracle/flash_recovery_area ','/opt/oracle/flash_recovery_area'

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/aa696af0a864dc12dde30f3378078e3c.html