How to clean up large TiDB logs

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: tidb日志很大了怎么清理

| username: zhanggame1

[TiDB Usage Environment] Production Environment / Testing / PoC
[TiDB Version] 7.1
[Reproduction Path]
[Encountered Problem: Problem Phenomenon and Impact]
The tidb.log and slow logs under the tidb node have recently grown very large. I want to clean them up. Should I delete them directly or stop the tidb node service before deleting?

| username: hey-hoho | Original post link

Keep the latest one, the old ones can be deleted directly.

There are parameters in the configuration file to configure the log retention time or retention quantity:

| username: zhanggame1 | Original post link

Thank you, so just set the parameters to enable automatic cleanup, right?

| username: redgame | Original post link

Just delete it.

| username: Kongdom | Original post link

You can just delete it directly, classmate.

| username: linnana | Original post link

It’s best to back up before deleting in the production environment.

| username: liuis | Original post link

Just delete the most recent log errors.

| username: maokl | Original post link

You can set the retention days and the number of retained files.

| username: xingzhenxiang | Original post link

Delete while retaining for seven days

| username: Anna | Original post link

log.file

Configuration items related to log files.

filename

  • The name of the general log file.
  • Default value: “”
  • If set, general logs will be output to this file.

max-size

  • The size limit of the log file.
  • Default value: 300
  • Unit: MB
  • The maximum setting limit is 4096.

max-days

  • The maximum number of days to retain logs.
  • Default value: 0
  • By default, logs are not cleaned; if a parameter value is set, TiDB will clean up expired log files after max-days.

max-backups

  • The maximum number of log backups to retain.
  • Default value: 0
  • By default, all logs are saved; if set to 7, a maximum of 7 old log files will be retained.
| username: system | Original post link

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.