dg搭建 oracle rac_oracle 12c rac dg搭建 - CSDN
精华内容
参与话题
  • Oracle 12C DG 搭建(RAC-RAC/RAC-单机)

    千次阅读 2017-02-07 11:28:37
    主库上操作 1.开启RAC的 force logging SQL> alter database force logging;...SQL> alter system set log_archive_config='DG_CONFIG=(eisoo,eisoos)'; SQL> alter system set log_archive_dest_2
    主库上操作
    1.开启RAC的 force logging
    SQL> alter database force logging;
    SQL>
    2.修改RAC初始化参数文件
    SQL> alter system set log_archive_config='DG_CONFIG=(eisoo,eisoos)';
    SQL> alter system set log_archive_dest_2='SERVICE=eisoos ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=eisoos' scope=spfile;
    SQL> alter system set log_archive_dest_state_1=ENABLE;
    SQL> alter system set log_archive_dest_state_2=ENABLE;
    SQL> alter system set fal_server=eisoos;
    SQL> alter system set db_file_name_convert='eisoos','eisoo' scope=spfile;
    SQL>  alter system set db_file_name_convert='/data/oradata/eisoos','+DATA/EISOO/DATAFILE' scope=spfile;   //如果备库没有使用asm
    SQL> alter system set log_file_name_convert='eisoos','eisoo' scope=spfile;
    SQL> alter system set log_file_name_convert='/data/oradata/eisoos','+DATA/EISOO/ONLINELOG' scope=spfile;//如果备库没有使用asm
    SQL> alter system set standby_file_management='AUTO';
    SQL> alter system set log_archive_max_processes=30;
    3.开启归档模式
    srvctl stop database -d eisoo
    srvctl start database -d eisoo-i eisoo -o mount
    SQL>alter database archivelog;
    SQL>alter database open;
    4.创建standby logfile;
    SQL> select thread#,group#,bytes/1024/1024 from v$log;

       THREAD#     GROUP# BYTES/1024/1024
    ---------- ---------- ---------------
         1        1           50
         1        2           50
         2        3           50
         2        4           50
    SQL> alter database add standby logfile thread 1 group 10 size 50M;
    SQL> alter database add standby logfile thread 1 group 11 size 50M;
    SQL> alter database add standby logfile thread 1 group 12 size 50M;
    SQL> alter database add standby logfile thread 2 group 13 size 50M;
    SQL> alter database add standby logfile thread 2 group 14 size 50M;
    SQL> alter database add standby logfile thread 2 group 15 size 50M;
    SQL> select thread#,group#,bytes/1024/1024 from v$standby_log;

       THREAD#     GROUP# BYTES/1024/1024
    ---------- ---------- ---------------
         1       10           50
         1       11           50
         1       12           50
         2       13           50
         2       14           50
         2       15           50
    5.创建备库参数文件
    SQL> show parameter spfile;

    NAME                     TYPE                  VALUE
    ------------------------------------ ----------- ------------------------------
    spfile                     string     +DATA/EISOO/PARAMETERFILE/spfile.281.923255053
    SQL> create pfile='/tmp/initeisoos.ora' from spfile='+DATA/EISOO/PARAMETERFILE/spfile.281.923255053';
    [oracle@rac1 tmp]$ scp initeisoos.ora 192.168.180.48:$ORACLE_HOME/dbs
    备库上操作:
    1.修改参数文件
    使用asm:
    *.audit_file_dest='/u01/app/oracle/admin/eisoos/adump'
    *.audit_trail='db'
    *.compatible='12.1.0.2.0'
    *.control_files='/data/oradata/eisoos/control01.ctl'
    *.db_block_size=8192
    *.db_create_file_dest='/data/oradata/eisoos'
    *.db_domain=''
    *.db_file_name_convert='eisoo','eisoos'
    *.db_name='eisoo'
    *.db_unique_name='eisoos'
    *.diagnostic_dest='/u01/app/oracle'
    *.dispatchers='(PROTOCOL=TCP) (SERVICE=eisoosXDB)'
    *.fal_server='EISOOS'
    *.log_archive_config='DG_CONFIG=(eisoo,eisoos)'
    *.log_archive_dest_1='LOCATION=/data/oradata/eisoos/archivelog'
    *.log_archive_dest_2='SERVICE=eisoo ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=eisoo'
    *.log_archive_dest_state_1='ENABLE'
    *.log_archive_dest_state_2='ENABLE'
    *.log_archive_format='%t_%s_%r.arc'
    *.log_archive_max_processes=30
    *.log_file_name_convert='eisoo','eisoos'
    *.open_cursors=300
    *.pga_aggregate_target=453m
    *.processes=300
    *.remote_login_passwordfile='exclusive'
    *.sga_target=1361m
    *.standby_file_management='AUTO'
    eisoos.undo_tablespace='UNDOTBS1'

    单机未使用asm:
    *.audit_file_dest='/u01/app/oracle/admin/eisoos/adump'
    *.audit_trail='db'
    *.compatible='12.1.0.2.0'
    *.control_files='/data/oradata/eisoos/control01.ctl'#Restore Controlfile
    *.db_block_size=8192
    *.db_create_file_dest='/data/oradata/eisoos'
    *.db_domain=''
    *.db_file_name_convert='+DATA/EISOO/DATAFILE','/data/oradata/eisoos','+DATA/EISOO/TEMPFILE','/data/oradata/eisoos'
    *.db_name='eisoo'
    *.db_unique_name='eisoos'
    *.diagnostic_dest='/u01/app/oracle'
    *.dispatchers='(PROTOCOL=TCP) (SERVICE=eisoosXDB)'
    *.fal_server='EISOOS'
    *.log_archive_config='DG_CONFIG=(eisoo,eisoos)'
    *.log_archive_dest_1='LOCATION=/data/oradata/eisoos/archivelog'
    *.log_archive_dest_2='SERVICE=eisoo ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=eisoo'
    *.log_archive_dest_state_1='ENABLE'
    *.log_archive_dest_state_2='ENABLE'
    *.log_archive_format='%t_%s_%r.arc'
    *.log_archive_max_processes=30
    *.log_file_name_convert='+DATA/EISOO/ONLINELOG','/data/oradata/eisoos'
    *.open_cursors=300
    *.pga_aggregate_target=453m
    *.processes=300
    *.remote_login_passwordfile='exclusive'
    *.sga_target=1361m
    *.standby_file_management='AUTO'
    eisoos.undo_tablespace='UNDOTBS1'

    2.启动到 nomout状态
    SQL> startup nomount pfile='/u01/app/oracle/product/12.1.0/db_1/dbs/initeisoos.ora';

    ORACLE instance started.

    Total System Global Area 1442840576 bytes
    Fixed Size            2924448 bytes
    Variable Size          486539360 bytes
    Database Buffers      939524096 bytes
    Redo Buffers           13852672 bytes
    SQL>
    SQL>ALTER SYSTEM SET SEC_CASE_SENSITIVE_LOGON=false;
    备注:SEC_CASE_SENSITIVE_LOGON参数是决定密码文件是否可以在本地创建,否则只能从主库拷贝到备库。默认值是“true”,
    3.在本地创建密码文件
    ocrl:/u01/app/oracle/product/12.1.0/db_1/dbs@oracle1>orapwd file=orapweisoos password=oracle entries=10 ignorecase=y force=y

    4.配置监听文件,保证primary和standby能够互连
    备库:
    LISTENER =
      (DESCRIPTION_LIST =
        (DESCRIPTION =
          (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.180.41)(PORT = 1521))
          (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
        )
      )

    SID_LIST_LISTENER =
      (SID_LIST =
        (SID_DESC =
          (GLOBAL_DBNAME = eisoos)
          (ORACLE_HOME = /u01/app/oracle/product/12.1.0/db_1)
          (SID_NAME = eisoos)
        )
       )
    或者
    SID_LIST_LISTENER_EISOOS =
      (SID_LIST =
        (SID_DESC =
          (GLOBAL_DBNAME = eisoos)
          (ORACLE_HOME = /u01/app/oracle/product/12.1.0/db_1)
          (SID_NAME = eisoos)
        )
       )
    主库和备库是tnsname.ora 配置如下:
    eisoo =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.180.51)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = eisoo)
        )
      )

    eisoos =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.180.41)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = eisoos)
        )
      )
    主备分别验证:

    [oracle@rac1 ~]$ sqlplus sys/oracle@eisoo as sysdba
    [oracle@rac1 ~]$ sqlplus sys/oracle@eisoos as sysdba
    [oracle@rac2 ~]$ sqlplus sys/oracle@eisoo as sysdba
    [oracle@rac2 ~]$ sqlplus sys/oracle@eisoos as sysdba
    5.备份恢复数据

    eisoos:/home/oracle@oracle1>rman target sys/oracle@eisoo auxiliary sys/oracle@eisoos

    Recovery Manager: Release 12.1.0.2.0 - Production on Mon Sep 26 16:50:42 2016

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

    connected to target database: EISOO (DBID=3774196505)
    connected to auxiliary database: EISOO (not mounted)

    RMAN> duplicate target database for standby from active database;

    Starting Duplicate Db at 2016/09/26 16:52:12
    6.开启实时同步

    SQL> alter database recover managed standby database using current logfile disconnect from session;
    验证:
    1)
    SQL> select dest_name,error from v$archive_dest;//通过查看archive_log_dest_2列是否有error报错,如果有报错,则需要先根据报错内容解决问题
    2)
    查询主库最大归档序号和备库最大归档序号
    select max(sequence#) from v$archived_log;
    然后在主库切换日志:alter system switch logfile;
    再次查询备库最大归档序号,一致即归档同步成功。
    主库:
    SQL> select max(sequence#) from v$archived_log;

    MAX(SEQUENCE#)
    --------------
           133

    SQL> alter system switch logfile;

    System altered.

    SQL> select max(sequence#) from v$archived_log;

    MAX(SEQUENCE#)
    --------------
           134

    SQL>
    备库:
    SQL> select max(sequence#) from v$archived_log;

    MAX(SEQUENCE#)
    --------------
           134

    SQL>

    3)
     主库验证
    SQL>select SEQUENCE#, FIRST_TIME, NEXT_TIME, APPLIED, ARCHIVED from V$ARCHIVED_LOG;
     备库验证
    SQL>select SEQUENCE#, FIRST_TIME, NEXT_TIME, APPLIED, ARCHIVED from V$ARCHIVED_LOG;
    备注:观察主备库日志是否同步,如一致则表示日志CDP同步正常。

    主备切换
    1.检查DG是否同步是否正常
    主库:  
    SQL> select switchover_status,database_role from gv$database;

    SWITCHOVER_STATUS    DATABASE_ROLE
    -------------------- ----------------
    TO STANDBY         PRIMARY
    TO STANDBY         PRIMARY
    备库:
    SQL> select switchover_status,database_role from gv$database;

    SWITCHOVER_STATUS    DATABASE_ROLE
    -------------------- ----------------
    NOT ALLOWED         PHYSICAL STANDBY

    2.准备切换工作:
    关闭RAC库,并把rac1起到open 状态
    [oracle@rac1 ~]$ srvctl stop database -d eisoo
    [oracle@rac1 ~]$ sqlplus / as sysdba

    SQL*Plus: Release 12.1.0.2.0 Production on Tue Sep 27 09:12:25 2016

    Copyright (c) 1982, 2014, Oracle.  All rights reserved.

    Connected to an idle instance.

    SQL> startup
    ORACLE instance started.

    Total System Global Area 1442840576 bytes
    Fixed Size            2924448 bytes
    Variable Size          553648224 bytes
    Database Buffers      872415232 bytes
    Redo Buffers           13852672 bytes
    Database mounted.
    Database opened.
    SQL>
    3.开始切换
    主库:
    SQL> alter database commit to switchover to physical standby with session shutdown;
    重启数据库到mount状态
    SQL> startup mount
    ORACLE instance started.

    Total System Global Area 1442840576 bytes
    Fixed Size            2924448 bytes
    Variable Size          553648224 bytes
    Database Buffers      872415232 bytes
    Redo Buffers           13852672 bytes
    Database mounted.
    SQL>
    查看数据库角色与状态
    SQL> select status from v$instance;

    STATUS
    ------------
    MOUNTED

    SQL> select database_role from v$database;

    DATABASE_ROLE
    ----------------
    PHYSICAL STANDBY

    SQL>
    此时rac1已变成备库
    备库:
    SQL> alter database commit to switchover to primary with session shutdown;

    Database altered.

    SQL> alter database open;

    Database altered.




    展开全文
  • CentOS7.5搭建ORACLE RAC+DG

    千次阅读 2018-08-09 16:13:50
    RAC+DG RAM:4G ,OS:CENTOS7.5 HOSTNAME:RAC1: PUBLIC IP:162.168.145.244,PRIV IP:192.168.89.219,VIP:192.168.145.144,scanip:192.168.145.140 HOSTNAME:RAC2: PUBLIC IP:162.168.145.245,PRIV ...

    环境

    RAC+DG RAM:4G  ,OS:CENTOS7.5
    HOSTNAME:RAC1: PUBLIC IP:162.168.145.244,PRIV IP:192.168.89.219,VIP:192.168.145.144,scanip:192.168.145.140
    HOSTNAME:RAC2: PUBLIC IP:162.168.145.245,PRIV IP:192.168.89.220,VIP:192.168.145.145,scanip:192.168.145.140
    备库(hostname:racdg): ip:192.168.145.247 
    rac DB

    DB_NAME=oem      db_unique_Name=oem 

    备库

    DB_NAME=oem      db_unique_name=oem_dg

    安装步骤

    1.主库(也就是RAC)设置强制归档

    sql> alter database force loggin

    如果数据库未开启归档,通过以下的方式进行开启

    查看数据库是否运行在归档模式:

    sql>archive log list;

    如上所示未开启归档,可按下面方法开启数据库归档

    SQL> shutdown immediate    #关闭数据库

    SQL> startup mount;    #启动到mount状态

    SQL> alter database archivelog;    #开启归档

    SQL> alterdatabase open;   #open数据库

    2.主库设置参数

    alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(oem,oem_dg)' scope=both sid='*';
    alter system set LOG_ARCHIVE_DEST_1='LOCATION=USE_DB_RECOVERY_FILE_DEST  VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=oem' scope=both sid='*';
    alter system set LOG_ARCHIVE_DEST_2='SERVICE=oem_dg LGWR AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=oem_dg' scope=both sid='*';
    alter system set log_archive_format='%t_%s_%r.arc' scope=spfile sid='*';
    alter system set log_archive_max_processes=4 scope=both sid='*';
    alter system set fal_server=oem_dg scope=both sid='*';
    alter system set DB_FILE_NAME_CONVERT='/oradata/oem_dg/datafile/','+DATADG/oem/datafile/' scope=spfile sid='*';
    alter system set LOG_FILE_NAME_CONVERT='/oradata/oem_dg/','+DATADG/oem/' scope=spfile sid='*';
    alter system set standby_file_management=AUTO scope=both sid='*';

    3.主库建立standby redolog

    查看每个实例的最大日志:

    select inst_id,count(1),max(bytes) from gv$log group by inst_id;

    每个实例有四组log,最大50M,每个实例需要建立count+1个strandby日志,大小为最大日志大小,也就是5组50M大小的standby日志:

    ASMCMD> pwd
       +DATADG/OEM
    ASMCMD> mkdir STANDBYLOG
    alter system set standby_file_management=manual scope=both sid='*';
     
    alter database add standby logfile thread 1 group 9 '+datadg/oem/standbylog/standby_group_01.log' size 52428800;
    alter database add standby logfile thread 1 group 10 '+datadg/oem/standbylog/standby_group_02.log' size 52428800;
    alter database add standby logfile thread 1 group 11 '+datadg/oem/standbylog/standby_group_03.log' size 52428800;
    alter database add standby logfile thread 1 group 12 '+datadg/oem/standbylog/standby_group_04.log' size 52428800;
    alter database add standby logfile thread 1 group 13 '+datadg/oem/standbylog/standby_group_05.log' size 52428800;
    
    alter system set standby_file_management=auto scope=both sid='*';
    
    select count(*) from v$standby_log;
    

    4.主rman备份整个库

     oracle用户下执行 rman target /进入rman,然后执行下面的命令备份

    run
    {
         sql "alter system switch logfile";
         allocate channel ch1 type disk format '/u01/app/oracle/backup/Primary_for_DG_%U';
         backup database;
         backup current controlfile for standby;
         sql "alter system archive log current";
    }
    

    5.拷贝主库rman备份文件到备份库的相同的目录下

    scp /u01/app/oracle/backup/* 192.168.145.247:/u01/app/oracle/backup/

    6.主库:建立standby(备库)的pfile,从primay(主)的spfile:

    create pfile='/u01/app/oracle/standby_pfile.ora' from spfile;

    7.主库:修改生成的pfile,作为DATAGUARD的目标库的pfile也就是备库

    *.audit_file_dest='/u01/app/oracle/admin/oem_dg/adump'
    *.audit_trail='db'
    *.cluster_database=false
    *.compatible='11.2.0.4.0'
    *.control_files='/oradata/oem_dg/controlfile/control01.ctl','/oradata/oem_dg/controlfile/control02.ctl'
    *.db_block_size=8192
    *.db_create_file_dest='/oradata'
    *.db_domain=''
    *.db_file_name_convert='+DATADG/oem/datafile/','/oradata/oem_dg/datafile/'
    *.db_name='oem'
    *.db_unique_name='oem_dg'
    *.diagnostic_dest='/u01/app/oracle'
    *.dispatchers='(PROTOCOL=TCP) (SERVICE=oemXDB)'
    *.fal_server='OEM'
    *.job_queue_processes=100
    *.log_archive_config='DG_CONFIG=(oem,oem_dg)'
    *.log_archive_dest_1='LOCATION=/backup/oem VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=oem_dg'
    *.log_archive_dest_2='SERVICE=oem LGWR AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=oem'
    *.log_archive_format='%t_%s_%r.arc'
    *.log_archive_max_processes=4
    *.log_buffer=10485760
    *.log_file_name_convert='+DATADG/oem/','/oradata/oem_dg/'
    *.memory_target=1581252608
    *.open_cursors=300
    *.processes=150
    *.remote_login_passwordfile='exclusive'
    *.session_cached_cursors=300
    *.sessions=800
    *.standby_file_management='AUTO'
    *.undo_tablespace='UNDOTBS1'
    

    修改了之后,传递给备库

    scp /u01/app/oracle/standby_pfile.ora 192.168.145.247:/u01/app/oracle/

    8.修改oracle的sys密码,保持所有主库和备份库一致:

    #这里主库的ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
    #从库的ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
    #主库的ORACLE_SID=oem
    #从库的ORACLE_SID=oem
    #主库执行
    scp $ORACLE_HOME/dbs/orapw$ORACLE_SID  192.168.145.247:/
    #从库执行
    #从库将复制过来的文件放在$ORACLE_HOME/dbs/下
    mv $ORACLE_HOME/dbs/orapw$ORACLE_SID $ORACLE_HOME/dbs/orapw$ORACLE_SID.bak
    #接下来将传过来的orapwoem1复制到$ORACLE_HOME/dbs/目录下并更名为orapwoem,和从库的sid保持一致,即是替换掉了原来的密码,现在使用主库的密码
    #如果更换密码不成功,后面在做日志传输的时候会报错
    

    9.主库:修改的tnsnames.ora文件,添加主库和备库的配置:

    OEM =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = scanip)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = oem)
        )
      )
    
    OEM_DG =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST=192.168.145.247)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = oem_dg)
          (SID=oem)
              (UR=A)
        )
    )
    
    OEM1 =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST=192.168.145.244)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = oem)
          (SID=oem1)
        )
      )
    
    OEM2 =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST=192.168.145.245)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = oem)
          (SID=oem2)
      )
      )
    

    10.建立目标库所需要的目录结构

    #oracle用户下:
    mkdir -p /app/oracle/admin/oem_dg/adump
    
    mkdir -p /app/oracle/diag/rdbms/oem_dg/oem/trace/cdump
    #root用户下:
    #用于spfile中的.log_archive_dest_1
    mkdir /backup
    chown oracle:oinstall /backup
    #创建oradata相关的目录,这里对应着RAC的ASM磁盘上的储存文件
    mkdir -p /oradata/oem_dg/
    cd /oradata/oem_dg/
    
    mkdir controlfile
    mkdir datafile
    mkdir onlinelog
    mkdir standbylog
    chown oracle:oinstall /oradata
    chown oracle:oinstall /oradata/*
    

    11.备库修改tnsnames,添加源库和目标库配置

    # tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
    # Generated by Oracle configuration to
    OEM =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST=192.168.145.140)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = oem)
        )
      )
    
    OEM_DG =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST=192.168.145.247)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = oem_dg)
          (SID=oem)
        )
    )
    
    OEM1 =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST=192.168.145.244)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = oem)
          (SID=oem1)
        )
      )
    
    OEM2 =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST=192.168.145.245)(PORT = 1521))
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = oem)
          (SID=oem2)
      )
      )
    ~
    

    12.备库:nomount启动数据库:

    export ORACLE_SID=oem
    sqlplus sys as sysdba
    startup nomount pfile='/u01/app/oracle/standby_pfile.ora';

    13.主库端:rman建立dataguard数据库:

    rman target / auxiliary sys/111111@oem_dg
    #111111是密码
    #rman下执行
    DUPLICATE TARGET DATABASE FOR STANDBY NOFILENAMECHECK;

    14.备份库创建spfile

    create spfile from pfile='/u01/app/oracle/standby_pfile.ora';
    
    #关闭
    shutdown immediate
    #开启并挂载
    startup mount
    

    15.主库设置为最大可用模式

    alter database set standby database to maximize availability;

    16.目标库启用日志应用

    alter database recover managed standby database  disconnect from session;

    17.测试效果:

    主库创建表

    create table testdg as select * from user_tables;
    alter system switch logfile;

    备库查看相关的日志输出

    tail -f /u01/app/oracle/diag/rdbms/oem_dg/oem/trace/alert_oem.log

    18.检测日志输出

    SELECT a.th, a.seq transfered, b.seq archived
    FROM (SELECT local.thread# th, MAX (local.sequence#) seq
          FROM (SELECT thread#, sequence#
                FROM v$archived_log
                WHERE dest_id = 1) local
          WHERE local.sequence# IN
                      (SELECT sequence#
                       FROM v$archived_log
                       WHERE dest_id = 2 AND thread# = local.thread#)
          GROUP BY local.thread#) a,
         (SELECT thread# th, MAX (sequence#) seq
          FROM v$archived_log
          WHERE dest_id = 1
          GROUP BY thread#) b
    WHERE a.th = b.th
    ORDER BY 1;

     

    展开全文
  • 一步一步搭建oracle 11gR2 rac+dg之环境准备(二) 一步一步在RHEL6.5+VMware Workstation 10上搭建 oracle 11gR2 rac + dg 之环境准备 (二) 本篇目录结构: Linux 环境准备 安装linux的环境,我就不...

    一步一步搭建oracle 11gR2 rac+dg之环境准备(二)

     

    一步一步在RHEL6.5+VMware Workstation 10上搭建 oracle 11gR2 rac + dg 之环境准备 (二)

    本篇目录结构:

     

    1. Linux 环境准备

      安装linux的环境,我就不介绍了,这一部分如果不会的童鞋就去百度吧,一百度一大堆,如果还是不会的话就直接下载我已经安装好的系统吧,下载下来直接可用(http://yunpan.cn/cgkEsf8wpHC2G (提取码:90f5)),复制3份,直接命名为rac1、rac2和dg即可,如图:

       

     

    1. 前期环境准备

      1. 关闭防火墙

    在rac1 和rac2 2个节点上分别执行如下语句:

     

    [root@rac01 ~]# service iptables stop

    [root@rac01 ~]# chkconfig iptables off

    [root@rac01 ~]# chkconfig iptables --list

    iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off

     

    chkconfig iptables off ---永久

    service iptables stop ---临时

    /etc/init.d/iptables status ----会得到一系列信息,说明防火墙开着。

    /etc/rc.d/init.d/iptables stop ----------关闭防火墙

     

     

    1. 修改主机名

     

    #vi /etc/sysconfig/network

    HOSTNAME=rac1

     

    # hostname rac1

     

     

    Rac 2 上同样执行

     

    1. 修改hosts文件--网络配置(网卡配置)

    hosts文件:

    [grid@rac1 ~]$ more /etc/hosts

    127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4

    ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

     

     

    #Public IP

    192.168.59.135 rac1

    192.168.59.136 rac2

     

    #Private IP

    192.168.116.133 rac1-priv

    192.168.116.134 rac2-priv

     

    #Virtual IP

    192.168.59.137 rac1-vip

    192.168.59.138 rac2-vip

     

    #Scan IP

    192.168.59.139 rac-scan

     

     

     

     

    1. 配置内核参数

      1. 修改/etc/sysctl.conf文件

    [root@rac01 ~]# vi /etc/sysctl.conf

    # for oracle 11g

    fs.aio-max-nr = 1048576

    fs.file-max = 6815744

    kernel.shmall = 2147483648

    kernel.shmmax = 68719476736

    kernel.shmmni = 4096

    kernel.sem = 250 32000 100 128

    net.ipv4.ip_local_port_range = 9000 65500

    net.core.rmem_default = 262144

    net.core.rmem_max = 4194304

    net.core.wmem_default = 262144

    net.core.wmem_max = 1048586

     

    使修改参数立即生效:

    [root@rac01 ~]# /sbin/sysctl -p

     

    1. 修改limits文件

    [root@rac01 ~]# vi /etc/security/limits.conf

    grid soft nproc 2047

    grid hard nproc 16384

    grid soft nofile 1024

    grid hard nofile 65536

    oracle soft nproc 2047

    oracle hard nproc 16384

    oracle soft nofile 1024

    oracle hard nofile 65536

     

    1. 修改/etc/pam.d/login文件

    [root@rac01 ~]# vi /etc/pam.d/login

    session required pam_limits.so

     

    1. 修改/etc/profile文件

    [root@rac01 ~]# vi /etc/profile

    if [ $USER = "oracle" ] || [ $USER = "grid" ]; then

    if [ $SHELL = "/bin/ksh" ]; then

    ulimit -p 16384

    ulimit -n 65536

    else

    ulimit -u 16384 -n 65536

    fi

    umask 022

    fi

     

    1. 禁用 selinux

    [root@rac01 ~]# vi /etc/selinux/config

    # This file controls the state of SELinux on the system.

    # SELINUX= can take one of these three values:

    # enforcing - SELinux security policy is enforced.

    # permissive - SELinux prints warnings instead of enforcing.

    # disabled - No SELinux policy is loaded.

    SELINUX=disabled

    # SELINUXTYPE= can take one of these two values:

    # targeted - Targeted processes are protected,

    # mls - Multi Level Security protection.

    SELINUXTYPE=targeted

     

    getsebool

    getsebool: SELinux is disabled

     

     

     

     

    1. 停止 ntp 服务,11gR2 新增的检查项

    root 用户双节点运行:

     

    gird时间同步所需要的设置(11gR2新增检查项)

    #Network Time Protocol Setting

    /sbin/service ntpd stop

    mv /etc/ntp.conf /etc/ntp.conf.bak (这时候oracle会自动启用自己的NTP服务)

     

    [root@node1 ~]# service ntpd status

    ntpd is stopped

    [root@node1 ~]# chkconfig ntpd stop

    [root@node1 ~]# cat /etc/ntp

    ntp/ ntp.conf

    [root@node1 ~]# cp /etc/ntp.conf /etc/ntp.conf.bak

    [root@node1 ~]# rm -rf /etc/ntp.conf

    [root@node1 ~]#

     

     

     

    1. /dev/shm 共享内存不足的处理

    解决方法:

    例如:为了将/dev/shm的大小增加到1GB,修改/etc/fstab的这行:默认的:

    none /dev/shm tmpfs defaults 0 0

    改成:

    none /dev/shm tmpfs defaults,size=1024m 0 0

    size参数也可以用G作单位:size=1G。

    或者使用命令: mount -o remount,size=4G /dev/shm

    重新mount /dev/shm使之生效:

    # mount -o remount /dev/shm

    或者:

    # umount /dev/shm

    # mount -a

    马上可以用"df -h"命令检查变化。

     

    1. 添加组和用户

      1. 添加oracle和grid用户

    groupadd -g 501 oinstall

    groupadd -g 502 dba

    groupadd -g 503 oper

    groupadd -g 504 asmadmin

    groupadd -g 505 asmoper

    groupadd -g 506 asmdba

    useradd -g oinstall -G dba,asmdba,oper oracle

    useradd -g oinstall -G asmadmin,asmdba,asmoper,oper,dba grid

     

     

    为oracle和grid用户设密码:

    [root@rac01 ~]# passwd oracle

    [root@rac01 ~]# passwd grid

     

     

    检查:

    [root@ora1 ~]# id oracle

    uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba),503(oper),506(asmdba)

    [root@ora1 ~]# id grid

    uid=502(grid) gid=501(oinstall)

    groups=501(oinstall),502(dba),503(oper),504(asmadmin),505(asmoper),506(asmdba)

     

    1. 创建目录并且配置 grid 和 oracle 用户的环境变量文件

    ? GRID 软件的 ORACLE_HOME 不能是 ORACLE_BASE 的子目录

     

     

    --在2个节点均创建,root用户下创建目录:

    mkdir -p /u01/app/oracle

    mkdir -p /u01/app/grid

    mkdir -p /u01/app/11.2.0/grid

    chown -R grid:oinstall /u01/app/grid

    chown -R grid:oinstall /u01/app/11.2.0

    chown -R oracle:oinstall /u01/app/oracle

    chmod -R 775 /u01

     

    mkdir -p /u01/app/oraInventory

    chown -R grid:oinstall /u01/app/oraInventory

    chmod -R 775 /u01/app/oraInventory

     

     

     

     

    修改gird、oracle用户的.bash_profile文件,以oracle账号登陆,编辑.bash_profile

    或者在root直接编辑:

    vi /home/oracle/.bash_profile

    vi /home/grid/.bash_profile

     

     

    --------Oracle User----切换到Oracle用户下------

    [root@rhel_linux_asm ~]# su - oracle

    [oracle@rhel_linux_asm ~]$ vi ~/.bash_profile

    export ORACLE_SID=rac1

    export ORACLE_BASE=/u01/app/oracle

    export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1

    export LD_LIBRARY_PATH=$ORACLE_HOME/lib

    export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"

    export TMP=/tmp

    export TMPDIR=$TMP

    export PATH=$PATH:$ORACLE_HOME/bin

     

    --------Grid User-----切换到grid用户下-----

    [grid@rhel_linux_asm ~]$ vim .bash_profile

    export ORACLE_SID=+ASM1

    export ORACLE_BASE=/u01/app/grid

    export ORACLE_HOME=/u01/app/11.2.0/grid

    export LD_LIBRARY_PATH=$ORACLE_HOME/lib

    export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"

    export PATH=$ORACLE_HOME/bin:$PATH

     

    注意:另外一台数据库实例名须做相应修改:

    Oracle:export ORACLE_SID=rac2

    grid:export ORACLE_SID=+ASM2

     

     

    1. 软件包的检查

    依据官方文档要求,Red Hat Enterprise Linux 5须安装如下软件包

     

    1. binutils-2.17.50.0.6

    2. compat-libstdc++-33-3.2.3

    3. compat-libstdc++-33-3.2.3(32 位)

    4. elfutils-libelf-0.125

    5. elfutils-libelf-devel-0.125

    6. elfutils-libelf-devel-static-0.125

    7. gcc-4.1.2

    8. gcc-c++-4.1.2

    9. glibc-2.5-24

    10. glibc-2.5-24(32 位)

    11. glibc-common-2.5

    12. glibc-devel-2.5

    13. glibc-devel-2.5(32 位)

    14. glibc-headers-2.5

    15. ksh-20060214

    16. libaio-0.3.106

    17. libaio-0.3.106(32 位)

    18. libaio-devel-0.3.106

    19. libaio-devel-0.3.106(32 位)

    20. libgcc-4.1.2

    21. libgcc-4.1.2(32 位)

    22. libstdc++-4.1.2

    23. libstdc++-4.1.2(32 位)

    24. libstdc++-devel 4.1.2

    25. make-3.81

    26. sysstat-7.0.2

    27. unixODBC-2.2.11

    28. unixODBC-2.2.11(32 位)

    29. unixODBC-devel-2.2.11

    30. unixODBC-devel-2.2.11(32 位)

     

    一般情况下除了compat的一些包没有安装外,其他的包都已经安装了,可以使用rpm –qa |grep 命令进行查询,注意一定要与操作系统版本相符

     

     

    rpm -qa | grep binutils-

    rpm -qa | grep compat-libstdc++-

    rpm -qa | grep elfutils-libelf-

    rpm -qa | grep elfutils-libelf-devel-

    rpm -qa | grep glibc-

    rpm -qa | grep glibc-common-

    rpm -qa | grep glibc-devel-

    rpm -qa | grep gcc-

    rpm -qa | grep gcc-c++-

    rpm -qa | grep libaio-

    rpm -qa | grep libaio-devel-

    rpm -qa | grep libgcc-

    rpm -qa | grep libstdc++-

    rpm -qa | grep libstdc++-devel-

    rpm -qa | grep make-

    rpm -qa | grep sysstat-

    rpm -qa | grep unixODBC-

    rpm -qa | grep unixODBC-devel-

     

     

    rpm -ivh compat-libstdc++-33-3.2.3-69.el6.i686.rpm --force --nodeps

    rpm -ivh unixODBC-* --force --nodeps

     

    rhel6 还应该安装一个包:compat-libcap1-1.10-1.x86_64.rpm

     

    1. 关闭不需要的服务

    chkconfig autofs off

    chkconfig acpid off

    chkconfig sendmail off

    chkconfig cups-config-daemon off

    chkconfig cpus off

    chkconfig xfs off

    chkconfig lm_sensors off

    chkconfig gpm off

    chkconfig openibd off

    chkconfig pcmcia off

    chkconfig cpuspeed off

    chkconfig nfslock off

    chkconfig ip6tables off

    chkconfig rpcidmapd off

    chkconfig apmd off

    chkconfig sendmail off

    chkconfig arptables_jf off

    chkconifg microcode_ctl off

    chkconfig rpcgssd off

    chkconfig ntpd off

     

     

     

    1. 配SSH互信,建立 ssh 等效性--11G不用配置

    虽然在安装软件的过程中,oracle 会自动配置 SSH 对等性,建议在安装软件之前手工配置。

     

    以oracle身份在每个节点执行

     

    为ssh和scp创建连接,检验是否存在:

    ls -l /usr/local/bin/ssh

    ls -l /usr/local/bin/scp

    不存在则创建

    /bin/ln -s /usr/bin/ssh /usr/local/bin/ssh

    /bin/ln -s /usr/bin/scp /usr/local/bin/scp

     

    [root@rac01 ~]# /bin/ln -s /usr/bin/ssh /usr/local/bin/ssh

    [root@rac01 ~]# /bin/ln -s /usr/bin/scp /usr/local/bin/scp

     

    为oracle用户配置SSH:

    生成用户的公匙和私匙,在每个节点上:

    [root@rac01 ~]# su – oracle

    [oracle@rac01 ~]# mkdir ~/.ssh

    [oracle@rac01 ~]#cd .ssh

    [oracle@rac01 ~]# ssh-keygen -t rsa

    [oracle@rac01 ~]# ssh-keygen -t dsa

     

    在节点1上,把所有节点的authorized_keys文件合成一个,再用这个文件覆盖各个节点.ssh下的同名文件:

    [oracle@rac01 ~]# touch authorized_keys

    [oracle@rac01 ~]# ssh rac01 cat /home/oracle/.ssh/id_rsa.pub >> authorized_keys

    [oracle@rac01 ~]# ssh rac02 cat /home/oracle/.ssh/id_rsa.pub >> authorized_keys

    [oracle@rac01 ~]# ssh rac01 cat /home/oracle/.ssh/id_dsa.pub >> authorized_keys

    [oracle@rac01 ~]# ssh rac02 cat /home/oracle/.ssh/id_dsa.pub >> authorized_keys

    [oracle@rac01 ~]# scp authorized_keys rac02:/home/oracle/.ssh/

     

    分别在每个节点上执行检验操作:

    [oracle@rac01 ~]# ssh rac01 date

    [oracle@rac01 ~]# ssh rac02 date

     

    [oracle@rac01 ~]# ssh-agent $SHELL

    [oracle@rac01 ~]# ssh-add

     

     

    为grid用户配置SSH:

    在每个节点上:

    [root@rac01 ~]# su – grid

    [grid@rac01 ~]# mkdir ~/.ssh

    [grid@rac01 ~]#cd .ssh

    [grid@rac01 ~]# ssh-keygen -t rsa

    [grid@rac01 ~]# ssh-keygen -t dsa

     

    在节点1上

    [grid@rac01 ~]# touch authorized_keys

    [grid@rac01 ~]# ssh rac01 cat /home/grid/.ssh/id_rsa.pub >> authorized_keys

    [grid@rac01 ~]# ssh rac02 cat /home/grid/.ssh/id_rsa.pub >> authorized_keys

    [grid@rac01 ~]# ssh rac01 cat /home/grid/.ssh/id_dsa.pub >> authorized_keys

    [grid@rac01 ~]# ssh rac02 cat /home/grid/.ssh/id_dsa.pub >> authorized_keys

    [grid@rac01 ~]# scp authorized_keys rac02:/home/grid/.ssh/

     

     

    分别在每个节点上:

    [grid@rac01 ~]# ssh rac01 date

    [grid@rac01 ~]# ssh rac02 date

     

    [grid@rac01 ~]# ssh-agent $SHELL

    [grid@rac01 ~]# ssh-add

     

    --------------------------------------------------------------------------------------自己:

    为Oracle用户配置SSH:

    以oracle身份在每个节点执行以下代码

    su - oracle

    mkdir ~/.ssh

    cd .ssh

    ssh-keygen -t rsa

    ssh-keygen -t dsa

    cat *rsa.pub >> authorized_keys

    cat *dsa.pub >> authorized_keys

     

    然后在rac1下:

    ssh rac2 cat /home/oracle/.ssh/authorized_keys >> authorized_keys

    scp authorized_keys rac2:/home/oracle/.ssh/

     

    然后分别在每个节点上执行检验操作:

    ssh rac1 date

    ssh rac2 date

    ssh-agent $SHELL

    ssh-add

     

    为grid用户配置SSH:

    以grid身份在每个节点执行

    su - grid

    mkdir ~/.ssh

    cd ~/.ssh

    ssh-keygen -t rsa

    ssh-keygen -t dsa

    cat *rsa.pub >> authorized_keys

    cat *dsa.pub >> authorized_keys

     

    然后在rac1节点下执行:

    ssh rac2 cat /home/grid/.ssh/authorized_keys >> authorized_keys

    scp authorized_keys rac2:/home/grid/.ssh/

     

    然后分别在每个节点上执行检验操作:

    ssh rac1 date

    ssh rac2 date

    ssh rac1-priv date

    ssh rac2-priv date

     

    第二次执行时不再提示输入口令,并且可以成功执行命令,则表示 oracle 用户 SSH 对等性

    配置成功,至此,Oracle 用户 SSH 对等性配置完成!重复上述步骤,以 grid 用户配置对等性。

     

     

    ssh-agent $SHELL

    ssh-add

     

    注意: 该步骤可以不配置然后在安装的过程中有如下的界面可以来配置:

    1. 配置NTP

    root用户下执行:

    1. rac1执行

    A. sed -i 's/OPTIONS/#OPTIONS/g' /etc/sysconfig/ntpd

    B.

    cat >> /etc/sysconfig/ntpd << EOF

    OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid"

    EOF

    C.

    mv /etc/ntp.conf /etc/ntp.confbak

    D.

    cat > /etc/ntp.conf << EOF

    restrict 0.0.0.0 mask 0.0.0.0 nomodify

    server 127.127.1.0

    fudge 127.127.1.0 stratum 10

    driftfile /var/lib/ntp/drift

    broadcastdelay 0.008

    authenticate no

    keys /etc/ntp/keys

    EOF

    1. rac2执行

    A.

    sed -i 's/OPTIONS/#OPTIONS/g' /etc/sysconfig/ntpd

    B.

    cat >> /etc/sysconfig/ntpd << EOF

    OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid"

    EOF

    C.

    mv /etc/ntp.conf /etc/ntp.confbak

    D.

    cat >> /etc/ntp.conf << XL

    restrict default kod nomodify notrap nopeer noquery

    restrict 182.168.8.0 mask 255.255.255.0 nomodify notrap

    restrict 127.0.0.1

    server 182.168.8.61

    server 127.127.1.0 # local clock

    fudge 127.127.1.0 stratum 10

    driftfile /var/lib/ntp/drift

    broadcastdelay 0.008

    authenticate no

    keys /etc/ntp/keys

    XL

    1. 启动服务(双节点执行)

    #service ntpd restart

    #chkconfig ntpd on

    展开全文
  • Oracle 11g RAC 到 单实例 DG 环境搭建

    千次阅读 2019-05-22 09:20:25
    Primary Database 是一个两节点的RAC,存储采用ASM 方式,具体如下图: RAC Primary rac1 rac2 Public IP 192.168.1.60/24 192.168.1.62/24 Private IP 192.168.56.80/24 192.168.56.82/24 ...

    1 环境说明

    Primary Database 是一个两节点的RAC,存储采用ASM 方式,具体如下图:

     

    RAC Primary  rac1 rac2
    Public IP 192.168.1.60/24 192.168.1.62/24
    Private IP 192.168.56.80/24 192.168.56.82/24
    Vritual IP 192.168.1.61/24 192.168.1.63/24
     San IP                                         192.168.1.125 
     Instance  leo1  leo2
     DB_NAME                                               leo 
     Data、Control File、Redo File                                              ASM 

     

    Standby Database (Single Instance) 环境介绍

     

     

    Single instance Standby                            说明
    IP 192.168.1.65/24
    Oracle 单实例
    Instance orcl
    DB_NAME leo
     Data  /u01/app/oracle/oradata/orcl/data tempfile
     Control File  /u01/app/oracle/oradata/orcl/control01.ctl
     /u01/app/oracle/fast_recovery_area/orcl
     Redo FileRedo File  /u01/app/oracle/oradata/orcl/redo

     

     

    2  主库设置为 force logging 模式

    rac 节点1 执行
    
    SQL> alter database force logging;
    
    Database altered.
    
    SQL> select force_logging from v$database; 
    
    FOR
    ---
    YES

    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     30
    Current log sequence	       31
    
    
    切换归档,将所有节点都必须处于 mount 状态。 在其中一个节点修改模式,然后在其他节点正常启动即可。
    
    SQL> shutdown immediate
    Database closed.
    Database dismounted.
    ORACLE instance shut down.
    
    SQL> startup mount
    ORACLE instance started.
    
    Total System Global Area 1269366784 bytes
    Fixed Size		    2252864 bytes
    Variable Size		  872419264 bytes
    Database Buffers	  385875968 bytes
    Redo Buffers		    8818688 bytes
    Database mounted.
    
    SQL> alter database archivelog;
    
    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     30
    Next log sequence to archive   31
    Current log sequence	       31
    
    SQL> select name , open_mode, log_mode,force_logging from gv$database;
    
    NAME	  OPEN_MODE	       LOG_MODE     FOR
    --------- -------------------- ------------ ---
    LEO	  READ WRITE	       ARCHIVELOG   YES
    LEO	  READ WRITE	       ARCHIVELOG   YES
    
    SQL>  show parameter db_recover 
    
    NAME				     TYPE	 VALUE
    ------------------------------------ ----------- ------------------------------
    db_recovery_file_dest		     string	 +DATA
    db_recovery_file_dest_size	     big integer 4407M
    
    
    我 2 个节点的归档都指向了+DATA 这个磁盘组。 也可以指向其他的磁盘组或者本地的位置,如: 
    SQL> alter system set log_archive_dest_1='location=/u01/leo1arch' sid='leo1'; 
    SQL> alter system set log_archive_dest_1='location=/u01/leo2arch' sid='leo2';

    4  主备库添加 standby Redo log 文件 

    RAC 每个 Redo Thread 都需要创建对应的 Standby Redo Log。 创建原则和单实例一样,包括日志 文件大小相等,日志组数量要多 1 组。
    主库
    SQL> set lines 120
    SQL> col member for a50
    SQL> select a.thread#,a.group#,a.bytes/1024/1024,b.member from v$log a,v$logfile b where a.group#=b.group#;
    
       THREAD#     GROUP# A.BYTES/1024/1024 MEMBER
    ---------- ---------- ----------------- --------------------------------------------------
    	 1	    2		     50 +DATA/leo/onlinelog/group_2.277.943664411
    	 1	    2		     50 +DATA/leo/onlinelog/group_2.278.943664413
    	 1	    1		     50 +DATA/leo/onlinelog/group_1.275.943664407
    	 1	    1		     50 +DATA/leo/onlinelog/group_1.276.943664409
    	 2	    3		     50 +DATA/leo/onlinelog/group_3.281.943668673
    	 2	    3		     50 +DATA/leo/onlinelog/group_3.282.943668675
    	 2	    4		     50 +DATA/leo/onlinelog/group_4.283.943668677
    	 2	    4		     50 +DATA/leo/onlinelog/group_4.284.943668679
    
    8 rows selected.
    --主库添加 standby redo log: 
    SQL> alter database add standby logfile thread 1 group 10 ('+DATA') size 50m; 
    
    Database altered.
    
    SQL> alter database add standby logfile thread 1 group 11 ('+DATA') size 50m; 
    
    Database altered.
    
    SQL> alter database add standby logfile thread 1 group 12 ('+DATA') size 50m; 
    
    Database altered.
    
    SQL> alter database add standby logfile thread 1 group 13 ('+DATA') size 50m; 
    
    Database altered.
    
    SQL> alter database add standby logfile thread 1 group 14 ('+DATA') size 50m; 
    
    Database altered.
    
    
    SQL> alter database add standby logfile thread 2 group 15 ('+DATA') size 50m; 
    
    Database altered.
    
    SQL> alter database add standby logfile thread 2 group 16 ('+DATA') size 50m;
    
    Database altered.
    
    SQL> alter database add standby logfile thread 2 group 17 ('+DATA') size 50m; 
    
    Database altered.
    
    SQL> alter database add standby logfile thread 2 group 18 ('+DATA') size 50m; 
    
    Database altered.
    
    SQL> alter database add standby logfile thread 2 group 19 ('+DATA') size 50m; 
    
    Database altered.
    
    
    
    --验证: 
    SQL> select group#,type,member from v$logfile order by 2;
    
        GROUP# TYPE    MEMBER
    ---------- ------- --------------------------------------------------
    	 2 ONLINE  +DATA/leo/onlinelog/group_2.277.943664411
    	 4 ONLINE  +DATA/leo/onlinelog/group_4.284.943668679
    	 4 ONLINE  +DATA/leo/onlinelog/group_4.283.943668677
    	 3 ONLINE  +DATA/leo/onlinelog/group_3.282.943668675
    	 3 ONLINE  +DATA/leo/onlinelog/group_3.281.943668673
    	 1 ONLINE  +DATA/leo/onlinelog/group_1.276.943664409
    	 1 ONLINE  +DATA/leo/onlinelog/group_1.275.943664407
    	 2 ONLINE  +DATA/leo/onlinelog/group_2.278.943664413
    	18 STANDBY +DATA/leo/onlinelog/group_18.330.945089519
    	17 STANDBY +DATA/leo/onlinelog/group_17.329.945089515
    	16 STANDBY +DATA/leo/onlinelog/group_16.328.945089509
    
        GROUP# TYPE    MEMBER
    ---------- ------- --------------------------------------------------
    	15 STANDBY +DATA/leo/onlinelog/group_15.327.945089505
    	14 STANDBY +DATA/leo/onlinelog/group_14.294.944422059
    	13 STANDBY +DATA/leo/onlinelog/group_13.293.944422047
    	12 STANDBY +DATA/leo/onlinelog/group_12.292.944422039
    	11 STANDBY +DATA/leo/onlinelog/group_11.291.944422031
    	19 STANDBY +DATA/leo/onlinelog/group_19.331.945089523
    	10 STANDBY +DATA/leo/onlinelog/group_10.290.944422017
    
    18 rows selected.

    5 配置主备库的监听:listener.ora 
    用 net manager 工具,在备库创建一个监听。 也可以手动的修改 listener.ora 文件。 
    --对于 RAC 环境: 

    在 grid 用户的 listener.ora 文件中加入如下内容:  
    [grid@rac1 admin]$ cat listener.ora
    # listener.ora Network Configuration File: /u01/app/11.2.0/grid/network/admin/listener.ora
    # Generated by Oracle configuration tools.
    
    ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1 = ON
    
    SID_LIST_LISTENER =
      (SID_LIST =
        (SID_DESC =
          (GLOBAL_DBNAME = leo)
          (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
          (SID_NAME = leo1)
        )
      )
    
    LISTENER =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER))
      )
    
    ADR_BASE_LISTENER = /u01/app/grid
    
    ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER = ON
    
    LISTENER_SCAN1 =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER_SCAN1))
      )
    
    ADR_BASE_LISTENER_SCAN1 = /u01/app/grid
    
     节点 2,对应修改即可。
     [grid@rac2 admin]$ cat listener.ora
    # listener.ora Network Configuration File: /u01/app/11.2.0/grid/network/admin/listener.ora
    # Generated by Oracle configuration tools.
    
    ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1 = ON
    
    SID_LIST_LISTENER =
      (SID_LIST =
        (SID_DESC =
          (GLOBAL_DBNAME = leo)
          (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
          (SID_NAME = leo2)
        )
      )
    
    LISTENER =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER))
      )
    
    ADR_BASE_LISTENER = /u01/app/grid
    
    ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER = ON
    
    LISTENER_SCAN1 =
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER_SCAN1))
      )
    
    ADR_BASE_LISTENER_SCAN1 = /u01/app/grid
    
    
    --这里写的 Oracle 用户的 ORACLE_HOME,否则连接时会报错:
    ORA-01031: insufficient privileges 
     
    然后重启监听。  
     
    注意在 oracle 11gR2 的 RAC 环境下,监听是在 grid 用户下配置的。所以这里可以用 grid 用户连接,
    并修 改。 最后重启监听。 
     
    对于单实例,直接在 listener.ora 里添加: 
    
    [oracle@localhost admin]$ cat listener.ora 
    # listener.ora Network Configuration File: /u01/app/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 = orcl)
          (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
          (SID_NAME = orcl)
        )
      )
    
    LISTENER =
      (DESCRIPTION_LIST =
        (DESCRIPTION =
          (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
        )
        (DESCRIPTION =
          (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
        )
      )
    
    ADR_BASE_LISTENER = /u01/app/oracle

    6 配置主备库的 Net Server: tnsnames.ora 

    节点1,节点2,单实例 的 tnsnames.ora 文件是一致的,添加以下内容: 

    leo=
     (DESCRIPTION =
       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.61)(PORT = 1521))
       (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.63)(PORT = 1521))
       (CONNECT_DATA =
        (SERVER = DEDICATED)
        (SERVICE_NAME =leo)
        )
      )
    
    orcl_st=
      (DESCRIPTION =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.65)(PORT = 1521))  
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = orcl)
        )
      )
    
    配置完成后,使用 tnsping 命令效验:
      
    [oracle@rac1 admin]$ tnsping orcl_st
    
    TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 29-MAY-2017 01:59:09
    
    Copyright (c) 1997, 2013, Oracle.  All rights reserved.
    
    Used parameter files:
    
    
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.65)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))
    OK (0 msec)
    
    [oracle@localhost dbs]$ tnsping leo
    
    TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 29-MAY-2017 01:59:38
    
    Copyright (c) 1997, 2013, Oracle.  All rights reserved.
    
    Used parameter files:
    
    
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.61)(PORT = 1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.63)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME =leo)))
    OK (0 msec)

    7 单实例创建相关目录 

    --FRA目录
    [oracle@rac2 ~]$ mkdir -p /u01/app/oracle/fast_recovery_area/orcl
    --DATAFILE
    [oracle@rac2 ~]$ mkdir -p /u01/app/oracle/oradata/orcl
    [oracle@rac2 ~]$ mkdir -p /u01/app/oracle/admin/orcl/adump
    [oracle@rac2 ~]$ mkdir -p /u01/app/oracle/admin/orcl/data
    [oracle@rac2 ~]$ mkdir -p /u01/app/oracle/admin/orcl/redo
    [oracle@rac2 ~]$ mkdir -p /u01/app/oracle/admin/orcl/tempfile

    8 创建备库口令文件 

    [oracle@localhost dbs]$ pwd
    /u01/app/oracle/product/11.2.0/db_1/dbs
    [oracle@localhost dbs]$ orapwd file=$ORACLE_HOME/dbs/orapwleo1 password=oracle
    [oracle@localhost dbs]$ orapwd file=$ORACLE_HOME/dbs/orapwleo2 password=oracle
    [oracle@localhost dbs]$ orapwd file=$ORACLE_HOME/dbs/orapworcl password=oracle
    
    或者把节点的口令文件copy 到备库(在哪个节点执行操作就在把那个节点的口令文件copy过去)
    [oracle@rac1 dbs]$ scp orapwleo1 192.168.1.65:/u01/app/oracle/product/11.2.0/db_1/dbs/orapworcl 

    9 创建修改主备库的参数文件 

    --主库参数
    
    db_file_name_convert 和 log_file_name_convert 仅当数据库被 standby 时才会生效,
    这里配置,是 为切换做准备。 log_file_name_convert 指的是 online redo log。  
    在 Oracle 11g 已经废除了 fal_client 参数。   
    RAC 的 spfile 是放在共享设备上的,所以如果想创建,就需要先创建一份 pfile 到本地,在修改,
    如果不想这么折腾,就直接使用 SQL 语句修改:
    1)使用 ASM 作为存储时,datafile 和 tempfile 是分别放在两个目录下的,所以在Standby 
    上也单独创建一个tempdata 目录。并在db_file_name_convert 中作相应的设置。
    2)在使用ASM 的RAC中,注意不要改变db_unique_name 的参数值;因为ASM 存放文件的规则,是按照
    +diskgroup_name/data_unique_name/file/tag_name.file_member.incarnation 这样一个规则存放的,
    但是第二项database_unique_name 并不是db_name;如果改变了db_unique_name,则之后创建的数据文件
    会放在新的目录下,会导致db_file_name_convert 的失效,这一点需要特别注意。
    3)如果RAC中使用db_create_online_log_dest_n 系列参数,要相应调整stangby 上的log_file_name_convert 参数。
    
    alter system set db_unique_name='leo'  scope=spfile sid='*'; 
    alter system set log_archive_config='dg_config=(leo,orcl_st)'   scope=spfile sid='*';
    alter system set log_archive_dest_1='location=+FRA valid_for=(all_logfiles,all_roles) db_unique_name=leo'  scope=spfile sid='*';
    alter system set log_archive_dest_2='service=orcl_st valid_for=(online_logfiles,primary_role) db_unique_name=orcl_st'   scope=spfile sid='*';
    alter system set log_archive_dest_state_1=enable   scope=spfile sid='*';
    alter system set log_archive_dest_state_2=enable   scope=spfile sid='*';
    alter system set standby_file_management='auto'   scope=spfile sid='*';
    alter system set fal_server='orcl_st'   scope=spfile sid='*';
    alter system set db_file_name_convert='/u01/app/oracle/oradata/orcl/data','+DATA/leo/datafile','/u01/app/oracle/oradata/orcl/tempfile','+DATA/leo/tempfile' scope=spfile sid='*';
    alter system set log_file_name_convert='/u01/app/oracle/oradata/orcl/redo','+DATA/leo/onlinelog' scope=spfile sid='*';
    alter system set log_archive_format='%t_%s_%r.arch' scope=spfile sid='*';
    
    --备库参数
    
    --在主库创建pfile 文件并scp 到备库修改
    主要指定一些pfile的路径,不要直接create pfile from spfile 
    
    create pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/tmp.ora' from spfile;
    [oracle@rac1 dbs]$ scp tmp.ora 192.168.1.65:/u01/app/oracle/product/11.2.0/db_1/dbs/initorcl.ora
    
    [oracle@localhost dbs]$ pwd
    /u01/app/oracle/product/11.2.0/db_1/dbs
    [oracle@localhost dbs]$ cat initorcl.ora 
    orcl.__db_cache_size=436207616
    orcl.__java_pool_size=16777216
    orcl.__large_pool_size=33554432
    orcl.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from environment
    orcl.__pga_aggregate_target=520093696
    orcl.__sga_target=754974720
    orcl.__shared_io_pool_size=0
    orcl.__shared_pool_size=251658240
    orcl.__streams_pool_size=0
    *.audit_file_dest='/u01/app/oracle/admin/orcl/adump'
    *.audit_trail='db'
    *.compatible='11.2.0.4.0'
    *.control_files='/u01/app/oracle/oradata/orcl/control01.ctl','/u01/app/oracle/fast_recovery_area/orcl/control02.ctl'
    *.db_block_size=8192
    *.db_domain=''
    *.db_name='leo'
    *.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
    *.db_recovery_file_dest_size=4621074432
    *.diagnostic_dest='/u01/app/oracle'
    *.dispatchers='(PROTOCOL=TCP) (SERVICE=leoXDB)'
    *.log_archive_dest_1='location=/u01/archive/'
    *.memory_target=1048576000
    *.open_cursors=300
    *.processes=150
    *.remote_login_passwordfile='exclusive'
    *.undo_tablespace='UNDOTBS1'
    --添加以下内容,对应修改上面的参数
    *.service_names='orcl_st'
    *.db_unique_name='orcl_st'
    *.log_archive_config='dg_config=(leo,orcl_st)' 
    *.log_archive_dest_1='location=/u01/archive valid_for=(all_logfiles,all_roles) db_unique_name=orcl_st' 
    *.log_archive_dest_2='service=leo valid_for=(online_logfiles,primary_role) db_unique_name=leo'
    *.log_archive_dest_state_1=enable 
    *.log_archive_dest_state_2=enable
    *.log_archive_format=%t_%s_%r.arc 
    *.standby_file_management='auto'
    *.fal_server='leo' 
    *.log_file_name_convert='+DATA/leo/onlinelog','/u01/app/oracle/oradata/orcl/redo'
    *.db_file_name_convert='+DATA/leo/datafile','/u01/app/oracle/oradata/orcl/data','+DATA/leo/tempfile','/u01/app/oracle/oradata/orcl/tempfile'

    10 使用 spfile 将备库启动 nomount 状态并启动监听 

    [oracle@localhost ~]$ lsnrctl start
    
    LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 28-MAY-2017 10:31:13
    
    Copyright (c) 1991, 2013, Oracle.  All rights reserved.
    
    Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...
    
    TNSLSNR for Linux: Version 11.2.0.4.0 - Production
    System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
    Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
    
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
    STATUS of the LISTENER
    ------------------------
    Alias                     LISTENER
    Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
    Start Date                28-MAY-2017 10:31:15
    Uptime                    0 days 0 hr. 0 min. 0 sec
    Trace Level               off
    Security                  ON: Local OS Authentication
    SNMP                      OFF
    Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
    Listener Log File         /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
    Listening Endpoints Summary...
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
      (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
    Services Summary...
    Service "orcl" has 1 instance(s).
      Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
    The command completed successfully
    
    [oracle@localhost dbs]$ sqlplus /nolog
    
    SQL*Plus: Release 11.2.0.4.0 Production on Sun May 28 22:36:14 2017
    
    Copyright (c) 1982, 2013, Oracle.  All rights reserved.
    
    SQL> conn /as sysdba
    Connected.
    
    SQL> create spfile from pfile;
    
    File created.
    
    SQL> startup nomount
    ORACLE instance started.
    
    Total System Global Area 1043886080 bytes
    Fixed Size		    2259840 bytes
    Variable Size		  654312576 bytes
    Database Buffers	  381681664 bytes
    Redo Buffers		    5632000 bytes

    11 开始进行 duplicate 

    [oracle@rac1 ~]$ rman target sys/oracle@leo auxiliary sys/oracle@orcl_st
    
    Recovery Manager: Release 11.2.0.4.0 - Production on Sun May 28 22:42:26 2017
    
    Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
    
    connected to target database: LEO (DBID=1717931218)
    connected to auxiliary database: LEO (not mounted)
    
    RMAN> duplicate target database for standby from active database dorecover;
    
    Starting Duplicate Db at 2017:05:28 22:42:36
    using target database control file instead of recovery catalog
    allocated channel: ORA_AUX_DISK_1
    channel ORA_AUX_DISK_1: SID=19 device type=DISK
    
    contents of Memory Script:
    {
       backup as copy reuse
       targetfile  '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwleo2' auxiliary format 
     '/u01/app/oracle/product/11.2.0/db_1/dbs/orapworcl'   ;
    }
    executing Memory Script
    
    Starting backup at 2017:05:28 22:42:37
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=53 instance=leo2 device type=DISK
    Finished backup at 2017:05:28 22:42:38
    
    contents of Memory Script:
    {
       backup as copy current controlfile for standby auxiliary format  '/u01/app/oracle/oradata/orcl/control01.ctl';
       restore clone controlfile to  '/u01/app/oracle/fast_recovery_area/orcl/control02.ctl' from 
     '/u01/app/oracle/oradata/orcl/control01.ctl';
    }
    executing Memory Script
    
    Starting backup at 2017:05:28 22:42:38
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting datafile copy
    copying standby control file
    output file name=/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_leo2.f tag=TAG20170528T224238 RECID=12 STAMP=945211363
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:04
    Finished backup at 2017:05:28 22:42:45
    
    Starting restore at 2017:05:28 22:42:45
    using channel ORA_AUX_DISK_1
    
    channel ORA_AUX_DISK_1: copied control file copy
    Finished restore at 2017:05:28 22:42:46
    
    contents of Memory Script:
    {
       sql clone 'alter database mount standby database';
    }
    executing Memory Script
    
    sql statement: alter database mount standby database
    
    contents of Memory Script:
    {
       set newname for tempfile  1 to 
     "/u01/app/oracle/oradata/orcl/tempfile/temp.279.943664427";
       switch clone tempfile all;
       set newname for datafile  1 to 
     "/u01/app/oracle/oradata/orcl/data/system.269.943664299";
       set newname for datafile  2 to 
     "/u01/app/oracle/oradata/orcl/data/sysaux.270.943664299";
       set newname for datafile  3 to 
     "/u01/app/oracle/oradata/orcl/data/undotbs1.271.943664301";
       set newname for datafile  4 to 
     "/u01/app/oracle/oradata/orcl/data/users.272.943664301";
       set newname for datafile  5 to 
     "/u01/app/oracle/oradata/orcl/data/undotbs2.280.943665551";
       backup as copy reuse
       datafile  1 auxiliary format 
     "/u01/app/oracle/oradata/orcl/data/system.269.943664299"   datafile 
     2 auxiliary format 
     "/u01/app/oracle/oradata/orcl/data/sysaux.270.943664299"   datafile 
     3 auxiliary format 
     "/u01/app/oracle/oradata/orcl/data/undotbs1.271.943664301"   datafile 
     4 auxiliary format 
     "/u01/app/oracle/oradata/orcl/data/users.272.943664301"   datafile 
     5 auxiliary format 
     "/u01/app/oracle/oradata/orcl/data/undotbs2.280.943665551"   ;
       sql 'alter system archive log current';
    }
    executing Memory Script
    
    executing command: SET NEWNAME
    
    renamed tempfile 1 to /u01/app/oracle/oradata/orcl/tempfile/temp.279.943664427 in control file
    
    executing command: SET NEWNAME
    
    executing command: SET NEWNAME
    
    executing command: SET NEWNAME
    
    executing command: SET NEWNAME
    
    executing command: SET NEWNAME
    
    Starting backup at 2017:05:28 22:42:53
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00001 name=+DATA/leo/datafile/system.269.943664299
    output file name=/u01/app/oracle/oradata/orcl/data/system.269.943664299 tag=TAG20170528T224253
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:46
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00002 name=+DATA/leo/datafile/sysaux.270.943664299
    output file name=/u01/app/oracle/oradata/orcl/data/sysaux.270.943664299 tag=TAG20170528T224253
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00003 name=+DATA/leo/datafile/undotbs1.271.943664301
    output file name=/u01/app/oracle/oradata/orcl/data/undotbs1.271.943664301 tag=TAG20170528T224253
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:08
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00005 name=+DATA/leo/datafile/undotbs2.280.943665551
    output file name=/u01/app/oracle/oradata/orcl/data/undotbs2.280.943665551 tag=TAG20170528T224253
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
    channel ORA_DISK_1: starting datafile copy
    input datafile file number=00004 name=+DATA/leo/datafile/users.272.943664301
    output file name=/u01/app/oracle/oradata/orcl/data/users.272.943664301 tag=TAG20170528T224253
    channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
    Finished backup at 2017:05:28 22:44:36
    
    sql statement: alter system archive log current
    
    contents of Memory Script:
    {
       backup as copy reuse
       archivelog like  "+FRA/leo_pd/archivelog/2017_05_28/thread_2_seq_56.304.945211383" auxiliary format 
     "/u01/archive/2_56_943664406.arc"   archivelog like 
     "+FRA/leo_pd/archivelog/2017_05_28/thread_1_seq_72.302.945199597" auxiliary format 
     "/u01/archive/1_72_943664406.arc"   archivelog like 
     "+FRA/leo_pd/archivelog/2017_05_28/thread_2_seq_57.306.945211479" auxiliary format 
     "/u01/archive/2_57_943664406.arc"   archivelog like 
     "+FRA/leo_pd/archivelog/2017_05_28/thread_1_seq_73.303.945211381" auxiliary format 
     "/u01/archive/1_73_943664406.arc"   archivelog like 
     "+FRA/leo_pd/archivelog/2017_05_28/thread_1_seq_74.305.945211477" auxiliary format 
     "/u01/archive/1_74_943664406.arc"   ;
       catalog clone archivelog  "/u01/archive/2_56_943664406.arc";
       catalog clone archivelog  "/u01/archive/1_72_943664406.arc";
       catalog clone archivelog  "/u01/archive/2_57_943664406.arc";
       catalog clone archivelog  "/u01/archive/1_73_943664406.arc";
       catalog clone archivelog  "/u01/archive/1_74_943664406.arc";
       switch clone datafile all;
    }
    executing Memory Script
    
    Starting backup at 2017:05:28 22:44:39
    using channel ORA_DISK_1
    channel ORA_DISK_1: starting archived log copy
    input archived log thread=2 sequence=56 RECID=98 STAMP=945211394
    output file name=/u01/archive/2_56_943664406.arc RECID=0 STAMP=0
    channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:03
    channel ORA_DISK_1: starting archived log copy
    input archived log thread=1 sequence=72 RECID=96 STAMP=945199602
    output file name=/u01/archive/1_72_943664406.arc RECID=0 STAMP=0
    channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:03
    channel ORA_DISK_1: starting archived log copy
    input archived log thread=2 sequence=57 RECID=100 STAMP=945211479
    output file name=/u01/archive/2_57_943664406.arc RECID=0 STAMP=0
    channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01
    channel ORA_DISK_1: starting archived log copy
    input archived log thread=1 sequence=73 RECID=97 STAMP=945211393
    output file name=/u01/archive/1_73_943664406.arc RECID=0 STAMP=0
    channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:03
    channel ORA_DISK_1: starting archived log copy
    input archived log thread=1 sequence=74 RECID=99 STAMP=945211477
    output file name=/u01/archive/1_74_943664406.arc RECID=0 STAMP=0
    channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:00
    Finished backup at 2017:05:28 22:44:51
    
    cataloged archived log
    archived log file name=/u01/archive/2_56_943664406.arc RECID=1 STAMP=945211492
    
    cataloged archived log
    archived log file name=/u01/archive/1_72_943664406.arc RECID=2 STAMP=945211492
    
    cataloged archived log
    archived log file name=/u01/archive/2_57_943664406.arc RECID=3 STAMP=945211493
    
    cataloged archived log
    archived log file name=/u01/archive/1_73_943664406.arc RECID=4 STAMP=945211493
    
    cataloged archived log
    archived log file name=/u01/archive/1_74_943664406.arc RECID=5 STAMP=945211493
    
    datafile 1 switched to datafile copy
    input datafile copy RECID=12 STAMP=945211493 file name=/u01/app/oracle/oradata/orcl/data/system.269.943664299
    datafile 2 switched to datafile copy
    input datafile copy RECID=13 STAMP=945211493 file name=/u01/app/oracle/oradata/orcl/data/sysaux.270.943664299
    datafile 3 switched to datafile copy
    input datafile copy RECID=14 STAMP=945211493 file name=/u01/app/oracle/oradata/orcl/data/undotbs1.271.943664301
    datafile 4 switched to datafile copy
    input datafile copy RECID=15 STAMP=945211493 file name=/u01/app/oracle/oradata/orcl/data/users.272.943664301
    datafile 5 switched to datafile copy
    input datafile copy RECID=16 STAMP=945211493 file name=/u01/app/oracle/oradata/orcl/data/undotbs2.280.943665551
    
    contents of Memory Script:
    {
       set until scn  2749620;
       recover
       standby
       clone database
        delete archivelog
       ;
    }
    executing Memory Script
    
    executing command: SET until clause
    
    Starting recover at 2017:05:28 22:44:53
    using channel ORA_AUX_DISK_1
    
    starting media recovery
    
    archived log for thread 1 with sequence 73 is already on disk as file /u01/archive/1_73_943664406.arc
    archived log for thread 1 with sequence 74 is already on disk as file /u01/archive/1_74_943664406.arc
    archived log for thread 2 with sequence 56 is already on disk as file /u01/archive/2_56_943664406.arc
    archived log for thread 2 with sequence 57 is already on disk as file /u01/archive/2_57_943664406.arc
    archived log file name=/u01/archive/1_73_943664406.arc thread=1 sequence=73
    archived log file name=/u01/archive/2_56_943664406.arc thread=2 sequence=56
    archived log file name=/u01/archive/2_57_943664406.arc thread=2 sequence=57
    archived log file name=/u01/archive/1_74_943664406.arc thread=1 sequence=74
    media recovery complete, elapsed time: 00:00:00
    Finished recover at 2017:05:28 22:44:56
    Finished Duplicate Db at 2017:05:28 22:45:14

    12 启动备库 
    --完成 duplicate 之后,备库就是 mount 状态: 

    SQL>  select NAME,open_mode from v$database; 
    
    NAME	  OPEN_MODE
    --------- --------------------
    LEO	  MOUNTED
    
    SQL> alter database open;
    
    Database altered.
    
    SQL> select open_mode from v$database;
    
    OPEN_MODE
    --------------------
    READ ONLY

    13 启动 MRP 进程 

    SQL>  alter database recover managed standby database disconnect from session;
    
    Database altered.
    
    SQL>  select open_mode from v$database; 
    
    OPEN_MODE
    --------------------
    READ ONLY WITH APPLY

    14 验证同步 

    节点1 执行
    
    SQL>  create table leo2 as select * from dba_users;
    
    Table created.
    
    SQL> alter system switch logfile;
    
    System altered.
    
    节点2 执行
    
    SQL> create table nancy as select * from dba_users;
    
    Table created.
    
    SQL> alter system switch logfile;
    
    System altered.
    
    --备库查询
    
    SQL> select count(*) from leo2;
    
      COUNT(*)
    ----------
    	31
    
    SQL> select count(*) from nancy; 
    
      COUNT(*)
    ----------
    	31
    
    SQL> select THREAD#,sequence#,applied from v$archived_log order by 1,2;
    
       THREAD#  SEQUENCE# APPLIED
    ---------- ---------- ---------
    	 1	   72 NO
    	 1	   73 YES
    	 1	   74 YES
    	 2	   56 YES
    	 2	   57 NO
    展开全文
  • Oracle 11g 单实例到RAC DG搭建步骤

    千次阅读 2019-05-17 09:05:25
    1.Oracle单实例到RAC DG搭建步骤 1.1.环境说明 角色 主库 备库 IP 192.168.1.59 192.168.1.51/52 数据库类型 单实例 RAC 实例 orcl orcl1,orcl2 db_name orcl orcl db_...
  • 实验:Oracle单实例通过DG迁移至RAC集群(Oracle 11g)步骤1:Oracle单实例搭建安装前准备:步骤2:Oracle RAC 双节点搭建步骤3:搭建DG步骤4:切换主备 步骤1:Oracle单实例搭建 操作系统:Oracle Linux 6.4 ...
  • Oracle 12c rac下的dg搭建

    2018-01-04 17:48:23
    具体rac搭建可下载参照我另外一份oracle 12c rac安装。
  • 一步一步在RHEL6.5+VMware Workstation 10上搭建 oracle 11gR2 rac + dg 之前传 (一) 2014年国庆放七天假,但对于我来说放不放假都一样,单身的我也不愿意多出去转转了,觉得没意思,看着人家一对一对的,我...
  • oracle 11gr2在linux下的安装配置,包括1.集群规划;2.RAC主库安装实施;3.RAC共享存储安装配置;4.安装GRID集群;5.ASM磁盘安装;6.安装数据库软件;7.安装数据库实例;8.备库安装配置。
  • 搭建rac+racdg

    2020-01-08 23:48:00
    主库 # rac1 192.168.56.33 rac1 192.168.56.111 rac1-vip 10.10.10.1 rac1-priv # rac2 192.168.56.44 rac2 192.168.56.112 rac2-vip 10.10.10.2 r...
  • Oracle 11g RAC+DG项目实战(共15集)视频

    千次阅读 2019-09-04 10:11:39
    下载地址: ...在15集视频中详细阐述了Oracle RAC的安装,RAC如何配置Active Data Guard,DG如何切换!绝对重量级的视频。掌握这个技术,资深Oracle DBA的岗位你也轻松秒杀! 实验手册在最后一集视频...
  • ORACLE 12C RAC 到 单机 DG 部署详细过程,遇到任何问题可以留言
  • Oracle 11g RAC搭建(VMware环境)

    万次阅读 多人点赞 2016-04-15 12:44:25
    Oracle 11g RAC搭建(VMware环境)Oracle 11g RAC搭建VMware环境 安装环境与网络规划 安装环境 网络规划 环境配置 通过SecureCRT建立命令行连接 关闭防火墙 创建必要的用户组和目录并授权 节点配置检查 系统文件设置...
  • 完整搭建Oracle 11gR2_RAC+ASM+DG ,满满的都是干货。。。
  • RAC上的DG搭建

    千次阅读 2017-07-29 10:00:41
    修改rman_backup这个文件的所有者和所属组,修改为oracle用户的oinstall组的文件 #chown –Roracle:oinstall /rman_backup/ 主库和备库都要执行   RAC主库准备工作: 1.RAC主库必须为归档模式: 查看是否为归档...
  • su - oracle lsnrctl services 如果没有,需要用grid用户在$ORACLE_HOME/network/admin/listener.ora文件中添加静态注册,然后reload listener(双节点): [grid@rac1 ~]$ vi listener.ora LISTENER=...
  • Oracle 19c使用dbca来搭建物理DG--主racrac SELECTCDBFROMV$DATABASE; alterdatabasearchivelog; alterdatabaseforcelogging; alterdatabaseflashbackon; alterdatabaseopen; alterpluggabledatabasea...
  • Oracle 11g RAC 搭建详细步骤

    万次阅读 2018-08-06 23:35:59
    Oracle RAC 搭建步骤详解 前期准备: 数据库:11.2.0.4 OS:Centos 6.8 IP分配: #publice ip 192.168.180.2 rac1 192.168.180.3 rac2 #private ip 10.10.10.2 rac1-priv 10.10.10.3 rac2-priv #vip ...
  • linux搭建oracle rac实操

    2019-03-05 21:00:44
    Oracle 11g RAC搭建(VMware环境) Oracle 11g RAC搭建(VMware环境) 安装环境与网络规划 安装环境 网络规划 环境配置 通过SecureCRT建立命令行连接 关闭防火墙 创建必要的用户、组和目录,并授权 节点配置检查 ...
1 2 3 4 5 ... 20
收藏数 1,394
精华内容 557
关键字:

dg搭建 oracle rac