Wrong path in the /etc/logrotate.d/mysql and /etc/my.cnf configuration files

Description

Install percona-server-server-8.0.32-24.1.el9.x86_64.rpm on the Rocky Linux from official Percona Server for MySQL repo.

In the provided in the rpm  default ```/etc/my.cnf``` file I see:

```

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

```

But in the ```/etc/logrotate.d/mysql``` I can see different path: ```/var/lib/mysql/mysqld.log```.

This is means, what ```/etc/logrotate.d/mysql``` configuration file is totally useless, because  it never can rotate the ```/var/log/mysqld.log``` mysqld error log.

Path ```/var/lib/mysql/mysqld.log``` in the ```/etc/logrotate.d/mysql``` is wrong, because logs should be stored inside ```/var/log/``` but not nside ```/var/lib/```.

 

Also it will be very good, if ```slow-query-log-file=/var/log/mysqld-slow.log``` also will be included in the ```/etc/my.cnf``` file, disabled by default, for example like this:

```

slow_query_log=OFF
slow_query_log_file = /var/log/mysqld-slow.log
```

and in rpm file as zero length file with mysql:mysql owner and 0600 permissions.

this will greatly simplify Percona Server for MySQL usagage, especially for new users.

Ideally, log file ```/var/log/mysqld-slow.log``` should be also included in the ```/etc/logrotate.d/mysql``` config for no need for manual logrotate configuration in the future.

 

Proposed variant of ```/etc/logrotate.d/mysql``` configuration file for including in the future releases of Percona Server for MySQL:

```
/var/log/mysqld.log
/var/log/mysqld-slow.log
{
        create 600 mysql mysql
        notifempty
        daily
        rotate 5
        missingok
        #compress
        nodateext
    postrotate
    # just if mysqld is really running
    if test -x /usr/bin/mysqladmin && \
       /usr/bin/mysqladmin ping &>/dev/null
    then
       /usr/bin/mysqladmin flush-logs
    fi
    endscript
}

```

compression is disabled by default for easy of view and analyze logs with percona-tools,

nodateext is set for more beautiful look of files in the /var/log/ directory. For example:

 

```

  1. ls -la /var/log/mysql*
    rw------ 1 mysql mysql         0 Mar 31 03:27 /var/log/mysqld.log
    rw------ 1 mysql mysql       222 Mar 30 09:27 /var/log/mysqld.log.1
    rw------ 1 mysql mysql       222 Mar 28 10:40 /var/log/mysqld.log.2
    rw------ 1 mysql mysql       222 Mar 24 11:36 /var/log/mysqld.log.3
    rw------ 1 mysql mysql       222 Mar 23 17:41 /var/log/mysqld.log.4
    rw------ 1 mysql mysql       222 Mar 22 11:09 /var/log/mysqld.log.5
    rw------ 1 mysql mysql 710046076 Apr 24 01:07 /var/log/mysqld-slow.log
    rw------ 1 mysql mysql 820775869 Apr 23 03:32 /var/log/mysqld-slow.log.1
    rw------ 1 mysql mysql 760071061 Apr 22 03:08 /var/log/mysqld-slow.log.2
    rw------ 1 mysql mysql 833239054 Apr 21 03:36 /var/log/mysqld-slow.log.3
    rw------ 1 mysql mysql 792484303 Apr 20 03:39 /var/log/mysqld-slow.log.4
    rw------ 1 mysql mysql 799129876 Apr 19 03:35 /var/log/mysqld-slow.log.5

```

P.S.

 

Also, ```pid-file=/var/run/mysqld/mysqld.pid``` - is the wrong setting.

 

May be it will me better to use just ```pid-file=/run/mysqld/mysqld.pid``` ?

Because /var/run is just symlink to the ```../run``` on the all modern distros.

 

In the configuration file ```/usr/lib/tmpfiles.d/mysql.conf ``` already right path, for creating ```/run/mysqld``` directory: ```d /run/mysqld 0755 mysql mysql  -```.

 

In the rpm file directory ```/var/run/mysqld``` is useless, because if you remove file ```/usr/lib/tmpfiles.d/mysql.conf ``` on the package uninstall - this directory ```/var/run/mysqld``` fill not be more created on the ```/run``` tmpfs filesystem after reboot.

 

Can you please fix these packaging bugs and errors in the Percona Server for MySQL rpm?

 

Environment

Rocky Linux 9.1

 

percona-server-server-8.0.32-24.1.el9.x86_64.rpm from the official Percona Server for MySQL repo.

Activity

Show:

Aaditya Dubey February 20, 2024 at 7:56 AM

Hi

Verified as described.
Thank you Connecting Percona!

Gena Makhomed May 8, 2023 at 8:51 PM

in rpm file percona-server-server-8.0.32-24.1.el9.x86_64.rpm

/etc/my.cnf

log-error=/var/log/mysqld.log

/etc/logrotate.d/mysql

/var/lib/mysql/mysqld.log

 

Percona Server write log files to /var/log/mysqld.log, logrotate expect log file at /var/lib/mysql/mysqld.log - this lead what log file /var/log/mysqld.log was never been seen by logrotate and never be rotated, this is bug - misconfiguration, logrotate config should also point to /var/log/mysqld.log path, not only /etc/my.cnf config.

 

/var/lib/mysql/ path not for log files, /var/lib/mysql/ path is for database files, see https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard for details. MySQL log files should be placed inside /var/log/ directory, not inside /var/lib/mysql/

 

Also warning in error log "Insecure configuration for --secure-log-path: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path" is stupid, because log file will have permissions 0600 and only mysql user can have access to log file, more details about this bug in the ticket https://jira.percona.com/browse/PS-8733

 

Aaditya Dubey April 24, 2023 at 8:13 AM

Hi ,

Thank you for the report.
Could you please let us know what error is being thrown for this set-up?

Done

Details

Assignee

Reporter

Needs QA

Yes

Components

Priority

Smart Checklist

Created April 23, 2023 at 10:28 PM
Updated August 6, 2024 at 3:16 PM
Resolved August 6, 2024 at 3:15 PM