mysql modifies parameter variables without restarting
- 2020-06-19 11:51:33
- OfStack
Generally speaking, updating mysql configuration my. cnf requires a restart of mysql to take effect, but sometimes mysql is online and allows you to restart. What should you do?
Look at an example:
mysql
>
show variables like 'log_slave_updates';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| log_slave_updates | OFF |
+-------------------+-------+
row in set (0.00 sec)
mysql
>
set global log_slave_updates=1;
ERROR 1238 (HY000): Variable 'log_slave_updates' is a read only variable
See? An error!
Later, I checked 1 data and found that there was a thing called gdb, which was quite impressive. It could change the parameters of mysql online, please see the example:
mysql
>
system gdb -p $(pidof mysqld) -ex "set opt_log_slave_updates=1" -batch
mysql
>
show variables like 'log_slave_updates';
+-------------------+-------+
| Variable_name | Value |
+-------------------+-------+
| log_slave_updates | ON |
+-------------------+-------+
row in set (0.00 sec)
But in the 1 repeatable parameters, can not be directly changed with set, then what to do? Foreigners offer a solution:
mysql> show slave status \G
...
Replicate_Do_DB: test
...
mysql> system gdb -p $(pidof mysqld)
-ex 'call rpl_filter->add_do_db(strdup("hehehe"))' -batch
mysql> show slave status \G
...
Replicate_Do_DB: test,hehehe
...