Navigation
Records in this category
- How to rebuild Solaris Device Tree
- Installing and Configuring MySQL on Solaris 10 with Service Management Facility
- Using ZFS for Zone Backups or Snapshots
- How to get access to the parallel port from a freshly installed system
- Moving a harddisk with a Sun Solaris 9 installation from one x86 machine to another
- Solaris root password recovery
- The Best MQSeries FAQ
- Installing and Configuring Oracle on Sun Solaris
- Solaris reminders
- Using truss,nm and ldd command to troubleshoot binary files
- Configuring Samba in Sun Solaris
- The best DNS FAQ for solaris
- The best NFS document for Solaris
- OS Patching technique with VxVM
- Replacing D1000 disks in Solaris
Tags
Sticky FAQs
Sun Solaris
Installing and Configuring MySQL on Solaris 10 with Service Management Facility
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. 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 that contains the following:
cat > /var/svc/manifest/network/mysql.xml <<’EOF’
<?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='-1'>
<method_context>
<method_credential user='mysql' group='mysql' />
</method_context>
</exec_method>
<exec_method
type='method'
name='stop'
exec=':kill'
timeout_seconds='-1'>
</exec_method>
<exec_method
type='method'
name='restart'
exec='/lib/svc/method/svc-mysql restart'
timeout_seconds='-1'>
</exec_method>
</service>
</service_bundle>
EOF
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
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
Tags: Mysql, SMF, Sun Solaris
Related entries:
- How to rebuild Solaris Device Tree
- up2date tutorial
- Veritas Cluster - Commands
- Statistical-Based Intrusion Detection
- Intrusion Detection Terminology (Part One)
Last update: 2009-06-18 18:13
AuthorLuke Francis
Revision: 1.1
You cannot comment on this entry