1、环境信息:
系统:
oracle-linux 5.7

数据库版本:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production

主库:192.168.12.31 SID:yoon db_unique_name:yoon 
备库:192.168.12.231 SID:yoon db_unique_name:yoondg

2、查看DG是否已经安装:
SQL> select * from v$option where parameter = 'Oracle Data Guard';
PARAMETER VALUE
-------------------- --------------------
Oracle Data Guard TRUE
TRUE表示已经安装可以配置,否则需要安装相应软件

3、查看主库是否开启归档:
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 4
Current log sequence 6

4、设置主库为归档模式:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount
ORACLE instance started.

Total System Global Area 2505338880 bytes
Fixed Size 2230952 bytes
Variable Size 553649496 bytes
Database Buffers 1946157056 bytes
Redo Buffers 3301376 bytes
Database mounted.

SQL> alter database archivelog;

Database altered.

SQL> alter database open;

Database altered.

SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 4
Next log sequence to archive 6
Current log sequence 6

5、设置主库为强制记录日志:
SQL> alter database force logging;

Database altered.

6、创建standy log files:
SQL> select group#,member from v$logfile;

GROUP# MEMBER
------- -----------------------------------
3 /opt/oracle/oradata/yoon/redo03.log
2 /opt/oracle/oradata/yoon/redo02.log
1 /opt/oracle/oradata/yoon/redo01.log
添加:
SQL> alter database add standby logfile group 7 '/opt/oracle/oradata/yoon/standby07.log' size 50m;

Database altered.

SQL> alter database add standby logfile group 8 '/opt/oracle/oradata/yoon/standby08.log' size 50m;

Database altered.

SQL> alter database add standby logfile group 9 '/opt/oracle/oradata/yoon/standby09.log' size 50m;

Database altered.

SQL> alter database add standby logfile group 10 '/opt/oracle/oradata/yoon/standby10.log' size 50m;

Database altered.

7、创建standby控制文件:
SQL> shutdown immediate

SQL> startup mount

SQL> alter database create standby controlfile as '/opt/oracle/oradata/yoon/standby_control01.ctl';

Database altered.

SQL>alter database open;

8、设置db_unique_name:
默认db_name和db_unique_name是一样的,主库是yoon
在配置DG中主库和备库的SID可以一样,But,db_unique_name不能相同,备库设置为:yoondg
SQL> show parameter db_unique_name;

NAME TYPE VALUE
------------------------------------ ---------- ------------------------------
db_unique_name string yoon

--注意虽然默认db_unique_name和db_name是一致的,但是需要显式设置,否则在spfile中没有此参数
SQL> alter system set db_unique_name=yoon scope=spfile;

System altered.

9、配置主库listener.ora:
# listener.ora Network Configuration File: /opt/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER=
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = yoon)
(ORACLE_HOME = /opt/oracle/product/11.2.0/db_1/)
(SID_NAME = yoon)
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.31)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)

ADR_BASE_LISTENER = /opt/oracle

配置tnsnames.ora
# listener.ora Network Configuration File: /opt/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

YOON =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.31)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = yoon)
)
)

YOONDG =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.231)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = yoondg)
)
)

10、将主库listener.ora和tnsnames.ora拷贝到备库修改
[root@1231 admin]# scp listener.ora tnsnames.ora oracle@192.168.12.231:/opt/oracle/product/11.2.0/db_1/network/admin/ 
配置listener.ora
# listener.ora Network Configuration File: /opt/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER=
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = yoon)
(ORACLE_HOME = /opt/oracle/product/11.2.0/db_1/)
(SID_NAME = yoon)
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.231)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)

ADR_BASE_LISTENER = /opt/oracle

配置tnsnames.ora
# listener.ora Network Configuration File: /opt/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

YOONDG =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.231)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = yoondg)
)
)

YOON =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.31)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = yoon)
)
)

11、配置完以后在主和备的oralce用户下测试下是否能ping通
主:
[oracle@1231 ~]$ tnsping yoon
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.31)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = yoon)))
OK (0 msec)

[oracle@1231 ~]$ tnsping yoondg
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.231)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = yoondg)))
OK (10 msec)

备:
[oracle@12231 ~]$ tnsping yoon
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.31)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = yoon)))
OK (0 msec)

[oracle@12231 ~]$ tnsping yoondg
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.12.231)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = yoondg)))
OK (0 msec)

12、重做日志传输配置
a.配置归档日志位置:
SQL> alter system set log_archive_dest_1='location=/opt/oracle/archive_bak valid_for=(all_logfiles,primary_roles) db_unique_name=yoon' scope=spfile;

System altered.

b.配置重做日志到备份库:
SQL> alter system set log_archive_dest_2='service=yoondg lgwr sync valid_for=(online_logfiles,primary_role) db_unique_name=yoondg' scope=spfile;

System altered.

