-
Notifications
You must be signed in to change notification settings - Fork 36
config databaseroles
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 Melody to use additional servers, you start by specifying the 'DatabaseRoles' configuration setting.
none
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.
config.cgi
Database mtdb
DBUser melody
DBPassword nelson
DatabaseRoles path/relative/to/mt-config-file/DBRoles.yaml
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 Melody database connections. Melody 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 config file) -
user
- Database username (defaults to 'DBUser' from config file) -
pass
- Database password (defaults to 'DBPassword' from config file) -
host
- Database hostname (defaults to 'DBHost' from config file) -
port
- Database port number (defaults to 'DBPort' from config file) -
sock
- Database socket (defaults to 'DBSocket' from 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.
config.cgi
Database mtdb
DBUser melody
DBPassword nelson
DatabaseRoles SingleSlaveDB.yaml
SingleSlaveDB.yaml
global:
host: dbrw-1.ai.com
cycle: 60
slaves:
- host: dbro-1.ai.com
config.cgi
Database mtdb
DBUser melody
DBPassword nelson
DatabaseRoles MultiReadOnlyDB.yaml
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
- Categories: Appendix: Configuration Directives
- Tags: config, database, database server, master, roles, server, slave, yaml