免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2078 | 回复: 7

使用smf 管理mysql的问题. [复制链接]

论坛徽章:
0
发表于 2007-04-06 17:07 |显示全部楼层
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 太快?
不知道是什么原因?请大哥们指点一下 谢谢!!

论坛徽章:
0
发表于 2007-04-06 18:18 |显示全部楼层
顶一下

论坛徽章:
0
发表于 2007-04-06 21:22 |显示全部楼层
我来帮你顶 我刷品能够

论坛徽章:
0
发表于 2007-04-06 21:49 |显示全部楼层
Can you start mysql manually with script svc-mysql?

论坛徽章:
0
发表于 2007-04-09 09:21 |显示全部楼层
svc-mysql  能执行
#svc-mysql start
#
没有报错信息,因该是正确的,我怀疑是不是脚本有问题?
一启用服务
#svcadm enable /network/mysql


svclog就报告 服务启动太快进入维护状态........

什么问题呢?

想起个问题在这里讨教一下:

在svc-mysql 的脚本中:
#!/bin/sh


. /lib/svc/share/smf_include.sh


这行命令因该是先执行:/lib/svc/share/smf_include.sh  脚本,没错吧?
但是我手动启动:/lib/svc/share/smf_include.sh   这个脚本,提示不能执行

#ls -l /lib/svc/share/smf_include.sh
#-r--r--r--   1 root     bin         3728 11月  7日 14:03 smf_include.sh

是不是这个原因呢? 测试一下 呵呵!
请兄弟们赐教!!

[ 本帖最后由 lazy_bug 于 2007-4-9 10:15 编辑 ]

论坛徽章:
0
发表于 2007-04-09 12:14 |显示全部楼层
没有报错信息,因该是正确的
No necessary. Make sure your mysql is actually started. The message "Restarting too quickly, changing state to maintenance " tells you that the service was terminated and restarted more frequently than normal. The Solaris Service Manager placed the service into maintenance mode instead of restarting it again.

论坛徽章:
0
发表于 2007-04-09 13:57 |显示全部楼层

  1. 这行命令因该是先执行:/lib/svc/share/smf_include.sh  脚本,没错吧?
  2. 但是我手动启动:/lib/svc/share/smf_include.sh   这个脚本,提示不能执行

  3. #ls -l /lib/svc/share/smf_include.sh
  4. #-r--r--r--   1 root     bin         3728 11月  7日 14:03 smf_include.sh

复制代码


#chmod 544 /lib/svc/share/smf_include.sh

然后再运行看看

论坛徽章:
0
发表于 2007-04-10 09:15 |显示全部楼层
测试过
#chmod 544 /lib/svc/share/smf_include.sh

问题不存在于此,mysql.xml 和svc-mysql脚本存在问题?
寻求中..............................................................
希望兄弟们指点........................谢谢! 谢谢 楼上的给位回贴兄弟!非常感谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP