This sounds a lot like something I created back in February 2011. In fact, I placed the code for the mysqlservice
script in one post : Running multiple instances on the same host (Sep 30, 2011)
The mysqlservice script is a quasi-service I created to help set up multiple mysql instances. The idea is to create
- my.cnf for a specific port number
- service filename to launch the service
In this case, you should see a file called /etc/init.d/mysql3307
. If you do not have one, please create it. It should look like this :
#!/bin/sh
#
# readahead: Prereads programs required for startup into memory
#
# chkconfig: 2345 4 99
# description: This service causes the programs used during startup \
# to be loaded into memory before they are needed,\
# thus improving startup performance
#
#
# Sanity checks.
[ -x /usr/sbin/readahead ] || exit 0
# Check for > 384 MB
#free -m | gawk '/Mem:/ {exit ($2 >= 384)?0:1}' || exit 0
# Source function library.
#. /etc/rc.d/init.d/functions
WHICH=/usr/bin/which
SERVICE=`${WHICH} service`
MYSQL=`${WHICH} mysql`
PORT_NUMBER=3307
# See how we were called.
case "$1" in
start) ${SERVICE} mysqlservice ${PORT_NUMBER} start ;;
stop) ${SERVICE} mysqlservice ${PORT_NUMBER} stop ;;
status) ${SERVICE} mysqlservice ${PORT_NUMBER} status ;;
restart) ${SERVICE} mysqlservice ${PORT_NUMBER} restart ;;
mycnf) ${SERVICE} mysqlservice ${PORT_NUMBER} mycnf ;;
edit) ${SERVICE} mysqlservice ${PORT_NUMBER} edit ;;
*)
echo $"Usage: $0 {start|stop|restart|status|mycnf}"
;;
esac
After creating the file, please run
chmod +x /etc/init.d/mysql3307
Now, the service can be summoned with
service mysql3307 start
Under the hood, it will call
service mysqlservice 3307 start
You could call it that way as well. Yet, setting up /etc/init.d/mysql3307 makes the service have a name that's easy to remember.
Give it a Try !!!
CAVEAT : You have to create a my.cnf file for port 3307 called /etc/my3307.cnf
The file /etc/my3307.cnf
must include
[mysqld]
port=3307
datadir=<whatever folder you have for 3307's mysql instance>
The fundamentals difference between services are
You can start and stop the services independent of each other. While mysqld_multi
allows you to have multiple MySQL Instances under one my.cnf via setting up mysqld groups, I created the mysqlservice
quasi-service to use distinct my.cnf files for each instance. That way, you do not have to worry setting up my.cnf to know what is common to all MySQL Instances vs. what is unique to each MySQL Instance.
If you setup more than two services in this manner, you become responsible for assigning the proper amount of RAM for buffers, caches, and threads.