Configuring MySQL to Use With Service Management Facility (SMF)William Pool (Puddle), October 2005
The Solaris 10 OS uses the Service Management Facility (SMF) to handle
services. Traditional means like To take advantage of the SMF in the Solaris 10 OS using MySQL, follow these steps. Note: Read the scripts and "change" the path of MySQL or MySQL's data-directory accordingly! If you haven't initialized the MySQL database, do that first: /opt/sfw/bin/mysql_install_db
This will install the database into
Note: If you change the location, change the information below!
First create a
Then create the
Create a service manifest file:
This contains the following: <?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<!--
William Pool (Puddle) 02/05
Service manifest for MySQL
E-mail: puddle@flipmotion.com
-->
<service_bundle type='manifest' name='mysql:mysql'>
<service
name='network/mysql'
type='service'
version='1'>
<create_default_instance enabled='false' />
<single_instance />
<dependency name='fs'
grouping='require_all'
restart_on='none'
type='service'>
<service_fmri value='svc:/system/filesystem/local' />
</dependency>
<dependency name='net'
grouping='require_all'
restart_on='none'
type='service'>
<service_fmri value='svc:/network/loopback' />
</dependency>
<exec_method
type='method'
name='start'
exec='/lib/svc/method/svc-mysql start'
timeout_seconds='-1'>
<method_context>
<method_credential user='mysql' group='mysql' />
</method_context>
</exec_method>
<exec_method
type='method'
name='stop'
exec=':kill'
timeout_seconds='-1'>
</exec_method>
<exec_method
type='method'
name='restart'
exec='/lib/svc/method/svc-mysql restart'
timeout_seconds='-1'>
</exec_method>
</service>
</service_bundle>
Now create your "Service Method File" in
#!/usr/bin/sh
#
# William Pool (Puddle) 01/05
# SMF Method file for MySQL
# E-mail: puddle@flipmotion.com
#
# This uses Sun's default MySQL packages
# SUNWmysqlu SUNWmysqlr
#
# Modify accordingly!
#
# NOTE: Make sure DB_DIR is owned BY the mysql user and group and chmod
# 700.
#
.. /lib/svc/share/smf_include.sh
DB_DIR=/var/mysql
PIDFILE=${DB_DIR}/`/usr/bin/uname -n`.pid
case "$1" in
start)
/usr/sfw/sbin/mysqld_safe --user=mysql --datadir=${DB_DIR} --pid-file=${PIDFILE} > /dev/null &
;;
stop)
if [ -f ${PIDFILE} ]; then
/usr/bin/pkill mysqld_safe >/dev/null 2>&1
/usr/bin/kill `cat ${PIDFILE}` > /dev/null 2>&1 && echo -n ' mysqld'
fi
;;
'restart')
stop
while pgrep mysqld > /dev/null
do
sleep 1
done
start
;;
*)
echo ""
echo "Usage: `basename $0` { start | stop | restart }"
echo ""
exit 64
;;
esac
#---EOF
Now fix the permissions for the two files created: chown root:bin /lib/svc/method/svc-mysql chmod 555 /lib/svc/method/svc-mysql chown root:sys /var/svc/manifest/network/mysql.xml chmod 444 /var/svc/manifest/network/mysql.xml Fix permissions on the MySQL data directory: chown -R mysql:mysql /var/mysql chmod -R 700 /var/mysql Import the service into the service repository:
Enable the service:
References for Further Information
The information and links on this page have been provided by a BigAdmin user. The submitter is solely responsible for such information and links. Sun is not responsible for the availability of external sites or resources, and does not endorse and is not responsible or liable for any content, advertising, products, or other materials on or available from such sites or resources. Sun will not be responsible or liable, directly or indirectly, for any actual or alleged damage or loss caused by or in connection with use of or reliance on the information posted here, or goods or services available on or through any external site or resource. Unless otherwise licensed, code in all technical manuals herein (including articles, FAQs, samples) is provided under this License. |
| |||