This is documentation about a configuration directive, which can be placed within Movable Type’s core configuration file,
mt-config.cgi, to customize the behavior of the system.
This optional configuration setting allows you to specify a file that defines additional database servers that can be used to distribute load for database requests. This would require you to configure multiple database servers, one as a ‘master’ and additional ‘slave’ servers that replicate the data from the master database server. The additional slave database servers can be used for handling read-only requests (SELECT queries).
To configure MT to use additional servers, you start by specifying the ‘DatabaseRoles’ configuration setting.
The value for the setting is a file name for a YAML-formatted text file.
All config settings/directives where you specify a path or a path+filename are specified relative to the location of the config file itself (like a CSS file in that regard; where all url() references in a stylesheet file are relative to the location of the stylesheet file).
A full path can also be used of course.
Database mtdb DBUser melody DBPassword nelson DatabaseRoles path/relative/to/mt-config-file/DBRoles.yaml
global: user: default-readonly-username slaves: - host: read-only-slave1.example.com user: user-for-slave1 - host: read-only-slave2.example.com - host: read-only-slave3.example.com
The ‘global’ heading identifies the ‘global’ role, which is the primary role for Movable Type database connections. MT currently only supports a single master database, but will be offering support for multiple master databases in the future. So for now, ‘global’ is the only role supported. Under the role heading (“global:”), you may specify the following settings which will serve as the default values for any slave connections declared. The following values may be given:
dbname- Database name (defaults to ‘Database’ from mt-config file)
user- Database username (defaults to ‘DBUser’ from mt-config file)
pass- Database password (defaults to ‘DBPassword’ from mt-config file)
host- Database hostname (defaults to ‘DBHost’ from mt-config file)
port- Database port number (defaults to ‘DBPort’ from mt-config file)
sock- Database socket (defaults to ‘DBSocket’ from mt-config file)
cycle- Limit to length of any persistent database connection (specified in minutes)
Under the “slaves:” heading, you provide the information necessary to make a connection to each slave you have configured. Each of the above settings may also be defined for each slave, if necessary. Values that are not specified for the slave configuration are drawn from the “global” settings instead.
Database mtdb DBUser melody DBPassword nelson DatabaseRoles SingleSlaveDB.yaml
global: host: dbrw-1.ai.com cycle: 60 slaves: - host: dbro-1.ai.com
Database mtdb DBUser melody DBPassword nelson DatabaseRoles MultiReadOnlyDB.yaml
global: cycle: 60 host: dbrw-0.ai.com slaves: - host: dbro-1.ai.com - host: dbro-2.ai.com - host: dbro-3.ai.com