Binarylog processing of MySQL

Source: Internet
Author: User

During busy periods, the new server and app will be renewed. In addition, many configurations will be changed when the company moves at the end of the month.
In the morning, when you do not want to change the dns via telnet, it is found that the MySQL daily quota is very large... It's strange that I have changed all settings ..
Later, it was found that this machine was brought by a subsidiary .... In the past, the configurations were not completed. Let's sort them out today and share them with you.

 

1. Clear the current BINLOG first:

$ Mysql-uroot-p
Login using secret and secret

Mysql>SHOW MASTER LOGS; Begin indicates LOG first
+ ------------------------ + ------------ +
| Log_name | File_size |
+ ------------------------ + ------------ +
| Mysql-bin.000001 | 74149684 |
| Mysql-bin.000002 | 73741963 |
| Mysql-bin.000003 | 73742026 |
| Mysql-bin.000004 | 73741905 |
:
| Mysql-bin.000065 | 3273742014 |
| Mysql-bin.000066 | 98746708 |
+ ------------------------ + ------------ +
66 rows in set (0.00 sec)

 

Except LOG

Except for a certain day's hosts file:
Mysql> purge master logs to 'mysql-bin.000066 ';
Except all the day before the first day:
Mysql> purge binary logs before DATE_SUB (NOW (), INTERVAL7DAY );

Except all day-olds before a certain day
Mysql> purge master logs before '2017-03-19 00:00:00 ';

When the division is complete, set it to your own.
In the/etc/my. cnf file, locate the mysql configuration file:

# Here follows entries for some specific programs
# The MySQL server
[Mysqld]
Default-character-set = utf8
Port = 3306
Socket =/tmp/mysql. sock

... ...

# Replication Master Server (default)
# Binary logging is required for replication
LOg-bin = mysql-bin
... ...

Then, add the following content:

 

 Expire_logs_days = 30(Number of days in which the BINLOG is automatically deleted)

Modify my. cnf and then restart MySQL !!! Note:

 

You can directly modify the MySQL variable volume environment:
$ Mysql-uroot-p
Mysql> SETGLOBALExpire_logs_days = 30;
|
This does not require restart

 

Remember not to confirm after modification:

Mysql>Show global variablesLike 'expire % ';
+ ------------------ + ------- +
| Variable_name | Value |
+ ------------------ + ------- +
| Expire_logs_days | 30 |
+ ------------------ + ------- +

Hope to help you

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.