• ORACLE11G搭建DATA GUARD


    一、准备环境
    1、两台虚拟机、一台正常运行oracle数据库的,一台装了软件没有启动数据库的(没有进行dbca)
    2、主库备库 修改环境变量,修改主机名,将主库备库的主机名都写入hosts文件
    二、开始搭建
    1.查看主库是否开启归档模式,查看是否开启强制日志(若没开启则开启)
    SYS@WWDB1> select log_mode,force_logging from v$database;
    SYS@WWDB1> alter database force logging;
    SYS@WWDB1> archive log list;
    SYS@WWDB1> show parameter db_recovery
    SYS@WWDB11> alter system switch logfile;
    2.创建STANDBY LOGFILE
    SYS@WWDB1>define _editor=vim
    SYS@WWDB1>ed1
    alter database add standby logfile group 4 ('/u01/app/oracle/oradata/WWDB1/stlog01.log') size 100m;
    alter database add standby logfile group 5 ('/u01/app/oracle/oradata/WWDB1/stlog02.log') size 100m;
    alter database add standby logfile group 6 ('/u01/app/oracle/oradata/WWDB1/stlog03.log') size 100m;
    alter database add standby logfile group 7 ('/u01/app/oracle/oradata/WWDB1/stlog04.log') size 100m;
    SYS@WWDB1>@1
    3.创建参数文件
    SYS@WWDB1>create pfile from spfile;
    4.修改参数文件
    [oracle@oracle01 ~]$ cd /u01/app/oracle/product/11.2.4/dbhome_1/dbs/
    [oracle@oracle01 dbs]$ vi initWWDB1.ora
    在原有参数文件上添加 下列参数来自于官方文档
    DB_UNIQUE_NAME=WWDB1
    LOG_ARCHIVE_CONFIG='DG_CONFIG=(WWDB1,SBDB1)'
    LOG_ARCHIVE_DEST_1=
     'LOCATION=use_db_recovery_file_dest
      VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
      DB_UNIQUE_NAME=WWDB1'
    LOG_ARCHIVE_DEST_2=
     'SERVICE=SBDB1 ASYNC
      VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
      DB_UNIQUE_NAME=SBDB1'
    LOG_ARCHIVE_DEST_STATE_1=ENABLE
    LOG_ARCHIVE_DEST_STATE_2=ENABLE
    REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
    LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
    #下边的在备库上才有用,在主库中先添加上scp到备库 
    FAL_SERVER=SBDB1
    DB_FILE_NAME_CONVERT='SBDB1','WWDB1'
    LOG_FILE_NAME_CONVERT='SBDB1','WWDB1'
    STANDBY_FILE_MANAGEMENT=AUTO
     
    dg_broker_start=true
    5.修改监听文件
    [oracle@oracle01 admin]$ vi listener.ora
    添加静态监听
    SID_LIST_LISTENER=
      (SID_LIST=
        (SID_DESC=
          (GLOBAL_DBNAME=WWDB1)
          (ORACLE_HOME=/u01/app/oracle/product/11.2.4/dbhome_1)
          (SID_NAME=WWDB1))
        (SID_DESC=
          (GLOBAL_DBNAME=WWDB1_DGMGRL)
          (ORACLE_HOME=/u01/app/oracle/product/11.2.4/dbhome_1)
          (SID_NAME=WWDB1))
        (SID_DESC=
          (SID_NAME=plsextproc)
          (ORACLE_HOME=/u01/app/oracle/product/11.2.4/dbhome_1)
          (PROGRAM=extproc)))      
     
    [oracle@oracle01 admin]$ vi tnsnames.ora
    ##添加如下内容
    SBDB1 =
      (DESCRIPTION =
        (ADDRESS_LIST =
          (ADDRESS = (PROTOCOL = TCP)(HOST = oracle02)(PORT = 1521))
        )
        (CONNECT_DATA =
          (SERVICE_NAME = SBDB1)
        )
      )
    6.将监听文件、TNS文件、口令文件、参数文件
    ##重要的是口令文件跟参数文件文件名要改成备库的名称
    scp initWWDB1.ora oracle02:/u01/app/oracle/product/11.2.4/dbhome_1/dbs/initSBDB1.ora
    scp orapwWWDB1 oracle02:/u01/app/oracle/product/11.2.4/dbhome_1/dbs/orapwSBDB1
    scp ../network/admin/listener.ora ../network/admin/tnsnames.ora oracle02:/u01/app/oracle/product/11.2.4/dbhome_1/network/admin
     
    7.重启主库使配置生效
    注:重启库之前先重启监听
    三、到备库中
    1.创建对应路径
    [oracle@oracle01~]$ cd /u01/app/oracle/
    [oracle@oracle01 oracle]$ mkdir -p admin/SBDB1/adump
    [oracle@oracle01 oracle]$ mkdir -p oradata/SBDB1
    [oracle@oracle01 dbs]$ mkdir -p /home/oracle/flash
    2.修改参数文件
    [oracle@oracle01 oracle]$ cd $ORACLE_HOME/dbs
    [oracle@oracle01 oracle]$ vi initSBDB1.ora(从主库中scp过来的)
    注:用替换SBDB1全部替换成WWDB1然后需要注意的是db_name=主库sid
    3.修改网络配置文件(配置监听文件)
    LISTENER =
      (DESCRIPTION_LIST =
        (DESCRIPTION =
          (ADDRESS = (PROTOCOL = TCP)(HOST = oracle02)(PORT = 1521))
          (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
        )
      )
     
    ADR_BASE_LISTENER = /u01/app/oracle
     
    SID_LIST_LISTENER=
      (SID_LIST=
        (SID_DESC=
          (GLOBAL_DBNAME=SBDB1)
          (ORACLE_HOME=/u01/app/oracle/product/11.2.4/dbhome_1)
          (SID_NAME=SBDB1))
        (SID_DESC=
          (GLOBAL_DBNAME=SBDB1_DGMGRL)
          (ORACLE_HOME=/u01/app/oracle/product/11.2.4/dbhome_1)
          (SID_NAME=SBDB1))
        (SID_DESC=
          (SID_NAME=plsextproc)
          (ORACLE_HOME=/u01/app/oracle/product/11.2.4/dbhome_1)
          (PROGRAM=extproc)))
    4.重启网络设置
    ##重启监听
    [oracle@oracle01 oracle]$ lsnrctl reload
    注:启动完看一下有一个动态监听一个静态监听
    5.启动备库实例
    SQL> create spfile from pfile;
    备库启动到nomount状态
    SQL> startup nomount
    创建快速闪回区的目录
    mkdir -p /u01/app/oracle/fast_recovery_area/SBDB1
     
    6.搭建备库:
    使用复制数据库技术搭建备库
    [oracle@oracle01 oracle]$ rman target sys/oracle@WWDB1 auxiliary sys/oracle@sbdb1
    RMAN> DUPLICATE TARGET DATABASE
    FOR STANDBY
    FROM ACTIVE DATABASE
    DORECOVER
    NOFILENAMECHECK;
    运行成功,即备库搭建成功!
    四、备库中运行一遍日志文件
    SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
    ---备库中就会产生与主库一样的数据文件。
    --------------------------------------------------------------------------------------------------------------------------------------------------
    会报错
    1、参数文件里不要出现汉语,注释也不要添加汉字,以及多余符号,连接符。
    2、若快速恢复区没开的话,在配置参数文件的时候,需要将LOCATION=(需要改成主库数据库归档日志的本地目录)。
     
  • 相关阅读:
    [Unit Testing] Angular Unit Testing, ui-router, httpbackend and spy
    [Redux] Reducer Composition with Arrays
    [Redux] Writing a Todo List Reducer (Toggling a Todo)
    [Redux] Writing a Todo List Reducer (Adding a Todo)
    [Javascript] Advanced Reduce: Common Mistakes
    [Javascript] Advanced Reduce: Additional Reducer Arguments
    [Redux] Avoiding Object Mutations with Object.assign() and ...spread
    [Javascript] Introducing Reduce: Common Patterns
    AI-Info-Micron-Insight:工业 5.0,伟大的思想将殊途同归
    AI-Info-Micron-Insight:案例分析:美光使用数据和人工智能来发现、倾听和感觉
  • 原文地址:https://www.cnblogs.com/Wardenking/p/9598209.html
Copyright © 2020-2023  润新知