os: centos 7.4
db: oracle 12.1.0.2

primary 和 standby 都创建两个 service:workload 和 reports
其中 workload 是运行在 primary 上,reports 是运行在 standby 上.

Application Service Considerations with Data Guard:

In an Oracle Data Guard configuration, applications must use Services to connect to the databases as there is more than one database with different SID names that could be the Primary database. And with Oracle Active Data Guard, any physical standby database could be made available to provide read only access to the data. To enable client connections, services need to be created for the workload that performs updates which will only be started on the database in the configuration that is currently in the ‘Primary’ role as well as services for read only reports and queries that should only be present on physical standbys that are open in Active Data Guard.

Note: Refer to MOS Note 2123709.1 for full Client Failover configuration MAA Best Practices.

The following is an example of how to configure a Read/Write service (workload) and a Read/Only service (reports) on the Primary and Standby database.

If the primary / standby is configured with Oracle Restart, RAC One Node or RAC, the services are created using srvctl. (Note for JDBC application server side TAF attributes should be set to NONE). If you are creating services for a multitenant database then use service commands that include the –pdb option.

For example, here we add show adding two services to each database in the configuration. WORKLOAD for Read/Write connections and REPORTS for Read/Only connections. WORKLOAD will only run on the database that is running in the Primary role and REPORTS will only run on the database that is in the PHYSICAL STANDBY role.

primary database

$ srvctl add service -db orclp -pdb orclpdb -service workload -preferred orclp1,orclp2 -role PRIMARY          -notification true -failovertype SESSION -failovermethod BASIC -failoverdelay 10 -failoverretry 150 ;
  srvctl add service -db orclp -pdb orclpdb -service reports  -preferred orclp1,orclp2 -role PHYSICAL_STANDBY -notification true -failovertype SESSION -failovermethod BASIC -failoverdelay 10 -failoverretry 150 ;
  srvctl start service -db orclp -service workload ;
  srvctl start service -db orclp -service reports ;
  srvctl stop  service -db orclp -service reports ;

$ srvctl config service -db orclp

standby database

# srvctl add service -db orcls1 -pdb orclpdb -service workload -preferred orcls11,orcls12 -role PRIMARY           -notification true -failovertype SESSION -failovermethod BASIC -failoverdelay 10 -failoverretry 150 ;
  srvctl add service -db orcls1 -pdb orclpdb -service reports  -preferred orcls11,orcls12 -role PHYSICAL_STANDBY  -notification true -failovertype SESSION -failovermethod BASIC -failoverdelay 10 -failoverretry 150 ;
  srvctl start service -db orcls1 -service workload ;
  srvctl start service -db orcls1 -service reports ;
  srvctl stop  service -db orcls1 -service workload ;

$ srvctl config service -db orcls1

tns 连接串

rac_withdg_workload=
  (DESCRIPTION=
    (ADDRESS_LIST=
      (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.141)(PORT=1521))
	  (ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.241)(PORT=1521))
     )
	 (CONNECT_DATA=
	  (SERVER = DEDICATED)
      (SERVICE_NAME=workload)
	  )
   )
   

oracle 12.1.0.2 使用 MAA 架构之三 connect primary standby database by service name

参考:
<<Creating a Physical Standby using RMAN Duplicate (RAC or Non-RAC) (Doc ID 1617946.1)>>
https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=7119337177578&parent=DOCUMENT&sourceId=2275154.1&id=1617946.1&_afrWindowMode=0&_adf.ctrl-state=m8k42u9f6_4
<< Application Client Failover Considerations in an Oracle Data Guard Environment (Doc ID 2123709.1)>>
https://support.oracle.com/epmos/faces/DocumentDisplay?_afrLoop=24635666949625&parent=DOCUMENT&sourceId=1617946.1&id=2123709.1&_afrWindowMode=0&_adf.ctrl-state=h2nosnad6_53
<<Client Failover Best Practices for Highly Available Oracle Databases for Oracle Database 12c>>
http://www.oracle.com/technetwork/database/availability/client-failover-2280805.pdf

相关文章: