A database service can serve highly-available data to a MySQL database application. The application can then provide network access to database client systems, such as Web servers. If the service fails over, the application accesses the shared database data through the new cluster system. A network-accessible database service is usually assigned one IP address, which is failed over along with the service to maintain transparent access for clients.
An example of a configuring a MySQL database service is as follows:
The MySQL server packages are installed on each cluster system that will run the service. The MySQL database directory resides on a file system that is located on a disk partition on shared storage. This allows the database data to be accessed by all cluster members. In the example, the file system is mounted as /var/lib/mysql, using the shared disk partition /dev/sda1.
An IP address is associated with the MySQL service to accommodate network access by clients of the database service. This IP address is automatically migrated among the cluster members as the service fails over. In the example below, the IP address is 10.1.16.12.
The script that is used to start and stop the MySQL database is the standard init script mysqld. If general logging of connections and queries is needed, edit the mysqld script to add the option --log=/var/log/mysqld.log as the last option to the safe_mysqld command. The resulting line should appear similar to the following (Note: the forward slash (\) denotes the continuation of one line):
/usr/bin/safe_mysqld --defaults-file=/etc/my.cnf --log=/var/log/mysqld.log \ >/dev/null 2>&1 & |
If the --log option is added to the mysqld script, the new mysqld script should be copied to the other cluster members that can run the MySQL service, so that they can log connections and queries if the MySQL service fails over to those members.
by default, a client connection to a MySQL server times out after eight hours of inactivity. This connection limit can be modified by setting the wait_timeout variable in the /etc/my.cnf file. For example, to set timeouts to four hours, add the following line to the [mysqld] section of /etc/my.cnf:
set-variable = wait_timeout=14400 |
Restart the MySQL service. Note that after this change is made, the new /etc/my.cnf file should be copied to all the other cluster members that can run the MySQL service.
To check if a MySQL server has timed out, invoke the mysqladmin command and examine the uptime. If it has timed out, invoke the query again to automatically reconnect to the server.
Depending on the Linux distribution, one of the following messages may indicate a MySQL server timeout:
CR_SERVER_GONE_ERROR CR_SERVER_LOST |
To add a MySQL service using the Cluster Configuration Tool, perform the following:
Start the Cluster Configuration Tool by choosing Main Menu => System Settings => Server Settings => Cluster or by typing redhat-config-cluster at a shell prompt. The Cluster Status Tool appears by default.
Start the Cluster Configuration Tool by selecting Cluster => Configure from the Cluster Status Tool menus.
Click the Services tab.
Add the MySQL service.
Click New. The Service dialog appears.
Enter a Service Name for the MySQL service.
Select a Failover Domain or leave it as None.
Type a quantity (seconds) in the Check Interval box if you want to check the health of the MySQL service through the status directive of the mysqld init script.
Enter a User Script, such as /etc/init.d/mysqld.
Click OK.
Add an IP address for the MySQL service.
Select the MySQL service and click Add Child.
Select Add Service IP Address and click OK. The Service IP Address dialog appears.
Enter an IP Address.
Enter a Netmask, or leave it None.
Enter a Broadcast Address, or leave it None.
Click OK.
Add a device for the MySQL service.
Select the MySQL service and click Add Child.
Select Add Device and click OK. The Device dialog appears.
Enter the Device Special File (for example, /dev/sdc3).
In the Mount Point field, enter /var/lib/mysql.
Select the file system type in FS Type or leave it blank.
Enter any mount point Options, including rw (read-write).
Check or uncheck Force Unmount.
Click OK.
Choose File => Save to save the MySQL service.