Uploaded image for project: 'RHEL'
  1. RHEL
  2. RHEL-5470

[BUG] Logrotate configuration for mysql does not work as advertised

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Undefined Undefined
    • rhel-9.7
    • rhel-9.3.0
    • mysql
    • None
    • None
    • rhel-sst-cs-databases
    • None
    • False
    • Hide

      None

      Show
      None
    • No
    • None
    • None
    • None
    • If docs needed, set a value
    • None

      Description of problem:
      The /etc/logrotate.d/mysqld configuration file has the following content:

      1. For the mysqladmin commands below to work, root account
      2. password is required. Use mysql_config_editor(1) to store
      3. authentication credentials in the encrypted login path file
      4. ~/.mylogin.cnf
        #
      5. Example usage:
        #
      6. mysql_config_editor set --login-path=client --user=root --host=localhost --password
        #
      7. When these actions has been done, un-comment the following to
      8. enable rotation of mysqld's log error.

      However, on RHEL 9 logrotate no longer runs under cron but rather under systemd. As such there is no $HOME variable for the logrotate process, which causes in turn for mysql_config_editor to have no $HOME variable. This has the effect of making /root/.mylogin.cnf to never be read so only this gets printed in the logs:

      logrotate[179140]: error: 'Access denied for user 'root'@'localhost' (using password: NO)'
      logrotate[179136]: error: error running non-shared postrotate script for /var/log/mysql/mysqld.log of '/var/log/mysql/mysqld.log '

      The workaround for this is to specify the HOME variable before both mysqladmin commands thus:

      if test -x /usr/bin/mysqladmin && \
      HOME=/root /usr/bin/mysqladmin ping &>/dev/null
      then
      HOME=/root /usr/bin/mysqladmin flush-logs
      fi

      Version-Release number of selected component (if applicable):
      mysql-server-8.0.32-1.el9_2.x86_64

      How reproducible:
      Every time

      Steps to Reproduce:
      1. Uncomment the /var/log/mysql/mysqld.log entry from /etc/logrotate.d/mysqld.
      2. Run the following command as advised in the logrotate configuration file:

      1. mysql_config_editor set --login-path=client --user=root --host=localhost --password
        3. Wait for logrotate to run

      Actual results:
      mysqld log does not rotate properly.

      Expected results:
      mysqld log should rotate properly.

      Additional info:
      This was not an issue in RHEL 7/8 as logrotate ran under cron and, while cron does have a very limited environment, the $HOME variable was being passed to logrotate.

      Also note, the package is mysql-server but for some reason it is not present in the component list.

              mschorm@redhat.com Michal Schorm
              rhn-support-jsantos Juan Santos
              Michal Schorm Michal Schorm
              Jakub Heger Jakub Heger
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated: