zoukankan      html  css  js  c++  java
  • 不重启mysql情况修改参数变量

    地球人都知道,更新mysql配置my.cnf需要重启mysql才能生效,但是有些时候mysql在线上,不一定允许你重启,这时候应该怎么办呢?

    看一个例子:

    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

    看到了吧?报错了!

    后来查了一下资料,发现有一个叫gdb的东西,感觉相当牛X,可以实现在线更改mysql参数,请看例子:

    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更改,那这时候又要怎么办呢?老外给了一个解决方案:

    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
    ...
  • 相关阅读:
    综合练习:词频统计
    Dart SDK 2.0安装问题
    The DartEditor executable launcher was unable to locate its companion shared library.
    pycharm中如何正确配置pyqt5
    发现黑苹果带双显示器无法启动的原因
    Pycharm中用鼠标改变字体大小
    失望的visual studio for mac
    laravel 函数测试 --- Route::has()
    laragon 之Nginx
    laragon 之xdebug
  • 原文地址:https://www.cnblogs.com/huidaoli/p/3232265.html
Copyright © 2011-2022 走看看