Write Affinity for Composite Active/Active environments was introduced in version 6.1.12
Setting write affinity allows write statements to be routed to the remote Active cluster, while reads may follow the affinity for the local cluster. This provides the ability to ensure conflicts do not occurr when writing to multiple active clusters.
This can be configured in a number of different ways, depending upon the configuration of your connectors.
For Proxy Routing:
When running in Proxy mode, you can set the affinity via the user.map
by specifying the
Write Dataservice and Read Dataservice as follows:
user password global remoteWriteCluster:localReadCluster
Additionally, affinity can be set per connection, for example:
mysql -u username -p secret -h connector1 -P 3306 database@affinity=remoteWriteCluster:localReadCluster
For Bridge Mode Routing:
You can enable the affinity for Bridge Mode connections by setting the --connector-affinity
tpm property, for example, add the following in your ini file:
connector-affinity=remoteWriteCluster:localReadCluster
The serviceName specified either side of the : can be a single service, or a comma separated list or services.
The serviceName to the left of the : is the Write affinity, serviceNames to the right of the : apply to Read affinity
For example:
user password global remoteWriteCluster,localWriteCluster:localReadCluster,remoteReadCluster