Conventions Make for Easy Automation
[oracle@ol7-121-dg1 ~]$ echo $ORACLE_SID hawk [oracle@ol7-121-dg1 ~]$ /sf_working/dg_show.sh DGMGRL for Linux: Version 12.1.0.2.0 - 64bit Production Copyright (c) 2000, 2013, Oracle. All rights reserved. Welcome to DGMGRL, type "help" for information. DGMGRL> connect / Connected as SYSDG. DGMGRL> show configuration Configuration - dg_hawk Protection Mode: MaxPerformance Members: hawka - Primary database hawkb - Physical standby database Fast-Start Failover: DISABLED Configuration Status: SUCCESS (status updated 54 seconds ago) DGMGRL> show database hawka Database - hawka Role: PRIMARY Intended State: TRANSPORT-ON Instance(s): hawk Database Status: SUCCESS DGMGRL> show database hawkb Database - hawkb Role: PHYSICAL STANDBY Intended State: APPLY-ON Transport Lag: 0 seconds (computed 4 seconds ago) Apply Lag: 0 seconds (computed 4 seconds ago) Average Apply Rate: 1.00 KByte/s Real Time Query: OFF Instance(s): hawk Database Status: SUCCESS DGMGRL> exit [oracle@ol7-121-dg1 ~]$ Show Data Guard status from host2:
[oracle@ol7-121-dg2 ~]$ echo $ORACLE_SID hawk [oracle@ol7-121-dg2 ~]$ /sf_working/dg_show.sh DGMGRL for Linux: Version 12.1.0.2.0 - 64bit Production Copyright (c) 2000, 2013, Oracle. All rights reserved. Welcome to DGMGRL, type "help" for information. DGMGRL> connect / Connected as SYSDG. DGMGRL> show configuration Configuration - dg_hawk Protection Mode: MaxPerformance Members: hawka - Primary database hawkb - Physical standby database Fast-Start Failover: DISABLED Configuration Status: SUCCESS (status updated 18 seconds ago) DGMGRL> show database hawka Database - hawka Role: PRIMARY Intended State: TRANSPORT-ON Instance(s): hawk Database Status: SUCCESS DGMGRL> show database hawkb Database - hawkb Role: PHYSICAL STANDBY Intended State: APPLY-ON Transport Lag: 0 seconds (computed 3 seconds ago) Apply Lag: 0 seconds (computed 3 seconds ago) Average Apply Rate: 1.00 KByte/s Real Time Query: OFF Instance(s): hawk Database Status: SUCCESS DGMGRL> exit [oracle@ol7-121-dg2 ~]$ Stop Transport from host1:
[oracle@ol7-121-dg1 ~]$ /sf_working/dg_transport_on_off.sh /sf_working/dg_transport_on_off.sh: line 4: 2: ---> USAGE: /sf_working/dg_transport_on_off.sh ORACLE_UNQNAME <ON|OFF> [oracle@ol7-121-dg1 ~]$ /sf_working/dg_transport_on_off.sh hawka off DGMGRL for Linux: Version 12.1.0.2.0 - 64bit Production Copyright (c) 2000, 2013, Oracle. All rights reserved. Welcome to DGMGRL, type "help" for information. DGMGRL> connect / Connected as SYSDG. DGMGRL> show configuration Configuration - dg_hawk Protection Mode: MaxPerformance Members: hawka - Primary database hawkb - Physical standby database Fast-Start Failover: DISABLED Configuration Status: SUCCESS (status updated 10 seconds ago) DGMGRL> edit database hawka set state=TRANSPORT-off; Succeeded. DGMGRL> show database hawka Database - hawka Role: PRIMARY Intended State: TRANSPORT-OFF Instance(s): hawk Database Status: SUCCESS DGMGRL> exit [oracle@ol7-121-dg1 ~]$ Start Transport from host2:
[oracle@ol7-121-dg2 ~]$ /sf_working/dg_transport_on_off.sh hawka on DGMGRL for Linux: Version 12.1.0.2.0 - 64bit Production Copyright (c) 2000, 2013, Oracle. All rights reserved. Welcome to DGMGRL, type "help" for information. DGMGRL> connect / Connected as SYSDG. DGMGRL> show configuration Configuration - dg_hawk Protection Mode: MaxPerformance Members: hawka - Primary database hawkb - Physical standby database Fast-Start Failover: DISABLED Configuration Status: SUCCESS (status updated 36 seconds ago) DGMGRL> edit database hawkb set state=TRANSPORT-on; Error: ORA-16516: current state is invalid for the attempted operation Failed. DGMGRL> show database hawkb Database - hawkb Role: PHYSICAL STANDBY Intended State: APPLY-ON Transport Lag: 0 seconds (computed 15 seconds ago) Apply Lag: 0 seconds (computed 15 seconds ago) Average Apply Rate: 1.00 KByte/s Real Time Query: OFF Instance(s): hawk Database Status: SUCCESS DGMGRL> exit [oracle@ol7-121-dg2 ~]$ dg_show.sh
#!/bin/bash -e
check_dg()
{
dgmgrl -echo << EOF
connect /
show configuration
show database ${ORACLE_SID}a
show database ${ORACLE_SID}b
exit
EOF
}
check_dg
exit dg_transport_on_off.sh
#!/bin/bash -e
DN=`dirname $0`
BN=`basename $0`
ST=${2:?"---> USAGE: $DN/$BN ORACLE_UNQNAME <ON|OFF>"}
check_dg()
{
dgmgrl -echo << EOF
connect /
show configuration
edit database ${ORACLE_UNQNAME} set state=TRANSPORT-${ST};
show database ${ORACLE_UNQNAME}
exit
EOF
}
check_dg
exit
Conclusions? None necessary :=)
On this page
Share this
Share this
More resources
Learn more about Pythian by reading the following blogs and articles.
How to test an Oracle database upgrade using a physical standby
How to test an Oracle database upgrade using a physical standby
Sep 13, 2018 12:00:00 AM
10
min read
Automating Oracle RMAN backup configuration on Linux with Ansible

Automating Oracle RMAN backup configuration on Linux with Ansible
Aug 17, 2017 8:35:00 AM
26
min read
Management and Troubleshooting Features: Data Guard Command-Line Interface (DGMGRL) 19c
Management and Troubleshooting Features: Data Guard Command-Line Interface (DGMGRL) 19c
Oct 1, 2020 12:00:00 AM
7
min read
Ready to unlock value from your data?
With Pythian, you can accomplish your data transformation goals and more.