13、配置FAL_SERVER
主:
SQL> alter system set fal_server='yoondg';

System altered.

14、Data Guard 配置里的另外一个库的名字
SQL> alter system set log_archive_config='dg_config=(yoon,yoondg)';

System altered.

SQL> alter system set log_archive_dest_state_1=enable scope=spfile;

System altered.

SQL> alter system set log_archive_dest_state_2=enable scope=spfile;

System altered.

SQL> create pfile from spfile;

File created.

SQL> create spfile from pfile;

File created.

15、查看主库inityoon.ora信息
yoon.__db_cache_size=1946157056
yoon.__java_pool_size=16777216
yoon.__large_pool_size=16777216
yoon.__oracle_base='/opt/oracle'#ORACLE_BASE set from environment
yoon.__pga_aggregate_target=838860800
yoon.__sga_target=2516582400
yoon.__shared_io_pool_size=0
yoon.__shared_pool_size=520093696
yoon.__streams_pool_size=0
*.audit_file_dest='/opt/oracle/admin/yoon/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/opt/oracle/oradata/yoon/control01.ctl','/opt/oracle/fast_recovery_area/yoon/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='yoon'
*.db_recovery_file_dest='/opt/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4322230272
*.db_unique_name='YOON'
*.diagnostic_dest='/opt/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=yoonXDB)'
*.fal_server='yoondg'
*.log_archive_config='dg_config=(yoon,yoondg)'
*.log_archive_dest_1='location=/opt/oracle/archive_bak valid_for=(all_logfiles,primary_roles) db_unique_name=yoon'
*.log_archive_dest_2='service=yoondg lgwr sync valid_for=(online_logfiles,primary_role) db_unique_name=yoondg'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.open_cursors=300
*.pga_aggregate_target=837812224
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='AUTO'
*.sga_target=2514485248
*.undo_tablespace='UNDOTBS1'

16、将主库的数据文件、控制文件、参数文件、密码文件拷贝到备库对应的目录
[root@1231 oracle]# scp -r admin/ fast_recovery_area/ oradata/ oracle@192.168.12.231:/opt/oracle/

17、修改备库参数文件
yoon.__db_cache_size=1946157056
yoon.__java_pool_size=16777216
yoon.__large_pool_size=16777216
yoon.__oracle_base='/opt/oracle'#ORACLE_BASE set from environment
yoon.__pga_aggregate_target=838860800
yoon.__sga_target=2516582400
yoon.__shared_io_pool_size=0
yoon.__shared_pool_size=520093696
yoon.__streams_pool_size=0
*.audit_file_dest='/opt/oracle/admin/yoon/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/opt/oracle/oradata/yoon/control01.ctl','/opt/oracle/fast_recovery_area/yoon/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='yoon'
*.db_recovery_file_dest='/opt/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4322230272
*.db_unique_name='YOONDG'
*.diagnostic_dest='/opt/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=yoonXDB)'
*.fal_server='yoon'
*.log_archive_config='dg_config=(yoondg,yoon)'
*.log_archive_dest_1='location=/opt/oracle/archive_bak valid_for=(all_logfiles,primary_roles) db_unique_name=yoondg'
*.log_archive_dest_2='service=yoon lgwr sync valid_for=(online_logfiles,primary_role) db_unique_name=yoon'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='ENABLE'
*.open_cursors=300
*.pga_aggregate_target=837812224
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='AUTO'
*.sga_target=2514485248
*.undo_tablespace='UNDOTBS1'

18、在备库通过pfile创建spfile

19、删除备库的控制文件control01.ctl和control02.ctl
将standby_control01.ctl替换成control01.ctl和control02.ctl

20、启动备库
SQL> startup nomount
ORACLE instance started.

Total System Global Area 2505338880 bytes
Fixed Size 2230952 bytes
Variable Size 553649496 bytes
Database Buffers 1946157056 bytes
Redo Buffers 3301376 bytes
SQL>

SQL> alter database mount standby database;

Database altered.

启用redo应用
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

停止standby
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
SQL>shutdown immediate;

21、备用服务器的管理模式与只读模式
a.启动到管理模式

SQL>shutdown immediate;

SQL>startup nomount;

SQL>alter database mount standby database;

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

b.启动到只读模式
SQL>shutdown immediate;

SQL>startup nomount;

SQL>alter database mount standby database;

SQL> alter database open read only;

c.在管理恢复模式下到只读模式
SQL> recover managed standby database cancel;

SQL> alter database open read only;

d.从只读方式到管理恢复方式
SQL> recover managed standby database disconnect from session;

22、DG启动:
监听:先起备库再起主库

数据库:先起备库再起主库

关闭:与启动相反.

