免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1008 | 回复: 0
打印 上一主题 下一主题

Configuring MySQL to Use With SMF [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-04-09 14:49 |只看该作者 |倒序浏览
摘自《sun技术论坛》
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 /etc/rc?.d scripts still work, but as a legacy means. (For more information on SMF, see the References section.)
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 /var/mysql to override that use:
/opt/sfw/bin/mysql_install_db -ldata=/opt/sfw/var/mysql
Note: If you change the location, change the information below!
First create a mysql group:
/usr/sbin/groupadd mysql
Then create the mysql user:
/usr/sbin/useradd -s /bin/false -g mysql -d /var/mysql -c "MySQL User" mysql
Create a service manifest file:
/var/svc/manifest/network/mysql.xml
This contains the following:

        William Pool (Puddle) 02/05
        Service manifest for MySQL
        E-mail:
puddle@flipmotion.com
-->


         
         
         
                 
         
         
                 
         
         
               
                        
                 
         
         
         
  
         



Now create your "Service Method File" in /lib/svc/method called svc-mysql:
#!/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:
# svccfg import /var/svc/manifest/network/mysql.xml
Enable the service:
# svcadm -v enable mysql


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/14514/showart_97258.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP