Ad Widget

Collapse

Zabbix disk space eaten by mySQL .bin files

Collapse
This topic has been answered.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Liam92
    Junior Member
    • Apr 2022
    • 2

    #1

    Zabbix disk space eaten by mySQL .bin files

    Hi all,

    Version: Zabbix 5.4.10
    OS: CentOS 8

    I'm very new to Linux - in fact the first time I've spent more than 10min working with Linux is when I started configuring Zabbix a few months back so apologies for the potentially very noob question. I've spent a few hours trying to find a way to stop the disk filling up in my Zabbix VM but I'm admitting defeat.

    Believe it or not it's not related to housekeeper - I've narrowed it down to the ever expanding .bin files located in /var/lib/mysql. they're constantly filling up and require me to run the below command in mySQL to purge them every few weeks.

    PURGE BINARY LOGS BEFORE '2022-04-10'

    I've not been able to find what change I need to make in what config file, or what command I need to run to stop these .bin files generating completely, or even just to set some kind of retention so the disk doesn't eventually fill up.

    I tried running the below command, which appeared to work, until I noticed that it was not being saved after a restart of mySQL

    SET @@global.binlog_expire_logs_seconds=86400;

    Any advice is appreciated. Thanks!

    Liam
    Last edited by Liam92; 22-04-2022, 08:22.
  • Answer selected by Liam92 at 27-04-2022, 01:47.
    tim.mooney
    Senior Member
    • Dec 2012
    • 1427

    You don't say what version of MySQL you're using, but with CentOS 8 you probably have both a '/etc/my.cnf' and a directory /etc/my.cnf.d. If that's the case, create a text file named something like:

    Code:
    /etc/my.cnf.d/mysql-local-settings.cnf
    In that text file, add:

    Code:
    [mysqld]
    
    # expire binary logs every day
    binlog_expire_logs_seconds=86400
    This is equivalent to the dynamic setting you listed above.

    Comment

    • tim.mooney
      Senior Member
      • Dec 2012
      • 1427

      #2
      You don't say what version of MySQL you're using, but with CentOS 8 you probably have both a '/etc/my.cnf' and a directory /etc/my.cnf.d. If that's the case, create a text file named something like:

      Code:
      /etc/my.cnf.d/mysql-local-settings.cnf
      In that text file, add:

      Code:
      [mysqld]
      
      # expire binary logs every day
      binlog_expire_logs_seconds=86400
      This is equivalent to the dynamic setting you listed above.

      Comment

      • Liam92
        Junior Member
        • Apr 2022
        • 2

        #3
        Originally posted by tim.mooney
        You don't say what version of MySQL you're using, but with CentOS 8 you probably have both a '/etc/my.cnf' and a directory /etc/my.cnf.d. If that's the case, create a text file named something like:

        Code:
        /etc/my.cnf.d/mysql-local-settings.cnf
        In that text file, add:

        Code:
        [mysqld]
        
        # expire binary logs every day
        binlog_expire_logs_seconds=86400
        This is equivalent to the dynamic setting you listed above.
        Thanks heaps Tim! I've done that and it looks like it's worked.

        Comment


        • tim.mooney
          tim.mooney commented
          Editing a comment
          You're welcome.

          You may want to read up on what the MySQL/MariaDB binlog files are for, and why you generally don't want to clear older binary logs until you have them backed up. It's arguably less important for a Zabbix install than for most other applications that use MySQL/MariaDB, but it still helps to have an idea the purpose they serve.
      Working...