> For the complete documentation index, see [llms.txt](https://prosbcdocs.telcobridges.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://prosbcdocs.telcobridges.com/tmedia-documentation/server-and-os-administration/fn13763-mysql-binary-log-files-accumulate-and-fill-the-var-partition.md).

# FN13763 - MySQL binary log files accumulate and fill the /var partition

## Affected Products

* TMG800, TMG3200, TMG7800-CTRL
* Solution Developer (Tdev) Linux server with (CentOS, RedHat, etc) running Toolpack software

## Problem Symptoms

* The web portal become unaccessible or Toolpack application loose connection to the MySQL database.
* ssh is still accessible and /var is at 100% : \[root\@TB00xxxx]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda5 3.9G 1.1G 2.7G 29% / /dev/sda7 21G 3.7G 17G 19% /mnt/.0 /dev/sda6 2.0G 36M 1.9G 2% /tmp '''/dev/sda2 4.9G 4.6G 5.3M 100% /var''' /dev/sda1 494M 16M 453M 4% /boot tmpfs 997M 0 997M 0% /dev/shm

## Problem Description

The MySQL database binary log is a set of files that contain information about data modifications made by the MySQL server. The log consists of a set of binary log files, plus an index file. The log max files size is set by default to 1G. When it reaches that limit, another file is created. If those files are not purged from the system, if fill up the /var partition.

* System which are shipped before January 2013 requires this fix
* System installed by a solution developper following TelcoBridges wiki for MySQL server configuration (my.cnf) requires this fix
* This fix is applicable if the /etc/my.cnf **does not contain** the parameter 'expire\_logs\_days=30'

**To verify if this field notice apply to your system**

* ssh and login with root account grep 'expire\_logs\_days' /etc/my.cnf
* If grep does not return a value, apply the solution below.

## Solution

For the following procedure, you must first make sure that the management interface is named **'mgmt0**' on your system. Some Solution Developer systems or old version of TMG might have another name for the management interface.

* ssh and login with root account \[root\@TB00xxxx]# ifconfig | grep mgmt0 -A 1 mgmt0 Link encap:Ethernet HWaddr 4C:72:B9:7B:AE:C0 inet addr:192.168.3.180 Bcast:192.168.3.255 Mask:255.255.255.0
* If there is no output, [please contact TelcoBridges](https://github.com/telcobridges-main/tmedia-wiki/tree/main/reference/misc/contacting-telcobridges-technical-support/README.md) support.
* Follow the procedure bellow

### Step 1: Purge unneeded MySQL binary logs from /var

#### Procedure for TMG800, TMG3200, TMG7800-CTRL standalone or Toolpack running on 1 server

**Find latest log file**

* ssh and login with root account \[root\@TB00xxxx]# mysql -h `ifconfig | grep mgmt0 -A 1 | grep "inet addr" | sed 's/\s\+/:/g' | cut -d':' -f4` -u tbdb -ptbdbpw -e"show binary logs\G" | tail -n 2 Log\_name: mysqld-bin.000081 File\_size: 25334528

**Purge the logs**

* In the command bellow, change 'mysqld-bin.xxxxxx' for the value returned by the previous command (ie. mysqld-bin.000081) \[root\@TB00xxxx]# mysql -h `ifconfig | grep mgmt0 -A 1 | grep "inet addr" | sed 's/\s\+/:/g' | cut -d':' -f4` -u tbdb -ptbdbpw -e"PURGE BINARY LOGS TO 'mysqld-bin.xxxxxx';"

#### Procedure TMG800 1+1, TMG3200 1+1, TMG7800-CTRL redundant or Toolpack running HA on 2 servers

**Identify the slave and the master database unit**

To find which unit is the slave database, run the following commands on both 1+1 units, TMG7800-CTRLs or Toolpack HA servers:

* ssh and login with root account mysql -h `ifconfig | grep mgmt0 -A 1 | grep "inet addr" | sed 's/\s\+/:/g' | cut -d':' -f4` -u tbdb -ptbdbpw -e"show slave status\G" | grep Master\_Log\_File

The **Master database unit** returns **no value** and the **slave database unit** returns a value for **Master\_Log\_File** parameter.

**For example:**

Unit A output returns **nothing**

Unit B output returns: Master\_Log\_File: mysqld-bin.000012 Relay\_Master\_Log\_File: mysqld-bin.000012

\=> A is the master database unit

\=> B is the slave database unit

**Purge the master database unit logs**

* ssh to the master database unit and login with root account
* In the command bellow, change 'mysqld-bin.xxxxx' for the 'Master\_Log\_File' value returned by the slave database unit (ie. mysqld-bin.000012) mysql -h `ifconfig | grep mgmt0 -A 1 | grep "inet addr" | sed 's/\s\+/:/g' | cut -d':' -f4` -u tbdb -ptbdbpw -e"PURGE BINARY LOGS TO 'mysqld-bin.xxxxx';"

**Purge the slave database unit logs**

* ssh to the slave database unit and login with root account
* Execute the following commands to show the latest log: \[root\@TB00xxxx]# mysql -h `ifconfig | grep mgmt0 -A 1 | grep "inet addr" | sed 's/\s\+/:/g' | cut -d':' -f4` -u tbdb -ptbdbpw -e"show binary logs\G" | tail -n 2 Log\_name: mysqld-bin.000010 File\_size: 43248618
* In the command bellow, change 'mysqld-bin.xxxxx' for the value returned by the previous command (ie. mysqld-bin.000010) \[root\@TB00xxxx]# mysql -h `ifconfig | grep mgmt0 -A 1 | grep "inet addr" | sed 's/\s\+/:/g' | cut -d':' -f4` -u tbdb -ptbdbpw -e"PURGE BINARY LOGS TO 'mysqld-bin.xxxxx';"

### Step 2: Modify /etc/my.cnf

* ssh to the units and login with root account cp /etc/my.cnf /etc/my.bak.cnf cat /etc/my.bak.cnf | sed -r 's/(\[mysqld].\*)$/\1\nexpire\_logs\_days=30/g' > /etc/my.new\.cnf cp /etc/my.new\.cnf /etc/my.cnf

**Note:** must be executed on both units in case of TMG800 1+1, TMG3200 1+1, TMG7800-CTRL redundant or Toolpack running HA on 2 servers.

### Step 3: Change "expire\_logs\_days=30" on current running instance

* ssh to the units and login with root account mysql -h `ifconfig | grep mgmt0 -A 1 | grep "inet addr" | sed 's/\s\+/:/g' | cut -d':' -f4` -u tbdb -ptbdbpw -e"SET GLOBAL expire\_logs\_days=30"

**Note:** must be executed on both units in case of TMG800 1+1, TMG3200 1+1, TMG7800-CTRL redundant or Toolpack running HA on 2 servers.

## Validate

* ssh to the units and login with root account \[root\@TB00xxxx]# grep 'expire\_logs\_days' /etc/my.cnf expire\_logs\_days=30

  \[root\@TB00xxxx]# mysql -h `ifconfig | grep mgmt0 -A 1 | grep "inet addr" | sed 's/\s\+/:/g' | cut -d':' -f4` -u tbdb -ptbdbpw -e"SHOW VARIABLES LIKE 'expire\_logs\_days'" +------------------+-------+ | Variable\_name | Value | +------------------+-------+ | expire\_logs\_days | 30 | +------------------+-------+

## References

MySQL PURGE BINARY LOGS Syntax <https://dev.mysql.com/doc/refman/5.0/en/purge-binary-logs.html>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://prosbcdocs.telcobridges.com/tmedia-documentation/server-and-os-administration/fn13763-mysql-binary-log-files-accumulate-and-fill-the-var-partition.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
