A commonly used deployment scenario is the primary/secondary database architecture where the primary database replicates all information to the secondary databases.
For primary/secondary database architecture, you might want all WRITE requests to be sent to the primary database and all READ requests to the secondary databases.
The following figure shows the entities and the values of the parameters that you need to configure on the appliance.
Figure 1. DataStream Entity Model for Primary/Secondary Database Setup
Primary/secondary database setup
In this example scenario, a service (Svc_mysql_1) is created to represent the primary database and is bound to a load balancing virtual server (Lb_vsr_mysql_primary). Three more services (Svc_mysql_2, Svc_mysql_3, and Svc_mysql_4) are created to represent the three secondary databases, and they are bound to another load balancing virtual server (Lb_vsr_mysql_secondary).
A content switching virtual server (Cs_vsr_mysql_1) is configured with associated policies to send all WRITE requests to the load balancing virtual server, Lb_vsr_mysql_primary. All READ requests are sent to the load balancing virtual server, Lb_vsr_mysql_secondary.
When a request reaches the content switching virtual server, the virtual server applies the associated content switching policies to that request. After evaluating the policies, the content switching virtual server routes the request to the appropriate load balancing virtual server, which sends it to the appropriate service.
The following table lists the names and values of the entities and the policy configured on the NetScaler appliance.
| Entity Type |
Name |
IP Address |
Protocol |
Port |
Expression |
| Services |
Svc_mysql_1 |
198.51.100.5 |
MYSQL |
3306 |
NA |
|
Svc_mysql_2 |
198.51.100.6 |
MYSQL |
3306 |
NA |
|
Svc_mysql_3 |
198.51.100.7 |
MYSQL |
3306 |
NA |
|
Svc_mysql_4 |
198.51.100.8 |
MYSQL |
3306 |
NA |
| Monitor |
lb_mon1 |
NA |
MYSQL-ECV |
NA |
mysql.res.atleast_rows_count(1) |
| Load balancing virtual servers |
Lb_vsr_mysql_primary |
198.51.100.201 |
MYSQL |
3306 |
NA |
|
Lb_vsr_mysql_secondary |
198.51.100.202 |
MYSQL |
3306 |
NA |
| Content switching virtual server |
Cs_vsr_mysql_1 |
198.51.100.161 |
MYSQL |
3306 |
NA |
| Content switching policy |
Cs_select |
NA |
NA |
NA |
MYSQL.REQ.QUERY.COMMAND.contains("select") |
Table 1. Entity and Policy Names and Values