주 콘텐츠로 건너뛰기

Binary logs

Database에서
저자 리스트
발표됨: 2023년 5월 16일|최종 업데이트됨: 2023년 7월 19일

By default, MySQL 8 sets binary log retention to 2592000 seconds (30 days) and the maximum size of each binary log to 1GB.

This can mean that the MySQL binary logs can consume a large amount of space on your server with the default settings - especially on very active databases.

Manually purging binary logsCopy link to Manually purging binary logs to clipboard

If you need to clear space immediately on your server, you can also manually clear the binary logs by issuing the following command in a MySQL prompt:

mysql> PURGE BINARY LOGS BEFORE NOW() - INTERVAL 3 DAY;
copy

This would clear any binary logs older than 3 days. You can adjust the interval as required so that you can clear the desired amount of space.


Setting log retention periodCopy link to Setting log retention period to clipboard

If space is a long-term concern, you can reduce the retention period by setting the binlog_expire_logs_seconds to less than 30 days (e.g. 259200 seconds - 3 days). This will then consume less space on disk whilst still enabling you to setup replication on your MySQL database.

To change this setting in the OPC, you can add this setting to the custom database configuration on the database page:

  1. Navigate to the database you want to change the settings for in the navigation menu:

    database menu item
  2. Click the "Edit" button a the bottom of the page:

    edit database button
  3. Enter the configuration settings you wish to apply in the text box and click "Save Changes":

    update mysqld config
[mysqld] binlog_expire_logs_seconds = 259200
copy
  1. The progress screen will confirm that changes have been applied:

    update database progress
  2. You can then view the updated settings on the database information page:

    updated settings
도움이 되었습니다도움이 되지 않음
다음 페이지Reclaiming disk space from the database

댓글을 작성하려면 로그인하거나 등록하셔야 합니다.