Anyway, here are the steps that I followed:
1. create a manifest file in /var/svc/manifest/network called mysql.xml The manifest file is what solaris looks at start start/stop/etc on services. In it, you define the methods for starting, stopping, etc.
My manifest file looks like this:
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 name='net'
grouping='require_all'
restart_on='none'
type='service'>
service_fmri value='svc:/network/loopback' />
exec_method
type='method'
name='start'
exec='/lib/svc/method/svc-mysql start'
timeout_seconds='-1'>
method_context working_directory='/apps/mysql'>
method_credential user='mysql' group='mysql' />
exec_method
type='method'
name='stop'
exec=':kill'
timeout_seconds='-1'>
exec_method
type='method'
name='restart'
exec='/lib/svc/method/svc-mysql restart'
timeout_seconds='-1'>
make sure root:sys owns this file and that the permissions are 444
chown root:sys mysql.xml
chmod 444 mysql.xml
The main difference between this script and the other samples is when I would start, I got a "svc.startd could not set context for method: chdir: No such file or directory" error. Apparently, when you start the service under the mysql user/group, it looks for a working directory. On Solaris 10, the mysql user/group already exist with no home dir, so I added the "working_directory='/apps/mysql'" to the start method. This solved everything
2. Next, create the method file (script) which looks remarkably like something you'd put in the rc3.d dir. Here's what mine looks like (modified for my dirs)
#!/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
. /lib/svc/share/smf_include.sh
DB_DIR=/apps/mysql
PIDFILE=${DB_DIR}/`/usr/bin/hostname`.pid
case "$1" in
start)
/usr/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
make sure root:bin owns it and the permissions are 555
chown root:bin svc-mysql
chmod 555 svc-mysql
make sure the data dir is owned by mysql user/group
chown -R mysql:mysql
3. now verify that the manifest file is good
svccfg validate /var/svc/manifest/network/mysql.xml
4. import the manifest file
svccf import /var/svc/manifest/network/mysql.xml
5. check the status
svcs mysql
The status should be "disabled", so enable it
svcadm enable mysql
6. check the status again
svcs mysql
It should be "online". If it is "maintenance", then there was a problem starting it. Look in /var/svc/log/network-mysql..... log file and look for errors. You can also do a svcs -x mysql command it will be tell you some info. The log file is where I found the error about the working directory. Of course the error wasn't that nice, but whatever.
Now you have mysql running as a service on Solaris 10. yeah.
1 comment:
I'm not very familar with xml syntax, but I think my browser is getting confused by the '|tag_start|' '|/tag_end|' in the xml file. It looks very different from the one on BigAdmin
http://www.sun.com/bigadmin/content/submitted/mysql_smf_tip.html
(In fact I'm having a hard time posting this comment due to the example tags above and I've had to replace "<" "/>" pair with "|")
Can you please post a link to the file instead? I'm seeing the same error regarding the working dir as you've described.
Post a Comment