Beruflich Dokumente
Kultur Dokumente
Contents
DataStream.....................................................................................................
12
13
14
15
16
19
21
22
23
26
28
29
30
32
34
35
38
40
46
47
Character Sets...............................................................................
48
Transactions .................................................................................
49
Special Queries..............................................................................
50
52
DataStream
The NetScaler DataStream feature provides an intelligent mechanism for request switching
at the database layer by distributing requests based on the SQL query being sent.
When deployed in front of database servers, a NetScaler ensures optimal distribution of
traffic from the application servers and Web servers. Administrators can segment traffic
according to information in the SQL query and on the basis of database names, usernames,
character sets, and packet size.
You can either configure load balancing to switch requests based on load balancing
algorithms or elaborate the switching criteria by configuring content switching to make a
decision based on an SQL query parameters. You can further configure monitors to track the
state of database servers.
Note: NetScaler DataStream is supported only for MySQL and MS SQL databases. For
information about the supported protocol version, character sets, special queries, and
transactions, see DataStream Reference.
User name
Database name
Packet size
Character set
show db dbProfile
Example
> add dbProfile myDBProfile -interpretQuery YES -stickiness YES -kcdAccount mykcdaccnt
Done
> show dbProfile myDBProfile
Name: myDBProfile
Interpret Query: YES
Stickyness: YES
KCD Account: mykcdaccnt
Reference count: 0
Done
>
show db dbProfile
No parameters provided in this topic or the command has no parameters. View
description(s) in command reference Top
11
12
13
In the following example, the number of rows in the response is evaluated to determine the
state of the server.
14
15
16
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(\"selec
17
18
MS SQL
MYSQL.REQ.QUERY.TEXT
MSSQL.REQ.QUERY.TEXT
MYSQL.REQ.QUERY.TEXT(n)
MSSQL. REQ.QUERY.TEXT(n)
MYSQL.REQ.QUERY.COMMAND
MSSQL.REQ.QUERY.COMMAND
MYSQL.CLIENT.USER
MSSQL.CLIENT.USER
MYSQL.CLIENT.DATABASE
MSSQL.CLIENT.DATABASE
MYSQL.CLIENT.CAPABILITIES
The following example shows how the NetScaler DataStream feature works when you
configure the token method of load balancing.
Figure 1. How DataStream Works with the Token Method of Load Balancing
In this example, the token is the name of the database. A request with token books is sent
to Database Server1 and a request with token music is sent to Database Server2.
All subsequent requests with token books are sent to Database Server1 and requests
with token music are sent to Database Server2. This configuration provides pseudo
19
20
21
Configure the NetScaler appliance as the default gateway for both clients and servers.
If you do not want to configure the USIP option globally, create MSSQL services
with the USIP option enabled on each of them. If you configure services, you do not
have to create a port-specific wildcard virtual server. For instructions, see
Configuring Transparent Mode by Using MSSQL Services.
Configure audit logging, AppFlow, or Action Analytics to log or collect statistics about
the requests. If you configure a virtual server, you can bind your policies either to the
virtual server or to the global bind point. If you do not configure a virtual server, you
can bind your policies to only the global bind point. For information about configuring
audit logging, see Audit Logging. For information about configuring AppFlow, see
AppFlow. For information about configuring Action Analytics, see Action Analytics.
22
If you can configure the use source IP address (USIP) option globally, create a
load balancing virtual server with a wildcard IP address and the port number on
which the MSSQL servers listen for requests (a port-specific wildcard virtual server).
Then, enable the USIP option globally. If you configure a port-specific wildcard
virtual server, you do not have to create MSSQL services on the appliance. The
appliance discovers the services on the basis of the destination IP address in the
client requests. For instructions, see Configuring Transparent Mode by Using a
Wildcard Virtual Server.
Example
> add lb vserver wildcardLbVs MSSQL * 1433
Done
> show lb vserver wildcardLbVs
wildcardLbVs (*:1433) - MSSQL Type: ADDRESS
State: UP
...
Done
>
23
show ns mode
Example
> enable ns mode USIP
Done
> show ns mode
Mode
------...
3) Use Source IP
...
Done
>
Acronym
------USIP
Status
-----ON
24
show lb vserver
name
Name of the virtual server. If no name is provided, statistical data of all configured
virtual servers is displayed.
View description(s) in command reference Top
enable ns mode
No parameters provided in this topic or the command has no parameters. View
description(s) in command reference Top
show ns mode
No parameters provided in this topic or the command has no parameters. View
description(s) in command reference Top
25
Example
> add service myDBservice 192.0.2.0 MSSQL 1433 -usip YES
Done
> show service myDBservice
myDBservice (192.0.2.0:1433) - MSSQL
State: UP
...
Use Source IP: YES
Use Proxy Port: YES
...
Done
>
26
show service
name
Name of the service for which to display configuration details.
View description(s) in command reference Top
27
28
29
enable ns feature LB
show ns feature
Example
1)
2)
3)
.
.
.
24) NetScaler Push
Done
Acronym
------WL
SP
LB
push
Status
-----OFF
ON
ON
OFF
30
show ns feature
No parameters provided in this topic or the command has no parameters. View
description(s) in command reference Top
31
Example
In the following example, we create a Microsoft SQL virtual server.
32
Configuring a Load Balancing Virtual Server for Database Specific Load Balancing
show lb vserver
name
Name of the virtual server. If no name is provided, statistical data of all configured
virtual servers is displayed.
View description(s) in command reference Top
33
Configuring Services
After you enable the load balancing feature, you must create at least one service for each
application server that is to be included in your load balancing setup. The services that you
configure provide the connections between the NetScaler appliance and the load balanced
servers. Each service has a name and specifies an IP address, a port, and the type of data
that is served.
If you create a service without first creating a server object, the IP address of the service is
also the name of the server that hosts the service. If you prefer to identify servers by name
rather than IP address, you can create server objects and then specify a server's name
instead of its IP address when you create a service.
Example
In the following example, we create a service of type MSSQL
34
35
36
37
Example
In the following example, we create an MSSQL-ECV type monitor.
> add lb monitor mssql-monitor1 MSSQL-ECV -userName user1 -sqlQuery "select name
from sys.databases where state=0" -evalRule "MSSQL.RES.TYPE.NE(ERROR)" -storedb ENABLED
Done
> show lb monitor mssql-monitor1
1) Name.......: mssql-monitor1 Type......: MSSQL-ECV
State....: ENABLED
...
Special parameters:
Database.....:""
User name.....:"user1"
38
39
40
Service
S1
S2
DB3, DB4
S3
DB3, DB4
S4
DB1, DB2
S5
DB1, DB2
Databases
AV1
DB1, DB2
S1, S4, S5
AV2
DB3, DB4
Queries flow as follows:
S1, S2, S3
1. A READ query for AV1 is load balanced between S4 and S5. S1 is the primary for AV1.
2. A WRITE query for AV1 is directed to L1.
3. A READ query for AV2 is load balanced between S1 and S3. S2 is the primary for AV2.
4. A WRITE query for AV1 is directed to L2.
41
Sample Configuration
1. Configure load balancing and content switching virtual servers.
42
43
add service
No parameters provided in this topic or the command has no parameters. View
description(s) in command reference Top
add db user
password
Password for logging on to the database. Must be the same as the password specified in
the database.
View description(s) in command reference Top
add lb monitor
userName
User name with which to probe the RADIUS, NNTP, FTP, FTP-EXTENDED, MYSQL, MSSQL,
POP3, CITRIX-AG, CITRIX-XD-DDC, CITRIX-WI-EXTENDED, CITRIX-XNC or CITRIX-XDM
server.
sqlQuery
SQL query for a MYSQL-ECV or MSSQL-ECV monitor. Sent to the database server after the
server authenticates the connection.
evalRule
Default syntax expression that evaluates the database server's response to a MYSQL-ECV
or MSSQL-ECV monitoring query. Must produce a Boolean result. The result determines
the state of the server. If the expression returns TRUE, the probe succeeds.
For example, if you want the appliance to evaluate the error message to determine the
state of the server, use the rule MYSQL.RES.ROW(10) .TEXT_ELEM(2).EQ("MySQL").
storedb
Store the database list populated with the responses to monitor probes. Used in database
specific load balancing if MSSQL-ECV/MYSQL-ECV monitor is configured.
Possible values: ENABLED, DISABLED
Default value: DISABLED
View description(s) in command reference Top
add cs policy
rule
44
bind service
monitorName
Name of the monitor to bind to the service.
View description(s) in command reference Top
45
DataStream Reference
This reference describes the MySQL and TDS protocols, the database versions, the
authentication methods, and the character sets supported by the DataStream feature. It
also describes how NetScaler handles transaction requests and special queries that modify
the state of a connection.
You can also configure the NetScaler appliance to generate audit log messages for the
DataStream feature.
46
MySQL Database
MS SQL Database
Database
Versions
Protocols
Authenticati
on Methods
47
Character Sets
The DataStream feature supports only the UTF-8 charset.
The character set used by the client while sending a request may be different from the
character set used in the database server responses. Although the charset parameter is set
during the connection establishment, it can be changed at any time by sending an SQL
query. The character set is associated with a connection, and therefore, requests on
connections with one character set cannot be multiplexed onto a connection with a
different character set.
NetScaler parses the queries sent by the client and the responses sent by the database
server.
The character set associated with a connection can be changed after the initial handshake
by using the following two queries:
48
Transactions
In MySQL, transactions are identified by using the connection parameter AUTOCOMMIT or
the BEGIN:COMMIT queries. The AUTOCOMMIT parameter can be set during the initial
handshake, or after the connection is established by using the query SET AUTOCOMMIT.
NetScaler explicitly parses each and every query to determine the beginning and end of a
transaction.
In MySQL protocol, the response contains two flags to indicate whether the connection is a
transaction, the TRANSACTION and AUTOCOMMIT flags.
If the connection is a transaction, the TRANSACTION flag is set. Or, if the AutoCommit
mode is OFF, the AUTOCOMMIT flag is not set. NetScaler parses the response, and if either
the TRANSACTION flag is set or the AUTOCOMMIT flag is not set, it does not do connection
multiplexing. When these conditions are no longer true, the NetScaler begins connection
multiplexing.
49
Special Queries
There are special queries, such as SET and PREPARE, that modify the state of the
connection and may break request switching, and therefore, these need to be handled
differently.
On receiving a request with special queries, NetScaler sends an OK response to the client
and additionally, stores the request in the connection.
When a non-special query, such as INSERT and SELECT, is received along with a stored
query, the NetScaler first, looks for the server-side connection on which the stored query
has already been sent to the database server. If no such connections exist, NetScaler
creates a new connection, and sends the stored query first, and then, sends the request
with the non-special query.
In case of SET, USE db, and INIT_DB special queries, the appliance modifies a field in the
server side connection corresponding to the special query. This results in better reuse of
the server side connection.
Only 16 queries are stored in each connection.
The following is a list of the special queries for which NetScaler has a modified behavior.
SET query
The SET SQL queries define variables that are associated with the connection. These
queries are also used to define global variables, but as of now, NetScaler is unable to
differentiate between local and global variables. For this query, the NetScaler uses the
'store and forward' mechanism described earlier .
USE <db> query
Using this query, the user can change the database associated with a connection. In this
case, NetScaler parses the <db> value sent and modifies a field in the server side
connection to reflect the new database to be used.
INIT_DB command
Using this query, the user can change the database associated with a connection. In this
case, NetScaler parses the <init_db> value sent and modifies a field in the server side
connection to reflect the new database to be used.
COM_PREPARE
NetScaler stops request switching on receiving this command.
PREPARE query
This query is used to create prepared statements that are associated with a connection.
For this query, the NetScaler uses the 'store and forward' mechanism described earlier in
this section.
50
Special Queries
51
52