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 MYSQL 3306 NA
  Svc_mysql_2 MYSQL 3306 NA
  Svc_mysql_3 MYSQL 3306 NA
  Svc_mysql_4 MYSQL 3306 NA
Load balancing virtual servers Lb_vsr_mysql_master MYSQL 3306 NA
  Lb_vsr_mysql_slave MYSQL 3306 NA
Content switching virtual server Cs_vsr_mysql_1 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 mysql 3306

add service Svc_mysql_2 mysql 3306

add service Svc_mysql_3 mysql 3306

add service Svc_mysql_4 mysql 3306

add lb vserver Lb_vsr_mysql_master mysql 3306

add lb vserver Lb_vsr_mysql_slave mysql 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 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