How to configure MySQL to enable SMF for 64-bit
MySQL 5.0.45 is available in Solaris Express Developer Edition (SXDE) 01/08 with Solaris Service Management Facility (SMF) enabled. Recently MySQL 5.0.45 for 64-bit content was integrated with Open Solaris build 87.
First a quick recap of what is SMF:
SMF is the core component of the predictive self-healing technology available in Solaris 10, which provides automatic recovery from software and hardware failures as well as adminstrative errors. Some of the advantages of using SMF are as under:
- Failed services are automatically restarted in dependency order, whether they failed as the result of administrator error, software bug, or were affected by an uncorrectable hardware error.
- More information is available about misconfigured or misbehaving services, including an explanation of why a service isn't running , as well as individual, persistent log files for each service.
- Problems during the boot process are easier to debug, as boot verbosity can be controlled, service startup messages are logged, and console access is provided more reliably during startup failures. *Administrators can securely delegate tasks to non-root users more easily, including the ability to configure, start, stop, or restart services .
- Large systems boot faster by starting services in parallel according to their dependencies.
Below are the SMF service manifest to enable the 64-bit server and accompanying shell script needed to integrate MySQL with Solaris SMF.
Perform the following steps to import the manifest into the SMF repository.
1.Save the following XML code to a file called "mysql.xml" in /var/svc/manifest/application/database. You need to create the directory if it doesn't exist and have the appropriate privileges to perform this action.
getproparg() {
val=`svcprop -p $1 $SMF_FMRI`
[ -n "$val" ] && echo $val
}
MYSQLBIN=`getproparg mysql/bin`
MYSQLDATA=`getproparg mysql/data`
PIDFILE=${MYSQLDATA}/`/usr/bin/uname -n`.pid
if [ -z $SMF_FMRI ]; then
echo "SMF framework variables are not initialized."
exit $SMF_EXIT_ERR
fi
if [ -z ${MYSQLDATA} ]; then
echo "mysql/data property not set"
exit $SMF_EXIT_ERR_CONFIG
fi
if [ ! -d ${MYSQLDATA} ]; then
echo "mysql/data directory ${MYSQLDATA} is not a valid MySQL data directory"
exit $SMF_EXIT_ERR_CONFIG
fi
if [ ! -d ${MYSQLDATA}/mysql ]; then
${MYSQLBIN}/mysql_install_db --user=mysql --datadir=${MYSQLDATA}
fi
mysql_start() {
MYSQLDVAL=`getproparg mysql/enable_64bit mysql:version_50`
if [ "$MYSQLDVAL" != "" ] ; then
case "$MYSQLDVAL" in
true|1)
#Check if the system architecture supports 64-bit applications
PLATFORM=`isainfo -b`
if [ "${PLATFORM}" != "64" ]; then
echo "This system is not capable of supporting 64-bit applications."
echo "Set the \"enable_64bit\" property value to \"false\" to start the 32-bit server."
exit $SMF_EXIT_ERR_CONFIG
else
echo ${MYSQLBIN}/64/mysqld --user=mysql --datadir=${MYSQLDATA} --pid-file=${PIDFILE} > /dev/null &
${MYSQLBIN}/64/mysqld --user=mysql --datadir=${MYSQLDATA} --pid-file=${PIDFILE} > /dev/null &
fi
;;
false|0)
echo ${MYSQLBIN}/mysqld --user=mysql --datadir=${MYSQLDATA} --pid-file=${PIDFILE}
${MYSQLBIN}/mysqld --user=mysql --datadir=${MYSQLDATA} --pid-file=${PIDFILE} > /dev/null &
;;
esac
fi
}
mysql_stop() {
if [ -f ${PIDFILE} ]; then
pkill mysqld
fi
}
case "$1" in
'start')
mysql_start
;;
'stop')
mysql_stop
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
;;
esac
exit $SMF_EXIT_OK