问题原文
原帖链接 · the_nuts · CC BY-SA 4.0
We have only 450 GB nvme space on our master server and the binlogs are using a lot of space, even if they are kept for only two days.
Does writing the MySQL binlogs to a slower disk (like a remote directory) slow down the MySQL performance?
社区高分解答
原帖链接 · HBruijn · CC BY-SA 4.0
Binary logging is done immediately after a statement or transaction completes but before any locks are released or any commit is done, so I imagine that placing your logs on a slower disk can have an impact as other transactions will be delayed until the current transaction is logged.
I would keep your binary logs on your fastest storage, but reduce the amount of logs on the flash drive by keeping only those that are still required for replication.
You can automate and more frequently run the procedure for purging logs as outlined in the manual and delete all logs that are no longer needed because the slaves have processed them.
On each slave server, use
SHOW SLAVE STATUSto check which log file it is reading.Obtain a listing of the binary log files on the master server with
SHOW BINARY LOGS.Determine the earliest log file among all the slaves. This is the target file. If all the slaves are up to date, this is the last log file on the list.
Make a backup of all the log files you are about to delete. (This step is optional, but always advisable.)
Purge all log files up to but not including the target file.
If you want to retain more logs, for instance for auditing purposes, in step 4 copy those logs to a slower (spinning) disk before deleting them from your flash drive with the PURGE BINARY LOGS TO or PURGE BINARY LOGS BEFORE MySQL statement.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
