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. The default instance of the manifest assumes that the database user is mysql and the database directory is /var/mysql/5.0/data . If any of them is different, update the above XML accordingly.

2. Save the following shell script to a file called "mysql"

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

3. Place the shell script "mysql" in /lib/svc/method.

4. Change the permission to 555. You need to have the appropriate write privileges to copy files into this directory.

5. Initially the service instance is disabled. Use the following command to see the state.

# svcs mysql

6. Start the service for the default instance by executing the following command:

# /usr/sbin/svcadm enable mysql

By default the 32 bit mysqld server is started .

7. To start the 64-bit mysqld server via SMF ,do the following .

#svccfg

svc>select mysql:version_50

svc:/application/database/mysql:version_50>listprop mysql/enable_64bit

mysql/enable_64bit boolean false

svc:/application/database/mysql:version_50>setprop mysql/enable_64bit=true svc:/application/database/mysql:version_50>listprop mysql/enable_64bit

mysql/enable_64bit boolean true

svc:/application/database/mysql:version_50>quit

8. Refresh the manifest as follows with the updated configuration

#svcadm refresh mysql:version_50

9. Start the 64-bit mysqld server

#svcadm enable mysql:version_50

10.Check if the mysqld is started from /usr/mysql/5.0/bin/64 do the following

# svcs mysql

STATE   STIME        FMRI

online     21:08:38          svc:/application/database/mysql:version_50

# ps -eaf | grep mysqld

mysql 18181 1 0 21:08:38 ? 0:07 /usr/mysql/5.0/bin/64/mysqld --user=mysql --datadir=/var/mysql/5.0/data --pid-file

The 64-bit server is initiated. From this point on the MySQL process is controlled by the Solaris SMF. For more details on how to use SMF, refer to the following BigAdmin site: http://www.sun.com/bigadmin/content/selfheal/

Comments:

Post a Comment:
  • HTML Syntax: NOT allowed

This blog copyright 2009 by Sunanda Menon