如何批量清除128组节点db上面的过期的binlog,释放磁盘空间_MySQL
bitsCN.com
如何批量清除128组节点db上面的过期的binlog,释放磁盘空间
如果10台以内的db的话,自己手动ssh进去,clean就足以,但是上百台呢,就要写脚本了。大概思路:在 一台db跳转机上面, 写一个脚本,访问slave,远程获取正在复制的master上面的binlog位置, 然后再远程去purge master上面的binlog.
1, 建立slave dbserver列表 slavelist; 一个slave一行。
2,远程获取slave db上面的binlog位置以及slave的master主机名(也许是ip地址)
3,拿到binlog位置以及master主机名,然后ssh远程清理掉master上面的binlog
4,shell for循环操作step 2以及step 3。
附带脚本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 ##### 获取binlog信息
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]
# 获取master主机名或者ip地址
db01=`echo $db01tmp | awk '{print $2}'`
# 开始清理binlog日志信息
[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/server-key.pem -e /"purge master logs to '$log_file';/" "
# check master上面的binlog信息
[python]
ssh $db01 " df -h /mysql/binlog ";
[python]
附带批量for循环脚本2:
for s in `cat slavelist`; do sh clean_binlog.sh $s; done
这个是比较粗略的方案,肯定有不足之处,我的128组是mm组合,所以这样操作是可以的,架构不同估计会有变动,这里还涉及到purge之前的binlog的备份等等(有专门的备份机以及备份脚本)。
bitsCN.com
Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



This article is reprinted from the WeChat public account "Living in the Information Age". The author lives in the information age. To reprint this article, please contact the Living in the Information Age public account. In machine learning, a basic concept is how to judge the difference between two samples, so that the similarity and category information between the two samples can be evaluated. The measure to judge this similarity is the distance between two samples in the feature space. There are many measurement methods based on different data characteristics. Generally speaking, for two data samples x, y, define a function d(x, y). If it is defined as the distance between the two samples, then d(x, y) needs to satisfy the following basic properties : Non-negativity: d(x, y)>=0 Identity: d(x, y)=0 ⇔ x=y pair

Swap space plays an important role in Linux systems, especially when the system is low on memory. It acts as a backup memory storage space that helps the system run smoothly and maintain stability even under high load. This article provides you with a detailed guide to adding swap space on Ubuntu 22.04LTS to ensure that your system performance is optimized and can handle various workloads. Understanding Swap Space Swap space provides virtual memory that is used to supplement the system's physical RAM. When the system is low on RAM, the kernel swaps data to disk to prevent out-of-memory and system crashes. Linux systems commonly use swap space to handle this situation. Run multiple memory-intensive applications simultaneously to process very large files or data

The remaining space on the c drive is 50-80G which is more suitable. Since the system will generate junk files, cache files, etc. in the future, it is recommended to reserve at least 50GB-80GB of space for the C drive; if you are not used to choosing a path when installing software and do not clean your computer frequently, then at least 100GB is required. .

As we all know, if the system disk occupied is too large after the system installation is completed, it may cause system lags, delays, and even file loss. Therefore, before you install the win11 system, you need to know how much C drive space is required to upgrade win11. Let’s take a look with the editor. How much C drive space is required to upgrade win11: Answer: Upgrading win11 requires 20-30GB of C drive space. 1. According to Microsoft’s win11 configuration requirements, you can see that win11 installation requires 64GB of hard drive space. 2. But in fact, generally speaking, there is no need for such a large space. 3. According to feedback from users who have already installed win11, the win11 upgrade requires about 20-30GB of C drive space. 4. But if our door only has

The Xbox console has a huge selection of games to download and play. Coupled with Microsoft's Xbox Game Pass subscription, the fun never stops with your game collection. However, there is the issue of space available for games, which is 356GB on Xbox Series S and 850GB on Xbox Series X. While this was fine in previous versions of the game, the maximum size of the game was probably between 20 and 45GB, which isn't the case with recent games. Recently available games end up taking up a lot of space on the disk, leaving us less space to download other games. ForzaHorizon5 and Halo5Guardians and more

If you have an iPhone 15 or iPhone 15 Pro Max, iOS 17.2 lets you record spatial video for viewing in the Photos app on Apple's upcoming Vision Pro headphones. Here's how you do it. Apple's VisionPro headphones are expected to be released around February 2024. Until then, one way you can prepare for this is to use your iPhone to record video in a special format called spatial video, which can be viewed on Apple's headphones. Spatial videos appear as normal videos when viewed on an iPhone, but they offer near three-dimensionality on VisionPro

1. Introduction Due to the explosive growth of current computer networks, the ensuing problem is the rapidly increasing number of network attacks. Various sectors of our society, from government departments to various critical infrastructures in society, are heavily dependent on computer networks and information technology. Apparently they are also vulnerable to cyberattacks. Typical network attacks disable the target computer, take services offline, or access the target computer's data. The number and impact of cyberattacks has increased significantly since the 1990s. Network security refers to a set of technologies used to protect network device activities and measures to protect them from all possible threats. In traditional network security technology, most of them are static access management, and the security control system will protect based on preset definitions.

What are the employment prospects of clinical pharmacy at Harbin Medical University? Although the national employment situation is not optimistic, pharmaceutical graduates still have good employment prospects. Overall, the supply of pharmaceutical graduates is less than the demand. Pharmaceutical companies and pharmaceutical factories are the main channels for absorbing such graduates. The demand for talents in the pharmaceutical industry is also growing steadily. According to reports, in recent years, the supply-demand ratio for graduate students in majors such as pharmaceutical preparations and natural medicinal chemistry has even reached 1:10. Employment direction of clinical pharmacy major: After graduation, students majoring in clinical medicine can engage in medical treatment, prevention, medical research, etc. in medical and health units, medical research and other departments. Employment positions: Medical representative, pharmaceutical sales representative, sales representative, sales manager, regional sales manager, investment manager, product manager, product specialist, nurse
