Thursday, October 19, 2023

Farewell to ClickOps: OCI CLI seamless Data Guard Replication for ExaC@C


Intro

Since the very beginning, everyone got introduced to  Cloud services through the console as it’s very quick. But the cloud CLI tooling provides a stronger, yet user-friendly way to automate tasks, often covering features not even available in the console. Moreover, DBAs often assume that the CLI is primarily designed for managing compute-based services, overlooking its potential benefits for their database fleet. In this tutorial, we'll demonstrate how to automate the Data Guard association of your database between two Exadata Cloud at Customer infrastructures in separate regions.
On top of it, I’ll show you where to look and the type of logs that are generated if you need to troubleshoot.

 

Using the API to Enable Data Guard on ExaC@C

REST API Endpoint
Obviously, Rest APIs provided by the Cloud platform is the core vehicle that allows anything (infrastructure resource, or cloud services) to be created, deleted or managed.
This why the best thing to explore a new feature is to check the REST API Endpoint.
In our case the endpoint is
CreateDataGuardAssociation

POST /20160918/databases/{databaseId}/dataGuardAssociations

You can check more details here CreateDataGuardAssociationDetails 


API method for a Data guard association using existing cluster


Below is the configuration details for creating a Data Guard association for a ExaCC Vmcluster database



The attributes are as below


