Maintain the Binary Log on Query Servers

Use this procedure to purge the binary log of a query server platform that will have one or more daisy-chained query servers. (Perform this procedure on Query Servers B and D, as shown in Figure 1.)

Note: Monitor the binary log size and delete unnecessary binary log files on a weekly basis, following the steps listed below.
  1. Use the following commands to identify what log each daisy-chained query server is replicating from and record your findings:

    # cd /opt/mysql/mysql/bin

    # mysql -u root -p

    Enter password:

    <daisy-chained Query Server’s MySql root user password

    >mysql> SHOW SLAVE STATUS \G;

    mysql> exit;

  2. From Step 1, find the earliest log among all the daisy-chained query servers (if all the daisy-chained query servers are up-to-date, this is the last log on the list).

    On the query server that has query servers daisy-chained from it, list the binary log files. The target log is the one just before the earliest one in use.

    # cd /opt/mysql/mysql/bin

    # mysql -u root -p

    Enter password:

    <Query Server’s MySql root user password>

    mysql> SHOWMASTERLOGS;

  3. Use the following command to purge the master binary log files on the query server (that has one or more query servers daisy-chained from it) excluding the target log:

    mysql> PURGE MASTER LOGS TO '<binary_log_file>';