oracle 12c dg structures standby switching troubleshooting

  1. Content
    single to single , real-time synchronization
  2. 11G began to read and write separation, prepared by the library is mount state, can be synchronized in real time, and can be read by the library, do reporting applications. (10G prepared by the library is prepared by the library, can not read)
  3. Main library standby database
    instance name prod sbdb
    still listening 1522 1522
    DBCA need not require
    oracle_unqname prod sbdb
    (profile)
    the ORACLE_SID prod sbdb
    (profile)
    GlobalName (installed base) Prod
    sid (installed base) Prod
    listener GLOBAL_DBNAME Prod Prod
    listener SID_NAME prod sbdb
    initialization parameter
    db_name Prod Prod
    instance_name Prod sbdb
    DB_UNIQUE_NAME Prod sbdb
    the tnsnames.ora tnsprod, tnssbdb tnsprod, tnssbdb
    SERVICE_NAME Prod Prod
    (the tnsname.ora)
    service name prod prod (service code does not change the connection side)
    (corresponding to listener.ora lsnrctl of-service global_dbname)

  4. Main library configuration parameters
    to view database parameter command, the Parameter Show *****
    (1) can be set FORCE LOGGING option at the database level or table space level. The priority is from the database to the table space. If you create or change a table space to enable FORCE LOGGING, then any changes to the table space will enter the redo logs can be used for recovery.

Similarly, if you create or change the database to enable FORCE LOGGING, then any change (except for temporary segment table space and temporary) database will be used to restore redo logs.
Database v $ desc
the SELECT force_logging from v $ Database;
the ALTER Force Database logging;
(2) to enable archiving, two ways of viewing, 11g need to open, 12c turned on by default
Archive log List;
the SELECT log_mode from v $ Database;
two parameters
log_archive_format
System SET log_archive ALTER the format = 'T% %% r.arc S_' scope = SPFILE; (static variables, to restart the database)
LOG_ARCHIVE_DEST (_1 and _2 modify the next step)

shutdown immediate
startup mount
alter database archivelog;
alter database open;

(3) static listener
listener.ora file configuration

LISTENER1=
(
DESCRIPTION_LIST=
(
DESCRIPTION=
(
ADDRESS_LIST=
(
ADDRESS=(PORTOCOL=TCP)(HOSTNAME=oracle12cpri)(PORT=1522)
)
)
)
)

SID_LIST_LISTENER1=
(
SID_LIST=
(
SID_DESC=
(GLOBAL_DBNAME=prod)
(SID_NAME=prod)
(ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1)
)
)

As can be seen from the configuration file: sid_name instance name prod, global_dbname external service name prod.
Note that the file three points
marked red place names to be consistent
global_dbname correspondence (Status lsnrctl listener) Services
SID_NAME correspondence (lsnrctl status listener) instance