oracle-11g-配置dataguard的更多相关文章

  1. Oracle 11g 物理Dataguard日常操作维护(二)

    Oracle 11g 物理Dataguard日常操作维护(二) 2017年8月25日 14:34 3.3 3.3.1 查看备库进程状态 SYS(125_7)@fpyj123> select pr ...

  2. oracle 11g 配置口令复杂度

    oracle 11g 配置口令复杂度 使用ORACLE自带的utlpwdmg.sql脚本来实现 找到本地的utlpwdmg.sql脚本 find / -name utlpwdmg.sql 查看 /ho ...

  3. ORACLE 11G 配置DG 报ORA-10458、ORA-01152、ORA-01110

    操作系统: Oracle Linux Server release 5.7 数据库版本: Oracle Database 11g Enterprise Edition Release 11.2.0.3 ...

  4. oracle 11G 配置侦听文件

    lsnrctl status   130  2017-08-23 03:15:16 oracle cat /etc/hosts   131  2017-08-23 03:15:26 oracle ca ...

  5. 【Oracle】Oracle安装配置、创建数据库实例及用户和连接

    https://blog.csdn.net/wudiyong22/article/details/78904361 参考资料:https://www.cnblogs.com/hoobey/p/6010 ...

  6. Oracle 11g dataguard check RTA(real time apply)

    Oracle 11g dataguard check RTA(real time apply) 2017年8月24日 16:38 环境:oracle 11.2.0.1 OEL 5.8 注:以下操作都在 ...

  7. Oracle 11g DataGuard搭建(一) - 单节点到单节点

    (一)DataGuard概要 DataGuard中文称为”数据卫士“,提供了数据库高可用性.数据保护和灾难恢复的功能.DataGuard通过建立primary数据库和standby数据库来确立参照关系 ...

  8. Oracle 11g Dataguard参数详解

    https://www.jb51.net/article/52269.htm注:本文译自<Oracle Data Guard 11g Handbook> Page 78 – Page 88 ...

  9. Linux平台oracle 11g单实例 安装部署配置 快速参考

    1.重建主机的Oracle用户 组 统一规范 uid gid 以保证共享存储挂接或其他需求的权限规范 userdel -r oracle groupadd -g 7 oinstall groupadd ...

  10. Oracle 11g DG配置简明版

    环境: 主库A机:在线生产环境,RHEL 6.4 + Oracle 11.2.0.3 备库B机:新增备机,RHEL 6.4 需求: 对生产环境最小影响前提下配置DG备库. 目录: 一.B机安装相同版本 ...

随机推荐

  1. java处理高并发高负载类网站的优化方法

    java处理高并发高负载类网站中数据库的设计方法(java教程,java处理大量数据,java高负载数据) 一:高并发高负载类网站关注点之数据库 没错,首先是数据库,这是大多数应用所面临的首个SPOF ...

  2. 用Shell实现俄罗斯方块代码(Tetris.sh)

    本代码来源于网络: 文件下载地址:http://files.cnblogs.com/files/DreamDrive/Tetris.sh #!/bin/bash # Tetris Game # 10. ...

  3. hdu 3594 仙人掌图

    思路:利用它的几条性质 #include<set> #include<map> #include<cmath> #include<queue> #inc ...

  4. css隐藏元素display:none,opacity:0;filter:alpha(opacity=0-100;,visibility:hidden的区别

    在CSS中,让元素隐藏(指屏幕范围内肉眼不可见)的方法很多,有的占据空间,有的不占据空间:有的可以响应点击,有的不能响应点击.我们一般有三种方式:display:none, opacity:0;fil ...

  5. 十大Intellij IDEA快捷键(转)(2015年06月15日)

    注:本文转自:http://blog.csdn.net/dc_726/article/details/42784275 Intellij IDEA中有很多快捷键让人爱不释手,stackoverflow ...

  6. 基础面试题——Javascript

    1.介绍js的基本数据类型 Undefined.Null.Boolean.Number.String 2.js有哪些内置对象? 数据封装类对象:Object.Array.Boolean.Number ...

  7. .net上传图片并转成二进制流

    话不多说,直接上代码 <input id="InputFile" style="width: 399px" type="file" r ...

  8. cocos2d-x一些核心概念截杀

    Cocos2d-x中有很多概念,这些概念很多来源于动画.动漫和电影等行业,例如:导演.场景和层等概念,当然也有些有传统的游戏的概念.Cocos2d-x中核心概念:导演, 场景,层,节点,精灵,菜单动作 ...

  9. 一次MVVM+ReactiveCocoa实践

    前言 学习MVVM和ReactiveCocoa(简称RAC)也有一段时间了,不过都仅限于看博客,一直对这两个东西很感兴趣,觉得很创新,也一直想找个机会在项目中实践一下,但是还是有一些顾虑,毕竟没有实践 ...

  10. Python中lambda表达式学习

    lambda只是一个表达式,函数体比def简单很多. lambda的主体是一个表达式,而不是一个代码块.仅仅能在lambda表达式中封装有限的逻辑进去. lambda表达式是起到一个函数速写的作用.允 ...