mysql> show variables like 'log_slave_updates'; +-------------------+-------+ | Variable_name | Value | +-------------------+-------+ | log_slave_updates | OFF | +-------------------+-------+ 1 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 看到了吧?报错了!
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 | +-------------------+-------+ 1 row in set (0.00 sec) 但是在一些可重复的参数,不能直接用set更改,那这时候又要怎么办呢?老外给了一个解决方案:
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 ... =========================================================================
mysql很多参数都需要重启才能生效,有时候条件不允许,可以使用gdb作为最后的手段
先看看修改之前
mysql> show global variables like '%connection%'; +--------------------------+-------------------+ | Variable_name | Value | +--------------------------+-------------------+ | character_set_connection | latin1 | | collation_connection | latin1_swedish_ci | | max_connections | 151 | | max_user_connections | 0 | +--------------------------+-------------------+ 4 rows in set (0.01 sec)