geerlingguy / ansible-role-mysql

Ansible Role - MySQL
https://galaxy.ansible.com/geerlingguy/mysql/
MIT License
1.05k stars 865 forks source link

unknown option '--syslog' #440

Closed kraxor closed 3 years ago

kraxor commented 3 years ago

Following the main README.md I'm trying to get a very basic mysql setup that logs to syslog on a fairly clean Ubuntu 20.04 virtual machine. My vars:

mysql_root_password: "{{secret_root_password}}"                                                                                    
mysql_root_password_update: yes                                                                                                    

mysql_log: syslog                                                                                                                  
mysql_log_error: syslog                                                                                                            
mysql_syslog_tag: mysql                                                                                                            

mysql_databases:                                                                                                                   
  - name: test                                                                                                                     

mysql_users:                                                                                                                       
  - name: test                                                                                                                     
    host: "{{hostvars[inventory_hostname]['private_ip'] | regex_replace('\\.[0-9]*$', '.0/255.255.255.0')}}"                       
    password: "{{secret_test_password}}"                                                                                           
    priv: "test.*:ALL"                                                                                                             

...but mysql fails to start:

$ systemctl status mysql.service
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: activating (start) since Wed 2021-03-31 13:30:32 UTC; 1s ago
    Process: 12330 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 12338 (mysqld)
     Status: "Server startup in progress"
      Tasks: 30 (limit: 1136)
     Memory: 317.9M
     CGroup: /system.slice/mysql.service
             └─12338 /usr/sbin/mysqld

Mar 31 13:30:32 mercy-vagrant systemd[1]: Starting MySQL Community Server...
Mar 31 13:30:33 mercy-vagrant mysqld[12338]: 2021-03-31T13:30:33.201334Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic link>
Mar 31 13:30:33 mercy-vagrant mysqld[12338]: 2021-03-31T13:30:33.202906Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld >
Mar 31 13:30:33 mercy-vagrant mysqld[12338]: 2021-03-31T13:30:33.233786Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has>
Mar 31 13:30:33 mercy-vagrant mysqld[12338]: 2021-03-31T13:30:33.415970Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has>
Mar 31 13:30:33 mercy-vagrant mysqld[12338]: 2021-03-31T13:30:33.535898Z 0 [System] [MY-011323] [Server] X Plugin ready for connec>
Mar 31 13:30:33 mercy-vagrant mysqld[12338]: 2021-03-31T13:30:33.634323Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is>
Mar 31 13:30:33 mercy-vagrant mysqld[12338]: 2021-03-31T13:30:33.634559Z 0 [System] [MY-013602] [Server] Channel mysql_main config>
Mar 31 13:30:33 mercy-vagrant mysqld[12338]: 2021-03-31T13:30:33.639537Z 0 [ERROR] [MY-000068] [Server] unknown option '--syslog'.
Mar 31 13:30:33 mercy-vagrant mysqld[12338]: 2021-03-31T13:30:33.640234Z 0 [ERROR] [MY-010119] [Server] Aborting
kraxor commented 3 years ago

Moving the related entries in /etc/mysql/my.cnf from the [mysqld] section to the [mysqld_safe] section seems to solve the issue:

[mysqld_safe]
pid-file = /var/run/mysqld/mysqld.pid
syslog
syslog-tag = mysql

Perhaps this should be done automatically when mysql_log is set to syslog?

kraxor commented 3 years ago

After some more digging I found this:

Using these options to control mysqld logging is deprecated as of MySQL 5.7.5. Use the server log_syslog system variable instead. To control the facility, use the server log_syslog_facility system variable. (https://dev.mysql.com/doc/refman/5.7/en/mysqld-safe.html#option_mysqld_safe_syslog)

Details on log_syslog: https://dev.mysql.com/doc/refman/5.7/en/error-log-syslog.html

kraxor commented 3 years ago

... and then they changed it again in 8.0.13: https://dev.mysql.com/doc/refman/8.0/en/error-log-syslog.html

Going to give up for now, because a proper solution would require version-specific changes in my.cnf and I don't have the free capacity to test with different versions of mysql. The workaround provided in PR #441 should work with all versions, even though it uses a deprecated method.

stale[bot] commented 3 years ago

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

stale[bot] commented 3 years ago

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.

kraxor commented 3 years ago

You're stale.