Running a two node RAC 19c cluster.
Also, running a two node Data Guard 19c environment to provide resilience for the primary environment.
If you were to do a Data Guard switch you would need to manually change any connection strings to reflect the fact that that Data Guard environment is the "new" primary otherwise applications or SQL Developer / TOAD etc will be pointing to the "original" i.e now standby side.
However, there is a way to have your connections "float" between your Primary and Secondary environments.
Please note - SCAN listeners, RAC, DataGuard, TDE etc outside of this post.
++++++++++++++++++++
Example values - very simplistic setup for clarity :
ENV_lhr34g - database. ENV1 & ENV2 (RAC instances) - pdbs read write
ENV_lhr456 - database. ENV1 & ENV2 (Data Guard env) - pdbs read only (active dataguard)
TEST - pluggable database
TSTS - pluggable database service (example)
db-1 & db2 (two nodes on 'Primary' side)
db-3 & db-4 (two nodes on 'Secondary' i.e. 'DataGuard' side)
Remember after "switch over" these will swap.
env1-scan.example.com - SCAN listener name on primary
env2-scan.example.com - SCAN listener name on secondary (Data Guard side)
++++++++++++++++++++
Added the service (after a bit of trial and error with syntax and options) -
[oracle@db-1
~]$ srvctl add service -d ENV_lhr34g -s TSTS -pdb TEST -l primary -r
"ENV1,ENV2"
Started the service -
[oracle@db-1 ~]$ srvctl
start service -service TSTS -db ENV_lhr34g
Check
[oracle@db-1 ~]$ srvctl status database -db ENV_lhr34g -v
Instance ENV1 is running on node db-1 with online services TSTS. Instance status: Open.
Instance ENV2 is running on node db-2 with online services TSTS. Instance status: Open.
You can confirm which service is running against which pdb by running the following -
select name, con_id from v$active_services order by 1
or
SQL> select a.name, a.con_id, b.name from v$active_services a, v$pdbs b where a.CON_ID = b.con_id order by 2
NAME CON_ID NAME
------- ---------- ---------
TSTS 2 TEST
SQL> select host_name from gv$instance where instance_number=userenv('instance');
----------------------------------------------------------------
db-1
Trying logging in and out a few times and SCAN listener will point you to either db-1 or db-2
Now amend the Data Guard side
[oracle@db-3 ~]$ srvctl add service -d ENV_lhr456 -s TSTS -pdb TEST -l primary -r "ENV1,ENV2"
DO NOT start the service this will happen when you do a switchover !
(If you try and start the service prior to switching over it will fail with an error and the only way to start it, is to stop the service on the primary first and then start the service on the Data Guard side. However, that would mean you would connect to the read only pdb on the Data Guard side and not the primary database. One way to ensure you always connect to the primary is to change the ordering of the HOST= option in the service name in the tnsnames.ora file so that the connection is correct - something I have not had a chance to try but may update this at a later date. If you do want to connect to the read only pdb on the secondary suggest an alternative service name is created. For simplicity suggest the service is only started on the primary - let the dataguard switchover look after it).
Add a tnsnames entry as per the primary side on both Data Guard nodes.
1 OFFLINE OFFLINE STABLE
2 OFFLINE OFFLINE STABLE
sqlplus user1/password@TEST
SQL> select host_name from gv$instance where instance_number=userenv('instance');
HOST_NAME
----------------------------------------------------------------
db-3
SQL> show con_name;
------------------------------
TEST
No comments:
Post a Comment