Purge MYSQL Binary Logs On TMG
From TBwiki
(Difference between revisions)
Nicole Tan (Talk | contribs) (NT: Created the new page) |
(Redirect to a field notice page with more details) |
||
(4 intermediate revisions by one user not shown) | |||
Line 1: | Line 1: | ||
− | This page shows how to manually | + | #REDIRECT [[FN13763]] |
+ | This page shows how to manually erase MYSQL Binary Logs On TMG to save your hard disk space | ||
<br> | <br> | ||
+ | You need to SSh to the TMG host for the following procedures: | ||
== Verify your hard disk space == | == Verify your hard disk space == | ||
+ | [root@TB00xxxx mysql]# 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 | ||
== MYSQL binlogs location == | == MYSQL binlogs location == | ||
+ | The directory of MYSQL binlogs is defined at /etc/my.cnf | ||
+ | |||
+ | [mysqld] | ||
+ | |||
+ | datadir=/var/lib/mysql | ||
== Purge unnecessary binlogs == | == Purge unnecessary binlogs == | ||
1. Access mysql database | 1. Access mysql database | ||
− | mysql -u user –ppassword | + | mysql -u user –ppassword |
− | e.g. mysql -u tbdb –ptbdbpw | + | e.g. mysql -u tbdb –ptbdbpw |
2. Execute the Purge command: | 2. Execute the Purge command: | ||
− | + | To erase all binlogs before a specific binlog file: | |
− | To erase all binlogs before a specific binlog file: | + | PURGE BINARY LOGS TO 'mysql-bin.010'; |
− | PURGE BINARY LOGS TO 'mysql-bin.010 | + | |
− | + | ||
− | + | ||
+ | To erase all binlogs before a specific Date/Time: | ||
+ | PURGE BINARY LOGS BEFORE '2015-04-02 22:46:26'; | ||
== Expire binary log files automatically == | == Expire binary log files automatically == | ||
Line 25: | Line 39: | ||
[mysqld] | [mysqld] | ||
expire-logs-days=60 | expire-logs-days=60 | ||
− | Note: a 60 days rotation log is enabled by default in more recent TB products. | + | **Note: a 60 days rotation log is enabled by default in more recent TB products. |
Restart mysql | Restart mysql | ||
+ | service mysqld restart | ||
Then mysqld will delete them for you automatically | Then mysqld will delete them for you automatically |
Latest revision as of 12:10, 20 July 2015
- REDIRECT FN13763
This page shows how to manually erase MYSQL Binary Logs On TMG to save your hard disk space
You need to SSh to the TMG host for the following procedures:
Contents |
Verify your hard disk space
[root@TB00xxxx mysql]# 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
MYSQL binlogs location
The directory of MYSQL binlogs is defined at /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
Purge unnecessary binlogs
1. Access mysql database
mysql -u user –ppassword e.g. mysql -u tbdb –ptbdbpw
2. Execute the Purge command:
To erase all binlogs before a specific binlog file: PURGE BINARY LOGS TO 'mysql-bin.010';
To erase all binlogs before a specific Date/Time: PURGE BINARY LOGS BEFORE '2015-04-02 22:46:26';
Expire binary log files automatically
You can also set the expire_logs_days system variable to expire binary log files automatically after a given number of days. Simply add this to /etc/my.cnf
[mysqld] expire-logs-days=60
- Note: a 60 days rotation log is enabled by default in more recent TB products.
Restart mysql service mysqld restart
Then mysqld will delete them for you automatically