(4)初始化参数
db_unique_name
alter system set db_unique_name=’prod’ scope=spfile; prod要加引号,不加引号就是大写
log_archive_config
alter system set log_archive_config=’DG_CONFIG=(prod,sbdb)’ scope=both;
log_archive_dest_1
alter system set log_archive_dest_1=’LOCATION=/u01/arch VALID_FOR=
(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=prod’ scope=both;
Log_archive_dest_2
alter system set log_archive_dest_2=’SERVICE=tnssbdb LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=sbdb’ scope=both;

Tnsnames.ora configuration file
copy prod () which code for the modified prod tnssbdb, oracle12csta = Host
Port = 1522, SERVICE_NAME constant standby machine because access of the same name.

db_file_name_convert 数据文件 (select from v$dbfile;)
alter system set db_file_name_convert=’/u01/app/oracle/oradata/sbdb’,’/u01/app/oracle/oradata/prod’ scope=spfile;
log_file_name_convert 重做日志文件 (select
from v$logfile)
alter system set db_file_name_convert=’/u01/app/oracle/oradata/sbdb’,’/u01/app/oracle/oradata/prod’ scope=spfile;

standby_file_management
ALTER SET standby_file_management = Auto System; quotes is not capitalized

FAL_CLIENT present as a client terminal
ALTER System FAL_CLIENT = SET 'tnsprod' scope = both;
FAL_SERVER preparation machine as a peer server
alter system set fal_server = 'tnssbdb' scope = both;

  1. Preparation of the physical parameters of the library
    (1) copy of the password file, the user password sys standby database consistency
    CD $ ORACLE_HOME / DBS
    SCP orapwprod oracle12csta: /u01/app/oracle/product/12.2.0/dbhome_1/dbs
    in standby machine orapwprod orapwsbdb mv
    (2) under preparation machine dbs directory
    Touch initsbdb.ora,
    spfileprod.ora main library copied, spfileprod.ora remember do not change the main library, is a binary file
    db_name unchanged, log_archive_config unchanged, the other must configuration according to the initialization parameter to get rid of the main library, and create a corresponding directory
    (3) preparation machine sqlplus / AS SYSDBA
    Create SPFILE from pfile;
    $ ORACLE_HOME / DBS will generate a spfilesbdb.ora the following initsbdb.ora
    stratup nomount default file Looking .ora
    If the error content, change the configuration file backup machine initsbdb.ora re SPFILE from pfile the Create; the Startup nomount
    (4) listens to configure static
    host a copy, hostname, sid_name wanted to change the standby database
    global_dbname the main library and the same, because the Foreign service
    be sure to configure a static library equipment monitoring, as a nomount state only static came even listen to examples
    (5) tns configuration
    Host tnsnames.ora file completion
    tnssbdb =
    (
    the DESCRIPTION =
    (
    ADDRESS = (PROTOCOL = TCP) (HOST = oracle12csta) (PORT = 1522)
    )
    (
    CONNECT_DATA =
    (SERVER = DEDICATED)
    (SERVICE_NAME = Prod)
    )
    )

tnsprod =
(
DESCRIPTION=
(
ADDRESS=(PROTOCOL=TCP)(HOST=oracle12cpri)(PORT=1522)
)
(
CONNECT_DATA=
(SERVER=DEDICATED)
(SERVICE_NAME=prod)
)
)

Document preparation machine to the main library scp, leaving only the above tnsprod tndsbdb
and do tnsping test
tnsping tnsprod tnsping tnssbdb
standby libraries are attached under
sqlplus SYS / ora123 @ tnsprod AS sysdba
sqlplus SYS / ora123 @ tnssbdb AS sysdba

参数检查
db_unique_name
compatible
log_archive_config
log_archive_dest_1
log_archive_dest_2
log_archive_dest_state_2: enable-启用 defer-禁用
db_file_name_convert
log_file_name_convert
standby_file_management
log_archive_format

So far, the preparation work, prepared by the library in the state unmount
the SELECT Status from v $ instance;
Started state has started

  1. Used to create a physical duplicate standby
    master database
    rman target sys / ora123 @ tnsprod this manner must enter a password
    Connect Auxiliary SYS / ora123 @ tnssbdb
    duplicate for standby target from Active Database Database nofilenamecheck;
    lower case checking, / u01 / app / oracle / oradata / sbdb have data, and the master library following consistent prod

  2. Add standby log group and opened in synchronization with
    the number of standby log group: redo log group +1
    primary database:
    SELECT from V $ logfile; see three groups redo.log, and the corresponding path
    SELECT
    from V $ log; see each size BYTES 50M
    ALTER STANDBY logfile the Add Group Database. 4 ( '/u01/app/oracle/oradata/prod/stredo04.log') size 50M;
    ALTER STANDBY logfile the Add Group Database. 5 ( '/ u01 / App / Oracle / oradata / Prod / stredo05 .log ') size 50M;
    ALTER STANDBY logfile the Add Group Database. 6 (' /u01/app/oracle/oradata/prod/stredo06.log ') size 50M;
    ALTER STANDBY logfile the Add Group Database. 7 (' / u01 / App / Oracle /oradata/prod/stredo07.log ') size 50M;
    Usually redo log does not end with the suffix .log
    view standby log group select * from v $ standby_log;

备库:此时备库要处于mount状态,
startup nomount alter database mount;
select * from v$instance; mounted
alter database add standby logfile group 4 (‘/u01/app/oracle/oradata/sbdb/stredo04.log’) size 50M;
alter database add standby logfile group 5 (‘/u01/app/oracle/oradata/sbdb/stredo05.log’) size 50M;
alter database add standby logfile group 6 (‘/u01/app/oracle/oradata/sbdb/stredo06.log’) size 50M;
alter database add standby logfile group 7 (‘/u01/app/oracle/oradata/sbdb/stredo07.log’) size 50M;

If the directory wrong, execute the following
alter database drop logfile group 4;

Open Sync:
library equipment:
the ALTER Database Open;
open real-time synchronization
the ALTER Database Recover Managed STANDBY Database a using Current logfile disconnect from the session;
l log switch before synchronization
alter database recover managed standby database disconnect from session;
stop synchronization
alter database recover managed standby database cancel ;
the SELECT open_mode, database_role, Protection mode, protection_level from v $ database;
open real-time synchronization, open_mode be read only with apply
not open, a read only
view the main library is read write

  1. Three protection modes
    for maximum performance maximize performance | LGWR ASYNC NOAFFIRM
    highest available maximize availability with the production, network problems automatically switches to the highest performance mode, after the network is restored turn into the highest available | LGWR SYNC AFFIRM
    highest Protection to protect the Maximize | LGWR SYNC AFFIRM
    the SYNC : the commit before the main database, waiting for acceptance preparation completion log data library, at least one standby database
    ASYNC: the commit before the main database, without waiting for
    the AFFIRM: log information is written to the backup repository standby_log, it notifies the master database log yield finished
    NOAFFIRM: no other log Preparation standby database information is written to the log, it notifies the master database log been received
    maximum performance available to the highest, with the proviso: log_archive_dest_2 = LGWR SYNC AFFIRM
    standby libraries are performed: Alter database set standby database to maximize availability;
    check:
    SELECT open_mode, database_role, protection_mode, protection_level from v $ database;
    test: main library create table t (id int); insert into t values (200);
    standby database: select * from t;
    at this standby state database is open

If the synchronization is not successful, the parameters of the main library prepared under then check whether correct, may be
log_archive_dest_state_2: enable- enable not open
then shutdown immediate startup of the main library equipment, library equipment open real-time synchronization
alter database recover managed standby database using current logfile disconnect from session;

This dg completed structures
Here is the view dataguard state, solve the problems encountered in some of dg

  1. Startup sequence
    to monitor the instance, the first rear main library library prepared
    shutdown procedure
    to shut the main library, and then close the standby database
    view:
    (. 1) V $ Database
    open_mode
    Read only, Read and Write, Read only with Apply, Mount
    database_role
    PHYSICAL STANDBY, sTANDBY the Logical, Primary, sTANDBY Snapshot
    Protection mode
    the Maximize dostępność, the Maximize Protection, the Maximize Performance,
    resynchronization (re-sync mode), unprotected
    (2) v $ managed_standby (prepared by the library execution)
    Process (PS - EF | grep ORA can see) ARCH archive , MRPO log real-time synchronization, RFS remote log receiving process
    select process, pid, status, sequence # from v $ managed_standby; process: ARCH: archiving process
    MRP0: log media recovery process for applications received (open real-time applications or non-real time application)
    RFS: remote file Server, receives a remote log file
    pid: operating system process ID
    status:
    CONNECTED: the main library and the establishment of a network connection
    CLOSING: archiving process has been completed, and turns off the archive log files
    WRITING: Process writing redo data to the archive.
    APPLYING_LOG: log being applied to the standby database, real-time applications open WAIT_FOR_LOG: Wait archive logs is completed (on non-real time applications, or between barrier standby)
    ALTER STANDBY Managed Database Database Recover the disconnect;
    Sequence #: SEQ ID NO archive log
    archive log list sequence 142
    ALTER System Switch logfile; Sequence increases. 1
    (. 3) V $ standby_log standby database query
    select group #, sequence #, archived , status from v $ standby_log;
    comparison:
    SELECT from V $ log;
    SELECT
    from V $ logfile;
    SELECT from $ standby_log V;
    (. 4) V $ archive_dest_status
    Status: the vALID: effective iNACTIVE: inactive DEFERRED: manually disabled (available temporary disable synchronization)
    ALTER System SET log_archive_dest_state_2 = 'the defer' synchronization command into a temporary
    alter system set log_archive_dest_state_2 = 'enable' open
    type: LOCAL: main library PHYSICAL: Physical standby LOGICAL: Logical standby SNAPSHOT: snapshot STANDBY
    error, synchronization_status, these three fields helps the synchronized view dg unsynchronized fault
    (5) v $ dataguard_status
    Preparation of database query
    the SELECT
    from $ dataguard_status t v t by the Order. "TIMESTAMP" desc
    the Message field, you can view some of the error DG

  2. New user database, sub-rights
    the Create the User the Test IDENTIFIED by the Test;
    Grant SYSOPER, Connect, Resource to the Test;

  3. Log GAP
    simulated fault:

    alter system set log_archive_state_2 = 'defer' ;
    master database data is inserted into a table
    alter system switch logfile; three

    Main Library: log archive list; sequence will and library equipment is not the same, protection_level main library = 're-sync mode'
    by the library: the SELECT from v $ managed_standby
    MRPO progress will be shown: wait_for_log, will now no application log (normal should be applying_log )
    main library: the main library will be more standby database squence #
    Select t "sequence #", t "applied", from v $ archived_log t where id = 1;..
    Preparation library:
    the Select T "Sequence #", T. . "Archived" from v $ archived_log the WHERE the above mentioned id = 1 t;
    the Select
    from v $ archive_dest_status;
    Error field will be error, like words changed to defer, not being given

Main library is not available, you need to manually operate
the gap off log files, archive files in the log list of the main library copy path past
the standby database is not registered in the past rman target / list archive all; saw a few log files are not the main library need to manually register
a small number of words: alter database register logfile '/ u01 / arch / ***';
a large number of words: rman> catalog start with '/ u01 / arch /';
see the standby database alert file
/ u01 / app / oracle / diag / rdbms / sbdb / sbdb / trace / alert_sbdb.log
automatically applied, does not work, restart the standby database log can be synchronized

  1. Roles
    (1) switchover standby swap, without loss of data
    standby database parameters under examination, (in fact, as long as the insert into a data synchronization parameters no problem)
    main library checks standby redo log, select * from v $ standby_log;
    ... SELECT T "NAME", T "database_role", T "The SWITCHOVER_STATUS" from V $ database T;
    The SWITCHOVER_STATUS:
    to sTANDBY: switchable
    session active: there is a session connection switchable
    standby database query: NOT ALLOWED
    verify that there GAP:
    the SELECT t "the STATUS", t "GAP_STATUS" from v $ archive_dest_status t the WHERE t "DEST_ID" = 2;...
    but also the implementation safest, insert
    operation
    alter database commit to switchover to physical standby ;
    sessions with the words,
    alter database commit to switchover to physical standby with session shutdown;
    startup主库
    alter database recover managed standby database using current logfile disconnect;

By the library:
... The SELECT t "NAME", t "database_role", t "SWITCHOVER_STATUS" from v $ Database t;
SWITCHOVER_STATUS:
to Primary
the session the Active
the ALTER Database the commit to switchover to Primary;
the ALTER Database the commit to switchover to Primary with the session the shutdown;
the shutdown load immediate;
the Startup
lower insert test, viewing mode
select open_mode, database_role, protection_mode, protection_level from v $ database;
Note: the production environment, then the library is running a long time, switch directly take a long time
standby database to perform: System BUFFER_CACHE the flush ALTER;
ALTER System the checkpoint;
the shutdown immediate
then restart standby database, real-time synchronization is opened by the library, the handover is performed
(2) failover failover main reservoir is broken, the primary standby database library turn, maximum protection is not lost and the maximum available data (relative switchover)
the step of:
stopping the application standby database log
alter database recover managed standby database cancel;
shut down the standby database log transport
attention must first solve the GAP, execute the following statement after solving
alter database recover managed standby database finish force ;
if not solve, execute the following, the result is lost data
alter database active physical standby database;
switching master database
alter database commit to switch to primary with session shutdown;
check:
SELECT open_mode, database_role from V $ database;
Read Write database_role

  1. Snapshot database
    will be placed by the library writable mode. Or the service test line test analog
    NOTE: Preparation of the library can accept the log of the primary database, but can not apply applications.
    Step: (1) arranged fast recovery zone
    by the library: DB_RECOVERY_FILE_DEST_SIZE (first set size) DB_RECOVERY_FILE_DEST
    ALTER System SET DB_RECOVERY_FILE_DEST_SIZE = 10g;
    ALTER System DB_RECOVERY_FILE_DEST SET = '/ u01 / Flash';
    Flashback Database need to open
    (2) to close the redo. apply to apply
    the ALTER database Recover Managed STANDBY database the Cancel;
    . (3) switch to snapshot snapshot database
    to snapshot STANDBY the ALTER database Convert for;
    the SELECT Status from v $ database; Mounted to open
    the ALTER database open
    the SELECT open_mode, database_role from v $ database;
    the Read the Write (same as the primary) snapshot standby
    test: insert
    this, a physical standby database -> snapshot database
    snapshot database -> physical standby database, cut back.
    (5) close the database, placed Mount
    the shutdown immediate
    Startup Mount
    (. 6) perform switchback command alter database convert to physical standby;.
    Examples are v $ instance status nomount state is started
    closed instance, to start Open
    ALTER Managed Database Recover STANDBY database using current logfile disconnect; open real-time applications
    insert test
    Note: snapshot read-write mode open at least once, in order to convert it back to a physical standby database
    command state $ instance status v
    the Startup open open
    the Startup nomount nomount Started
    the Startup Mount Mount Mounted
    the ALTER System open open open

Guess you like

Origin blog.51cto.com/12853079/2481585