This site is a work in progress — you can help! Please see the Site news for details.

MySQL (resource agent)

From Linux-HA

(Redirected from Mysql (resource agent))
Jump to: navigation, search

The MySQL resource agent (ocf:heartbeat:mysql in CRM shell syntax) manages a MySQL database as a highly available cluster resource. It supports multiple instances of MySQL in the cluster of which, if configured correctly, several may run concurrently on one node.

Reference information about this resource agent is contained in its manual page (man ocf_heartbeat_mysql); an on-line version is available in the Linux-HA User's Guide.

Contents

The binary parameter

For historical reasons, the default value for the binary resource agent parameter (which references the MySQL server binary) is safe_mysqld. All recent versions of MySQL use mysqld_safe as the MySQL server binary name. Please be sure to reflect this in your configuration:

primitive p_mysql ocf:heartbeat:mysql \
  params binary="/usr/sbin/mysqld" \
  op monitor depth="0" timeout="30" interval="10"

start and stop timeouts

Cluster resource managers such as Pacemaker enforce timeouts for starting and stopping resources. Many installations will use a default timeout of 20 seconds, which is most likely too short to accommodate graceful MySQL startup and shutdown. The recommended minimum timeouts for start and stop are 120 seconds, and can be configured as follows:

primitive p_mysql ocf:heartbeat:mysql \
  params binary="/usr/sbin/mysqld" \
  op start timeout="120" \
  op stop timeout="120" \
  op monitor depth="0" timeout="30" interval="10"

Busy MySQL servers may take longer to start up and shut down. Under such circumstances, the timeouts should be adjusted accordingly.

Multiple MySQL instances

When configuring multiple MySQL instances that should support running concurrently on the same node, it is vital to make sure that their datadir, pid, socket, and log parameters do not conflict. Also, it is usually wise to bind them to separate IP addresses via the --bind-address MySQL server option, passed in via additional_parameters:

primitive p_mysql1 ocf:heartbeat:mysql \
  params binary="/usr/sbin/mysqld" \
         datadir="/var/lib/mysql1" \
         pid="/var/run/mysqld/mysql1.pid" \
         socket="/var/run/mysqld/mysql1.sock" \
         log="/var/run/mysqld/mysql1.log" \
         additional_parameters="--bind-address=192.168.122.109" \
  op start timeout="120" \
  op stop timeout="120" \
  op monitor depth="0" timeout="30" interval="10"

primitive p_mysql2 ocf:heartbeat:mysql \
  params binary="/usr/sbin/mysqld" \
         datadir="/var/lib/mysql2" \
         pid="/var/run/mysqld/mysql2.pid" \
         socket="/var/run/mysqld/mysql2.sock" \
         log="/var/run/mysqld/mysql2.log" \
         additional_parameters="--bind-address=192.168.122.110" \
  op start timeout="120" \
  op stop timeout="120" \
  op monitor depth="0" timeout="30" interval="10"

In this configuration, it would be expected that both /var/lib/mysql1 and /var/lib/mysql2 are mounted from shared or replicated storage. Likewise, it is assumed that 192.168.122.109 and 192.168.122.110 are floating virtual IP addresses.


MySQL master/slave replication

In order to configure Pacemaker-managed MySQL replication, you must first initialize and configure a replicated database setup. Please check the MySQL documentation for details on doing so.

Once MySQL replication has been properly set up, you can take it under Pacemaker management with the following crm commands:

primitive p_mysql ocf:heartbeat:mysql \
  params binary="/usr/sbin/mysqld" \
  op start timeout="120" \
  op stop timeout="120" \
  op promote timeout="120" \
  op demote timeout="120" \
  op monitor role="Master" timeout="30" interval="10" \
  op monitor role="Slave" timeout="30" interval="10"
ms ms_mysql p_mysql \
  meta clone-max=3

Replace the clone-max value for the number of replicas you wish to manage.

Personal tools