oracle 搭建dg步骤

Wesley13
• 阅读 662

    如果搭建dg 先安装主库database 并建库,同时建备库database 软件,不需要建库。

1    主库打开归档功能

        启动到mount状态下,打开归档功能

        alter database archivelog;

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     17
Next log sequence to archive   19
Current log sequence           19
# 检查已经打开归档功能

2    配置主库监听和tnsnames文件

# listener.ora Network Configuration File: /u01/oracle/11g/network/admin/listene
r.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = orcl)
      (ORACLE_HOME = /u01/oracle/11g)
      (SID_NAME = orcl)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = porcl)    
      (ORACLE_HOME = /u01/oracle/11g)
      (SID_NAME = orcl)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = porcl_DGMGRL)
      (ORACLE_HOME = /u01/oracle/11g)
      (SID_NAME = orcl)
    )
  )

LISTENER =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = dghost)(PORT = 1521))
  )

ADR_BASE_LISTENER = /u01/oracle


[oracle@dghost root]$ cat /u01/oracle/11g/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/oracle/11g/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

SORCL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = dgstandby)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = sorcl)
    )
  )

PORCL =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = dghost)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = porcl)
    )
  )

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = dghost)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl.dghost)
    )
  )

    备库也配置监听

    注意主库和备库配置完监听要用tnsping测试都能ping通

[oracle@dghost root]$ tnsping porcl

TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 17-JAN-2017 00:19:12

Copyright (c) 1997, 2011, Oracle.  All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = dghost)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = porcl)))
OK (10 msec)
#主库tnsping自己成功
[oracle@dghost root]$ tnsping sorcl

TNS Ping Utility for Linux: Version 11.2.0.3.0 - Production on 17-JAN-2017 00:19:42

Copyright (c) 1997, 2011, Oracle.  All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = dgstandby)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = sorcl)))
OK (20 msec)
#主库tnsping备库成功
# 下面同样需要在备库中tnsping自己和主库,这里就不一一举例

3    主库修改db_unique_name

SQL> show parameter db_un

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_unique_name                       string      PORCL  #db_unique_name 需要配置成tnsname里面能解析的域名
db_unrecoverable_scn_tracking        boolean     TRUE
# alter system set db_unique_name='porcl' scope=spfile;

4    主库修改standby_file_management

SQL> show parameter standby_f

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
standby_file_management              string      AUTO #修改为auto

5    主库打开强制日志和dg_broker

    alter database force logging;

SQL> show parameter dg_b

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
dg_broker_config_file1               string      /u01/oracle/11g/dbs/dr1PORCL.d
                                                 at
dg_broker_config_file2               string      /u01/oracle/11g/dbs/dr2PORCL.d
                                                 at
dg_broker_start                      boolean     TRUE #设置为true 打开

6    增加备库日志

    alter database add standby logfile;

    多增加几个

7    切换日志

        alter system switch logfile;

        多切换几次

8    主库参数文件拷贝到备库中

[oracle@dgstandby dbs]$ strings spfileorcl.ora
orcl.__db_cache_size=218103808
orcl.__java_pool_size=4194304
orcl.__large_pool_size=4194304
orcl.__oracle_base='/u01/oracle'#ORACLE_BASE set from environment
orcl.__pga_aggregate_target=205520896
orcl.__sga_target=381681664
orcl.__shared_io_pool_size=0
orcl.__shared_pool_size=142606336
orcl.__streams_pool_size=4194304
*.archive_lag_target=0
*.audit_file_dest='/u01/oracle/admin/orcl/adump' #备库需要创建这个目录 
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u01/oracle/oradata/orcl/control01 #备库需要创建这个目录
.ctl','/u01/oracle/fast_recovery_area/orcl/control02.ctl' #备库需要创建这个目录
*.db_block_size=8192
*.db_domain='dghost'
*.db_name='orcl'
*.db_recovery_file_dest='/u01/oracle/fast_recovery_area' #备库需要创建这个目录
*.db_recovery_file_dest_size=4322230272
*.db_unique_name='SORCL'
*.dg_broker_start=TRUE
*.diagnostic_dest='/u01/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
*.fal_server='porcl'
*.log_archive_config='dg_config=(SORCL,porcl)'
*.log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST','valid_for=(ALL_LOG
FILES, ALL_ROLES)'
orcl.log_archive_format='%t_%s_%r.dbf'
*.log_archive_max_processes=4
*.log_archive_min_succeed_dest=1
orcl.log_archive_trace=0
*.memory_target=585105408
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'

    备库启动到nomount状态下,如果能正常启动到nomount 状态下说明参数文件没有问题

