SMF - WindyHana's Solanara

목차

개요

SMF 관리

svcs 명령

svcadm 명령

svccfg 명령

inet.d

MySQL을 SMF에 등록하기

MySQL을 등록할때는 아래와 같이 3가지 단계를 거친다.

서비스 번들 XML파일

SMF설정 파일(mysql.xml)을 /var/svc/manifest/application/database/mysql.xml에 복사한다.
mysql.xml
다운로드 (3,084 바이트)
<?xml version="1.0"?>
<!-- WindyHana's Solanara: SMF - http://www.solanara.net/solanara/smf -->
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type='manifest' name='mysql'>
<service
        name='application/database/mysql'
        type='service'
        version='1'>
        <!--
           Wait for network interfaces to be initialized.
        -->
        <dependency
                name='network'
                grouping='require_all'
                restart_on='none'
                type='service'>
                <service_fmri value='svc:/milestone/network:default' />
        </dependency>

        <!--
           Wait for all local filesystems to be mounted.
        -->
        <dependency
                name='filesystem-local'
                grouping='require_all'
                restart_on='none'
                type='service'>
                <service_fmri value='svc:/system/filesystem/local:default' />
        </dependency>

        <exec_method
                type='method'
                name='start'
                exec='/lib/svc/method/mysql start'
                timeout_seconds='120' />

        <exec_method
                type='method'
                name='stop'
                exec='/lib/svc/method/mysql stop'
                timeout_seconds='120' />

        <exec_method
                type='method'
                name='restart'
                exec='/lib/svc/method/mysql restart'
                timeout_seconds='240' />

        <property_group name='general' type='framework'>
                <propval name='value_authorization' type='astring'
                        value='solaris.smf.value.mysql' />
                <propval name='action_authorization' type='astring'
                        value='solaris.smf.manage.mysql' />
        </property_group>


        <instance name='version_50' enabled='false'>
                <method_context>
                        <method_credential user='mysql' group='mysql' />
                </method_context>
                <property_group name='mysql' type='application'>
                        <propval name='bin' type='astring'
                           value='/usr/local/mysql/bin' />
                        <propval name='data' type='astring'
                           value='/usr/local/mysql/var' />
                        <propval name='value_authorization' type='astring'
                           value='solaris.smf.value.mysql' />
                </property_group>
        </instance>

        <stability value='Evolving' />

        <template>
                <common_name>
                        <loctext xml:lang='C'>
                                MySQL RDBMS
                        </loctext>
                </common_name>
                <documentation>
                        <manpage title='MySQL 5.0' section='1' />
                        <doc_link name='mysql.com'
                                uri='http://www.mysql.com' />
                </documentation>
        </template>
</service>
</service_bundle>

SMF용 mysql 시작/종료 스크립트

MySQL을 실행할 수 있는 실행 파일을 /lib/svc/method/mysql에 넣어놓는다.
mysql
다운로드 (838 바이트)
#!/sbin/sh
#
# WindyHana's Solanara: SMF
# http://www.solanara.net/solanara/smf
#
. /lib/svc/share/smf_include.sh
getproparg() {
	val=`svcprop -p $1 $SMF_FMRI`
	[ -n "$val" ] && echo $val
}

MYSQLBIN=`getproparg mysql/bin`
MYSQLDATA=`getproparg mysql/data`
PIDFILE=${MYSQLDATA}/`/usr/bin/uname -n`.pid

if [ -z $SMF_FMRI ]; then
	echo "Error: SMF framework variables are not initialized"
	exit $SMF_EXIT_ERR
fi

if [ -z $MYSQLDATA ]; then
	echo "Error: mysql/data property not set"
	exit $SMF_EXIT_ERR_CONFIG
fi

if [ ! -d ${MYSQLDATA}/mysql ]; then
	$MYSQLBIN/mysql_install_db --user=mysql --datadir=$MYSQLDATA
fi

case "$1" in
'start'|'stop'|'restart'|'reload'|'force-reload'|'status')
	$MYSQLBIN/../share/mysql/mysql.server $1
	;;
*)
	echo "Usage: $0 {start|stop|restart|reload|force-reload|status}"
	exit 1
	;;
esac
exit $SMF_EXIT_OK

mysql.xml 검증 및 서비스에 등록

root@wl ~ # cd /var/svc/manifest/application/database
root@wl ~ # svccfg validate mysql.xml
root@wl ~ # svccfg import mysql.xml
root@wl ~ # svcs mysql
root@wl ~ # svcadm enable mysql
등록된 MySQL 서비스를 삭제하려면 svcadm disable mysql; svccfg delete mysql명령을 실행하면 된다.
RSS ATOM XHTML 1.0 CSS3