mysql.xml
文件如下:
<?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='30'>
<method_context >
<method_credential user='mysql' group='mysql' />
</method_context>
</exec_method>
<exec_method
type='method'
name='stop'
exec=':kill'
timeout_seconds='30'>
</exec_method>
<exec_method
type='method'
name='restart'
exec='/lib/svc/method/svc-mysql restart'
timeout_seconds='60'>
</exec_method>
</service>
</service_bundle>
svc-mysql 的文件如下:
#!/bin/sh
. /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
服务一直处在维护状态起不来,
使用以下
命令时候,日志抱错:
#svcadm clear /network/mysql
#svcadm enable /network/mysql
抱错日志如下:
Leaving maintenance because clear requested. ]
[ 4月 6 16:58:05 Enabled. ]
[ 4月 6 16:58:05 Executing start method ("/lib/svc/method/svc-mysql start") ]
[ 4月 6 16:58:05 Method "start" exited with status 0 ]
[ 4月 6 16:58:05 Stopping because all processes in service exited. ]
[ 4月 6 16:58:05 Executing stop method (:kill) ]
[ 4月 6 16:58:05 Executing start method ("/lib/svc/method/svc-mysql start") ]
[ 4月 6 16:58:06 Method "start" exited with status 0 ]
[ 4月 6 16:58:06 Stopping because all processes in service exited. ]
[ 4月 6 16:58:06 Executing stop method (:kill) ]
[ 4月 6 16:58:06 Executing start method ("/lib/svc/method/svc-mysql start") ]
[ 4月 6 16:58:06 Method "start" exited with status 0 ]
[ 4月 6 16:58:07 Stopping because all processes in service exited. ]
[ 4月 6 16:58:07 Executing stop method (:kill) ]
[ 4月 6 16:58:07 Executing start method ("/lib/svc/method/svc-mysql start") ]
[ 4月 6 16:58:07 Method "start" exited with status 0 ]
[ 4月 6 16:58:07 Stopping because all processes in service exited. ]
[ 4月 6 16:58:07 Executing stop method (:kill) ]
[ 4月 6 16:58:07 Executing start method ("/lib/svc/method/svc-mysql start") ]
[ 4月 6 16:58:08 Method "start" exited with status 0 ]
[ 4月 6 16:58:08 Stopping because all processes in service exited. ]
[ 4月 6 16:58:08 Executing stop method (:kill) ]
[ 4月 6 16:58:08 Executing start method ("/lib/svc/method/svc-mysql start") ]
[ 4月 6 16:58:08 Method "start" exited with status 0 ]
[ 4月 6 16:58:09 Stopping because all processes in service exited. ]
[ 4月 6 16:58:09 Executing stop method (:kill) ]
[ 4月 6 16:58:09 Executing start method ("/lib/svc/method/svc-mysql start") ]
[ 4月 6 16:58:09 Method "start" exited with status 0 ]
[ 4月 6 16:58:09 Stopping because all processes in service exited. ]
[ 4月 6 16:58:09 Executing stop method (:kill) ]
[ 4月 6 16:58:09 Executing start method ("/lib/svc/method/svc-mysql start") ]
[ 4月 6 16:58:09 Method "start" exited with status 0 ]
[ 4月 6 16:58:10 Stopping because all processes in service exited. ]
[ 4月 6 16:58:10 Executing stop method (:kill) ]
[ 4月 6 16:58:10 Executing start method ("/lib/svc/method/svc-mysql start") ]
[ 4月 6 16:58:10 Method "start" exited with status 0 ]
[ 4月 6 16:58:11 Stopping because all processes in service exited. ]
[ 4月 6 16:58:11 Executing stop method (:kill) ]
[ 4月 6 16:58:11 Restarting too quickly, changing state to maintenance ]
提示restart 太快?
不知道是什么原因?请大哥们指点一下 谢谢!!
__________________________________