{"id":1979,"date":"2020-08-14T12:46:20","date_gmt":"2020-08-14T10:46:20","guid":{"rendered":"http:\/\/www.ludovicocaldara.net\/dba\/?p=1979"},"modified":"2020-08-18T15:56:29","modified_gmt":"2020-08-18T13:56:29","slug":"dg-ezconnect-observer","status":"publish","type":"post","link":"https:\/\/www.ludovicocaldara.net\/dba\/dg-ezconnect-observer\/","title":{"rendered":"Data Guard, Easy Connect and the Observer for multiple configurations"},"content":{"rendered":"<p><strong>EZConnect<\/strong><\/p>\n<p>One of the challenges of automation in bin Oracle Environments is dealing with <em>tnsnames.ora<\/em> files.<br \/>\nThese files might grow big and are sometimes hard to distribute\/maintain properly.<br \/>\nThe worst is when manual modifications are needed: manual operations, if not made carefully, can screw up the connection to the databases.<br \/>\nThe best solution is always using <strong>LDAP <\/strong>naming resolution. I have seen customers using <em>OID, OUD, Active Directory, openldapd<\/em>, all with a great level of control and automation. However, some customer don&#8217;t have\/want this possibility and keep relying on TNS naming resolution.<br \/>\nWhen Data Guard (and eventually RAC) are in place, the tnsnames.ora gets filled by entries for the DGConnectIdentifiers and StaticConnectIdentifier. If I add the observer, an additional entry is required to access the dbname_CFG service created by the Fast Start Failover.<\/p>\n<p>Actually, all these entries are not required if I use Easy Connect.<\/p>\n<p>My friend Franck Pachot wrote a couple of nice blog posts about Easy Connect while working with me at CERN:<br \/>\n<a href=\"https:\/\/medium.com\/@FranckPachot\/19c-easy-connect-e0c3b77968d7\">https:\/\/medium.com\/@FranckPachot\/19c-easy-connect-e0c3b77968d7<\/a><\/p>\n<p><a href=\"https:\/\/medium.com\/@FranckPachot\/19c-ezconnect-and-wallet-easy-connect-and-external-password-file-8e326bb8c9f5\">https:\/\/medium.com\/@FranckPachot\/19c-ezconnect-and-wallet-easy-connect-and-external-password-file-8e326bb8c9f5<\/a><\/p>\n<p><strong>Basic Data Guard configuration<\/strong><\/p>\n<p>The basic configuration with Data Guard is quite simple to achieve with Easy Connect. In this examples I have:<br \/>\n&#8211; The primary database <strong>TOOLCDB1_SITE1<\/strong><br \/>\n&#8211; The duplicated database for standby <strong>TOOLCDB1_SITE2<\/strong><\/p>\n<p>After setting up the static registration (no Grid Infrastructure in my lab):<\/p>\n<pre class=\"lang:lisp decode:true \">SID_LIST_LISTENER=\r\n  (SID_LIST=\r\n    (SID_DESC=\r\n      (GLOBAL_DBNAME=TOOLCDB1_SITE1_DGMGRL)\r\n      (SID_NAME=TOOLCDB1)\r\n      (ORACLE_HOME=\/u01\/app\/oracle\/product\/db_19_8_0)\r\n    )\r\n  )<\/pre>\n<p>and copying the passwordfile, the configuration can be created with:<\/p>\n<pre class=\"lang:plsql highlight:0 decode:true \">DGMGRL&gt; create configuration TOOLCDB1 as primary database is TOOLCDB1_SITE1 connect identifier is 'newbox01:1521\/TOOLCDB1_SITE1';\r\nConfiguration \"toolcdb1\" created with primary database \"toolcdb1_site1\"\r\n\r\nDGMGRL&gt;  edit database TOOLCDB1_SITE1 set property 'StaticConnectIdentifier'='newbox01:1521\/TOOLCDB1_SITE1_DGMGRL';\r\nProperty \"StaticConnectIdentifier\" updated\r\n\r\nDGMGRL&gt;  add database TOOLCDB1_SITE2 as connect identifier is 'newbox02:1521\/TOOLCDB1_SITE2';\r\nDatabase \"toolcdb1_site2\" added\r\n\r\nDGMGRL&gt;  edit database TOOLCDB1_SITE2 set property 'StaticConnectIdentifier'='newbox02:1521\/TOOLCDB1_SITE2_DGMGRL';\r\nProperty \"StaticConnectIdentifier\" updated\r\n\r\nDGMGRL&gt;  enable configuration;\r\nEnabled.<\/pre>\n<p>That&#8217;s it.<\/p>\n<p>Now, if I want to have the configuration observed, I need to activate the Fast Start Failover:<\/p>\n<pre class=\"lang:plsql highlight:0 decode:true \">DGMGRL&gt; edit database toolcdb1_site1 set property LogXptMode='SYNC';\r\nProperty \"logxptmode\" updated\r\n\r\nDGMGRL&gt; edit database toolcdb1_site2 set property LogXptMode='SYNC';\r\nProperty \"logxptmode\" updated\r\n\r\nDGMGRL&gt; edit database toolcdb1_site1 set property FastStartFailoverTarget='toolcdb1_site2';\r\nProperty \"faststartfailovertarget\" updated\r\n\r\nDGMGRL&gt; edit database toolcdb1_site2 set property FastStartFailoverTarget='toolcdb1_site1';\r\nProperty \"faststartfailovertarget\" updated\r\n\r\nDGMGRL&gt; edit configuration set protection mode as maxavailability;\r\nSucceeded.\r\n\r\nDGMGRL&gt; enable fast_start failover;\r\nEnabled in Zero Data Loss Mode.\r\n<\/pre>\n<p>With just two databases, FastStartFailoverTarget is not explicitly needed, but I usually do it as other databases might be added to the configuration in the future.<br \/>\nAfter that, the broker complains that FSFO is enabled but there is no observer yet:<\/p>\n<pre class=\"lang:plsql highlight:0 decode:true \">DGMGRL&gt; show fast_start failover;\r\n\r\nFast-Start Failover: Enabled in Zero Data Loss Mode\r\n\r\n  Protection Mode:    MaxAvailability\r\n  Lag Limit:          0 seconds\r\n\r\n  Threshold:          180 seconds\r\n  Active Target:      toolcdb1_site2\r\n  Potential Targets:  \"toolcdb1_site2\"\r\n    toolcdb1_site2 valid\r\n  Observer:           (none)\r\n  Shutdown Primary:   TRUE\r\n  Auto-reinstate:     TRUE\r\n  Observer Reconnect: 180 seconds\r\n  Observer Override:  FALSE\r\n\r\nConfigurable Failover Conditions\r\n  Health Conditions:\r\n    Corrupted Controlfile          YES\r\n    Corrupted Dictionary           YES\r\n    Inaccessible Logfile            NO\r\n    Stuck Archiver                  NO\r\n    Datafile Write Errors          YES\r\n\r\n  Oracle Error Conditions:\r\n    (none)\r\n\r\n\r\nDGMGRL&gt; show configuration;\r\n\r\nConfiguration - toolcdb1\r\n\r\n  Protection Mode: MaxAvailability\r\n  Members:\r\n  toolcdb1_site1 - Primary database\r\n    Warning: ORA-16819: fast-start failover observer not started\r\n\r\n    toolcdb1_site2 - (*) Physical standby database\r\n\r\nFast-Start Failover: Enabled in Zero Data Loss Mode\r\n\r\nConfiguration Status:\r\nWARNING   (status updated 39 seconds ago)\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p><strong>Observer for multiple configurations<\/strong><\/p>\n<p>This feature has been introduced in 12.2 but it is still not widely used.<br \/>\nBefore 12.2, the Observer was a foreground process: the DBAs had to start it in a wrapper script executed with nohup in order to keep it live.<br \/>\nSince 12.2, the observer can run as a background process as far as there is a valid wallet for the connection to the databases.<br \/>\nAlso, 12.2 introduced the capability of starting multiple configurations with a single dgmgrl command: &#8220;START OBSERVING&#8221;.<\/p>\n<p>For more information about it, you can check the documentation here:<br \/>\n<a href=\"https:\/\/docs.oracle.com\/en\/database\/oracle\/oracle-database\/19\/dgbkr\/using-data-guard-broker-to-manage-switchovers-failovers.html#GUID-BC513CDB-1E06-4EB3-9FE1-E1331E15E492\">https:\/\/docs.oracle.com\/en\/database\/oracle\/oracle-database\/19\/dgbkr\/using-data-guard-broker-to-manage-switchovers-failovers.html#GUID-BC513CDB-1E06-4EB3-9FE1-E1331E15E492<\/a><\/p>\n<p><strong>How to set it up with Easy Connect?<\/strong><\/p>\n<p>First, I need a wallet. And here comes the first compromise:<br \/>\nHaving a single dgmgrl session to start all my configurations means that I have a single wallet for all the databases that I want to observe.<br \/>\nFair enough, all the DBs (CDBs?) are managed by the same team in this case.<br \/>\nIf I have only observers on my host I can easily point to the wallet from my central sqlnet.ora:<\/p>\n<pre class=\"lang:lisp decode:true \">WALLET_LOCATION =\r\n   (SOURCE =\r\n      (METHOD = FILE)\r\n      (METHOD_DATA = (DIRECTORY = \/u01\/app\/oracle\/admin\/observers\/wallet))\r\n  )\r\nSQLNET.WALLET_OVERRIDE = TRUE<\/pre>\n<p>Otherwise I need to create a separate TNS_ADMIN for my observer management environment.<br \/>\nThen, I create the wallet:<\/p>\n<pre class=\"lang:plsql decode:true\">$ WALLET_DIR=$ORACLE_BASE\/admin\/observers\/wallet\r\n$ mkdir -p $WALLET_DIR\r\n$ orapki wallet create -wallet $WALLET_DIR -auto_login_local -pwd Password2020\r\nOracle PKI Tool Release 21.0.0.0.0 - Production\r\nVersion 21.0.0.0.0\r\nCopyright (c) 2004, 2020, Oracle and\/or its affiliates. All rights reserved.\r\n\r\nOperation is successfully completed.<\/pre>\n<p>Now I need to add the connection descriptors.<\/p>\n<p><strong>Which connection descriptors do I need?<\/strong><br \/>\nThe Observer uses the <strong>DGConnectIdentifier<\/strong> to keep observing the databases, but needs <strong>a connection to both of them<\/strong> using the <strong>TOOLCDB1_CFG<\/strong> service (unless I specify something different with the broker configuration property <strong>ConfigurationWideServiceName<\/strong>) to connect to the configuration and get the DGConnectIdentifier information. Again, you can check it in the doc. or the note <strong>Oracle 12.2 &#8211; Simplified OBSERVER Management for Multiple Fast-Start Failover Configurations (Doc ID 2285891.1)<\/strong><\/p>\n<p>So I need to specify three secrets for three connection descriptors:<\/p>\n<pre class=\"lang:plsql highlight:0 decode:true \">$ mkstore -wrl \"$TNS_ADMIN\" -createCredential newbox01,newbox02:1521\/TOOLCDB1_CFG sysdg\r\nOracle Secret Store Tool Release 21.0.0.0.0 - Production\r\nVersion 21.0.0.0.0\r\nCopyright (c) 2004, 2020, Oracle and\/or its affiliates. All rights reserved.\r\n\r\nYour secret\/Password is missing in the command line\r\nEnter your secret\/Password:\r\nRe-enter your secret\/Password:\r\nEnter wallet password:\r\n\r\n$ mkstore -wrl \"$TNS_ADMIN\" -createCredential newbox01:1521\/TOOLCDB1_SITE1 sysdg\r\nOracle Secret Store Tool Release 21.0.0.0.0 - Production\r\nVersion 21.0.0.0.0\r\nCopyright (c) 2004, 2020, Oracle and\/or its affiliates. All rights reserved.\r\n\r\nYour secret\/Password is missing in the command line\r\nEnter your secret\/Password:\r\nRe-enter your secret\/Password:\r\nEnter wallet password:\r\n\r\n\r\n$ mkstore -wrl \"$TNS_ADMIN\" -createCredential newbox02:1521\/TOOLCDB1_SITE2 sysdg\r\nOracle Secret Store Tool Release 21.0.0.0.0 - Production\r\nVersion 21.0.0.0.0\r\nCopyright (c) 2004, 2020, Oracle and\/or its affiliates. All rights reserved.\r\n\r\nYour secret\/Password is missing in the command line\r\nEnter your secret\/Password:\r\nRe-enter your secret\/Password:\r\nEnter wallet password:\r\n<\/pre>\n<p>The first one will be used for the initial connection. The other two to observe the Primary and Standby.<br \/>\nI need to be careful that the first EZConnect descriptor matches EXACTLY what I put in observer.ora (see next step) and the last two match my DGConnectIdentifier (unless I specify something different with <strong>ObserverConnectIdentifier<\/strong>), otherwise I will get some errors and the observer will not observe correctly (or will not start at all).<\/p>\n<p>The dgmgrl needs then a file named observer.ora.<br \/>\n$ORACLE_BASE\/admin\/observers or the central TNS_ADMIN would be good locations, but what if I have observers that must be started from multiple Oracle Homes?<br \/>\nIn that case, having a observer.ora in $ORACLE_HOME\/network\/admin (or $ORACLE_BASE\/homes\/{OHNAME}\/network\/admin\/ if Read-Only Oracle Home is enabled) would be a better solution: in this case I would need to start one session per Oracle Home<\/p>\n<p>The content of my observer.ora must be something like:<\/p>\n<pre class=\"lang:lisp decode:true \">BROKER_CONFIGS=\r\n   (\r\n     (CONFIG=\r\n       (NAME=TOOLCDB1)\r\n       (CONNECT_ID=newbox01,newbox02:1521\/TOOLCDB1_CFG)\r\n       (CONFIG_HOME=\/export\/soft\/oracle\/admin\/TOOLCDB1\/observer)\r\n     )\r\n   )<\/pre>\n<p>This is the example for my configuration, but I can put as many (CONFIG=&#8230;) as I want in order to observe multiple configurations.<br \/>\nThen, if everything is configured properly, I can start all the observers with a single command:<\/p>\n<pre class=\"lang:plsql highlight:0 decode:true \">DGMGRL&gt; SET OBSERVERCONFIGFILE=\/u01\/app\/oracle\/admin\/observers\/observer.ora\r\nDGMGRL&gt; START OBSERVING\r\nObserverConfigFile=observer.ora\r\nobserver configuration file parsing succeeded\r\nSubmitted command \"START OBSERVER\" using connect identifier \"newbox01,newbox02:1521\/TOOLCDB1_CFG\"\r\n\r\nCheck superobserver.log, individual observer logs and Data Guard Broker logs for execution details.\r\n\r\nDGMGRL&gt; show observers\r\nObserverConfigFile=\/u01\/app\/oracle\/admin\/observers\/observer.ora\r\nobserver configuration file parsing succeeded\r\nSubmitted command \"SHOW OBSERVER\" using connect identifier \"newbox01,newbox02:1521\/TOOLCDB1_CFG\"\r\nConnected to \"TOOLCDB1_SITE2\"\r\n\r\nConfiguration - toolcdb1\r\n\r\n  Primary:            toolcdb1_site1\r\n  Active Target:      toolcdb1_site2\r\n\r\nObserver \"newbox03.trivadistraining.com1\" - Master\r\n\r\n  Host Name:                    newbox03.trivadistraining.com\r\n  Last Ping to Primary:         1 second ago\r\n  Last Ping to Target:          2 seconds ago\r\n<\/pre>\n<p><strong>Troubleshooting<\/strong><\/p>\n<p>If the observer does not work, sometimes it is not easy to understand the cause.<\/p>\n<ul>\n<li>Has SYSDG been granted to SYSDG user? Is SYSDG account unlocked?<\/li>\n<li>Does sqlnet.ora contain the correct wallet location?<\/li>\n<li>Is the wallet accessible in autologin?<\/li>\n<li>Are the entries in the wallet correct? (check with &#8220;sqlplus \/@connstring as sysdg&#8221;)<\/li>\n<\/ul>\n<p><strong>Missing pieces<\/strong><\/p>\n<p>Here, a few features that I think would be a nice addition in the future:<\/p>\n<ul>\n<li>Awareness for the ORACLE_HOME to be used for each observer<\/li>\n<li>Possibility to specify a different TNS_ADMIN per observer (different wallets)<\/li>\n<li>Integration with Grid Infrastructure (srvctl add observer&#8230;) and support for multiple observers<\/li>\n<\/ul>\n<p>&#8212;<\/p>\n<p>Ludovico<\/p>\n","protected":false},"excerpt":{"rendered":"<p>EZConnect One of the challenges of automation in bin Oracle Environments is dealing with tnsnames.ora files. These files might grow big and are sometimes hard to distribute\/maintain properly. The worst is when manual modifications are needed: manual operations, if not &hellip; <a href=\"https:\/\/www.ludovicocaldara.net\/dba\/dg-ezconnect-observer\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[321,327,326,329,3,52,308,315,132],"tags":[],"class_list":["post-1979","post","type-post","status-publish","format-standard","hentry","category-aced","category-oracle-maa","category-oracle","category-oracle-dg","category-oracledb","category-12c","category-oracle-database-18c","category-oracle-database-19c","category-triblog"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/1979","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/comments?post=1979"}],"version-history":[{"count":1,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/1979\/revisions"}],"predecessor-version":[{"id":1980,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/1979\/revisions\/1980"}],"wp:attachment":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/media?parent=1979"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/categories?post=1979"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/tags?post=1979"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}