How to bulk clear the expired Binlog above the 128 Group node DB and free up disk space. Go

Source: Internet
Author: User

If 10 units within the DB, you manually ssh in, clean is enough, but hundreds of units, it is necessary to write a script. Approximate idea: In a DB jump connection above, write a script, access slave, remotely get the copy of the master above the Binlog location, and then remote to purge master above the Binlog.

1, establish slave dbserver list slavelist; A slave line.

2, remotely obtain the Binlog location above slave db and the master hostname of slave (perhaps an IP address)

3, get Binlog location and master hostname, and then ssh remotely clean up the Binlog on master

4, Shell forloop operation Step 2 and step 3.

Companion script 1:clean_binlog.sh

[Python]View PlainCopyprint?
  1. #!/bin/bash
  2. # p1 the slave MySQL DB server
  3. db03=$1
  4. Echo $dbserver;
  5. ster_log_file= ' ssh $db mysql-uxx-pxx--ssl-ca=/opt/mysql/ssl/ca-cert.pem--s
  6. Sl-cert=/opt/mysql/ssl/server-cert.pem--ssl-key=/opt/mysql/ssl/server-key.pem-e \"show slave status\G;\" | Grep-i Master_log_file
  7. "`;
  8. # echo ##### Get binlog Info
  9. Log_file= ' echo $ster _log_file |  awk ' {print $} ';
  10. db01tmp= ' ssh $db mysql-uxx-pxx--ssl-ca=/opt/mysql/ssl/ca-cert.pem--s
  11. Sl-cert=/opt/mysql/ssl/server-cert.pem--ssl-key=/opt/mysql/ssl/server-key.pem-e \"show slave status\G;\" | Grep-i Master_host
  12. "`;
[Python]View PlainCopyprint?
    1. # get Master host name or IP address
    2. Db01= ' echo $db 01tmp | awk ' {print $} '
    3. # Start cleaning up Binlog log information
[Python]View PlainCopyprint?
    1. SSH $db "Mysql-uxxx-pxx--ssl-ca=/opt/mysql/ssl/ca-cert.pem--ssl-cert=/op
    2. T/mysql/ssl/server-cert.pem--ssl-key=/opt/mysql/ssl/server-key.pem-e \"purge master logs to ' $log _file '; \" "  
    3. # Binlog information on Check master
[Python]View PlainCopyprint?
    1. SSH $db "Df-h/mysql/binlog";
[Python]View PlainCopyprint?
    1. <strong><span style="color: #ff0000;" ></span></strong>

Included with batch for loop script 2:

For S in ' Cat slavelist '; do sh clean_binlog.sh $s; Done

This is a relatively rough plan, there must be shortcomings, my 128 group is a mm combination, so the operation is possible, the structure of different estimates will be changed, here is also related to purge before the Binlog backup and so on (with a dedicated backup machine and backup script).

How to bulk clear the expired Binlog above the 128 Group node DB and free up disk space. Go

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.