29

I have to configure a MySQL server to act as a replication-master.

I modified my.cnf to activate binary logs, but now in order to reload configuration I have to reload the service with /etc/init.d/mysqld restart. The problem is that the server receives several queries per second and I don't want to lose all the data that could arrive meanwhile.

Is there a way to reload configuration file my.cnf without restarting the service?

0

2 Answers 2

31

MySQL Specificly:
The options in my.cnf are system variables. These variables are either dynamic (can be changed at runtime) or not dynamic. The ones that are dynamic, can be changed at run time with the SET variable syntax. You can see the variables with SHOW VARIABLES;. But according to this link in the manual, the binary log option is not dynamic. So it looks like you have to restart. You might want to wait for someone who knows mysql a little better than myself to confirm this however.

Daemons in General:
In Linux, /etc/init.d/ holds scripts that start and stop daemons (services). Since these are scripts, you can view them with a text editor. Many of these scripts will take a reload argument. Looking at my mysql script, reload as an argument uses the mysqladmin command. So the manual for mysqladmin under reload says:

reload

Reload the grant tables.

So looks like in general, this isn't for configuration changes, but rather changes in privileges (Maybe the equivalent flush privileges command? ).

5
  • 2
    Hey, very good explanation. It seems that there is no way of doing it without restart though. If nobody answers a solution or a workaround I will accept your question. Thank you. Oct 28, 2009 at 13:14
  • According to your link, it looks like SET GLOBAL binlog_format = 'STATEMENT'; would do the trick?
    – Kyle Smith
    Oct 28, 2009 at 14:10
  • Other Kyle: Looks like it, but I think binary logging would already have to be enabled for that to do anything (and maybe be set). That variable was introduced later than my current 5.0.x version of mysql so I can't test. Oct 28, 2009 at 15:40
  • I had to search for the SET command syntax - here's a link in case anyone else needs it: dev.mysql.com/doc/refman/5.1/en/set-option.html Mar 1, 2011 at 6:52
  • 4
    It's also worth mentioning which variables are dynamic changes as you chance MySQL versions. For instance in 5.x you can enable the slow query log on-the-fly, but in 4.x you can't (as I discovered yesterday!).
    – Coops
    Mar 3, 2011 at 9:30
1

i've been looking around for a solution for this but wasn't satisfied by the limited help i found. One chap offered a kill -HUP .. didn't work for me ..

what i did was to pause the apache instances .. and then continue them later .. worked like a charm on a server where i have an average of 25 active requests per second.

with sudo (obviously) pkill -STOP httpd && /etc/init.d/mysqld restart && pkill -CONT httpd

ofcourse your apache process name and/or mysql restart scripts may vary from mine, but you get the idea right!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .