Wallet Consistency in Autonomous Database (ADB) DG
Ensuring Wallet Consistency in Autonomous Database (ADB) with Data Guard: A Cross-Region Implementation Guide
Introduction
When working with Oracle Autonomous Database (ADB) and Autonomous Data Guard (ADG), ensuring that wallets are synchronized between Primary and Standby databases is crucial.
π¨ Common Issues Due to Wallet Mismatch:
- Database connection failures due to mismatched SSL certificates.
- Application disruptions during a failover event.
This blog walks through a real-world scenario where we detected wallet mismatches between Primary and Standby ADB instances, and provides best practices for ensuring seamless failover and connectivity.
π« Why Canβt You Alter the Wallet in Autonomous Database?
Unlike traditional Oracle databases, in Autonomous Database, you cannot manually manage the wallet using SQL commands like:
ALTER SYSTEM SET ENCRYPTION WALLET OPEN IDENTIFIED BY 'password';
ALTER SYSTEM SET ENCRYPTION WALLET CLOSE;
ADMINISTER KEY MANAGEMENT SET KEY IDENTIFIED BY 'password' WITH BACKUP;
β
Oracle manages encryption keys and TDE automaticallyβyou donβt need to open or close the wallet manually.
β
Wallet rotation and key updates are fully automatedβyou cannot modify them.
β
If a switchover happens, the wallet automatically updates on the new Primaryβbut you must download it again.
π Step 1: Testing the Primary Wallet Connection
First, we test the connection using the wallet from Primary ADB.
source /Users/rmisri/Downloads/temp_wallet/Test_adw_wallet/prim/env_file
sqlplus admin@adb_high
Output:
SQL*Plus: Release 19.0.0.0.0 - Production
Connected to: Oracle Database 19c Enterprise Edition
β Primary wallet is working fine.
π Step 2: Performing a Switchover in Autonomous Data Guard
Use the OCI Console or CLI:
β How to Switchover via OCI Console:
- Go to OCI Console β Autonomous Database.
- Click on your Primary ADB instance.
- Under Autonomous Data Guard, select Switchover.
- Confirm the action and wait for Oracle to handle the process.
β How to Switchover via OCI CLI:
oci db autonomous-database switchover --autonomous-database-id <DB_OCID>
β How to Trigger Failover via OCI CLI:
oci db autonomous-database failover --autonomous-database-id <DB_OCID>
π Step 3: Testing the Wallet on Standby
After switchover, we check connectivity using the Standby wallet.
sqlplus admin@adb_high
Output:
SQL*Plus: Release 19.0.0.0.0 - Production
Connected to: Oracle Database 19c Enterprise Edition
β Standby wallet is also working.
π Step 4: Comparing Wallet Files
To ensure that both wallets are identical, we run checksum (md5sum) and certificate (openssl x509) comparisons.
πΈ Comparing Auto-Login Wallet (cwallet.sso)
md5sum cwallet.sso
Output:
Primary: bfde2a75dfdaf8ce8a0126f78eb834a3
Standby: 3f03b4c12b349b6f36fa0410da872c5a
π¨ Mismatch detected! The auto-login wallets are different.
πΈ Comparing SSL Certificates
openssl x509 -in ewallet.pem -noout -fingerprint
Output:
Primary: SHA1 Fingerprint=74:82:7A:37:83:7F:1B:0E:53:5E:08:E3:08:4F:E4:61:DA:97:CA:C7
Standby: SHA1 Fingerprint=BC:A0:1F:30:63:23:75:2F:02:B3:89:67:D8:89:CD:E2:27:85:DD:19
π¨ Mismatch detected! The certificates do not match.
π Step 5: Fixing the Wallet Mismatch
To resolve the issue, we synchronize the Standby wallet with the Primary wallet.
β Fixing the Issue – Steps
- Download the Primary Wallet from OCI Console:
- Navigate to Autonomous Database (Primary).
- Click Database Connection β Download Wallet.
- Replace the Standby Wallet:
unzip Wallet_Primary.zip -d /tmp/primary_wallet/ scp /tmp/primary_wallet/* standby_server:/tmp/standby_wallet/ - Restart Standby Database:
- Since
ALTER SYSTEM SET ENCRYPTION WALLETis not allowed in ADB, simply reconnect using the new wallet.
- Verify That the Wallets Match:
md5sum cwallet.sso & openssl x509 -in ewallet.pem -noout -fingerprint
β Ensure Wallets now match!
π Step 6: Preparing for Cross-Region Failover
Oracleβs Recommendation for Cross-Region Wallets
According to Oracle’s documentation, wallet handling in Autonomous Data Guard works as follows:
- Primary and Standby wallets contain different database hostnames and connection strings.
- Oracle recommends using the wallet from the same region as the primary database.
- If you need a single wallet that works across both regions, update
tnsnames.oramanually.
β How to Manually Construct a Cross-Region Wallet
- Download wallets from both Primary and Standby OCI Consoles.
- Extract both
tnsnames.orafiles. - Copy the Standby database connection descriptor into the Primary
tnsnames.ora. - Repackage the updated wallet.
zip -r Updated_Wallet.zip /tmp/primary_wallet/
With this approach, failover becomes seamless, as the wallet supports both the Primary and Standby hostnames.
π Final Thoughts & Best Practices
β Always download the latest wallet after a switchover or failover.
β Verify wallet consistency before performing failover.
β Modify tnsnames.ora manually for cross-region support.
β Automate wallet verification to prevent disruptions.
Would you like a script to automate wallet verification and downloads after failover?πLet me know in the comments!
Author: Rohit Mishri
