zoukankan      html  css  js  c++  java
  • DG一主两备搭建

    实验环境在单机上创建三个库,一主两备,三个实例

    SQL> archive log list;
    Database log mode Archive Mode
    Automatic archival Enabled
    Archive destination /home/oracle/arch
    Oldest online log sequence 384
    Next log sequence to archive 386
    Current log sequence 386

    开启了force_logging
    SQL> select force_logging from v$database;

    FOR
    ---
    YES

    [oracle@db1 dbs]$ cat /etc/hosts
    127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
    ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

    192.168.220.210 db1

    增加两个静态监听

    LISTENER_DG =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = db1)(PORT = 1522))
    )
    )

    SID_LIST_LISTENER_DG=
    (SID_LIST =
    (SID_DESC =
    (GLOBAL_DBNAME = orcl11gdg)
    (ORACLE_HOME = /oracle/app/oracle/product/11.2.0/dbhome_1)
    (SID_NAME = orcl11gdg)
    )
    )

    LISTENER_GJ =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = db1)(PORT = 1523))
    )
    )

    SID_LIST_LISTENER_GJ=
    (SID_LIST =
    (SID_DESC =
    (GLOBAL_DBNAME = orcl11ggj)
    (ORACLE_HOME = /oracle/app/oracle/product/11.2.0/dbhome_1)
    (SID_NAME = orcl11ggj)
    )
    )

    ###########tnsnames
    orcl11g =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = db1)(PORT = 1521))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = orcl11g)
    )
    )
    orcl11gdg =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = db1)(PORT = 1522))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = orcl11gdg)
    )
    )

    orcl11ggj =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = db1)(PORT = 1523))
    (CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = orcl11ggj)
    )
    )

    启动监听并测试TNSPING 

    [oracle@db1 admin]$ tnsping orcl11gdg

    TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 25-MAY-2020 14:36:34

    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 = db1)(PORT = 1522)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl11g_dg)))
    OK (0 msec)
    [oracle@db1 admin]$ tnsping orcl11ggj

    TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 25-MAY-2020 14:36:42

    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 = db1)(PORT = 1523)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl11g_gj)))
    OK (10 msec)

    从主库memory创建pfile,并cp两个密码文件和pfile文件

    SQL> create pfile from memory;

    File created.

    SQL> show parameter spfile

    PARAMETER_NAME TYPE VALUE
    ------------------------------------------------------------ ----------- ----------------------------------------------------------------------------------------------------
    spfile string /oracle/app/oracle/product/11.2.0/dbhome_1/dbs/spfileorcl11g.ora


    [oracle@db1 dbs]$ ls -l
    total 48
    -rw-rw----. 1 oracle oinstall 1544 May 25 10:51 hc_orcl11g.dat
    -rw-r--r--. 1 oracle oinstall 2851 May 15 2009 init.ora
    -rw-r--r--. 1 oracle oinstall 6335 May 25 14:30 initorcl11g.ora
    -rw-r-----. 1 oracle oinstall 24 Dec 15 2018 lkORCL11G
    -rw-r-----. 1 oracle oinstall 1536 Dec 1 10:36 orapworcl11g
    -rw-r-----. 1 oracle oinstall 1536 Dec 15 2018 orapworcl11g.bak
    -rw-r-----. 1 oracle oinstall 14848 May 25 10:52 spfileorcl11g.ora
    -rw-r-----. 1 oracle oinstall 3584 Feb 27 2019 spfileorcl11g.ora.bak
    [oracle@db1 dbs]$ more lkORCL11G
    DO NOT DELETE THIS FILE!
    [oracle@db1 dbs]$ rm orapworcl11g.bak
    [oracle@db1 dbs]$ rm spfileorcl11g.ora.bak
    [oracle@db1 dbs]$ cp initorcl11g.ora initorcl11gdg.ora
    [oracle@db1 dbs]$ cp initorcl11g.ora initorcl11ggj.ora
    [oracle@db1 dbs]$ cp orapworcl11g orapworcl11gdg
    [oracle@db1 dbs]$ cp orapworcl11g orapworcl11ggj
    [oracle@db1 dbs]$

    主库配置参数

    SQL> show parameter remote_login_passwordfile

    PARAMETER_NAME TYPE VALUE
    ------------------------------------------------------------ ----------- ----------------------------------------------------------------------------------------------------
    remote_login_passwordfile string EXCLUSIVE
    SQL>

    ###primary
    alter system set log_archive_config='dg_config=(orcl11g,orcl11gdg,orcl11ggj)';
    alter system set log_archive_dest_2='service=orcl11gdg lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcl11gdg';
    alter system set log_archive_dest_3='service=orcl11ggj lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcl11ggj';
    alter system set standby_file_management=auto;
    alter system set fal_server=orcl11gdg,orcl11ggj;
    alter system set fal_client=orcl11g;
    alter system set log_archive_dest_state_1=enable;
    alter system set log_archive_dest_state_2=enable;
    alter system set log_archive_dest_state_3=enable;

    alter system set log_archive_dest_state_2=defer;
    alter system set log_archive_dest_state_3=defer;

    SQL> show parameter arch

    PARAMETER_NAME TYPE VALUE
    ------------------------------------------------------------ ----------- ----------------------------------------------------------------------------------------------------
    archive_lag_target integer 0
    log_archive_config string dg_config=(orcl11g,orcl11gdg,orcl11ggj)
    log_archive_dest string
    log_archive_dest_1 string LOCATION=/home/oracle/arch
    log_archive_dest_10 string
    log_archive_dest_11 string
    log_archive_dest_12 string
    log_archive_dest_13 string
    log_archive_dest_14 string
    log_archive_dest_15 string
    log_archive_dest_16 string
    log_archive_dest_17 string
    log_archive_dest_18 string
    log_archive_dest_19 string
    log_archive_dest_2 string service=orcl11gdg lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcl11gdg
    log_archive_dest_20 string
    log_archive_dest_21 string
    log_archive_dest_22 string
    log_archive_dest_23 string
    log_archive_dest_24 string
    log_archive_dest_25 string
    log_archive_dest_26 string
    log_archive_dest_27 string
    log_archive_dest_28 string
    log_archive_dest_29 string
    log_archive_dest_3 string service=orcl11ggj lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcl11ggj
    log_archive_dest_30 string
    log_archive_dest_31 string
    log_archive_dest_4 string
    log_archive_dest_5 string
    log_archive_dest_6 string
    log_archive_dest_7 string
    log_archive_dest_8 string
    log_archive_dest_9 string
    log_archive_dest_state_1 string ENABLE
    log_archive_dest_state_10 string enable
    log_archive_dest_state_11 string enable
    log_archive_dest_state_12 string enable
    log_archive_dest_state_13 string enable
    log_archive_dest_state_14 string enable
    log_archive_dest_state_15 string enable
    log_archive_dest_state_16 string enable
    log_archive_dest_state_17 string enable
    log_archive_dest_state_18 string enable
    log_archive_dest_state_19 string enable
    log_archive_dest_state_2 string ENABLE
    log_archive_dest_state_20 string enable
    log_archive_dest_state_21 string enable
    log_archive_dest_state_22 string enable
    log_archive_dest_state_23 string enable
    log_archive_dest_state_24 string enable
    log_archive_dest_state_25 string enable
    log_archive_dest_state_26 string enable
    log_archive_dest_state_27 string enable
    log_archive_dest_state_28 string enable
    log_archive_dest_state_29 string enable
    log_archive_dest_state_3 string ENABLE
    log_archive_dest_state_30 string enable
    log_archive_dest_state_31 string enable
    log_archive_dest_state_4 string enable
    log_archive_dest_state_5 string enable
    log_archive_dest_state_6 string enable
    log_archive_dest_state_7 string enable
    log_archive_dest_state_8 string enable
    log_archive_dest_state_9 string enable
    log_archive_duplex_dest string
    log_archive_format string %t_%s_%r.dbf
    log_archive_local_first boolean TRUE
    log_archive_max_processes integer 4
    log_archive_min_succeed_dest integer 1
    log_archive_start boolean FALSE
    log_archive_trace integer 0
    standby_archive_dest string ?/dbs/arch

    创建两个备库的文件目录,并在ORACLE_BASE/admin下创建adump目录

    mkdir -P /oradata/orcl11gdg/archgj
    mkdir -p /oradata/orcl11ggj/archdg

    cd $ORACLE_BASE
    [oracle@db1 admin]$ mkdir orcl11gdg
    [oracle@db1 admin]$ cd orcl11gdg/
    [oracle@db1 orcl11gdg]$ ls
    [oracle@db1 orcl11gdg]$ mkdir adump
    [oracle@db1 orcl11gdg]$ cd ..
    [oracle@db1 admin]$ ls
    orcl11g orcl11gdg
    [oracle@db1 admin]$ mkdir orcl11ggj
    [oracle@db1 admin]$ cd orcl11ggj
    [oracle@db1 orcl11ggj]$ mkdir adump
    [oracle@db1 orcl11ggj]$ cd ..
    [oracle@db1 admin]$ ls
    orcl11g orcl11gdg orcl11ggj

    修改第一个备库的pfile只保留 db_name=orcl11g,并启动到nomount状态

    [oracle@db1 ~]$ export ORACLE_SID=orcl11gdg
    [oracle@db1 ~]$ sqlplus / as sysdba

    SQL*Plus: Release 11.2.0.4.0 Production on Mon May 25 15:16:55 2020

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

    Connected to an idle instance.

    SQL> startup nomount;
    ORACLE instance started.

    Total System Global Area 217157632 bytes
    Fixed Size 2251816 bytes
    Variable Size 159384536 bytes
    Database Buffers 50331648 bytes
    Redo Buffers 5189632 bytes
    SQL>

    rman target sys/oracle@orcl11g auxiliary sys/oracle@orcl11gdg

    run
    {
    allocate channel prim type disk;
    allocate channel prim1 type disk;
    allocate auxiliary channel aux type disk;
    allocate auxiliary channel aux1 type disk;
    duplicate target database for standby from active database nofilenamecheck
    spfile
    parameter_value_convert 'orcl11g','orcl11gdg'
    set db_unique_name='orcl11gdg'
    set log_archive_config='dg_config=(orcl11g,orcl11gdg)'
    set log_archive_dest_1='location=/oradata/orcl11gdg/archdg'
    set log_archive_dest_2='service=orcl11g lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcl11g'
    set log_archive_format='%t_%s_%r.arch'
    set control_files='/oradata/orcl11gdg/control01.ctl','/oradata/orcl11gdg/control02.ctl'
    set standby_file_management='AUTO'
    set db_file_name_convert='/oracle/app/oracle/oradata/ORCL11G/datafile','/oradata/orcl11gdg'
    set log_file_name_convert='/oracle/app/oracle/oradata/ORCL11G/onlinelog','/oradata/orcl11gdg'
    set fal_server='orcl11g,orcl11ggj'
    set fal_client='orcl11gdg'
    set audit_file_dest='/oracle/app/oracle/admin/orcl11gdg/adump';
    sql channel aux "alter database add standby logfile ''/oradata/orcl11gdg/stdby4.log'' size 50M";
    sql channel aux "alter database add standby logfile ''/oradata/orcl11gdg/stdby5.log'' size 50M";
    sql channel aux "alter database add standby logfile ''/oradata/orcl11gdg/stdby6.log'' size 50M";
    sql channel aux "alter database add standby logfile ''/oradata/orcl11gdg/stdby7.log'' size 50M";
    sql channel aux "alter database open read only";
    sql channel aux "ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT";
    sql channel prim "alter system archive log current";
    }

    ############standby1 日志

    RMAN> run
    2> {
    3> allocate channel prim type disk;
    4> allocate channel prim1 type disk;
    5> allocate auxiliary channel aux type disk;
    6> allocate auxiliary channel aux1 type disk;
    7> duplicate target database for standby from active database nofilenamecheck
    8> spfile
    9> parameter_value_convert 'orcl11g','orcl11gdg'
    10> set db_unique_name='orcl11gdg'
    11> set log_archive_config='dg_config=(orcl11g,orcl11gdg)'
    12> set log_archive_dest_1='location=/oradata/orcl11gdg/archdg'
    13> set log_archive_dest_2='service=orcl11g lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcl11g'
    14> set log_archive_format='%t_%s_%r.arch'
    15> set control_files='/oradata/orcl11gdg/control01.ctl','/oradata/orcl11gdg/control02.ctl'
    16> set standby_file_management='AUTO'
    17> set db_file_name_convert='/oracle/app/oracle/oradata/ORCL11G/datafile','/oradata/orcl11gdg'
    18> set log_file_name_convert='/oracle/app/oracle/oradata/ORCL11G/onlinelog','/oradata/orcl11gdg'
    19> set fal_server='orcl11g,orcl11ggj'
    20> set fal_client='orcl11gdg'
    21> set audit_file_dest='/oracle/app/oracle/admin/orcl11gdg/adump';
    22> sql channel aux "alter database add standby logfile ''/oracle/app/oracle/oradata/test/stdby4.log'' size 50M";
    23> sql channel aux "alter database add standby logfile ''/oracle/app/oracle/oradata/test/stdby5.log'' size 50M";
    24> sql channel aux "alter database add standby logfile ''/oracle/app/oracle/oradata/test/stdby6.log'' size 50M";
    25> sql channel aux "alter database add standby logfile ''/oracle/app/oracle/oradata/test/stdby7.log'' size 50M";
    26> sql channel aux "alter database open read only";
    27> sql channel aux "ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT";
    28> sql channel prim "alter system archive log current";
    29> }

    allocated channel: prim
    channel prim: SID=43 device type=DISK

    allocated channel: prim1
    channel prim1: SID=1 device type=DISK

    allocated channel: aux
    channel aux: SID=20 device type=DISK

    allocated channel: aux1
    channel aux1: SID=21 device type=DISK

    Starting Duplicate Db at 25-MAY-20

    contents of Memory Script:
    {
    backup as copy reuse
    targetfile '/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/orapworcl11g' auxiliary format
    '/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/orapworcl11gdg' targetfile
    '/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/spfileorcl11g.ora' auxiliary format
    '/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/spfileorcl11gdg.ora' ;
    sql clone "alter system set spfile= ''/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/spfileorcl11gdg.ora''";
    }
    executing Memory Script

    Starting backup at 25-MAY-20
    Finished backup at 25-MAY-20

    sql statement: alter system set spfile= ''/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/spfileorcl11gdg.ora''

    contents of Memory Script:
    {
    sql clone "alter system set background_dump_dest =
    ''/oracle/app/oracle/diag/rdbms/orcl11gdg/orcl11g/trace'' comment=
    ''Deprecate parameter'' scope=spfile";
    sql clone "alter system set core_dump_dest =
    ''/oracle/app/oracle/diag/rdbms/orcl11gdg/orcl11g/cdump'' comment=
    '''' scope=spfile";
    sql clone "alter system set dispatchers =
    ''(PROTOCOL=TCP) (SERVICE=orcl11gdgXDB)'' comment=
    '''' scope=spfile";
    sql clone "alter system set log_archive_dest_3 =
    ''service=orcl11gdggj lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcl11ggj'' comment=
    '''' scope=spfile";
    sql clone "alter system set user_dump_dest =
    ''/oracle/app/oracle/diag/rdbms/orcl11gdg/orcl11g/trace'' comment=
    ''Deprecate parameter'' scope=spfile";
    sql clone "alter system set db_unique_name =
    ''orcl11gdg'' comment=
    '''' scope=spfile";
    sql clone "alter system set log_archive_config =
    ''dg_config=(orcl11g,orcl11gdg)'' comment=
    '''' scope=spfile";
    sql clone "alter system set log_archive_dest_1 =
    ''location=/oradata/orcl11gdg/archdg'' comment=
    '''' scope=spfile";
    sql clone "alter system set log_archive_dest_2 =
    ''service=orcl11g lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcl11g'' comment=
    '''' scope=spfile";
    sql clone "alter system set log_archive_format =
    ''%t_%s_%r.arch'' comment=
    '''' scope=spfile";
    sql clone "alter system set control_files =
    ''/oradata/orcl11gdg/control01.ctl'', ''/oradata/orcl11gdg/control02.ctl'' comment=
    '''' scope=spfile";
    sql clone "alter system set standby_file_management =
    ''AUTO'' comment=
    '''' scope=spfile";
    sql clone "alter system set db_file_name_convert =
    ''/oracle/app/oracle/oradata/ORCL11G/datafile'', ''/oradata/orcl11gdg'' comment=
    '''' scope=spfile";
    sql clone "alter system set log_file_name_convert =
    ''/oracle/app/oracle/oradata/ORCL11G/onlinelog'', ''/oradata/orcl11gdg'' comment=
    '''' scope=spfile";
    sql clone "alter system set fal_server =
    ''orcl11g,orcl11ggj'' comment=
    '''' scope=spfile";
    sql clone "alter system set fal_client =
    ''orcl11gdg'' comment=
    '''' scope=spfile";
    sql clone "alter system set audit_file_dest =
    ''/oracle/app/oracle/admin/orcl11gdg/adump'' comment=
    '''' scope=spfile";
    shutdown clone immediate;
    startup clone nomount;
    }
    executing Memory Script

    sql statement: alter system set background_dump_dest = ''/oracle/app/oracle/diag/rdbms/orcl11gdg/orcl11g/trace'' comment= ''Deprecate parameter'' scope=spfile

    sql statement: alter system set core_dump_dest = ''/oracle/app/oracle/diag/rdbms/orcl11gdg/orcl11g/cdump'' comment= '''' scope=spfile

    sql statement: alter system set dispatchers = ''(PROTOCOL=TCP) (SERVICE=orcl11gdgXDB)'' comment= '''' scope=spfile

    sql statement: alter system set log_archive_dest_3 = ''service=orcl11gdggj lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcl11ggj'' comment= '''' scope=spfile

    sql statement: alter system set user_dump_dest = ''/oracle/app/oracle/diag/rdbms/orcl11gdg/orcl11g/trace'' comment= ''Deprecate parameter'' scope=spfile

    sql statement: alter system set db_unique_name = ''orcl11gdg'' comment= '''' scope=spfile

    sql statement: alter system set log_archive_config = ''dg_config=(orcl11g,orcl11gdg)'' comment= '''' scope=spfile

    sql statement: alter system set log_archive_dest_1 = ''location=/oradata/orcl11gdg/archdg'' comment= '''' scope=spfile

    sql statement: alter system set log_archive_dest_2 = ''service=orcl11g lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcl11g'' comment= '''' scope=spfile

    sql statement: alter system set log_archive_format = ''%t_%s_%r.arch'' comment= '''' scope=spfile

    sql statement: alter system set control_files = ''/oradata/orcl11gdg/control01.ctl'', ''/oradata/orcl11gdg/control02.ctl'' comment= '''' scope=spfile

    sql statement: alter system set standby_file_management = ''AUTO'' comment= '''' scope=spfile

    sql statement: alter system set db_file_name_convert = ''/oracle/app/oracle/oradata/ORCL11G/datafile'', ''/oradata/orcl11gdg'' comment= '''' scope=spfile

    sql statement: alter system set log_file_name_convert = ''/oracle/app/oracle/oradata/ORCL11G/onlinelog'', ''/oradata/orcl11gdg'' comment= '''' scope=spfile

    sql statement: alter system set fal_server = ''orcl11g,orcl11ggj'' comment= '''' scope=spfile

    sql statement: alter system set fal_client = ''orcl11gdg'' comment= '''' scope=spfile

    sql statement: alter system set audit_file_dest = ''/oracle/app/oracle/admin/orcl11gdg/adump'' comment= '''' scope=spfile

    Oracle instance shut down

    connected to auxiliary database (not started)
    Oracle instance started

    Total System Global Area 626327552 bytes

    Fixed Size 2255832 bytes
    Variable Size 343933992 bytes
    Database Buffers 276824064 bytes
    Redo Buffers 3313664 bytes
    allocated channel: aux
    channel aux: SID=20 device type=DISK
    allocated channel: aux1
    channel aux1: SID=21 device type=DISK

    contents of Memory Script:
    {
    backup as copy current controlfile for standby auxiliary format '/oradata/orcl11gdg/control01.ctl';
    restore clone controlfile to '/oradata/orcl11gdg/control02.ctl' from
    '/oradata/orcl11gdg/control01.ctl';
    }
    executing Memory Script

    Starting backup at 25-MAY-20
    channel prim: starting datafile copy
    copying standby control file
    output file name=/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_orcl11g.f tag=TAG20200525T154440 RECID=3 STAMP=1041349481
    channel prim: datafile copy complete, elapsed time: 00:00:01
    Finished backup at 25-MAY-20

    Starting restore at 25-MAY-20

    channel aux1: skipped, AUTOBACKUP already found
    channel aux: copied control file copy
    Finished restore at 25-MAY-20

    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
    "/oradata/orcl11gdg/o1_mf_temp_g18tnqlc_.tmp";
    set newname for tempfile 2 to
    "/oradata/orcl11gdg/o1_mf_temp_gy1q8tp3_.tmp";
    switch clone tempfile all;
    set newname for datafile 1 to
    "/oradata/orcl11gdg/o1_mf_system_g18tl0pq_.dbf";
    set newname for datafile 2 to
    "/oradata/orcl11gdg/o1_mf_sysaux_g18tl0t2_.dbf";
    set newname for datafile 3 to
    "/oradata/orcl11gdg/o1_mf_undotbs1_g18tl0t8_.dbf";
    set newname for datafile 4 to
    "/oradata/orcl11gdg/o1_mf_users_g18tl0tr_.dbf";
    set newname for datafile 5 to
    "/oradata/orcl11gdg/o1_mf_example_g18tnzhk_.dbf";
    set newname for datafile 6 to
    "/oradata/orcl11gdg/o1_mf_tbs2_gy6cdqxn_.dbf";
    set newname for datafile 7 to
    "/oradata/orcl11gdg/o1_mf_tbs3_gyg1rzln_.dbf";
    set newname for datafile 8 to
    "/oradata/orcl11gdg/o1_mf_ogg_h4s8h1jh_.dbf";
    backup as copy reuse
    datafile 1 auxiliary format
    "/oradata/orcl11gdg/o1_mf_system_g18tl0pq_.dbf" datafile
    2 auxiliary format
    "/oradata/orcl11gdg/o1_mf_sysaux_g18tl0t2_.dbf" datafile
    3 auxiliary format
    "/oradata/orcl11gdg/o1_mf_undotbs1_g18tl0t8_.dbf" datafile
    4 auxiliary format
    "/oradata/orcl11gdg/o1_mf_users_g18tl0tr_.dbf" datafile
    5 auxiliary format
    "/oradata/orcl11gdg/o1_mf_example_g18tnzhk_.dbf" datafile
    6 auxiliary format
    "/oradata/orcl11gdg/o1_mf_tbs2_gy6cdqxn_.dbf" datafile
    7 auxiliary format
    "/oradata/orcl11gdg/o1_mf_tbs3_gyg1rzln_.dbf" datafile
    8 auxiliary format
    "/oradata/orcl11gdg/o1_mf_ogg_h4s8h1jh_.dbf" ;
    sql 'alter system archive log current';
    }
    executing Memory Script

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    renamed tempfile 1 to /oradata/orcl11gdg/o1_mf_temp_g18tnqlc_.tmp in control file
    renamed tempfile 2 to /oradata/orcl11gdg/o1_mf_temp_gy1q8tp3_.tmp in control file

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    Starting backup at 25-MAY-20
    channel prim: starting datafile copy
    input datafile file number=00004 name=/oracle/app/oracle/oradata/ORCL11G/datafile/o1_mf_users_g18tl0tr_.dbf
    channel prim1: starting datafile copy
    input datafile file number=00003 name=/oracle/app/oracle/oradata/ORCL11G/datafile/o1_mf_undotbs1_g18tl0t8_.dbf
    output file name=/oradata/orcl11gdg/o1_mf_users_g18tl0tr_.dbf tag=TAG20200525T154455
    channel prim: datafile copy complete, elapsed time: 00:01:05
    channel prim: starting datafile copy
    input datafile file number=00001 name=/oracle/app/oracle/oradata/ORCL11G/datafile/o1_mf_system_g18tl0pq_.dbf
    output file name=/oradata/orcl11gdg/o1_mf_undotbs1_g18tl0t8_.dbf tag=TAG20200525T154455
    channel prim1: datafile copy complete, elapsed time: 00:01:05
    channel prim1: starting datafile copy
    input datafile file number=00002 name=/oracle/app/oracle/oradata/ORCL11G/datafile/o1_mf_sysaux_g18tl0t2_.dbf
    output file name=/oradata/orcl11gdg/o1_mf_sysaux_g18tl0t2_.dbf tag=TAG20200525T154455
    channel prim1: datafile copy complete, elapsed time: 00:00:35
    channel prim1: starting datafile copy
    input datafile file number=00005 name=/oracle/app/oracle/oradata/ORCL11G/datafile/o1_mf_example_g18tnzhk_.dbf
    output file name=/oradata/orcl11gdg/o1_mf_system_g18tl0pq_.dbf tag=TAG20200525T154455
    channel prim: datafile copy complete, elapsed time: 00:00:39
    channel prim: starting datafile copy
    input datafile file number=00007 name=/oracle/app/oracle/oradata/ORCL11G/datafile/o1_mf_tbs3_gyg1rzln_.dbf
    output file name=/oradata/orcl11gdg/o1_mf_example_g18tnzhk_.dbf tag=TAG20200525T154455
    channel prim1: datafile copy complete, elapsed time: 00:00:10
    channel prim1: starting datafile copy
    input datafile file number=00008 name=/oracle/app/oracle/oradata/ORCL11G/datafile/o1_mf_ogg_h4s8h1jh_.dbf
    output file name=/oradata/orcl11gdg/o1_mf_tbs3_gyg1rzln_.dbf tag=TAG20200525T154455
    channel prim: datafile copy complete, elapsed time: 00:00:10
    channel prim: starting datafile copy
    input datafile file number=00006 name=/oracle/app/oracle/oradata/ORCL11G/datafile/o1_mf_tbs2_gy6cdqxn_.dbf
    output file name=/oradata/orcl11gdg/o1_mf_tbs2_gy6cdqxn_.dbf tag=TAG20200525T154455
    channel prim: datafile copy complete, elapsed time: 00:00:01
    output file name=/oradata/orcl11gdg/o1_mf_ogg_h4s8h1jh_.dbf tag=TAG20200525T154455
    channel prim1: datafile copy complete, elapsed time: 00:00:04
    Finished backup at 25-MAY-20

    sql statement: alter system archive log current

    contents of Memory Script:
    {
    switch clone datafile all;
    }
    executing Memory Script

    datafile 1 switched to datafile copy
    input datafile copy RECID=3 STAMP=1041349610 file name=/oradata/orcl11gdg/o1_mf_system_g18tl0pq_.dbf
    datafile 2 switched to datafile copy
    input datafile copy RECID=4 STAMP=1041349610 file name=/oradata/orcl11gdg/o1_mf_sysaux_g18tl0t2_.dbf
    datafile 3 switched to datafile copy
    input datafile copy RECID=5 STAMP=1041349610 file name=/oradata/orcl11gdg/o1_mf_undotbs1_g18tl0t8_.dbf
    datafile 4 switched to datafile copy
    input datafile copy RECID=6 STAMP=1041349610 file name=/oradata/orcl11gdg/o1_mf_users_g18tl0tr_.dbf
    datafile 5 switched to datafile copy
    input datafile copy RECID=7 STAMP=1041349610 file name=/oradata/orcl11gdg/o1_mf_example_g18tnzhk_.dbf
    datafile 6 switched to datafile copy
    input datafile copy RECID=8 STAMP=1041349610 file name=/oradata/orcl11gdg/o1_mf_tbs2_gy6cdqxn_.dbf
    datafile 7 switched to datafile copy
    input datafile copy RECID=9 STAMP=1041349610 file name=/oradata/orcl11gdg/o1_mf_tbs3_gyg1rzln_.dbf
    datafile 8 switched to datafile copy
    input datafile copy RECID=10 STAMP=1041349610 file name=/oradata/orcl11gdg/o1_mf_ogg_h4s8h1jh_.dbf
    Finished Duplicate Db at 25-MAY-20

    sql statement: alter database add standby logfile ''/oracle/app/oracle/oradata/test/stdby4.log'' size 50M
    released channel: prim
    released channel: prim1
    released channel: aux
    released channel: aux1
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03009: failure of sql command on aux channel at 05/25/2020 15:46:55
    RMAN-11003: failure during parse/execution of SQL statement: alter database add standby logfile '/oracle/app/oracle/oradata/test/stdby4.log' size 50M
    ORA-00301: error in adding log file '/oracle/app/oracle/oradata/test/stdby4.log' - file cannot be created
    ORA-27040: file create error, unable to create file
    Linux-x86_64 Error: 2: No such file or directory
    Additional information: 1

    RMAN>

    错误是因为standby log路径写错


    SQL> select open_mode from v$database;

    OPEN_MODE
    --------------------
    MOUNTED

    SQL> alter database add standby logfile '/oradata/orcl11gdg/stdby4.log' size 50M;

    Database altered.

    SQL> alter database add standby logfile '/oradata/orcl11gdg/stdby5.log' size 50M;

    Database altered.

    SQL> alter database add standby logfile '/oradata/orcl11gdg/stdby6.log' size 50M;

    Database altered.

    SQL> alter database add standby logfile '/oradata/orcl11gdg/stdby7.log' size 50M;

    Database altered.

    SQL> alter database open read only;
    alter database open read only
    *
    ERROR at line 1:
    ORA-10458: standby database requires recovery
    ORA-01152: file 1 was not restored from a sufficiently old backup
    ORA-01110: data file 1: '/oradata/orcl11gdg/o1_mf_system_g18tl0pq_.dbf'


    SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;

    Database altered.

    #primary
    SQL> alter system set log_archive_dest_state_2=enable;

    System altered.

    SQL>

    ##standby

    SQL> select name,open_mode,database_role,db_unique_name,protection_mode,protection_level from v$database;

    NAME OPEN_MODE DATABASE_ROLE DB_UNIQUE_NAME PROTECTION_MODE PROTECTION_LEVEL
    --------- -------------------- ---------------- ------------------------------ -------------------- --------------------
    ORCL11G READ ONLY WITH APPLY PHYSICAL STANDBY orcl11gdg MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE

    ##########################################

     standby2    spfile搞起来到nomount状态

    [oracle@db1 dbs]$ export ORACLE_SID=orcl11ggj
    [oracle@db1 dbs]$ sqlplus / as sysdba

    SQL*Plus: Release 11.2.0.4.0 Production on Mon May 25 16:07:38 2020

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

    Connected to an idle instance.

    SQL> startup nomount;
    ORACLE instance started.

    Total System Global Area 217157632 bytes
    Fixed Size 2251816 bytes
    Variable Size 159384536 bytes
    Database Buffers 50331648 bytes
    Redo Buffers 5189632 bytes
    SQL> exit
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    [oracle@db1 dbs]$ sqlplus / as sysdba

    SQL*Plus: Release 11.2.0.4.0 Production on Mon May 25 16:10:24 2020

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


    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options


    SQL> create spfile from pfile;

    File created.

    SQL> alter system set log_archive_config='dg_config=(orcl11g,orcl11ggj)';

    System altered.

    SQL> alter system set log_archive_dest_1='location=/oradata/orcl11ggj/archgj';

    System altered.

    SQL> alter system set log_archive_dest_2='service=orcl11g lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcl11g';

    System altered.

    SQL> alter system set standby_file_management=auto;

    System altered.

    SQL> alter system set fal_server=orcl11g,orcl11gdg;

    System altered.

    SQL> alter system set fal_client=orcl11ggj;

    System altered.

    SQL> alter system set log_archive_dest_state_1=enable;

    System altered.

    SQL> alter system set log_archive_dest_state_2=enable;

    System altered.

    SQL> alter system set log_archive_format='%t_%s_%r.arch' scope=spfile;
    alter system set log_archive_format='%t_%s_%r.arch' scope=spfile
    *
    ERROR at line 1:
    ORA-32001: write to SPFILE requested but no SPFILE is in use


    SQL> alter system set db_file_name_convert='/oracle/app/oracle/oradata/ORCL11G/datafile','/oradata/orcl11ggj' scope=spfile;
    alter system set db_file_name_convert='/oracle/app/oracle/oradata/ORCL11G/datafile','/oradata/orcl11ggj' scope=spfile
    *
    ERROR at line 1:
    ORA-32001: write to SPFILE requested but no SPFILE is in use


    SQL> alter system set log_file_name_convert='/oracle/app/oracle/oradata/ORCL11G/onlinelog','/oradata/orcl11ggj' scope=spfile;
    alter system set log_file_name_convert='/oracle/app/oracle/oradata/ORCL11G/onlinelog','/oradata/orcl11ggj' scope=spfile
    *
    ERROR at line 1:
    ORA-32001: write to SPFILE requested but no SPFILE is in use


    SQL>
    SQL>
    SQL> shutdown abort
    ORACLE instance shut down.
    SQL> startup nomount
    ORACLE instance started.

    Total System Global Area 217157632 bytes
    Fixed Size 2251816 bytes
    Variable Size 159384536 bytes
    Database Buffers 50331648 bytes
    Redo Buffers 5189632 bytes
    SQL> alter system set log_archive_config='dg_config=(orcl11g,orcl11ggj)';

    System altered.

    SQL> alter system set log_archive_dest_1='location=/oradata/orcl11ggj/archgj';

    System altered.

    SQL> alter system set log_archive_dest_2='service=orcl11g lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcl11g';

    System altered.

    SQL> alter system set standby_file_management=auto;

    System altered.

    SQL> alter system set fal_server=orcl11g,orcl11gdg;

    System altered.

    SQL> alter system set fal_client=orcl11ggj;

    System altered.

    SQL> alter system set log_archive_dest_state_1=enable;

    System altered.

    SQL> alter system set log_archive_dest_state_2=enable;

    System altered.

    SQL> alter system set log_archive_format='%t_%s_%r.arch' scope=spfile;

    System altered.

    SQL> alter system set db_file_name_convert='/oracle/app/oracle/oradata/ORCL11G/datafile','/oradata/orcl11ggj' scope=spfile;

    System altered.

    SQL> alter system set log_file_name_convert='/oracle/app/oracle/oradata/ORCL11G/onlinelog','/oradata/orcl11ggj' scope=spfile;

    System altered.


    ###primary全库备份

    rman target / <<EOF
    run{allocate channel c1 type disk;
    allocate channel c2 type disk;
    backup full database format '/oradata/backup/full_%U.bak' plus archivelog;
    sql 'alter system switch logfile';
    backup current controlfile for standby format '/oradata/backup/c_%U.bak';
    release channel c1;
    release channel c2;
    }
    EOF

    ###standby 

    恢复controlfile,并启动到mount下

    [oracle@db1 dbs]$ rman target /

    Recovery Manager: Release 11.2.0.4.0 - Production on Mon May 25 16:33:43 2020

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

    connected to target database: ORCL11G (not mounted)

    RMAN> restore standby controlfile from '/oradata/backup/c_16v13hnh_1_1.bak';

    Starting restore at 25-MAY-20
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=19 device type=DISK

    channel ORA_DISK_1: restoring control file
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
    output file name=/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/cntrlorcl11ggj.dbf
    Finished restore at 25-MAY-20

    RMAN>

    [oracle@db1 dbs]$ cp /oracle/app/oracle/product/11.2.0/dbhome_1/dbs/cntrlorcl11ggj.dbf /oradata/orcl11ggj
    [oracle@db1 dbs]$ sqlplus / as sysdba

    SQL> alter system set control_files='/oradata/orcl11ggj/cntrlorcl11ggj.dbf' scope=spfile;

    System altered.

    shutdown abort
    ORACLE instance shut down.

    SQL> startup nomount;
    ORACLE instance started.

    Total System Global Area 217157632 bytes
    Fixed Size 2251816 bytes
    Variable Size 159384536 bytes
    Database Buffers 50331648 bytes
    Redo Buffers 5189632 bytes

    SQL> show parameter control

    NAME TYPE
    ------------------------------------ ----------------------
    VALUE
    ------------------------------
    control_file_record_keep_time integer
    7
    control_files string
    /oradata/ora11ggj/cntrlorcl11g
    gj.dbf
    control_management_pack_access string
    DIAGNOSTIC+TUNING
    SQL>


    SQL> alter database mount;
    alter database mount
    *
    ERROR at line 1:
    ORA-00201: control file version 11.2.0.4.0 incompatible with ORACLE version
    11.2.0.0.0
    ORA-00202: control file: '/oradata/orcl11ggj/cntrlorcl11ggj.dbf'


    SQL> show parameter compatible

    NAME TYPE VALUE
    ------------------------------------ ----------- ------------------------------
    compatible string 11.2.0


    SQL> create pfile from spfile;

    File created.

    SQL> shutdown abort
    ORACLE instance shut down.
    SQL>

    修改compatible
    [oracle@db1 dbs]$ cat initorcl11ggj.ora
    orcl11ggj.__oracle_base='/oracle/app/oracle'#ORACLE_BASE set from environment
    *.control_files='/oradata/orcl11ggj/cntrlorcl11ggj.dbf'#Restore Controlfile
    *.db_file_name_convert='/oracle/app/oracle/oradata/ORCL11G/datafile','/oradata/orcl11ggj'
    *.db_name='orcl11g'
    *.db_unique_name='orcl11ggj'
    *.fal_client='ORCL11GGJ'
    *.fal_server='ORCL11G','ORCL11GDG'
    *.log_archive_config='dg_config=(orcl11g,orcl11ggj)'
    *.log_archive_dest_1='location=/oradata/orcl11ggj/archgj'
    *.log_archive_dest_2='service=orcl11g lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=orcl11g'
    *.log_archive_dest_state_1='ENABLE'
    *.log_archive_dest_state_2='ENABLE'
    *.log_archive_format='%t_%s_%r.arch'
    *.log_file_name_convert='/oracle/app/oracle/oradata/ORCL11G/onlinelog','/oradata/orcl11ggj'
    *.standby_file_management='AUTO'
    *.compatible='11.2.0.4'

    [oracle@db1 dbs]$ rm spfileorcl11ggj.ora
    [oracle@db1 dbs]$
    SQL> startup mount;
    ORACLE instance started.

    Total System Global Area 217157632 bytes
    Fixed Size 2251816 bytes
    Variable Size 159384536 bytes
    Database Buffers 50331648 bytes
    Redo Buffers 5189632 bytes
    Database mounted
    SQL> create spfile from pfile;

    File created.

    SQL> shutdown abort
    ORACLE instance shut down.
    SQL> startup mount;
    ORACLE instance started.

    Total System Global Area 217157632 bytes
    Fixed Size 2251816 bytes
    Variable Size 159384536 bytes
    Database Buffers 50331648 bytes
    Redo Buffers 5189632 bytes
    Database mounted.

    ###对新库路径更改

    SQL> select file_id,file_name from dba_data_files;

    FILE_ID FILE_NAME
    ---------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    4 /oracle/app/oracle/oradata/ORCL11G/datafile/o1_mf_users_g18tl0tr_.dbf
    3 /oracle/app/oracle/oradata/ORCL11G/datafile/o1_mf_undotbs1_g18tl0t8_.dbf
    2 /oracle/app/oracle/oradata/ORCL11G/datafile/o1_mf_sysaux_g18tl0t2_.dbf
    1 /oracle/app/oracle/oradata/ORCL11G/datafile/o1_mf_system_g18tl0pq_.dbf
    5 /oracle/app/oracle/oradata/ORCL11G/datafile/o1_mf_example_g18tnzhk_.dbf
    6 /oracle/app/oracle/oradata/ORCL11G/datafile/o1_mf_tbs2_gy6cdqxn_.dbf
    7 /oracle/app/oracle/oradata/ORCL11G/datafile/o1_mf_tbs3_gyg1rzln_.dbf
    8 /oracle/app/oracle/oradata/ORCL11G/datafile/o1_mf_ogg_h4s8h1jh_.dbf

    8 rows selected.

    SQL> select * from v$tempfile;

    FILE# CREATION_CHANGE# CREATION_TIME TS# RFILE# STATUS ENABLED BYTES BLOCKS CREATE_BYTES BLOCK_SIZE NAME
    ---------- ---------------- ----------------- ---------- ---------- ------- ---------- ---------- ---------- ------------ ---------- ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    1 925780 20181215 10:44:39 3 1 ONLINE READ WRITE 176160768 21504 20971520 8192 /oracle/app/oracle/oradata/ORCL11G/datafile/o1_mf_temp_g18tnqlc_.tmp
    2 4208246 20191129 16:55:54 3 2 ONLINE READ WRITE 104857600 12800 104857600 8192 /oracle/app/oracle/oradata/ORCL11G/datafile/o1_mf_temp_gy1q8tp3_.tmp


    sql 'alter database mount standby database';
    run
    {set newname for datafile 1 to '/oradata/orcl11ggj/system01.dbf';
    set newname for datafile 2 to '/oradata/orcl11ggj/sysaux01.dbf';
    set newname for datafile 3 to '/oradata/orcl11ggj/undotbs1.dbf';
    set newname for datafile 4 to '/oradata/orcl11ggj/user01.dbf';
    set newname for datafile 5 to '/oradata/orcl11ggj/example01.dbf';
    set newname for datafile 6 to '/oradata/orcl11ggj/tbs2.dbf';
    set newname for datafile 7 to '/oradata/orcl11ggj/tbs3.dbf';
    set newname for datafile 8 to '/oradata/orcl11ggj/ogg.dbf';
    set newname for tempfile 1 to '/oradata/orcl11ggj/temp01.dbf';
    set newname for tempfile 2 to '/oradata/orcl11ggj/temp02.dbf';
    restore database;
    switch datafile all;
    switch tempfile all;
    recover database;
    }

    [oracle@db1 dbs]$ rman target /

    Recovery Manager: Release 11.2.0.4.0 - Production on Mon May 25 17:08:22 2020

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

    connected to target database: ORCL11G (DBID=1101818950, not open)

    RMAN> run
    2> {set newname for datafile 1 to '/oradata/orcl11ggj/system01.dbf';
    3> set newname for datafile 2 to '/oradata/orcl11ggj/sysaux01.dbf';
    4> set newname for datafile 3 to '/oradata/orcl11ggj/undotbs1.dbf';
    5> set newname for datafile 4 to '/oradata/orcl11ggj/user01.dbf';
    6> set newname for datafile 5 to '/oradata/orcl11ggj/example01.dbf';
    7> set newname for datafile 6 to '/oradata/orcl11ggj/tbs2.dbf';
    8> set newname for datafile 7 to '/oradata/orcl11ggj/tbs3.dbf';
    9> set newname for datafile 8 to '/oradata/orcl11ggj/ogg.dbf';
    10> set newname for tempfile 1 to '/oradata/orcl11ggj/temp01.dbf';
    11> set newname for tempfile 2 to '/oradata/orcl11ggj/temp02.dbf';
    12> restore database;
    13> switch datafile all;
    14> switch tempfile all;
    15> recover database;
    16> }

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    executing command: SET NEWNAME

    Starting restore at 25-MAY-20
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=16 device type=DISK

    channel ORA_DISK_1: starting datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    channel ORA_DISK_1: restoring datafile 00001 to /oradata/orcl11ggj/system01.dbf
    channel ORA_DISK_1: restoring datafile 00003 to /oradata/orcl11ggj/undotbs1.dbf
    channel ORA_DISK_1: restoring datafile 00006 to /oradata/orcl11ggj/tbs2.dbf
    channel ORA_DISK_1: restoring datafile 00007 to /oradata/orcl11ggj/tbs3.dbf
    channel ORA_DISK_1: reading from backup piece /oradata/backup/full_12v13hll_1_1.bak
    channel ORA_DISK_1: piece handle=/oradata/backup/full_12v13hll_1_1.bak tag=TAG20200525T163252
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
    channel ORA_DISK_1: starting datafile backup set restore
    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
    channel ORA_DISK_1: restoring datafile 00002 to /oradata/orcl11ggj/sysaux01.dbf
    channel ORA_DISK_1: restoring datafile 00004 to /oradata/orcl11ggj/user01.dbf
    channel ORA_DISK_1: restoring datafile 00005 to /oradata/orcl11ggj/example01.dbf
    channel ORA_DISK_1: restoring datafile 00008 to /oradata/orcl11ggj/ogg.dbf
    channel ORA_DISK_1: reading from backup piece /oradata/backup/full_11v13hlk_1_1.bak
    channel ORA_DISK_1: piece handle=/oradata/backup/full_11v13hlk_1_1.bak tag=TAG20200525T163252
    channel ORA_DISK_1: restored backup piece 1
    channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
    Finished restore at 25-MAY-20

    datafile 1 switched to datafile copy
    input datafile copy RECID=12 STAMP=1041354605 file name=/oradata/orcl11ggj/system01.dbf
    datafile 2 switched to datafile copy
    input datafile copy RECID=13 STAMP=1041354605 file name=/oradata/orcl11ggj/sysaux01.dbf
    datafile 3 switched to datafile copy
    input datafile copy RECID=14 STAMP=1041354605 file name=/oradata/orcl11ggj/undotbs1.dbf
    datafile 4 switched to datafile copy
    input datafile copy RECID=15 STAMP=1041354605 file name=/oradata/orcl11ggj/user01.dbf
    datafile 5 switched to datafile copy
    input datafile copy RECID=16 STAMP=1041354605 file name=/oradata/orcl11ggj/example01.dbf
    datafile 6 switched to datafile copy
    input datafile copy RECID=17 STAMP=1041354605 file name=/oradata/orcl11ggj/tbs2.dbf
    datafile 7 switched to datafile copy
    input datafile copy RECID=18 STAMP=1041354605 file name=/oradata/orcl11ggj/tbs3.dbf
    datafile 8 switched to datafile copy
    input datafile copy RECID=19 STAMP=1041354605 file name=/oradata/orcl11ggj/ogg.dbf

    renamed tempfile 1 to /oradata/orcl11ggj/temp01.dbf in control file
    renamed tempfile 2 to /oradata/orcl11ggj/temp02.dbf in control file

    Starting recover at 25-MAY-20
    using channel ORA_DISK_1
    datafile 7 not processed because file is read-only

    starting media recovery

    archived log for thread 1 with sequence 402 is already on disk as file /oradata/orcl11ggj/archgj1_402_994934666.arch
    archived log file name=/oradata/orcl11ggj/archgj1_402_994934666.arch thread=1 sequence=402
    unable to find archived log
    archived log thread=1 sequence=403
    RMAN-00571: ===========================================================
    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
    RMAN-00571: ===========================================================
    RMAN-03002: failure of recover command at 05/25/2020 17:10:05
    RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 403 and starting SCN of 8112986

    alter database add standby logfile '/oradata/orcl11ggj/stdby4.log' size 50M;
    alter database add standby logfile '/oradata/orcl11ggj/stdby5.log' size 50M;
    alter database add standby logfile '/oradata/orcl11ggj/stdby6.log' size 50M;


    primary
    SQL> alter system set log_archive_dest_state_3=enable;

    System altered.

    standby
    SQL> alter database recover managed standby database using current logfile disconnect from session;

    Database altered.

    alter database open 就可以打开了;启动实时应用

    SQL> select name,open_mode,database_role,db_unique_name,protection_mode,protection_level from v$database
    2 ;

    NAME OPEN_MODE DATABASE_ROLE DB_UNIQUE_NAME PROTECTION_MODE PROTECTION_LEVEL
    --------- -------------------- ---------------- ------------------------------ -------------------- --------------------
    ORCL11G READ ONLY WITH APPLY PHYSICAL STANDBY orcl11ggj MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE

    [oracle@db1 orcl11ggj]$ ps -ef | grep pmon
    oracle 6967 1 0 21:11 ? 00:00:00 ora_pmon_orcl11g
    oracle 7216 1 0 21:17 ? 00:00:00 ora_pmon_orcl11gdg
    oracle 7852 1 0 22:01 ? 00:00:00 ora_pmon_orcl11ggj
    oracle 8305 7609 0 23:25 pts/5 00:00:00 grep pmon
    [oracle@db1 orcl11ggj]$ ps -ef | grep tns
    root 15 2 0 15:15 ? 00:00:00 [netns]
    oracle 2515 1 0 15:24 ? 00:00:01 /oracle/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr LISTENER_GJ -inherit
    oracle 6230 1 0 20:42 ? 00:00:00 /oracle/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr listener_dg -inherit
    oracle 6924 1 0 21:11 ? 00:00:00 /oracle/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr LISTENER -inherit
    oracle 8307 7609 0 23:25 pts/5 00:00:00 grep tns

    至此搭建完成

    配置dg broker 见https://www.cnblogs.com/nadian-li/p/12963631.html

  • 相关阅读:
    LINQ 学习路程 -- 查询操作 Join
    LINQ 学习路程 -- 查询操作 GroupBy ToLookUp
    LINQ 学习路程 -- 查询操作 ThenBy & ThenByDescending
    LINQ 学习路程 -- 查询操作 OrderBy & OrderByDescending
    LINQ 学习路程 -- 查询操作 OfType
    LINQ 学习路程 -- 查询操作 where
    动态切换数据库(EF框架)
    ASP.NET 日期 时间 年 月 日 时 分 秒 格式及转换
    常用的Issue解决方案(EF框架)
    OpenFileDialog.Filter 属性
  • 原文地址:https://www.cnblogs.com/nadian-li/p/12963819.html
Copyright © 2011-2022 走看看