API Attributes
Attributes Required Description Value
creationType Yes Other Options: WithNewDbSystem, ExistingDbSystem ExistingVmCluster
databaseAdminPassword Yes The admin password and the TDE password must be the same.
isActiveDataGuardEnabled No True if active Data Guard is enabled. True
peerDbUniqueName No
  • DB_UNIQUE_NAME of peer DB to be created.
  • Unique across the fleet/tenancy
  • Defaults to
    <db_name>_<3 char>_<region-name>.
    peerSidPrefix No DB SID prefix to be created. unique in the VM cluster
    instance # is auto appended to the SID prefix
    protectionMode Yes MAXIMUM_AVAILABILITY
    MAXIMUM_PERFORMANCE
    MAXIMUM_PROTECTION
    MAXIMUM_PERFORMANCE
    transportType Yes SYNC
    ASYNC
    FASTSYNC
    ASYNC
    peerDbHomeId No Supply this value to create standby DB with an existing DB home
    databaseSoftwareImageId No The database software image OCID




    API request Examples


    Here is a basic API call example for Database system which slightly differs from the Exadata Cloud implantation.

     

    Response Body


    The response body will contain a single DataGuardAssociation resource.



    Using OCI CLI to Enable Data Guard on ExaCC

    Now that we’ve explored REST API structure, we can move to a practical example using OCI CLI. Both Exada Cloud@Customer (Edge DB service) are located in different regions in Canada in 2 DataCenters.   

    Usage

    $ oci db data-guard-association create from-existing-vm-cluster [OPTIONS]

    Generate a sample json file to be used with this command option.

    The best way to leverage OCI CLI with a complex structure is to generate a full command JSON construct. 

    # oci db data-guard-association create from-existing-vm-cluster \
    --generate-full-command-json-input > dg_assoc.json
    {
      "databaseAdminPassword": "string",
      "databaseId": "string",
      "databaseSoftwareImageId": "string",
      "peerDbHomeId": "string",
      "peerDbUniqueName": "string",
      "peerSidPrefix": "string",
      "peerVmClusterId": "string",
      "protectionMode":"MAXIMUM_AVAILABILITY|MAXIMUM_PERFORMANCE|MAXIMUM_PROTECTION"
    ,"transportType": "SYNC|ASYNC|FASTSYNC" }


    Practical Example

    Here we will configure a Data guard setup from an ExaC@C site to another with no existing standby DB home.

    • Below template matches a DG association without a peer Database Home in the standby VM Cluster

    # vi dg_assoc_MYCDB_nodbhome.json

    {
    "databaseAdminPassword": "Mypassxxxx#Z",      
    "databaseId": "ocid1.database.oc1.ca-toronto-1.xxxxx",   <--- primary DB
    "databaseSoftwareImageId": null,
    "peerDbHomeId": null,
    "peerDbUniqueName": "MYCDB_Region2",   <--- Standby DB
    "peerSidPrefix": "MYCDB",
    "peerVmClusterId": "ocid1.vmcluster.oc1.ca-toronto-1.xxxxxx", <--- DR cluster
    "protectionMode": "MAXIMUM_PERFORMANCE", "transportType": "ASYNC", "isActiveDataGuardEnabled": true   
    }

    • Now we can run the full command with the adjusted JSON template

    # oci db data-guard-association create from-existing-vm-cluster \
    --from-json file://dg_assoc_MYCDB_nodbhome.json


    Response Body


    Right after the run you’ll have the provisioning starting and the work request assigned

    • You will need the id to check the status (Check for SUCCESS or FAILURE)

    # export workreq_id=ocid1.coreservicesworkrequest.xxxxx
    # oci work-requests work-request get --work-request-id $workreq_id \
    --query data.status



    Troubleshooting


    Automating tasks with CLI provides the advantage of not leaving you in the dark when things go awry. Here are some valuable troubleshooting insights when using OCI CLI
    : 

    • The work request status and error detail is easily accessible using get command for troubleshooting 

    • API based operations on existing systems like DB replications, offer comprehensive logs that are invaluable for diagnosing issues inside the target servers (i.e Exadata Cloud VM clusters).

    • Oracle Data Guard association ensures clean rollbacks for quick retries in case of failures - a significant advantage over manual cleanup which we all hated back in on-premises setups.


    Work request


    The very first thing to check is the status of the request and the details of the error in case of failure.

    • Even without a work request ID, the below query allows you to list all previous data guard association jobs

    # oci work-requests work-request list -c $comp_id –-query \
    data[?\"operation-type\"=='Create Data Guard'].\
    {status:status,operation:\"operation-type\",percent:\"percent-complete\",
    \"workreq_id\":id
    }"
    --output table

    • The output will look like the below .

    • You want to display details about the error ? Sure there is an oci command for that 

    # oci work-requests work-request-error list --work-request-id $workreq_id –all \
    --query "data[].[code,message]"
    --output table

    • You can see few insights on the stage where your DG association failed for instance


    Logs in your ExaData Cloud@Customer


    When a database related operation is performed on an
    ExaC@C VM , log files from the operation are stored in subdirectories of /var/opt/oracle/log.


    check logs

    Running below find command while your Data guard association is running can help you list the modified logs

    $ find $1 -type f -print0 | xargs -0 stat --format '%Y :%y %n'| sort –nr \
    | cut -d: -f2- | head


    PRIMARY

    let’s see what logs are created on the primary side

    ☆ dg folder

    This will likely contain below files. 

    $ ls /var/opt/oracle/log/GRSP2/dbaasapi/db/dg dbaasapi_SEND_WALLET_*.log dbaasapi_CONFIGURE_PRIMARY_*.log dbaasapi_NEW_DGCONFIG_*.log dbaasapi_VERIFY_DG_PRIMARY_*.log dbaasapi_SEND_WALLET_*.log

    1. VERIFY_DG_PRIMARY
    First file created is {log_dir}/<Database_Name>/dbaasapi/db/dg/
    dbaasapi_VERIFY_DG_PRIMARY*.log

    $ tail -f dbaasapi_VERIFY_DG_PRIMARY_2022-05-27_*.log
    ...
    Command: timeout 3 bash -c 'cat < /dev/null > /dev/tcp/clvmd01.domain.com/1521' Exit: 124 Command has no output
    ERROR: Listener port down/not reachable on node: clvmd01.domain.com:1521
    ...

    Below excerpt shows the precheck step that failed, which was fixed by running the oci cli command again


    2. PRIMARY_Configure
    After the second run, the prechecks passed, but now there's an issue with the primary configuration (se below).

    Let’s dig a bit deeper , but it seems it’s related to some service not being able to start.

    ☆ dgcc folder

    "dgcc" represents the Data Guard Configuration checker, which is responsible for checking the Data Guard status and configurations. Below logs contain information about the activities and status of dgcc on the ExaC@C

    $ ls /var/opt/oracle/log/MYCDB/dgcc dgcc_configure-sql.log dgcc_configure-cmd.log dgcc_configure.log

    ☆ dgdeployer folder

    DGdeployer, is the process that performs the DG configuration. The dgdeployer.log file should contain the root cause of a failure to configure the primary database mentioned earlier.

    $ ls /var/opt/oracle/log/MYCDB/dgdeployer
    dgdeployer.log
    dgdeployer-cmd.log

    As displayed here, we can see that the PDB service failed to start

    ☆ dgrops folder


    The dgrops  log file contains the output of the dgrops script, which includes the steps performed, the commands executed, and any errors or warnings encountered.
    This log helped identifying the issue which was that the PDB state wasn't saved in the primary CDB.

    Solution

    On the primary CDB, restart the PDB and save its state and voila.The DG association should now be successful.    

    $ alter pluggable database MYPDB_TEST close instances=all;
    $
    alter pluggable database MYPDB_TEST open instances=all; $ alter pluggable database MYPDB_TEST save state instances=all;



    STANDBY

    At this point, there are no troubleshooting steps left. But I though I’d add a list of available logs at the DR site.
    ☆ prep folder

    This will store logs about preparation of the standby including creating the DB home based on our previous example

    $ view /var/opt/oracle/log/MYCDB/prep/prep.log

    ☆ dg folder

    This folder will include logs pertaining to the standby database creation as shown below

    $ view /var/opt/oracle/log/MYCDB/dbaasapi/db/dg/dbaasapi_CREATE_STANDBY_*.log


     

    Conclusion

    This tutorial we learned to

    • Seamlessly automate Data Guard associations between diverse ExadataCloud@Customer systems. 
    • leverage OCI CLI & JSON templates to discover its extensive utility beyond compute services.
    • Additionally, you now have a clear understanding of where to access and how to interpret the logs, essential for troubleshooting potential issues.
    • Hope this will encourage every DBA to start using OCI CLI every day for their administration tasks 

    Thank you for reading

    Thursday, September 7, 2023

    Top picks for Cloud Native sessions at Oracle Cloud World 2023


    Blabla free post: This is just some of my (personal) top Oracle Cloud World 2023 sessions I will have the chance to attend and speak at this September. Some of you may agree that there is no way to make a list that fits everyone but for those who are into Cloud native,IT Ops, and database migrations/upgrades this list might help. I know browsing the 3 days Agenda is a pain :), so why not spare you some time so you can triple check your packs and confirm you’re all set for the trip ;).


    Note:
      Exciting one, as I will be speaking for the 1st time this year where I will be exploring OCI Devops.
    Reserve your seat here “how to pipeline your terraform stack from GitHub to OCI”.


    Njoy!  and wish me luck for my session :).


    What you should know

     
    Session Format: In Person/On Demand or Both

    Top Session Types:

    • HOL: Hands-on Lab                                        LRN: Learning Session (45-min)

    • TUT: Tutorial                                                    PAN: Panel Session

    • THR: Theater session  (~20 min)                    DIV : Deep Dive Session

    • CME: Community Meet the Expert Session    KEY : Main stage keynotes 

    Journey-based tracks:

    Database tracks:


    Oracle Cloud World ON-AIR (Virtual)



    Can't make it to Vegas? No worries! CloudWorld On Air ✈️brings the fun to your living room for FREE, with on-demand feature to catch up at your own pace for a whole 30 days after the event. Here are the Pass benefits.
                      
                     So, why don’t you go ahead,and register now, to join in whenever it suits you best!


    My top list


    Day 1


    OCI platform

    ☆ [TUT2557] Best Practices to Design and Operate Oracle Cloud Infrastructure

    Time: Tuesday, Sep 19 11:30 AM - 1:30 PM PDT                       ROOM: Ballroom H, The Venetian, Level 2

                                                            

    ☆ [HOL2521] Deploying Oracle Cloud Infrastructure Center for Internet Security Landing Zone

    Time: Tuesday, Sep 19 11:30 AM - 1:00 PM PDT                       ROOM: San Polo 3504, The Venetian, Level 3


    ☆[LRN1563] OKE—Why It Makes Sense to Use Kubernetes in Oracle Cloud Infrastructure

    Time: Tuesday, Oct 19 8:30 AM - 9:15 AM PDT                         ROOM: Murano 3201, The Venetian, Level 3


    ☆[LRN2543] Three Infrastructure-as-Code Tools in 45 Minutes

    Time: Tuesday, Oct 19 11:30 AM - 12:15 AM PDT                          ROOM: Titian 2204, The Venetian, Level 2


    ☆[THR2868] The Missing Link: Using Terraform and Ansible Together

    Time: Tuesday, Oct 19 11:30 AM - 11:50 AM PDT                         ROOM: Unlock Theater, CloudWorld Hub


    ☆[LRN2537] Kubernetes on Oracle Cloud Infrastructure—Deep Dive

    Time: Tuesday, Oct 19 5:00 AM - 5:45 PM PDT                         ROOM: Lido 3105, The Venetian, Level 3



    Database


    ☆[LRN1030] Best Practices For Upgrade And Migration To Oracle Database 23c

    Time: Tuesday, Sep 19 08:30 AM - 09:15 AM PDT                 ROOM: Ballroom H, The Venetian, Level 2


    ☆[LRN2257] No-Slide Zone—Database Patchings Insights

    Time: Tuesday, Sep 19 11:30 AM - 1:00 PM PDT                 ROOM: Murano 3302, The Venetian, Level 3
     

    ☆[HOL2326] Automate Database, Application, and Stack Deployments

    Time: Tuesday, Sep 19 5:00 PM - 6:30 PM PDT                 ROOM: San Polo 3406, The Venetian, Level 3




    Day 2


    OCI platform


    ☆[LRN2547] One Cluster to Rule Them All: Kubernetes at Scale with Cluster API and GitOps

    Time: Wednesday, Sep 20 8:30 AM - 9:15 AM PDT                ROOM: Murano 3201, The Venetian, Level 3


    ☆[LRN2783] Automate Your IT Operations and Boost Productivity for Multicloud Environments

    Time: Wednesday, Sep 20 9:45 AM - 10:30 AM PDT               ROOM: Lido 3003, The Venetian, Level 3

                                            

    ☆[HOL2522] Cloud Native Access Governance to Centrally Manage Identities and Security

    Time: Wednesday, Sep 20 1:00 PM - 2:30 PM PDT              ROOM: San Polo 3504, The Venetian, Level 3



    ☆[TUT2782] Multicloud Network Connectivity

    Time: Wednesday, Sep 20 1:00 PM - 3:00 PM PDT              ROOM: The Venetian, Level 1: Room 202


    ☆[LRN2532] MultiCluster OKE Deployment: Trends, Challenges, Solutions

    Time: Wednesday, Sep 20 4:00 PM - 4:45 PM PDT                      ROOM: Lido 3106, The Venetian, Level 3



    ☆[LRN2540] Linux Internals for Developers: Tips and Tricks to Make Your Systems Run Better

    Time: Wednesday, Sep 20   5:15 PM - 6:00 PM PDT            ROOM: Murano 3302, The Venetian, Level 3


    Database


    ☆[HOL2227] Patch Me if You Can

    Time: Wednesday, Sep 20 8:30 AM - 10:00 AM PDT                 ROOM: San Polo 3405, The Venetian, Level 3



    ☆[THR3529] Multicloud Development with Microsoft Azure and Oracle Database Cloud

    Time: Wednesday,  Sep 20 05:05 PM - 5:25 PM PDT                 ROOM: Elevate Theater, CloudWorld Hub 


    Day 3

    OCI platform

    ⭐Reserve your seat for my session⭐ 

    ☆[THR1239] Explore OCI DevOps: Pipeline Your Terraform Stack from GitHub to OCIImage

    I will explore why OCI DevOps is a solution of choice for your CI/CD practice in OCI. We’ll cover features like seamless integrations with OCI vault and code repositories like GitHub or GitLab, or how to leverage OCI DevOps as a source  for your Resource Manager stack. Also a quick demo based on a Terraform configuration pipelined from GitHub into OCI DevOps.

    Time: Thursday, Oct 20 12:30 PM PDT                                     ROOM:  Uplift Theater, CloudWorld Hub




    ☆[HOL2520] Automate Disaster Recovery on OCI using Full Stack Disaster Recovery

    Time: Thursday, Sep 21 8:30 AM - 10:00 AM PDT              ROOM: San Polo 3403, The Venetian, Level 3


    ☆[HOL2515] Kubernetes Monitoring and Troubleshooting

    Time: Thursday, Sep 21 8:30 AM - 10:00 AM PDT              ROOM: San Polo 3404, The Venetian, Level 3


    ☆[TUT2555] Understanding Multicloud and Hybrid Cloud Deployments

    Time: Thursday, Sep 21 12:30 PM - 2:30 PM PDT               ROOM: Venetian Level 1: Room 201


    ☆[LRN2753] Multicloud Applications Using OCI Traffic Steering and a Container Platform

    Time: Thursday, Sep 21 1:45 PM - 2:30 PM PDT                  ROOM: Murano 3201, The Venetian, Level 3



    ☆[LRN2539] Monitor MultiCluster Kubernetes Across Regions and Multicloud

    Time: Thursday, Oct 20 12:30 PM - 1:15 PM PDT                ROOM: Titian 2204, The Venetian, Level 2



    Database

    ☆[LRN2358] Patching Best Practice For Oracle Database And Grid Infrastructure

    Time: Thursday, Sep 21 1:45 PM -2:30 PM PDT                   ROOM: Bellini 2006, The Venetian, Level 2


    ☆[LRN2361] Simplify Your Migration Of Databases To The Cloud

    Time: Thursday, Sep 21 12:30 PM - 1:15 PM PDT                 ROOM: Bellini 2006, The Venetian, Level 2






    ゚☆ See you there ☆゚