8. Data Guard
ocm8 Use Data Guard Manager and DGMGRL
https://shenh.tripod.com/Oracleblog/index.blog/1825057/ocm8-use-data-guard-manager-and-dgmgrl/
Dataguard Reference:
http://www.ahmedbaraka.com/computer/docs/oracle_10g_dg_1.0.pdf
http://www.oracle.com/technology/deploy/availability/pdf/TWP_DataGuard_10gR2.pdf
http://static7.userland.com/oracle/gems/alejandroVargas/DataGuardPhysicalStandbystep.pdf
http://blogs.oracle.com/alejandroVargas/gems/DataGuardBrokerandobserverst.pdf
http://static7.userland.com/oracle/gems/alejandroVargas/DataGuardBrokerandobserverst.pdf
http://blogs.oracle.com/AlejandroVargas/
http://blogs.oracle.com/AlejandroVargas/gems/
http://blogs.oracle.com/AlejandroVargas/newsItems/viewFullItem$251/
ocm8: Use Data Guard Manager and DGMGRL
dataguard db:
DGMGRL
grid control
1): Database List: Type --> Database Instance: Primary | Physical Standby
2): Instance Detail Pages
High Availability
3): --> maintenance --> High Availability --> Data Guard
-- ---------------------
. oenv sid
dgmgrl
> CONNECT /
>help
>help show
> SHOW CONFIGURATION;
> SHOW CONFIGURATION VERBOSE;
> SHOW DATABASE db_unique_name;
> SHOW DATABASE VERBOSE db_unique_name ;
-- database name from show configuration
> SHOW DATABASE sid_stdg1;
> SHOW DATABASE verbose sid_stdg1;
> SHOW DATABASE sid_stdg2;
> SHOW DATABASE verbose sid_stdg2;
> SHOW INSTANCE instance_name_from_database_name;
-- instance name from show database
> show instance sid on database sid_stdg1;
> show instance verbose sid on database sid_stdg1;
> show instance sid on database sid_stdg2;
> show instance verbose sid on database sid_stdg2;
show instance verbose sid on database sid_prd;
> SHOW INSTANCE VERBOSE;
sqlplus:
show parameter service_names
show parameter db_unique_name
show parameter db_name
show parameter db_domain
show parameter DG_BROKER_START
show parameter DG_BROKER_CONFIG
show parameter log_archive_config
show parameter log_archive_dest
show parameter fal_server
show parameter fal_client
show parameter standby_file_management
show parameter db_file_name_convert
show parameter log_file_name_convert
show parameter db_create_file_dest
show parameter remote_login_passwordfile
select host_name, status, DATABASE_STATUS, INSTANCE_ROLE from v$instance;
select name, DB_UNIQUE_NAME,
DATABASE_ROLE,
GUARD_STATUS, DATAGUARD_BROKER,
SWITCHOVER_STATUS,
OPEN_MODE, LOG_MODE,
PROTECTION_MODE, PROTECTION_LEVEL
from v$database;
Configuration of 10g Data Guard Broker and Observer for Switchover
Alejandro Vargas
Principal Support Consultant
Oracle Advanced Support Services
Configuring Data Guard Broker for Switchover, General Review. ......2
The Enviroment...2
Implementation notes:...................................2
Step by Step Implementation of Data Guard Broker................3
Enable Data Guard Broker Start on the Primary and Standby databases ................................3
Setup the Local_Listener parameter on both the Primary and Standby databases..................3
Setup the tnsnames to enable communication with both the Primary and Standby databases3
Check and edit database properties .............8
Enabling the configuration and databases..10
Enabling Fast Start Failover and the Observer ..................12
Ensure standby redo logs are configured on all databases ......12
Ensure the LogXptMode Property is set to SYNC .........13
Specify the FastStartFailoverTarget property ................14
Upgrade the protection mode to MAXAVAILABILITY, if necessary. ...................................14
Enable Flashback Database on the Primary and Standby databases. ...............................14
Enable fast start failover..........................16
Start the observer....................................17
Verify the fast-start failover configuration18
Perform a Switchover..............................19
Reference:.........23
Configuring Data Guard Broker for Switchover, General Review.
on this document I'm adding how to configure the broker and observer, setup the database to Maximum Availability and
managing switchover from Data Guard Manager, DGMGRL.
Data Guard Broker permit to manage a Data Guard Configuration, from both the Enterprise Manager Grid Control console, or from a
terminal in command line mode. In this document I will explore command line mode.
Pre requisites include the use of 10g Oracle server, using spfile on both the primary and standby and a third server for the Observer,
and configure the listeners to include a service for the Data Guard Broker.
The Enviroment
• 2 Linux servers, Oracle Distribution 2.6.9-55 EL i686 i386 GNU/Linux, the Primary and Standby databases are located on these
servers.
• 1 Linux server, RH Linux 2.6.9-42.ELsmp x86_64 GNU/Linux, The Data Guard Broker Observer is located on this server
• Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
ssh is configured for user oracle on both nodes
• Oracle Home is on identical path on both nodes
• Primary database WHITEOWL
• Standby database BLACKOWL
Implementation notes:
Once you have your primary and standby databases up and running these are the steps to follow:
1. Enable Data Guard Broker Start on the Primary and Standby databases.
2. Setup the Local_Listener parameter if the listener port is not the standard 1521, on both the Primary and Standby databases.
3. Setup the listener and tnsnames to enable communication with both the Primary and Standby databases.
4. Setup the Broker configuration files
5. Check and edit properties
6. Enable the configuration and databases
7. Enable Fast Start Failover and the Observer
Step by Step Implementation of Data Guard Broker
Enable Data Guard Broker Start on the Primary and Standby databases
SQL> ALTER SYSTEM SET DG_BROKER_START=TRUE SCOPE=BOTH;
Setup the Local_Listener parameter on both the Primary and Standby databases
SQL> ALTER SYSTEM SET LOCAL_LISTENER='LISTENER_VMRACTEST' SCOPE=BOTH;
Setup the tnsnames to enable communication with both the Primary and Standby databases
The listener.ora should include a service named global_db_nameDGMGRL to enable the broker to start the databases on the event of
switchover. This configuration needs to be included on both servers.
Listener.ora on Node 1
LISTENER_VMRACTEST =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vmractest2)(PORT = 1522)(IP = FIRST))
)
)
SID_LIST_LISTENER_VMRACTEST =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = whiteowl)
(ORACLE_HOME = /oradisk/app01/oracle/product/10gDB )
(SID_NAME = whiteowl)
)
(SID_DESC =
(SID_NAME=whiteowl)
(GLOBAL_DBNAME = whiteowl_DGMGRL)
(ORACLE_HOME = /oradisk/app01/oracle/product/10gDB )
)
)
Listener.ora on Node 2
LISTENER_VMRACTEST =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vmractest2)(PORT = 1522)(IP = FIRST))
)
)
Tnsnames.ora on Node 1, 2 and the observer node
whiteowl=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vmractest1)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = whiteowl_DGMGRL)
)
)
blackowl=
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vmractest2)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = blackowl_DGMGRL)
)
)
Setup the Broker configuration files
The broker configuration files are automatically created when the broker is started using
ALTER SYSTEM SET DG_BROKER_START=TRUE.
The default destination can be modified using the parameters
DG_BROKER_CONFIG_FILE1 and DG_BROKER_CONFIG_FILE2 On Primary:
SQL> show parameters DG_BROKER_CONFIG
NAME TYPE VALUE
---------------- ----------- ------------------------------
dg_broker_config_file1 string /oradisk/app01/oracle/product/
10gDB/dbs/dr1whiteowl.dat
dg_broker_config_file2 string /oradisk/app01/oracle/product/
10gDB/dbs/dr2whiteowl.dat
On Standby:
SQL> show parameters DG_BROKER_CONFIG
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
dg_broker_config_file1 string /oradisk/app01/oracle/product/
10gDB/dbs/dr1blackowl.dat
dg_broker_config_file2 string /oradisk/app01/oracle/product/
10gDB/dbs/dr2blackowl.dat
Next create from within the DGMGRL the configuration
[vmractest1] > dgmgrl
DGMGRL> CONNECT sys/oracle@whiteowl
DGMGRL> CREATE CONFIGURATION WHITEOWL AS
> PRIMARY DATABASE IS whiteowl
> CONNECT IDENTIFIER IS whiteowl;
Configuration "whiteowl" created with primary database "whiteowl"
Add the standby to the configuration and check it
DGMGRL> ADD DATABASE blackowl AS
> CONNECT IDENTIFIER IS blackowl
> MAINTAINED AS PHYSICAL;
Database "blackowl" added
DGMGRL> SHOW CONFIGURATION;
Configuration
Name: whiteowl
Enabled: NO
Protection Mode: MaxPerformance
Fast-Start Failover: DISABLED
Databases:
whiteowl - Primary database
blackowl - Physical standby database
Current status for "whiteowl":
DISABLED
Check and edit database properties
In this case parameter DbFileNameConvert has an error, it lacks the leading backslash:
DGMGRL> SHOW DATABASE VERBOSE blackowl;
Database
Name: blackowl
Role: PHYSICAL STANDBY
Enabled: NO
Intended State: OFFLINE
Instance(s):
blackowl
Properties:
InitialConnectIdentifier = 'blackowl'
LogXptMode = 'ASYNC'
Dependency = ''
DelayMins = '0'
Binding = 'OPTIONAL'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '180'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'auto'
ArchiveLagTarget = '0'
LogArchiveMaxProcesses = '30'
LogArchiveMinSucceedDest = '1'
DbFileNameConvert = 'vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/, /oradisk/od01/BLACKOWL/datafile/'
LogFileNameConvert = '/vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/, /oradisk/od01/BLACKOWL/onlinelog/'
FastStartFailoverTarget = ''
StatusReport = '(monitor)'
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
HostName = 'vmractest2.partnergsm.co.il'
SidName = 'blackowl'
LocalListenerAddress = '(ADDRESS=(PROTOCOL=TCP)(HOST=vmractest2)(PORT=1522)(IP=FIRST))'
StandbyArchiveLocation = '/oradisk/od01/BLACKOWL/archives/'
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = '%t_%s_%r.arc'
LatestLog = '(monitor)'
TopWaitEvents = '(monitor)'
Current status for "blackowl":
DISABLED
DGMGRL> EDIT DATABASE "blackowl" SET PROPERTY 'DbFileNameConvert' =
'/vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/, /oradisk/od01/BLACKOWL/datafile/';
Property "DbFileNameConvert" updated
The parameter DbFileNameConvert will be updated on the database also on the next restart.
Enabling the configuration and databases
DGMGRL> enable configuration;
DGMGRL> show configuration;
Configuration
Name: whiteowl
Enabled: YES
Protection Mode: MaxPerformance
Fast-Start Failover: DISABLED
Databases:
whiteowl - Primary database
blackowl - Physical standby database
Current status for "whiteowl":
SUCCESS
DGMGRL> enable database blackowl;
DGMGRL> SHOW DATABASE VERBOSE blackowl;
Database
Name: blackowl
Role: PHYSICAL STANDBY
Enabled: YES
Intended State: ONLINE
Instance(s):
blackowl
Properties:
InitialConnectIdentifier = 'blackowl'
LogXptMode = 'ASYNC'
Dependency = ''
DelayMins = '0'
Binding = 'OPTIONAL'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '180'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'auto'
ArchiveLagTarget = '0'
LogArchiveMaxProcesses = '30'
LogArchiveMinSucceedDest = '1'
DbFileNameConvert = '/vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/ , /oradisk/od01/BLACKOWL/datafile/'
LogFileNameConvert = '/vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/, /oradisk/od01/BLACKOWL/onlinelog/'
FastStartFailoverTarget = ''
StatusReport = '(monitor)'
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
HostName = 'vmractest2.partnergsm.co.il'
SidName = 'blackowl'
LocalListenerAddress = '(ADDRESS=(PROTOCOL=TCP)(HOST=vmractest2)(PORT=1522)(IP=FIRST))'
StandbyArchiveLocation = '/oradisk/od01/BLACKOWL/archives/'
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = '%t_%s_%r.arc'
LatestLog = '(monitor)'
TopWaitEvents = '(monitor)'
Current status for "blackowl":
SUCCESS
Enabling Fast Start Failover and the Observer
These are the steps required to enable and check Fast Start Failover and the Observer:
1. Ensure standby redo logs are configured on all databases.
2. Ensure the LogXptMode Property is set to SYNC.
3. Specify the FastStartFailoverTarget property.
4. Upgrade the protection mode to MAXAVAILABILITY, if necessary.
5. Enable Flashback Database on the primary and standby databases, if necessary.
6. Enable fast start failover.
7. Start the observer.
8. Verify the fast-start failover configuration.
9. Performing a Switchover Operation
Ensure standby redo logs are configured on all databases
This database is using Oracle Managed files so it is not necessary to pass a member name, i.e.:
ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 SIZE 50M;
SQL> set lines 120
SQL> col member for a80
SQL> select type,member from v$logfile order by type
2 /
TYPE MEMBER
------- --------------------------------------------------------------------------------
ONLINE /vmasmtest/whiteowl/recovery/WHITEOWL/onlinelog/o1_mf_2_3hkno95x_.log
ONLINE /vmasmtest/whiteowl/recovery/WHITEOWL/onlinelog/o1_mf_1_3hkno7jb_.log
ONLINE /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_1_3hkno747_.log
ONLINE /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_3_3hknoby2_.log
ONLINE /vmasmtest/whiteowl/recovery/WHITEOWL/onlinelog/o1_mf_3_3hknocmw_.log
ONLINE /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_2_3hkno8rq_.log
STANDBY /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_6_3gznrwd7_.log
STANDBY /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_4_3gznjc9v_.log
STANDBY /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_5_3gznnrh0_.log
9 rows selected.
Ensure the LogXptMode Property is set to SYNC
These commands will succeed only if database is configured with standby redo logs.
DGMGRL> connect sys/oracle@whiteowl
DGMGRL> EDIT DATABASE whiteowl SET PROPERTY 'LogXptMode'='SYNC';
Property "LogXptMode" updated
DGMGRL> EDIT DATABASE blackowl SET PROPERTY 'LogXptMode'='SYNC';
Property "LogXptMode" updated
Specify the FastStartFailoverTarget property
DGMGRL> EDIT DATABASE whiteowl SET PROPERTY FastStartFailoverTarget='blackowl';
Property "faststartfailovertarget" updated
DGMGRL> EDIT DATABASE blackowl SET PROPERTY FastStartFailoverTarget='whiteowl';
Property "faststartfailovertarget" updated
Upgrade the protection mode to MAXAVAILABILITY, if necessary.
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;
Operation requires shutdown of instance "whiteowl" on database "whiteowl"
Shutting down instance "whiteowl"...
Database closed.
Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "whiteowl" on database "whiteowl"
Starting instance "whiteowl"...
Unable to connect to database
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
Failed.
You are no longer connected to ORACLE
Please connect again.
Unable to start instance "whiteowl"
You must start instance "whiteowl" manually
Enable Flashback Database on the Primary and Standby databases.
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup mount;
On Both databases
To enter the standby into Flashback mode you must shutdown the both databases, then while the primary is down execute the
following commands on the standby:
SQL> ALTER SYSTEM SET UNDO_RETENTION=3600 SCOPE=SPFILE;
SQL> ALTER SYSTEM SET UNDO_MANAGEMENT='AUTO' SCOPE=SPFILE;
SQL> startup mount;
SQL> ALTER DATABASE FLASHBACK ON;
Enable fast start failover
[vmractest1] > dgmgrl
DGMGRL for Linux: Version 10.2.0.1.0 - Production
Copyright (c) 2000, 2005, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys/oracle@whiteowl
DGMGRL> SHOW CONFIGURATION;
Configuration
Name: whiteowl
Enabled: YES
Protection Mode: MaxAvailability
Fast-Start Failover: DISABLED
Databases:
whiteowl - Primary database
blackowl - Physical standby database
Current status for "whiteowl":
SUCCESS
DGMGRL> SHOW DATABASE blackowl;
Database
Name: blackowl
Role: PHYSICAL STANDBY
Enabled: YES
Intended State: ONLINE
Instance(s):
blackowl
Current status for "blackowl":
SUCCESS
DGMGRL> ENABLE FAST_START FAILOVER;
Enabled.
DGMGRL> SHOW CONFIGURATION;
Configuration
Name: whiteowl
Enabled: YES
Protection Mode: MaxAvailability
Fast-Start Failover: ENABLED
Databases:
whiteowl - Primary database
blackowl - Physical standby database
- Fast-Start Failover target
Current status for "whiteowl":
Start the observer
Start the observer from a third server on background. You may use a script like this:
---------------- script start on next line --------------------
#!/bin/ksh
# startobserver
export ORACLE_BASE=/vmractst3/app01/oracle
export ORACLE_HOME=/vmractst3/app01/oracle/product/10.2
export
BASE_PATH=/vmractst3/app01/oracle/scripts/general:/opt/CTEact/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/bin:/etc:/usr/loc
al/maint/oracle:/usr/ccs/bin:/usr/openwin/bin:/usr/dt/bin:/usr/local/bin:.
export PATH=$ORACLE_HOME/bin:$BASE_PATH
dgmgrl << eof
connect sys/oracle@whiteowl
START OBSERVER;
eof
---------------- script end on previous line --------------------
[vmractest3] > nohup ./startobserver &
[2] 22182
<oracle> /vmractst3/app01/oracle/product/10.2/dbs > DGMGRL for Linux: Version 10.2.0.3.0 - 64bit Production
Copyright (c) 2000, 2005, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
DGMGRL> Connected.
DGMGRL> Observer started
Verify the fast-start failover configuration.
DGMGRL> SHOW CONFIGURATION VERBOSE;
Configuration
Name: whiteowl
Enabled: YES
Protection Mode: MaxAvailability
Fast-Start Failover: ENABLED
Databases:
whiteowl - Primary database
blackowl - Physical standby database
- Fast-Start Failover target
Fast-Start Failover
Threshold: 30 seconds
Observer: vmractest3
Current status for "whiteowl":
SUCCESS
DGMGRL> SHOW DATABASE blackowl;
Database
Name: blackowl
Role: PHYSICAL STANDBY
Enabled: YES
Intended State: ONLINE
Instance(s):
blackowl
Current status for "blackowl":
SUCCESS
Perform a Switchover
Connect to DGMGRL on the observer server:
ORA Environement Variables:
ORACLE_BASE=/vmractst3/app01/oracle
ORACLE_HOME=/ vmractst 3/app01/oracle/product/10.2
[vmractst3] > dgmgrl
DGMGRL for Linux: Version 10.2.0.3.0 - 64bit Production
Copyright (c) 2000, 2005, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
DGMGRL> connect sys/oracle@whiteowl
DGMGRL>
Check that primary and standby are healthy
This check must return 'SUCCESS' as the status for both databases,
otherwise it means there is a configuration problem.
DGMGRL> show database whiteowl;
Database
Name: whiteowl
Role: PRIMARY
Enabled: YES
Intended State: ONLINE
Instance(s):
whiteowl
Current status for "whiteowl":
SUCCESS
DGMGRL> show database blackowl;
Database
Name: blackowl
Role: PHYSICAL STANDBY
Enabled: YES
Intended State: ONLINE
Instance(s):
blackowl
Current status for "blackowl":
SUCCESS
Execute the switchover
DGMGRL> SWITCHOVER TO blackowl;
Performing switchover NOW, please wait...
Operation requires shutdown of instance "whiteowl" on database "whiteowl"
Shutting down instance "whiteowl"...
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
Operation requires shutdown of instance "blackowl" on database "blackowl"
Shutting down instance "blackowl"...
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "whiteowl" on database "whiteowl"
Starting instance "whiteowl"...
ORACLE instance started.
Database mounted.
Operation requires startup of instance "blackowl" on database "blackowl"
Starting instance "blackowl"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "blackowl"
DGMGRL> show database blackowl
Database
Name: blackowl
Role: PRIMARY
Enabled: YES
Intended State: ONLINE
Instance(s):
blackowl
Current status for "blackowl":
SUCCESS
DGMGRL> show database whiteowl
Database
Name: whiteowl
Role: PHYSICAL STANDBY
Enabled: YES
Intended State: ONLINE
Instance(s):
whiteowl
Current status for "whiteowl":
SUCCESS
Reference:
Oracle® Data Guard Concepts and Administration
10g Release 2 (10.2)
Part Number B14239-04
http://download.oracle.com/docs/cd/B19306_01/server.102/b14230/cli.htm#BGBFEAFG
ocm8 Create and utilize a physical standby database
https://shenh.tripod.com/Oracleblog/index.blog/1825058/ocm8-create-and-utilize-a-physical-standby-database/
http://www.itpub.net/636810,1.html
alter database force logging;
alter database force nologging;
dataguard manager: primary database must use spfile;
alter database create standby controlfile as '\...\standyctf.con';
init.ora for standby db
db_file_name_covert
log_file_name_convert
log_archive_format
standby_file_management=auto vs. manual
standby_archive_dest
log_archive_start=true vs. manual
remote_archive_enable=true false send receive
on standby db:
startup mountpfile-stby_init.ora
alter database add standby logfile ( ..., ... ) size 500K;
alter database recover managed standy database disconnect;
on primary db:
alter system set log_archive_dest_2='service=standby mandatory';
alter system set log_archive_dest_stat_2=enable defer reset alternate;
archive_lag_target=1800 ( seconds ) max wait for a log switch to occur
------------------------------------------------------------------------------------------
Alejandro Vargas
Principal Support Consultant
Oracle Advanced Support Services
Creating a Data Guard Physical Standby environment, General Review.
The Enviroment
Implementation notes:
Step by Step Implementation of a Physical Standby Environment
Primary Database Steps
Primary Database General View
Enable Forced Logging
Create a Password File
Configure a Standby Redo Log
Enable Archiving
Set Primary Database Initialization Parameters
Standby Database Steps
Create a Control File for the Standby Database
Backup the Primary Database and transfer a copy to the Standby node
Prepare an Initialization Parameter File for the Standby Database
Configure the listener and tnsnames to support the database on both nodes
Set Up the Environment to Support the Standby Database on the standby node
Start the Primary Database
Verify the Physical Standby Database Is Performing Properly
Reference:
--------------------------------------------------------------------------------
Creating a Data Guard Physical Standby environment, General Review.
Manually setting up a Physical standby database is a simple task when all prerequisites and setup steps are carefully met and executed.
In this example I did use 2 hosts, that host a RAC database. All RAC preinstall requisites are then in place and no additional configuration was
necessary to implement Data Guard Physical Standby manually. Note that using Enterprise Manager Grid Control Data Guard Physical Standby
can be implemented from the Grid Control Console easily. Still, this exercise provide a degree of familiarity with Data Guard.
The Enviroment
2 Linux servers, Oracle Distribution 2.6.9-55 EL i686 i386 GNU/Linux
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0
ssh is configured for user oracle on both nodes
Oracle Home is on identical path on both nodes
Implementation notes:
Once you have your primary database up and running these are the steps to follow:
1. Enable Forced Logging
2. Create a Password File
3. Configure a Standby Redo Log
4. Enable Archiving
5. Set Primary Database Initialization Parameters
Having followed these steps to implement the Physical Standby you need to follow these steps:
1. Create a Control File for the Standby Database
2. Backup the Primary Database and transfer a copy to the Standby node.
3. Prepare an Initialization Parameter File for the Standby Database
4. Configure the listener and tnsnames to support the database on both nodes
5. Set Up the Environment to Support the Standby Database on the standby node.
6. Start the Physical Standby Database
7. Verify the Physical Standby Database Is Performing Properly
Step by Step Implementation of a Physical Standby Environment
Primary Database Steps
Primary Database General View
SQL> select name from v$database;
NAME
---------
WHITEOWL
SQL> select file_name from dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
/vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_users_310mzml9_.dbf
/vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_sysaux_310mzm34_.dbf
/vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_undotbs1_310mzmk2_.dbf
/vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_system_310mzm27_.dbf
/vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_test2_3117h15v_.dbf
/vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_test3_3117h8nv_.dbf
/vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_test4_3117hk7d_.dbf
7 rows selected.
SQL> select name from v$database;
NAME
---------
WHITEOWL
SQL> show parameters unique
NAME TYPE VALUE
-------- ----------- -------
db_unique_name string whiteowl
Enable Forced Logging
In order to implement Standby Database we enable 'Forced Logging'.
This option ensures that even in the event that a 'nologging' operation is done,
force logging takes precedence and all operations are logged
into the redo logs.
SQL> ALTER DATABASE FORCE LOGGING;
Database altered.
Create a Password File
A password file must be created on the Primary and copied over to the Standby site.
The sys password must be identical on both sites. T
his is a key prerequisite in order to be able to ship and
apply archived logs from Primary to Standby.
cd $ORACLE_HOME/dbs
[vmractest1] > orapwd file=orapwwhiteowl password=oracle force=y
Configure a Standby Redo Log
A Standby Redo log is added to enable Data Guard Maximum Availability and Maximum Protection modes.
It is important to configure the Standby Redo Logs (SRL) with the same size as the online redo logs.
In this example I'm using Oracle Managed Files, that's why I don't need to provide the SRL path and file name.
If you are not using OMF's, you then must pass the full qualified name.
SQL> select * from v$logfile;
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- ---------------------------------------------- ---
3 ONLINE /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_3_310n22jj_.log NO
2 ONLINE /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_2_310n21sx_.log NO
1 ONLINE /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_1_310n215q_.log NO
SQL> select bytes from v$log;
BYTES
----------
52428800
52428800
52428800
SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 SIZE 50M;
Database altered.
SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 SIZE 50M;
Database altered.
SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 SIZE 50M;
Database altered.
SQL> select * from v$logfile
2 /
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- ---------------------------------------------------------------------- ---
3 ONLINE /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_3_310n22jj_.log NO
2 ONLINE /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_2_310n21sx_.log NO
1 ONLINE /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_1_310n215q_.log NO
4 STANDBY /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_4_3gznjc9v_.log NO
5 STANDBY /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_5_3gznnrh0_.log NO
6 STANDBY /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_6_3gznrwd7_.log NO
6 rows selected.
Enable Archiving
On 10g you can enable archive log mode by mounting the database and executing the archivelog command:
SQL> startup mount;
SQL> alter database archivelog;
SQL> alter database open;
SQL> archive log list
Set Primary Database Initialization Parameters
Data Guard must use spfile,
SQL> create pfile='/oradisk/app01/oracle/product/10gDB/dbs/pfilewhiteowl.ora' from spfile;
db_name='whiteowl'
db_unique_name='whiteowl'
LOG_ARCHIVE_CONFIG='DG_CONFIG=(whiteowl,blackowl)'
control_files='/vmasmtest/od01/WHITEOWL/WHITEOWL/controlfile/o1_mf_310n1xf0_.ctl'
LOG_ARCHIVE_DEST_1='LOCATION=/vmasmtest/whiteowl/archdest/VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=whiteowl'
LOG_ARCHIVE_DEST_2='SERVICE=blackowl LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=blackowl'
LOG_ARCHIVE_DEST_STATE_1=ENABLE
LOG_ARCHIVE_DEST_STATE_2=ENABLE
REMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE
LOG_ARCHIVE_FORMAT=%t_%s_%r.arc
LOG_ARCHIVE_MAX_PROCESSES=30
# Standby role parameters --------------------------------------------------------------------
*.fal_server=blackowl
*.fal_client=whiteowl
*.standby_file_management=auto
*.db_file_name_convert='BLACKOWL/BLACKOWL','WHITEOWL/WHITEOWL'
*.log_file_name_convert='/vmasmtest/od01/BLACKOWL/BLACKOWL/','/vmasmtest/od01/WHITEOWL/WHITEOWL/'
# ---------------------------------------------------------------------------------------------
audit_file_dest='/oradisk/app01/oracle/admin/whiteowl/adump'
background_dump_dest='/oradisk/app01/oracle/admin/whiteowl/bdump'
core_dump_dest='/oradisk/app01/oracle/admin/whiteowl/cdump'
user_dump_dest='/oradisk/app01/oracle/admin/whiteowl/udump'
compatible='10.2.0.1.0'
db_block_size=8192
db_create_file_dest='/vmasmtest/od01/WHITEOWL'
db_domain=''
db_file_multiblock_read_count=16
job_queue_processes=10
open_cursors=300
pga_aggregate_target=94371840
processes=150
remote_login_passwordfile='EXCLUSIVE'
sga_target=283115520
undo_management='AUTO'
undo_tablespace='UNDOTBS1'
Once the new parameter file is ready we create from it the spfile:
SQL> shutdown immediate;
SQL> startup nomount pfile='/oradisk/app01/oracle/product/10gDB/dbs/pfilewhiteowl.ora';
SQL> create spfile from pfile='/oradisk/app01/oracle/product/10gDB/dbs/pfilewhiteowl.ora';
SQL> shutdown immediate;
SQL> startup;
Standby Database Steps
Create a Control File for the Standby Database
The standby database will use a control file that is generated on the primary database
SQL> startup mount;
SQL> ALTER DATABASE CREATE STANDBY CONTROLFILE AS '/oradisk/app01/oracle/product/10gDB/dbs/blackowl.ctl';
SQL> ALTER DATABASE OPEN;
Backup the Primary Database and transfer a copy to the Standby node.
Generate a script to copy datafiles
SQL> set pages 50000 lines 120 head off veri off flush off ti off
SQL> spool cpfiles
SQL> select 'scp -p '||file_name||' $v_dest' from dba_data_files;
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_users_310mzml9_.dbf $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_sysaux_310mzm34_.dbf $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_undotbs1_310mzmk2_.dbf $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_system_310mzm27_.dbf $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_test2_3117h15v_.dbf $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_test3_3117h8nv_.dbf $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_test4_3117hk7d_.dbf $v_dest
7 rows selected.
SQL> select 'scp -p '||file_name||' $v_dest' from dba_temp_files;
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_temp_310n2bnj_.tmp $v_dest
SQL> select 'scp -p '||member||' $v_dest' from v$logfile;
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_3_310n22jj_.log $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_2_310n21sx_.log $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_1_310n215q_.log $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_4_3gznjc9v_.log $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_5_3gznnrh0_.log $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_6_3gznrwd7_.log $v_dest
6 rows selected.
SQL> spool off
Shutdown the database, edit the script to add the v_dest location, and execute it.
[vmractest1] > mv cpfiles.lst cpfiles
#!/bin/ksh
v_dest=vmractest2:/oradisk/od01/BLACKOWL/datafile/
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_users_310mzml9_.dbf $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_sysaux_310mzm34_.dbf $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_undotbs1_310mzmk2_.dbf $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_system_310mzm27_.dbf $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_test2_3117h15v_.dbf $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_test3_3117h8nv_.dbf $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_test4_3117hk7d_.dbf $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/o1_mf_temp_310n2bnj_.tmp $v_dest
v_dest= vmractest2:/oradisk/od01/BLACKOWL/onlinelog/
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_3_310n22jj_.log $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_2_310n21sx_.log $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_1_310n215q_.log $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_4_3gznjc9v_.log $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_5_3gznnrh0_.log $v_dest
scp -p /vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_6_3gznrwd7_.log $v_dest
On the standby node create the required directories to get the datafiles
[root@vmractest2 root]# mkdir -p /oradisk/od01/BLACKOWL/datafile/
[root@vmractest2 root]# mkdir -p /oradisk/od01/BLACKOWL/onlinelog/
[root@vmractest2 root]# chown -R oracle:dba /oradisk/od01
On the primary node execute the script to copy the database while the main database is down (or in backup mode)
[vmractest1] > chmod 700 cpfiles
[vmractest1] > ./cpfiles
Prepare an Initialization Parameter File for the Standby Database
Copy and edit the primary init.ora to set it up for the standby role
*.db_name='whiteowl'
*.db_unique_name='blackowl'
*.audit_file_dest='/oradisk/app01/oracle/admin/blackowl/adump'
*.background_dump_dest='/oradisk/app01/oracle/admin/blackowl/bdump'
*.core_dump_dest='/oradisk/app01/oracle/admin/blackowl/cdump'
*.user_dump_dest='/oradisk/app01/oracle/admin/blackowl/udump'
*.compatible='10.2.0.1.0'
*.control_files='/oradisk/od01/BLACKOWL/controlfile/blackowl_01.ctl','/oradisk/od01/BLACKOWL/controlfile/blackowl_02.ctl'
*.db_block_size=8192
*.db_create_file_dest='/oradisk/od01/BLACKOWL'
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_file_name_convert='/oradisk/od01/BLACKOWL/datafile/','/vmasmtest/od01/WHITEOWL/WHITEOWL/datafile/'
*.log_file_name_convert='/oradisk/od01/BLACKOWL/onlinelog/','/vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/'
*.fal_server='whiteowl'
*.fal_client='blackowl'
*.job_queue_processes=10
*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(whiteowl,blackowl)'
*.LOG_ARCHIVE_DEST_1='LOCATION=/oradisk/od01/BLACKOWL/archives/
VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
DB_UNIQUE_NAME=blackowl'
*.LOG_ARCHIVE_DEST_2='SERVICE=whiteowl LGWR ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=whiteowl'
*.LOG_ARCHIVE_DEST_STATE_1='ENABLE'
*.LOG_ARCHIVE_DEST_STATE_2='ENABLE'
*.LOG_ARCHIVE_FORMAT='%t_%s_%r.arc'
*.LOG_ARCHIVE_MAX_PROCESSES=30
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=283115520
*.standby_file_management='auto'
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
Create all required directories for dump directories and archived log destination
[vmractest2] > mkdir -p /oradisk/app01/oracle/admin/blackowl/adump
{oracle} /oradisk/app01/oracle/product/10gDB/dbs [vmractest2] > mkdir -p /oradisk/app01/oracle/admin/blackowl/bdump
{oracle} /oradisk/app01/oracle/product/10gDB/dbs [vmractest2] > mkdir -p /oradisk/app01/oracle/admin/blackowl/cdump
{oracle} /oradisk/app01/oracle/product/10gDB/dbs [vmractest2] > mkdir -p /oradisk/app01/oracle/admin/blackowl/udump
{oracle} /oradisk/app01/oracle/product/10gDB/dbs [vmractest2] > mkdir -p /oradisk/od01/BLACKOWL/archives/
Copy from the primary the standby controlfile to its destination
scp -p blackowl.ctl vmractest2:/oradisk/od01/BLACKOWL/controlfile/blackowl_02.ctl
scp -p blackowl.ctl vmractest2:/oradisk/od01/BLACKOWL/controlfile/blackowl_01.ctl
Configure the listener and tnsnames to support the database on both nodes
Configure listener.ora on both servers to hold entries for both databases
# ON VMRACTEST1
LISTENER_VMRACTEST =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vmractest1)(PORT = 1522)(IP = FIRST))
)
)
SID_LIST_LISTENER_VMRACTEST =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = whiteowl)
(ORACLE_HOME = /oradisk/app01/oracle/product/10gDB )
(SID_NAME = whiteowl)
)
)
# ON VMRACTEST2
LISTENER_VMRACTEST =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vmractest2)(PORT = 1522)(IP = FIRST))
)
)
SID_LIST_LISTENER_VMRACTEST =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = blackowl)
(ORACLE_HOME = /oradisk/app01/oracle/product/10gDB )
(SID_NAME = blackowl)
)
)
Configure tnsnames.ora on both servers to hold entries for both databases
# ON VMRACTEST1
LISTENER_VMRACTEST =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vmractest1)(PORT = 1522)(IP = FIRST))
)
)
WHITHEOWL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vmractest1)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = whiteowl)
)
)
BLACKOWL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vmractest2)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = blackowl)
)
)
# ON VMRACTEST2
LISTENER_VMRACTEST =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vmractest2)(PORT = 1522)(IP = FIRST))
)
)
BLACKOWL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vmractest2)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = blackowl)
)
)
WHITHEOWL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = vmractest1)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = whiteowl)
)
)
Start the listener and check tnsping on both nodes to both services
[vmractest1.partnergsm.co.il] > tnsping whiteowl
{oracle} /oradisk/app01/oracle/product/10gDB/network/admin
[vmractest1.partnergsm.co.il] > tnsping blackowl
Set Up the Environment to Support the Standby Database on the standby node.
Copy the password file from Primary to Standby, sys password must be identical
[vmractest1]> scp orapwwhiteowl vmractest2:/oradisk/app01/oracle/product/10gDB/dbs/orapwblackowl
Setup the environment variables to point to the Satndby database
ORACLE_HOME=/oradisk/app01/oracle/product/10gDB
ORACLE_SID=blackowl
Startup nomount the Standby database and generate an spfile
{oracle} /oradisk/app01/oracle/product/10gDB/dbs [vmractest2] > sqlplus / as sysdba
SQL> startup nomount pfile='/oradisk/app01/oracle/product/10gDB/dbs/initblackowl.ora'
SQL> create spfile from pfile='/oradisk/app01/oracle/product/10gDB/dbs/initblackowl.ora';
SQL> shutdown immediate;
SQL> startup mount
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
The alert log of the standby will show the operations taking place
…
…
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION
Wed Sep 19 16:46:26 2007
Attempt to start background Managed Standby Recovery process (blackowl)
MRP0 started with pid=47, OS id=12498
Wed Sep 19 16:46:26 2007
MRP0: Background Managed Standby Recovery process started (blackowl)
Managed Standby Recovery not using Real Time Apply
Clearing online redo logfile 1 /oradisk/od01/BLACKOWL/onlinelog/o1_mf_1_310n215q_.log
Clearing online log 1 of thread 1 sequence number 95
Deleted Oracle managed file /oradisk/od01/BLACKOWL/onlinelog/o1_mf_1_310n215q_.log
Wed Sep 19 16:46:32 2007
Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION
Wed Sep 19 16:46:33 2007
Clearing online redo logfile 1 complete
Clearing online redo logfile 2 /oradisk/od01/BLACKOWL/onlinelog/o1_mf_2_310n21sx_.log
Clearing online log 2 of thread 1 sequence number 96
Deleted Oracle managed file /oradisk/od01/BLACKOWL/onlinelog/o1_mf_2_310n21sx_.log
Clearing online redo logfile 2 complete
Clearing online redo logfile 3 /oradisk/od01/BLACKOWL/onlinelog/o1_mf_3_310n22jj_.log
Clearing online log 3 of thread 1 sequence number 94
Deleted Oracle managed file /oradisk/od01/BLACKOWL/onlinelog/o1_mf_3_310n22jj_.log
Clearing online redo logfile 3 complete
Media Recovery Waiting for thread 1 sequence 96
Start the Primary Database
The alert log of the primary will show how it recognize the standby and start shipping archived logs
******************************************************************
LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_2
******************************************************************
Wed Sep 19 16:01:07 2007
LNS: Standby redo logfile selected for thread 1 sequence 100 for destination
LOG_ARCHIVE_DEST_2
Wed Sep 19 16:01:07 2007
Successfully onlined Undo Tablespace 1.
Wed Sep 19 16:01:07 2007
SMON: enabling tx recovery
Wed Sep 19 16:01:09 2007
Database Characterset is AL32UTF8
replication_dependency_tracking turned off (no async multimaster replication found)
Starting background process QMNC
QMNC started with pid=21, OS id=13864
Wed Sep 19 16:01:12 2007
Completed: ALTER DATABASE OPEN
Wed Sep 19 16:01:13 2007
ARCq: Standby redo logfile selected for thread 1 sequence 99 for destination
LOG_ARCHIVE_DEST_2
Wed Sep 19 16:05:05 2007
Thread 1 advanced to log sequence 101
Current log# 1 seq# 101 mem# 0:
/vmasmtest/od01/WHITEOWL/WHITEOWL/onlinelog/o1_mf_1_310n215q_.log
Wed Sep 19 16:05:06 2007
LNS: Standby redo logfile selected for thread 1 sequence 101 for destination
LOG_ARCHIVE_DEST_2
Verify the Physical Standby Database Is Performing Properly
Check archived redo log on Standby
SQL> show parameters db_unique_name;
NAME TYPE VALUE
----- ----------- ------------
db_unique_name string blackowl
SQL> l
1* SELECT NAME FROM V$DATABASE
SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
SEQUENCE# FIRST_TIM NEXT_TIME
---------- --------- ---------
96 19-SEP-07 19-SEP-07
97 19-SEP-07 19-SEP-07
98 19-SEP-07 19-SEP-07
99 19-SEP-07 19-SEP-07
100 19-SEP-07 19-SEP-07
Switch logfiles on Primary
SQL> alter system switch logfile;
SQL> archive log list
SQL> alter system switch logfile;
SQL> archive log list
SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
SEQUENCE# FIRST_TIME NEXT_TIME
---------- -------------- --------------
96 19/09/07 09:35 19/09/07 09:45
97 19/09/07 09:45 19/09/07 15:20
98 19/09/07 15:20 19/09/07 15:48
99 19/09/07 15:48 19/09/07 16:00
100 19/09/07 16:00 19/09/07 16:05
101 19/09/07 16:05 19/09/07 16:08
102 19/09/07 16:08 19/09/07 16:08
7 rows selected.
Reference:
Oracle® Data Guard Concepts and Administration
10g Release 2 (10.2)
Part Number B14239-04
http://download.oracle.com/docs/cd/B19306_01/server.102/b14239/create_ps.htm#SBYDB00210
ocm8 Create and utilize a logical standby database
https://shenh.tripod.com/Oracleblog/index.blog/1825059/ocm8-create-and-utilize-a-logical-standby-database/
1): data type
Select * from dba_logstdby_unsupported;
2):
select owner, table_name, bad_column from dba_logstdby_not_unique;
--> add primary key
3): force logging
select supplemental_log_data_pk,supplemental_log_data_ui from v$database;
ALTER DATABASE ADD SUPPLEMENTAL LOG DATA (PRIMARY KEY,UNIQUE INDEX) COLUMNS;
4):
JSSLDG>alter database recover managed standby database cancel;
EXECUTE DBMS_LOGSTDBY.BUILD;
shutdown immediate
startup mount;
5):
convert physical standby to logical standby
SQL> alter database recover to logical standby NEW_DBNAME;
alter database recover to logical standby jssldg;
6): enter logical apply
SQL> alter database open resetlogs;
SQL> alter database start logical standby apply immediate;
SQL> alter database stop logical standby apply immediate;
7): prepare to switch over
7a):
alter database prepare to switchover to logical standby;
select switchover_status from v$database;
7b):
alter database prepare to switchover to primary;
ALTER DATABASE PREPARE TO SWITCHOVER CANCEL;
8): commit to switch over
alter database commit to switchover to logical standby;
alter database commit to switchover to primary;
9): sql apply
alter database start logical standby apply;
10): failover
alter database activate logical standby database finish apply;
11):
alter session disable guard;
create database link getjssweb connect to jss identified by jss using 'jssweb';
alter session enable guard;
12); re-start sql apply
alter database start logical standby apply new primary getjssweb;
ocm8 Set up log transport services for various levels or protection
https://shenh.tripod.com/Oracleblog/index.blog/1825060/ocm8-set-up-log-transport-services-for-various-levels-or-protection/
249594.1
Dataguard Configuration: LOG_ARCHIVE_CONFIG and VALID_FOR in Oracle 10G
https://metalink.oracle.com/metalink/plsql/ml2_documents.showDocument?p_database_id=NOT&p_id=249594.1
http://vongates.itpub.net/post/2553/243187
arch vs. lgwr
sync vs. async ( lgwr only )
affirm vs. noaffirm
alter database set standby to maximize protection;
( must use sync, must use standby redo logs )
alter database set standby to maximize performance;
alter database set standby to maximize availibility;
--- ------------------------------------------------------------------
*.DB_UNIQUE_NAME=10gstandby
*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(10gpri,10gstandby)'
*.LOG_ARCHIVE_DEST_1='LOCATION=/archlog2/10gstandby/ VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=10gpri'
*.LOG_ARCHIVE_DEST_2='SERVICE=dbpri LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=10gpri'
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.LOG_ARCHIVE_DEST_STATE_2=ENABLE
-----------------------------------------------------------------------------------------------------------------
*.FAL_SERVER=dbpri
*.FAL_CLIENT=dbstandby
-- --------------------------------------------------------------------------------------------------------------
*.DB_FILE_NAME_CONVERT=
'/data1/powererp/','/data13/powererp/',
'/data2/powererp/','/data13/powererp/',
'/data3/powererp/','/data13/powererp/',
'/data4/powererp/','/data14/powererp/',
'/data5/powererp/','/data14/powererp/',
'/data6/powererp/','/data14/powererp/',
'/data1/olddata/','/data13/olddata/data1/',
'/data2/olddata/','/data13/olddata/data2/',
'/data3/olddata/','/data13/olddata/data3/',
'/data4/olddata/','/data14/olddata/data4/',
'/data5/olddata/','/data14/olddata/data5/',
'/data6/olddata/','/data14/olddata/data6/',
'/data1/oradata/ora8/','/data13/oradata/ora8/',
'/data2/oradata/ora8/','/data13/oradata/ora8/',
'/data3/oradata/ora8/','/data14/oradata/ora8/',
'/data1/timms/','/data13/timms/',
'/data6/statspack/','/data14/statspack/'
*.LOG_FILE_NAME_CONVERT=
'/archlog/10gpri/','/archlog2/10gstandby/'
*.STANDBY_FILE_MANAGEMENT=AUTO
-----------------------------------------------------------------------------------------------------------------
ocm8 Configure the network environment to allow communication between the standby database and the primary database
https://shenh.tripod.com/Oracleblog/index.blog/1825061/ocm8-configure-the-network-environment-to-allow-communication-between-the-standby-database-and-the-primary-database/
global_db_name_dgrmgrl.domain
configure static double service names:
ocm8 Open the physical standby database in a "ready-only" state
https://shenh.tripod.com/Oracleblog/index.blog/1825062/ocm8-open-the-physical-standby-database-in-a-readyonly-state/
http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10823/manage_ps.htm#1017113
http://www.databasejournal.com/features/oracle/article.php/3682421
1):
SQL> startup nomount pfile=/export/home/oracle/admin/SEAN/pfile/initSEAN.standby
SQL> atler database mount standby database;
2):
SQL> recover standby database;
AUTO
SQL> alter database open read only;
-- ---------------------------------
put it back in normal standby mount state
SQL> shutdown immediate;
SQL> startup nomount pfile=/export/home/oracle/admin/SEAN/pfile/initSEAN.standby
SQL> atler database mount standby database;
--------------------------------------------------------------------------------
SQL> alter system set db_recovery_file_dest_size=2g scope=both;
SQL> alter system set db_recovery_file_dest='/u01/app/oracle/flashback' scope=both;
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database flashback on;
Stop redo apply to the standby
SQL> alter database recover managed standby database cancel;
Create a restore point on the standby
SQL> create restore point Before_App_Test guarantee flashback database;
SQL> alter system archive log current;
Stop logfile transfer
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=DEFER;
Activate the physical standby database.
SQL> ALTER DATABASE ACTIVATE STANDBY DATABASE;
Startup mount force the standby
SQL> STARTUP MOUNT FORCE;
Set the standby protection mode to maximum performance
SQL> alter database set standby database to maximize performance;
SQL> ALTER DATABASE OPEN;
SQL> connect avargas/oracle
Connected.
SQL> create table myusers as select * from dba_users;
Table created.
SQL> insert into myusers select * from myusers;
22 rows created.
SQL> /
44 rows created.
SQL> /
88 rows created.
SQL> /
176 rows created.
-- ------------------------------
SQL> startup mount force;
SQL> flashback database to restore point before_app_test;
SQL> alter database convert to physical standby;
SQL> STARTUP MOUNT FORCE;
Put the standby database on recover mode.
SQL> alter database recover managed standby database disconnect;
Enable archive log shipping to the standby
SQL> alter system set log_archive_dest_state_2=enable;
ocm8 Perform a switchover operation and a failover operation
https://shenh.tripod.com/Oracleblog/index.blog/1825063/ocm8-perform-a-switchover-operation-and-a-failover-operation/
1): switchover
sql>alter database commit to switchover to physical standby;
sql>alter database commit to switchover to logical standby;
primary to standby:
a): ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY WITH SESSION SHUTDOWN WAIT;
b): ALTER DATABASE COMMIT TO SWITCHOVER TO LOGICAL STANDBY;
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP NOMOUNT;
SQL> ALTER DATABASE MOUNT STANDBY DATABASE;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;
standby to primary:
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN WAIT;
SQL> SHUTDOWN;
SQL> STARTUP;
2): failover
SQL> ALTER DATABASE ACTIVATE PHYSICAL STANDBY
DATABASE;
SQL> ALTER DATABASE ACTIVATE LOGICAL STANDBY
DATABASE;
Failover for Physical Standby Databases Using SQL
To perform failover for physical standby databases using SQL:
1. Initiate the failover operation on the standby database. If a failure occurs at the
primary database, a failover allows you to salvage incomplete standby redo logs
using the following statement:
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE
FINISH;
2. Convert the physical standby database to the primary role. You must now change the
standby database into the new primary database by issuing the following statement:
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
3. Register the missing redo logs. Once the archived standby redo logs have been
received and recovered on all destinations, the other standby databases are ready to
receive redo logs from the new primary database. To register the copied archived
redo logs, issue the following statement on each standby database:
ALTER DATABASE REGISTER
LOGFILE ’/standby/arch_dest/arch_1_101.arc’;
ocm8 Implement Data Guard
https://shenh.tripod.com/Oracleblog/index.blog/1825064/ocm8-implement-data-guard/