SAVE_BINARY_LOGS(1p)

πŸ“¦
version 0.58 Β· 3 versions
, in debian trixie, ubuntu noble, ubuntu questing

✨ SAVE_BINARY_LOGS(1p) ✨

okay bestie, so this is save_binary_logs from the User Contributed Perl Documentation crew πŸ’… β€” literally a lil script that saves your bacon after a master goes down. no cap.


πŸ’– NAME πŸ’–

save_binary_logs β€” Concatenating binary or relay logs from the specified file/position to the end of the log. This command is automatically executed from MHA Manager on failover, and manual execution should not be needed normally.

like. it does the thing by itself, you're just here to understand it 🫢


🌸 SYNOPSIS 🌸

okay so first, the test vibe check:

# Test

$ save_binary_logs --command=test  --binlog_dir=/var/lib/mysql
--start_file=mysqld-bin.000002

then the actual saving of binary logs, the main character moment:

# Saving binary logs

$ save_binary_logs --command=save --binlog_dir=/var/lib/mysql
--start_file=mysqld-bin.000002 --start_pos=312
--output_file=/var/tmp/aggregate.binlog

and the relay-log flavor πŸ¦‹:

# Saving relay logs

$ save_binary_logs --command=save --start_file=mysqld-relay-bin.000002
--start_pos=312 --relay_log_info=/var/lib/mysql/relay-log.info
--output_file=/var/tmp/aggregate.binlog

so basically save_binary_logs concatenates binary or relay logs from the specified log file/position to the end of the log. This tool is intended to be invoked from the master failover script(MHA Manager), and manual execution is normally not needed. it's giving "let the automation cook" πŸ”₯


πŸŽ€ DESCRIPTION πŸŽ€

okay imagine this: master is crashed πŸ’€ and the latest slave server has received binary logs up to mysqld-bin.000002:312. It is likely that master has more binary logs. If it is not sent to the slave, slaves will lose all binlogs from mysqld-bin.000002:312. and that's the whole reason save_binary_logs exists β€” its purpose is to save binary logs that are not replicated to slaves. If master is reachable through SSH and binary logs are readable, saving binary logs is possible. periodt. πŸ‘‘

here's an example, bestie:

$ save_binary_logs --command=save --start_file=mysqld-bin.000002
--start_pos=312 --output_file=/var/tmp/aggregate.binlog

Then all binary logs starting from mysqld-bin.000002:312 are concatenated and stored into /var/tmp/aggregate.binlog. If you have binary logs up to mysqld-bin.000004, the following mysqlbinlog outputs are written.

  • mysqld-bin.000002:Format Description Event(FDE), plus from 312 to the tail
  • mysqld-bin.000003:from 0 to the tail, excluding FDE
  • mysqld-bin.000004:from 0 to the tail, excluding FDE

like yes, it's stitching them together and skipping the FDE duplicates β€” obsessed honestly 🧚


and that's the whole page, bestie!! this was perl v5.36.0, dated 2023-10-03 β€” shoutout to the SAVE_BINARY_LOGS(1p) era πŸ’œ mwah, go save some binlogs ✨🌈

πŸ“¦ where this page comes from