地球人都知道,更新mysql配置my.cnf須要重啓mysql才能生效,可是有些時候mysql在線上,不必定容許你重啓,這時候應該怎麼辦呢?mysql
看一個例子:web
1
2
3
4
5
6
7
8
9
10
|
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
|
看到了吧?報錯了!sql
後來查了一下資料,發現有一個叫gdb的東西,感受至關牛X,能夠實如今線更改mysql參數,請看例子:spa
1
2
3
4
5
6
7
8
|
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更改,那這時候又要怎麼辦呢?老外給了一個解決方案:orm
1
2
3
4
5
6
7
8
9
10
|
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
...
|