How can I batch clear the expired binlogs on the 128 group of node databases and release the disk space? If there are less than 10 databases, manually enter the binlogs through ssh. clean is enough, but there are hundreds of databases, you have to write the script. General idea: On a db jump machine, write a script to access slave, remotely obtain the binlog location on the master that is being copied, and then remotely Go To The binlog on the purge master. 1. Create the slave dbserver list slavelist; one slave row. 2. Remotely obtain the binlog location on the slave db and the master Host Name (maybe IP address) of the slave. 3. Obtain the binlog location and master host name, and then ssh remotely cleans up binlog 4 on the master, shell for loop operations step 2 and step 3. Script 1: clean_binlog.sh [python] #! /Bin/bash # p1 the slave mysql db server db03 = $1 echo $ dbserver; ster_Log_File = 'ssh $ db03 "mysql-uxx-pxx -- ssl-ca =/opt/mysql/ssl/ca-cert.pem -- s 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" '; # echo ##### obtain binlog information log_file = 'echo $ ster_Log_File | awk' {print $2 }''; db01tmp = 'ssh $ db03 "mysql-uxx-pxx -- ssl -Ca =/opt/mysql/ssl/ca-cert.pem -- s 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 "'; [python] # obtain the master host name or IP address db01 = 'echo $ db01tmp | awk '{print $2} ''# start to clear binlog log information [python] ssh $ db01" mysql- uxxx-pxx -- ssl-ca =/opt/mysql/ssl/ca-cert.pem -- ssl-cert =/op t/mysql/ssl/server-cert.pem -- ssl-key =/opt/mysql/ ssl/serve R-key.pem-e \ "purge master logs to '$ log_file'; \" "# check binlog information on the master [python] ssh $ db01" df-h/mysql/binlog "; [python] <strong> <span style = "color: # ff0000;"> </span> </strong> comes with a batch for loop Script 2: for s in 'cat slavelist'; do sh clean_binlog.sh $ s; done is a rough solution and there must be deficiencies. My 128 groups are mm combinations, therefore, this operation can be performed, and the estimation may change depending on the architecture. Here, we also need to back up the binlog before purge (with dedicated backup machines and backup scripts ).