List:General Discussion« Previous MessageNext Message »
From:Nitin Mehta Date:May 11 2010 10:19am
Subject:Re: starting multiple instances with mysqld_multi
View as plain text  
Thanks, Prabhat! You're very right, but did you read the questions I asked?






________________________________
From: Prabhat Kumar <aim.prabhat@stripped>
To: Nitin Mehta <ntnmht@stripped>
Cc: mysql@stripped
Sent: Tue, May 11, 2010 11:54:22 AM
Subject: Re: starting multiple instances with mysqld_multi

Hi,

You can run multiple instances on the same host and specify configuration options either
by adding the options as arguments on the command line, or by storing them in
configuration files.

for example, from the command line:

shell> mysqld --port 3306 --log=/path/to/server1/log
shell> mysqld --port 3307 --log=/path/to/server2/log


So, when MySQL starts up it reads various config files in sequence. This means that you
can set global options for all instances in one file and then specific options for
individual instances in separate files.

The files it reads by default are (on linux)


>>/etc/my.cnf
>>the_mysql_data_dir/my.cnf
>>~/.my.cnf
>>
You can direct the server to read specific config files after it reads the default
/etc/my.cnf file with the following directive.

--defaults-extra-file=/path/to/extra/config/file

So, if you wanted 2 instances running with some shared options and some specific options,
you could create additional configuration files in /etc say:

/etc/my.server1.cnf
/etc/my.server2.cnf

where my.server1.cnf has the following lines:

port=3306
log=/path/to/log/file/for/server1
(other options here)

and my.server2.cnf is:

port=3307
log=/path/to/log/file/for/server2
(other options here)

then you could start the separate instances of mysqld as follows:

shell> mysqld --defaults-extra-file=/etc/my.server1.cnf
shell> mysqld --defaults-extra-file=/etc/my.server2.cnf

about mysqld_multi
mysqld_multi
>>mysqld_multi [ options] {start| stop| report} [ server_id]
>Use this to run multiple MySQL servers on different socket files and ports. To set up
>multiple servers, a different section of server options must be entered into a
configuration file (e.g., /etc/my.cnf). The naming scheme for each section must be
[mysqldn]
>>where n is a different number for each server. Options must be entered separately
for
>each server in its own section, even when servers use the same options. At a minimum,
>each server should use a different socket file and a different TCP/IP port. To see an
>>example of how a configuration file might be set up for multiple servers, enter
the
>following from the command line:
>mysqld_multi --example
>Once multiple servers have been configured, to start a server, you can enter
something
>>like the following from the command line:
>mysqld_multi start 3
>This line would start server number 3 listed in the configuration file as [mysqld3].
By
>entering report for the first argument, you can obtain the status on the server. For
>>starting and stopping the server, this script uses the mysqladmin utility. Here
is an
>alphabetical list of options specific to mysqld_multi that you can enter from the
>command line, along with a brief explanation of each:
>>--config-file=filename
>Specifies the path and name of the server’s configuration file if it is
different from
>the default.
>--example
>Displays a sample configuration file.
>--help
>Displays basic help information.
>>--log=filename
>Sets the path and name of the logfile. The default is /tmp/mysqld_multi.log.
>--mysqladmin=path
>Sets the path to the mysqladmin utility.
>--mysqld=path
>Specifies the path to mysqld.
>--no-log
>>Instructs the utility not to save messages to a log, but to send them to stdout
>instead.
>--password=password
>Provides the password for using mysqladmin.
>--tcp-ip
>Enables TCP/IP communication with the server instead of using a Unix-domain
>>socket.
>--user=user
>Provides the username for using mysqladmin. The same user must be used for all
>servers.
>--version
>Displays the version of the utility.
>
Thanks,



On Tue, May 11, 2010 at 9:54 AM, Nitin Mehta <ntnmht@stripped> wrote:

>Hi,
>
>>I am exploring multiple instances with MySQL which will be running using the same
set of binaries (single MySQL base). Two things which I'm not able to work out are -
>
>>        1. Why mysqld_multi stop <grp_id> doesn't work? Well, I know why it
doesn't because there is nothing in the script to handle a 'stop' call; the actual
question would be - why it doesn't work when it is mentioned in the MySQL reference
manual?
>>
>        2. how to (auto) restart the instances after a server restart? do I need to
write my own script for this or is there anything available which I'm not aware of?
>>If you have resolved these issues, please let me know.
>> 
>> 
>>Best Regards,
>Nitin
>
>
>>      


-- 
Best Regards,

Prabhat Kumar
MySQL DBA
Datavail-India Mumbai
Mobile     : 91-9987681929
www.datavail.com

My Blog: http://adminlinux.blogspot.com
My LinkedIn: http://www.linkedin.com/in/profileprabhat



      
Thread
starting multiple instances with mysqld_multiNitin Mehta11 May
  • Re: starting multiple instances with mysqld_multiPrabhat Kumar11 May
    • Re: starting multiple instances with mysqld_multiNitin Mehta11 May
  • Re: starting multiple instances with mysqld_multiYang Wang14 May