Oracle Dataguard Simple Configuration Documentation

Source: Internet
Author: User
Tags app service sqlplus

First, the preparation of the main library side



1. View the database directory structure in the main library


To view the database file path


Select T1.name,t2.name from V$tablespace t1,v$datafile T2 where t1.ts#=t2.ts#;


View Log file path


SELECT * from V$logfile;


View Control File path


SELECT * from V$controlfile;



2. Open the database archive and activate the Force logging mode


View Archive mode


Archive Log List

Turn on archive mode


ALTER DATABASE Archivelog;


ALTER DATABASE Noarchivelog;

Modify archive location and archive naming rules

Alter system set log_archive_dest_1= ' Location=/arch ' scope=spfile;


alter system set Log_archive_format = '%t_%s_%r.arc ' scope=spfile;


Open Force logging

ALTER DATABASE force logging;

ALTER DATABASE no force logging;


3. Modify the initialization parameter file



Create Pfile from SPFile; (backup initialization parameter file)



Alter system set log_archive_config= ' dg_config= (Zhuku,beiku) ';

Alter system set log_archive_dest_1= '/arch valid_for= (all_logfiles,all_roles) Db_unique_name=zhuku ';

Alter system set log_archive_dest_2= ' Service=beiku lgwr SYNC valid_for= (online_logfiles,primary_role) db_unique_name= Beiku ';

alter system set log_archive_dest_state_1=enable;

alter system set Log_archive_dest_state_2=defer;

Alter system set fal_client= ' Zhuku ';

Alter system set fal_server= ' Beiku ';

Alter system set db_file_name_convert= '/oracle/oradata/beiku/', '/oracle/oradata/zhuku/' scope=spfile;

Alter system set log_file_name_convert= '/oracle/oradata/beiku/', '/oracle/oradata/zhuku/' scope=spfile;

alter system set Standby_file_management=auto;



4. Restart the database so that the above changes take effect remain in the open state




Ii. preparation of the repository side


1. Create a related directory


Mkdir/oracle/admin/beiku/adump bdump cdump dpdump udump

Mkdir/oracle/oradata/beiku

The same backup directory as the main library and the archive log directory and modify permissions

2. Copy the Master library key file


Scp


3. Backup initialization parameter setting


The initialization file for the repository can be modified from the main library initialization parameter file.


Add the following content


*. Db_name= ' Zhuku '

*.remote_login_passwordfile= ' EXCLUSIVE


*. Db_unique_name= ' Beiku '

*.log_archive_config= ' dg_config= (Beiku,zhuku) '

*. Log_archive_dest_1= ' Location=/arch valid_for= (all_logfiles,all_roles) Db_unique_name=beiku '

*. Log_archive_dest_2= ' Service=zhuku lgwr SYNC valid_for= (online_logfiles,primary_role) Db_unique_name=zhuku '

*. log_archive_dest_state_1= ' ENABLE '

*. Log_archive_dest_state_2= ' ENABLE '

*. log_archive_format= '%t_%s_%r.arc '

*. Log_archive_max_processes=30

*. Fal_server= ' Zhuku '

*. Fal_client= ' Beiku '

*. Db_file_name_convert= '/oracle/oradata/zhuku/', '/oracle/oradata/beiku/'

*. Log_file_name_convert= '/oracle/oradata/zhuku/', '/oracle/oradata/beiku/'

*. Standby_file_management= ' AUTO '


4. Create SPFile

Create SPFile from pfile= ' $ORACLE _home/dbs/initracdb.ora '


5. Start the database to Mount state

sql> startup Nomount;



Iii. Configuring monitoring and TNS



You can configure both the main library and the standby library via the graphical interface NETCA netmgr to configure the TNS on both sides



Sid_list_listener =

(Sid_list =

(Sid_desc =

(Sid_name = Plsextproc)

(Oracle_home =/oracle/db10g)

(program = Extproc)

)


(Sid_desc =

(Global_dbname = Beiku)

(Oracle_home =/oracle/db10g)

(Sid_name = Beiku)

)

)



Verify Monitoring


Sqlplus Sys/[email protected] as Sysdba


Sqlplus Sys/[email protected] as Sysdba



Iv. Duplicate database under Rman, Recovery of Standby library


Method 1

The Master library makes a full-library backup and copies the backup set to the same directory as the repository

RUN {

Allocate channel C1 type disk;

Allocate channel C2 type disk;

SQL ' alter system archive log current ';

Backup current controlfile for standby format= '/backup/dgbackup_control_%u ';

BACKUP FORMAT '/backup/dgbackup_%u_%t ' skip inaccessible filesperset 5 DATABASE;

SQL ' alter system archive log current ';

BACKUP FORMAT '/backup/dgbackup_arch_%u_%t ' skip inaccessible filesperset 5 ARCHIVELOG all;

Release channel C2;

Release channel C1;

}



Rman target/auxiliary Sys/[email protected]

Duplicate target database for standby Nofilenamecheck dorecover;


Method 2 after 11g version applies


Use Rman to recover the main library on standby (repository side)


Rman target Sys/[email protected] auxiliary sys/[email protected]


Rman> duplicate target database for standby from active database Nofilenamecheck;

This command can directly recover data files, standby control files, standby log group, very overbearing





V. Opening of DG


Execute on the standby

Sql> select Instance_name,status from V$instance;


instance_name STATUS

---------------- ------------

RACDB Mounted


This mode copies and applies the log files from the primary database


alter system set log_archive_dest_state_2=enable;


ALTER DATABASE recover managed standby database disconnect from session;