9    主库密码文件拷贝到备库

10    在备库中克隆

[oracle@dgstandby dbs]$ rman target sys/oracle@porcl auxiliary sys/oracle@sorcl nocatalog;

Recovery Manager: Release 11.2.0.3.0 - Production on Tue Jan 17 00:31:46 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=1461163151)
using target database control file instead of recovery catalog
connected to auxiliary database: ORCL (DBID=1461163151)
# 通过rman链接了主库和备库

RMAN> duplicate target database for standby nofilenamecheck from active database;
# 用这个进行克隆,不能有任何错误

11   dgbroker 创建主库和备库

DGMGRL for Linux: Version 11.2.0.3.0 - 64bit Production

Copyright (c) 2000, 2009, Oracle. All rights reserved.

Welcome to DGMGRL, type "help" for information.
Connected.
#进入 dgbroker 环境
DGMGRL> help create

Creates a broker configuration

Syntax:

  CREATE CONFIGURATION <configuration name> AS
    PRIMARY DATABASE IS <database name>
    CONNECT IDENTIFIER IS <connect identifier>;
# 使用帮助查看创建dgbroker的语法
DGMGRL> CREATE CONFIGURATION dgc as PRIMARY DATABASE IS porcl CONNECT IDENTIFIER IS porcl;
# 创建主库dgbroker
DGMGRL> help add

Adds a standby database to the broker configuration

Syntax:

  ADD DATABASE <database name>
    [AS CONNECT IDENTIFIER IS <connect identifier>]
    [MAINTAINED AS {PHYSICAL|LOGICAL}];
#使用帮助文档查看添加备库dgbroker的语法
DGMGRL> ADD DATABASE sorcl as CONNECT IDENTIFIER  IS sorcl;

12    激活dgbroker

DGMGRL> enable configuration;

13    启动备库到open 中测试主库和备库是否实时同步。

14    主备切换

        switchover to sorcl;

点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
待兔 待兔
3个月前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Jacquelyn38 Jacquelyn38
3年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
Stella981 Stella981
3年前
DataGuard之DG环境搭建
DG环境搭建1.设置归档模式DG环境的搭建必须要把数据库启动到归档模式,并且为了避免开发人员使用nologging语句,我们还要把数据库设置为forcelogging。查看数据库是否运行在归档模式:su oracle$sqlplus/assysdbaSQLarchiveloglist;!(https:/
Wesley13 Wesley13
3年前
Oracle 12c DG备库Alert报错ORA
环境是12.2.0.1version,OracleDataGuard备库近段时间一直报错,但是备库主库同步一致,数据一致。20190306T23:42:22.18404808:00Errorsinfile/u01/app/oracle/diag/rdbms/ccdb/ccdb/trace/ccdb_m000_12
Stella981 Stella981
3年前
30分钟创建一个Oracle11g DataGuard物理备库的步骤
30分钟创建一个Oracle11gDataGuard物理备库的步骤:主库主机名:prmy备库主机名:sby1主库ip:192.168.1.1备库ip:192.168.1.2 主库dbname:prmy备库dbname:sby1主库db\_unique\_nameprmy备库db\_unique\_names
Wesley13 Wesley13
3年前
Oracle physical dataguard with broker部署
一、环境说明主库:10.110.96.88备库:10.110.96.87数据库实例:gisc二、主库操作1.开启forceloggingALTERDATABASEFORCELOGGING;2.开启日志归档a.查看日志归档是否开启ARCHIVELOGLI
Stella981 Stella981
3年前
Android蓝牙连接汽车OBD设备
//设备连接public class BluetoothConnect implements Runnable {    private static final UUID CONNECT_UUID  UUID.fromString("0000110100001000800000805F9B34FB");
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
9个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这