• 30961 deploys

Description

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.

Readme

Overview

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.

Percona 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.

http://www.mysql.com

http://www.percona.com/software/percona-server

Usage

General

To deploy a MySQL service:

juju deploy mysql

Once deployed, you can ssh into the deployed service and access the MySQL console as the MySQL root user:

juju ssh <unit>
mysql -u root -p
# enter root password - /var/lib/juju/mysql.passwd

To change deployment to a Percona server:

juju set mysql flavor=percona

Optimization

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>

e.g.

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

Replication

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 performance.

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

Monitoring

This charm provides relations that support monitoring via either Nagios or Munin. Refer to the appropriate charm for usage.

Configuration

vip_cidr
(int) Netmask that will be used for the Virtual IP
24
vip_iface
(string) Network Interface where to place the Virtual IP
eth0
block-size
(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).
5
tuning-level
(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.
safest
rbd-name
(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.
mysql1
query-cache-size
(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.
-1
query-cache-type
(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
OFF
vip
(string) Virtual IP to use to front mysql in ha configuration
binlog-format
(string) If binlogging is enabled, this is the format that will be used. Ignored when tuning-level == fast.
MIXED
ha-mcastport
(int) Default multicast port number that will be used to communicate between HA Cluster nodes.
5411
max-connections
(int) Maximum connections to allow. -1 means use the server's compiled in default.
-1
flavor
(string) Possible values are 'distro' or 'percona'
distro
preferred-storage-engine
(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.
InnoDB
dataset-size
(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.
80%
ha-bindiface
(string) Default network interface on which HA cluster will bind to communication with the other members of the HA Cluster.
eth0