修改binlog模式
<h1>普通修改,需要项目组停服时操作</h1>
<pre><code>ansible all -i 2.txt -m shell -a &quot;sed -i.bak 's/binlog_format = MIXED/binlog_format = ROW\nbinlog_row_image = full/g' /data/mysql/3306/my.cnf&quot; --become
ansible all -i 2.txt -m shell -a &quot;sed -i 's/expire_logs_days = 4/expire_logs_days = 7/g' /data/mysql/3306/my.cnf&quot; --become
ansible all -i 2.txt -m shell -a &quot;grep -e binlog_format -e binlog_row_image -e expire_logs_days /data/mysql/3306/my.cnf&quot; --become
ansible all -i 2.txt -m shell -a &quot;grep binlog_format /data/mysql/3306/my.cnf&quot; --become
ansible all -i 2.txt -m shell -a &quot;ls -l /data/mysql/3306/&quot; --become
ansible all -i 2.txt -m shell -a &quot;screen -ls -u sszgoms&quot; --become
ansible all -i 2.txt -m shell -a &quot;/root/mysql_stop&quot; --become
ansible all -i 2.txt -m shell -a &quot;/root/mysql_start&quot; --become
ansible all -i 2.txt -m shell -a &quot;ps -ef | grep mysql&quot; --become</code></pre>
<h1>热更改,不需要项目组停服</h1>
<pre><code>#设置
mysql -uroot -p`cat /data/save/mysql_root` -e &quot;SET GLOBAL expire_logs_days = 7;&quot;
#ansible格式跑
ansible all -i 4500.txt -m shell -a &quot;mysql -uroot -p\`cat /data/save/mysql_root\` -e \&quot;SET GLOBAL expire_logs_days = 14;\&quot;&quot;
#查看
mysql -uroot -p`cat /data/save/mysql_root` -e &quot;SHOW GLOBAL VARIABLES LIKE 'expire_logs_days';&quot;
#ansible格式跑
ansible all -i 4500.txt -m shell -a &quot;mysql -uroot -p\`cat /data/save/mysql_root\` -e \&quot;SHOW GLOBAL VARIABLES LIKE 'expire_logs_days';\&quot;&quot; --become
#查看binlog_format
ansible all -i 122.112.217.40:2020, -m shell -a &quot;mysql -uroot -p\`cat /data/save/mysql_root\` -e \&quot;SHOW GLOBAL VARIABLES LIKE 'binlog_format';\&quot;&quot; --become
#进入my.cnf文件手动修改
expire_logs_days</code></pre>