MySQL is a fast, stable and true multi-user, multi-threaded SQL database
server. SQL (Structured Query Language) is the most popular database query
language in the world. The main goals of MySQL are speed, robustness and
ease of use.
MySQL is a fast, stable and true multi-user, multi-threaded SQL database server. SQL (Structured Query Language) is the most popular database query language in the world. The main goals of MySQL are speed, robustness and ease of use.
This charm also can deploy Percona Server is fork of MySQL by Percona Inc. which focuses on maximizing performance, particularly for heavy workloads. It is a drop-in replacement for MySQL and features XtraDB, a drop-in replacement for the InnoDB storage engine.
To deploy a MySQL service:
juju deploy mysql
Once deployed, you can retrieve the MySQL root user password by logging in to the machine via
juju ssh and readin the
/var/lib/mysql/mysql.passwd file. To log in as root MySQL User at the MySQL console you can issue the following:
juju ssh mysql/0 mysql -u root -p`sudo cat /var/lib/mysql/mysql.passwd`
The charm supports simple backups. To enable them set
backup_schedule option. Optionally you can override default
juju set mysql backup_schedule="45 5 * * *" # cron formatted schedule juju set mysql backup_dir="/mnt/backup" juju set mysql backup_retention_count=28
Scale Out Usage
MySQL supports the ability to replicate databases to slave instances. This
allows you, for example, to load balance read queries across multiple slaves or
use a slave to perform backups, all whilst not impeding the master's
To deploy a slave:
# deploy second service juju deploy mysql mysql-slave # add master to slave relation juju add-relation mysql:master mysql-slave:slave
Any changes to the master are reflected on the slave.
Any queries that modify the database(s) should be applied to the master only.
The slave should be treated strictly as read only.
You can add further slaves with:
juju add-unit mysql-slave
You can tweak various options to optimize your MySQL deployment:
max-connections - Maximum connections allowed to server or '-1' for default.
preferred-storage-engine - A comma separated list of storage engines to optimize for. First in the list is marked as default storage engine. 'InnoDB' or 'MyISAM' are acceptable values.
tuning-level - Specify 'safest', 'fast' or 'unsafe' to choose required transaction safety. This option determines the flush value for innodb commit and binary logs. Specify 'safest' for full ACID compliance. 'fast' relaxes the compliance for performance and 'unsafe' will remove most restrictions.
dataset-size - Memory allocation for all caches (InnoDB buffer pool, MyISAM key, query). Suffix value with 'K', 'M', 'G' or 'T' to indicate unit of kilobyte, megabyte, gigabyte or terabyte respectively. Suffix value with '%' to use percentage of machine's total memory.
query-cache-type - Specify 'ON', 'DEMAND' or 'OFF' to turn query cache on, selectively (dependent on queries) or off.
query-cache-size - Size of query cache (no. of bytes) or '-1' to use 20% of memory allocation.
Each of these can be applied by running:
juju set <service> <option>=<value>
juju set mysql preferred-storage-engine=InnoDB juju set mysql dataset-size=50% juju set mysql query-cache-type=ON juju set mysql query-cache-size=-1
Deploying Percona Server is an option in this charm, you can do so by editing the
juju set mysql flavor=percona
WARNING: Migrating from MySQL to Percona Server in this fashion is currently a one-way migration, once you migrate you cannot migrate back via Juju.
To change the source that the charm uses for packages:
juju set mysql source="cloud:precise-icehouse"
This will enable the Icehouse pocket of the Cloud Archive and upgrade the install of any 'cloud' packages to the new version.
The source option can be used in a few different ways:
source="ppa:james-page/testing" - use the testing PPA owned by james-page source="http://myrepo/ubuntu main" - use the repository located at the provided URL
The charm also supports use of arbitary archive key's for use with private repositories:
juju set mysql key="C6CEA0C9"
Note that in clustered configurations, the upgrade can be a bit racey as the services restart and re-cluster; this is resolvable using:
juju resolved --retry mysql/1
When deploying MySQL on the local provider, there is a known memory exhaustion issue. To work around this until the issue is patched:
juju set mysql dataset-size='512M' juju resolved -r mysql/#
MySQL and Percona Server Contact Information
- (string) Directory where backups will be stored
- (int) Number of recent backups to retain.
- (string) Cron schedule used for backups. If empty backups are disabled
- (string) mysql bind host address
- (string) If binlogging is enabled, this is the format that will be used. Ignored when tuning-level == fast.
- (int) Default block storage size to create when setting up MySQL block storage. This value should be specified in GB (e.g. 100 not 100GB).
- (int) This value dictates the number of replicas ceph must make of any object it stores within the mysql rbd pool. Of course, this only applies if using Ceph as a backend store. Note that once the mysql rbd pool has been created, changing this value will not have any effect (although it can be changed in ceph by manually configuring your ceph cluster).
- (string) How much data do you want to keep in memory in the DB. This will be used to tune settings in the database server appropriately. Any more specific settings will override these defaults though. This currently sets innodb_buffer_pool_size or key_cache_size depending on the setting in preferred-storage-engine. If query-cache-type is set to 'ON' or 'DEMAND' 20% of this is given to query-cache-size. Suffix this value with 'K','M','G', or 'T' to get the relevant kilo/mega/etc. bytes. If suffixed with %, one will get that percentage of RAM devoted to dataset and (if enabled) query cache.
- (string) Possible values are 'distro' or 'percona'
- (string) Default network interface on which HA cluster will bind to communication with the other members of the HA Cluster.
- (int) Default multicast port number that will be used to communicate between HA Cluster nodes.
- (string) Key ID to import to the apt keyring to support use with arbitary source configuration from outside of Launchpad archives or PPA's.
- (int) Maximum connections to allow. -1 means use the server's compiled in default.
- (string) Used by the nrpe-external-master subordinate charm. A string that will be prepended to instance name to set the host name in nagios. So for instance the hostname would be something like: juju-myservice-0 If you're running multiple environments with the same services in them this allows you to differentiate between them.
- (boolean) If True enables IPv6 support. The charm will expect network interfaces to be configured with an IPv6 address. If set to False (default) IPv4 is expected. . NOTE: these charms do not currently support IPv6 privacy extension. In order for this charm to function correctly, the privacy extension must be disabled and a non-temporary address must be configured/available on your network interface.
- (string) Tune the server for usage of this storage engine. Other possible value is MyISAM. Comma separated will cause settings to split resources evenly among given engines.
- (int) Override the computed version from dataset-size. Still works if query-cache-type is "OFF" since sessions can override the cache type setting on their own.
- (string) Query cache is usually a good idea, but can hurt concurrency. Valid values are "OFF", "ON", or "DEMAND". http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_query_cache_type
- (string) The name that will be used to create the Ceph's RBD image with. If the image name exists in Ceph, it will be re-used and the data will be overwritten.
- (string) Optional configuration to support use of additional sources such as: . - ppa:myteam/ppa - cloud:precise-proposed/folsom - http://my.archive.com/ubuntu main . The last option should be used in conjunction with the key configuration option.
- (string) Valid values are 'safest', 'fast', and 'unsafe'. If set to safest, all settings are tuned to have maximum safety at the cost of performance. Fast will turn off most controls, but may lose data on crashes. unsafe will turn off all protections.
- (string) Virtual IP to use to front mysql in ha configuration
- (int) Netmask that will be used for the Virtual IP
- (string) Network Interface where to place the Virtual IP
- (int) The number of seconds the server waits for activity on a noninteractive connection before closing it. -1 means use the server's compiled in default.