Canceling the Log app


ALTER DATABASE recover managed standby database cancel



The Data Guard physical standby database in the previous version of Oracle 11g can open the database in a read-only manner, but the process of media recovery using the log to synchronize is stopped and the database cannot open the query if the physical standby database is in the process of recovery. That is, the log application and read-only open two states are mutually exclusive, and the Oracle 11g Active Data guard feature solves this contradiction, while using the log to recover data can be opened in a read-only way to open the database, the user can be on the standby database queries, reports and other operations, This is similar to the functionality of the logical data Guard standby database (query functionality), but data synchronization is more efficient and requires less hardware resources. This allows the performance of the hardware resources of the physical standby database to be used to a greater extent


Undo automatic recovery of a standby library

[Email protected]@> ALTER DATABASE recover managed standby database cancel;


Database altered.



Monitoring Repository Warning Log


Monitoring the main library warning log



18.13. View Log Synchronization Status


On the main library

Sql> Select sequence#, First_time, next_time from V$archived_log order by sequence#;


View the logs that have been applied


Sql> Select sequence#,applied from V$archived_log order by sequence#;



On the Standby library

Sql> Select sequence#, First_time, next_time from V$archived_log order by sequence#;


Sql> Select sequence#,applied from V$archived_log order by sequence#;


18.14. Configure the main library standby redo log

To view the log file size, the standby redolog must be larger than the log capacity of the online logs, mainly for the switchover of the main standby library

Select Group#,bytes from V$log;

ALTER DATABASE ADD standby logfile Group 5 ('/oracle/oradata/zhuku/redolog1.log ') size 50m;

ALTER DATABASE ADD standby logfile Group 6 ('/oracle/oradata/zhuku/redolog2.log ') size 50m;

ALTER DATABASE ADD standby logfile Group 7 ('/oracle/oradata/zhuku/redolog3.log ') size 50m;

ALTER DATABASE ADD standby logfile Group 8 ('/oracle/oradata/zhuku/redolog4.log ') size 50m;


View Results

Select Group#,thread#,sequence#,archived,status from V$standby_log;


18.15. Configure the Standby library standby redo Log


sql> ALTER DATABASE recover managed standby database cancel

sql> shutdown immediate;

sql> startup Mount;

ALTER DATABASE ADD standby logfile Group 5 ('/u01/app/oracle/oradata/racdb/redolog1.log ') size 100m;

ALTER DATABASE ADD standby logfile Group 6 ('/u01/app/oracle/oradata/racdb/redolog2.log ') size 100m;

ALTER DATABASE ADD standby logfile Group 7 ('/u01/app/oracle/oradata/racdb/redolog3.log ') size 100m;

ALTER DATABASE ADD standby logfile Group 8 ('/u01/app/oracle/oradata/racdb/redolog4.log ') size 100m;


View Results

Select Group#,thread#,sequence#,archived,status from V$standby_log;


Enable Receive Log

ALTER DATABASE recover managed standby database disconnect from session;



Prepare the database for validation data


Toggle Standby Database Read-only mode

ALTER DATABASE recover managed standby database cancel;

ALTER DATABASE open read only;

View the logs that have been applied

Select Sequence#,applied from V$archived_log order by sequence#;




Master Standby role switching

    1. In the main library to do the database fully prepared


2. Make sure that the log for node 1 has all been transferred to the standby repository


Sql> SELECT thread#, low_sequence#, high_sequence# from V$archive_gap;


3. On Node 1, confirm as To_standby


Sql> select Switchover_status from V$database;

Switchover_status

-------------------------

To STANDBY


4. Replace all nodes with a standby library


Sql> ALTER DATABASE commit to switchover-physical standby with session shutdown;


5. Close and restart the previous Master Library instance

sql> shutdown immediate;

Sql> Startup Mount

6. View the switch status of the standby in the V$database view of the standby library


Select Switchover_status from V$database;


To primary or sessions active


7. Switch the repository to the main library role


ALTER DATABASE commit to switchover to primary; (to primary state using this command)


ALTER DATABASE commit to switchover-primary with session shutdown; (Sessions active state using this command)


8. Complete the switchover to the main library


ALTER DATABASE open;


9. If the standby is open in read-only mode, close the data before restarting.


sql> shutdown immediate;

Sql> startup;


10. Restart the Redo Log app service on the new standby


sql> ALTER DATABASE recover managed standby database disconnect from session;


or sql> ALTER DATABASE recover managed standby database using current logfile disconnect from session;


11. Start sending redo data to the standby library

sql> alter system switch logfile;



Mode switch:

Maximize protection---> maximize availability----> Maximize performance

When the protection level of the Dataguard is lowered in this order, the primary library is not required to be in the Mount State, and the primary can execute the protected mode change command directly in the open state.

Maximize Protection <---maximize availability <----maximize performance

When the protection level of the Dataguard is raised in this order, the primary library is required to be in the Mount state, if the open change is reported as an error

Select Database_role,open_mode,protection_mode,protection_level from V$database; --View Protected mode

To toggle the main Library protection mode syntax:

ALTER Database SET STANDBY Database

To maximize {PROTECTION | Availability | Performance}

Sql> ALTER DATABASE set standby database to maximize performance;

Sql> ALTER DATABASE set standby database to maximize availability;

Sql> ALTER DATABASE set standby database to maximize protection;

All of this is done in the main library and the repository will change.


This article is from the "People Meditation Cool" blog, please make sure to keep this source http://19911117.blog.51cto.com/11329221/1752096

Oracle Dataguard Simple Configuration Documentation

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.