Use Case 1: Configuring DataStream for a Master/Slave Database Architecture

A commonly used deployment scenario is the master/slave database architecture where the master database replicates all information to the slave databases.

For master/slave database architecture, you may want all WRITE requests to be sent to the master database and all READ requests to the slave databases.

The following figure shows the entities and the values of the parameters you need to configure on the appliance.

Figure 1. DataStream Entity Model for Master/Slave Database Setup

localized image

In this example scenario, a service (Svc_mysql_1) is created to represent the master database and is bound to a load balancing virtual server (Lb_vsr_mysql_master). Three more services (Svc_mysql_2, Svc_mysql_3, and Svc_mysql_4) are created to represent the three slave databases, and they are bound to another load balancing virtual server (Lb_vsr_mysql_slave).

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_master, and all READ requests to the load balancing virtual server, Lb_vsr_mysql_slave.

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 10.102.29.5 MYSQL 3306 NA
  Svc_mysql_2 10.102.29.6 MYSQL 3306 NA
  Svc_mysql_3 10.102.29.7 MYSQL 3306 NA
  Svc_mysql_4 10.102.29.8 MYSQL 3306 NA
Load balancing virtual servers Lb_vsr_mysql_master 10.102.29.201 MYSQL 3306 NA
  Lb_vsr_mysql_slave 10.102.29.202 MYSQL 3306 NA
Content switching virtual server Cs_vsr_mysql_1 10.102.29.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

To configure DataStream for a master/slave database setup by using the command line interface

At the command prompt, type

-  add service Svc\_mysql\_1 10.102.29.5 mysql 3306
-  add service Svc\_mysql\_2 10.102.29.6 mysql 3306
-  add service Svc\_mysql\_3 10.102.29.7 mysql 3306
-  add service Svc\_mysql\_4 10.102.29.8 mysql 3306
-  add lb vserver Lb\_vsr\_mysql\_master mysql 10.102.29.201 3306
-  add lb vserver Lb\_vsr\_mysql\_slave mysql 10.102.29.202 3306
-  bind lb vserver Lb\_vsr\_mysql\_master svc\_mysql\_1
-  bind lb vserver Lb\_vsr\_mysql\_slave svc\_mysql\_2
-  bind lb vserver Lb\_vsr\_mysql\_slave svc\_mysql\_3
-  bind lb vserver Lb\_vsr\_mysql\_slave svc\_mysql\_4
-  add cs vserver Cs\_vsr\_mysql\_1 mysql 10.102.29.161 3306
-  add cs policy Cs\_select –rule "MYSQL.REQ.QUERY.COMMAND.contains(\\"select\\")"
-  bind cs vserver Cs\_vsr\_mysql\_1 Lb\_vsr\_mysql\_master
-  bind cs vserver Cs\_vsr\_mysql\_1 Lb\_vsr\_mysql\_slave –policy Cs\_select –priority 10

Use Case 1: Configuring DataStream for a Master/Slave Database Architecture