---
name: "ocf_heartbeat_mysql"
section: "7"
platform: "linux"
package: "resource-agents"
version: "1:4.16.0-3+deb13u2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/ocf_heartbeat_mysql"
---

# ocf\_heartbeat\_mysql(7)

Manages a MySQL database instance

## NAME

ocf\_heartbeat\_mysql - Manages a MySQL database instance

## SYNOPSIS

**mysql** \[start \| stop \| status \| monitor \| promote \| demote \| meta-data \| validate-all\]

## DESCRIPTION

Resource script for MySQL. May manage a standalone MySQL database, a clone set with externally managed replication, or a complete master/slave replication setup. Note, when master/slave replication is in use, the resource must be setup to use notifications. Set 'notify=true' in the metadata attributes when defining a MySQL master/slave instance.

While managing replication, the default behavior is to use uname -n values in the change master to command. Other IPs can be specified manually by adding a node attribute ${INSTANCE\_ATTR\_NAME}\_mysql\_master\_IP giving the IP to use for replication. For example, if the mysql primitive you are using is p\_mysql, the attribute to set will be p\_mysql\_mysql\_master\_IP.

## SUPPORTED PARAMETERS

**binary**

Location of the MySQL server binary

(optional, string, default "/usr/bin/mysqld\_safe")

**client\_binary**

Location of the MySQL client binary

(optional, string, default "mysql")

**config**

Configuration file

(optional, string, default "/etc/mysql/my.cnf")

**datadir**

Directory containing databases

(optional, string, default "/var/lib/mysql")

**user**

User running MySQL daemon

(optional, string, default "mysql")

**group**

Group running MySQL daemon (for logfile and directory permissions)

(optional, string, default "mysql")

**log**

The logfile to be used for mysqld.

(optional, string, default "/var/log/mysql/error.log")

**pid**

The pidfile to be used for mysqld.

(optional, string, default "/var/run/mysqld/mysqld.pid")

**socket**

The socket to be used for mysqld.

(optional, string, default "/var/run/mysqld/mysqld.sock")

**test\_table**

Table to be tested in monitor statement (in database.table notation)

(optional, string, default "mysql.user")

**test\_user**

MySQL test user, must have select privilege on test\_table

(optional, string, default "root")

**test\_passwd**

MySQL test user password

(optional, string, no default)

**enable\_creation**

If the MySQL database does not exist, it will be created

(optional, boolean, default 0)

**additional\_parameters**

Additional parameters which are passed to the mysqld on startup. (e.g. --skip-external-locking or --skip-grant-tables)

(optional, string, no default)

**replication\_user**

MySQL replication user. This user is used for starting and stopping MySQL replication, for setting and resetting the master host, and for setting and unsetting read-only mode. Because of that, this user must have SUPER, REPLICATION SLAVE, REPLICATION CLIENT, PROCESS and RELOAD privileges on all nodes within the cluster. Mandatory if you define a master-slave resource.

(optional, string, default "root")

**replication\_passwd**

MySQL replication password. Used for replication client and slave. Mandatory if you define a master-slave resource.

(optional, string, no default)

**replication\_port**

The port on which the Master MySQL instance is listening.

(optional, string, default "3306")

**replication\_require\_ssl**

Enables SSL connection to local MySQL service for replication user. i.e. if REQUIRE SSL for replication user in MySQL set, this should be set to "true".

(optional, string, default "false")

**replication\_master\_ssl\_ca**

The SSL CA certificate to be used for replication over SSL.

(optional, string, no default)

**replication\_master\_ssl\_cert**

The SSL CA certificate to be used for replication over SSL.

(optional, string, no default)

**replication\_master\_ssl\_key**

The SSL certificate key to be used for replication over SSL.

(optional, string, no default)

**max\_slave\_lag**

The maximum number of seconds a replication slave is allowed to lag behind its master. Do not set this to zero. What the cluster manager does in case a slave exceeds this maximum lag is determined by the evict\_outdated\_slaves parameter.

(optional, integer, default 3600)

**evict\_outdated\_slaves**

If set to true, any slave which is more than max\_slave\_lag seconds behind the master has its MySQL instance shut down. If this parameter is set to false in a primitive or clone resource, it is simply ignored. If set to false in a master/slave resource, then exceeding the maximum slave lag will merely push down the master preference so the lagging slave is never promoted to the new master.

(optional, boolean, default false)

**reader\_attribute**

An attribute that the RA can manage to specify whether a node can be read from. This node attribute will be 1 if it's fine to read from the node, and 0 otherwise (for example, when a slave has lagged too far behind the master).

A typical example for the use of this attribute would be to tie a set of IP addresses to MySQL slaves that can be read from.

This parameter is only meaningful in master/slave set configurations.

(unique, optional, string, default "readable")

## SUPPORTED ACTIONS

This resource agent supports the following actions (operations):

**start**

Starts the resource. Suggested minimum timeout: 120s.

**stop**

Stops the resource. Suggested minimum timeout: 120s.

**status**

Performs a status check. Suggested minimum timeout: 60s.

**monitor**

Performs a detailed status check. Suggested minimum timeout: 30s. Suggested interval: 20s.

**monitor (Promoted role)**

Performs a detailed status check. Suggested minimum timeout: 30s. Suggested interval: 10s.

**promote**

Promotes the resource to the Master role. Suggested minimum timeout: 120s.

**demote**

Demotes the resource to the Slave role. Suggested minimum timeout: 120s.

**notify**

Suggested minimum timeout: 90s.

**validate-all**

Performs a validation of the resource configuration. Suggested minimum timeout: 5s.

**meta-data**

Retrieves resource agent metadata (internal use only). Suggested minimum timeout: 5s.

## EXAMPLE CRM SHELL

The following is an example configuration for a mysql resource using the [**crm**(8)](/crm/8.md) shell:

```
primitive p_mysql ocf:heartbeat:mysql \
  op monitor depth="0" timeout="30s" interval="20s" \
  op monitor role="Promoted" depth="0" timeout="30s" interval="10s"
```

```
ms ms_mysql p_mysql \
  meta notify="true" interleave="true"
```

## EXAMPLE PCS

The following is an example configuration for a mysql resource using [**pcs**(8)](/pcs/8.md)

```
pcs resource create p_mysql ocf:heartbeat:mysql \
  op monitor OCF_CHECK_LEVEL="0" timeout="30s" interval="20s" \
  op monitor role="Promoted" OCF_CHECK_LEVEL="0" timeout="30s" interval="10s" promotable
```

## SEE ALSO

**http://clusterlabs.org/**

## AUTHOR

**ClusterLabs contributors (see the resource agent source for information about individual authors)**
