Ad Widget

Collapse

Zabbix and MySQL Multi instances issue with the frontend Apache/PHP

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • FMJ
    Junior Member
    • Aug 2021
    • 7

    #1

    Zabbix and MySQL Multi instances issue with the frontend Apache/PHP

    Hello,

    I've installed a Zabbix server in version 5.4 with a debian 10 (no SELinux), MySQL and Apache2. In standard configuration, everything works fine and I could move the repository of this default instance on a dedicated partition.

    Then I've wanted to share this Zabbix server host (a VM in fact) with a Syslog Server, with 2 separated MySQL database repositories. And so I had to change :
    > MySQL config file /etc/mysql/my.cnf :
    - comment the [mysqld] group which is no more usefull
    - create the [mysql_multi] group
    - create the [mysql1] group pour the Zabbix instance (datadir, socket and port are specific)
    - create the [mysql2] group pour the Syslog instance (datadir, socket and port are specific)
    --> I could start both instances sucessfully
    > Zabbix-server config file /etc/zabbix/zabbix_server.conf
    - change the DBSocket and the DBPort (the DBName and other MySQL parameters remain the same)
    --> Zabbix Server starts without error, even with a DBName=4

    So it looks like the relation between Zabbix Server and MySQL is OK : zabbix data polling is well stored in MySQL Zabbix database.

    But when I try to connect the Zabbix management page (HTTP://[ServerHost]/zabbix), it shows a "Database error : No such file or directory".
    So I suspected an issue between the frontend and Mysql.

    Indeed I found the Zabbix PHP config file /etc/zabbix/web/zabbix.conf.php where I could change the $DB['PORT'] parameter. But this config file doesn't refer to the MySQL socket.
    So I investigated a bit further and thanks to this post (https://www.zabbix.com/forum/zabbix-...mote-db-server) I found this PHP config file /etc/php/7.3/cli/php.ini where I changed 2 socket parameters :
    > pdo_mysql.default_socket= /var/run/mysqld/mysqld1.sock
    > mysqli.default_socket = /var/run/mysqld/mysqld1.sock
    where mysqld1.sock is off course the specific socket used for the dedicated Zabbix Server MySQL instance.

    But the issue remains the same : "Database error : No such file or directory" on the frontend. While Apache2 doesn't show any error in its logs (the HTML page is correctly rendered).

    Any suggestion to solve this issue would be appreciated. Thanks !
  • FMJ
    Junior Member
    • Aug 2021
    • 7

    #2
    Note that when you set DBHost=localhost (or 127.0.0.1) in my.cnf, MySQL will automatically use the socket parameter (then DBPort becomes useless). And when you set DBHost=[Host IP], it uses a TCP connection (then the DBSocket becones useless).

    So I tried to use the TCP connexion instead of the socket one (so with DBHost=[Host IP])--> and it works fine. But I think I would be a bit stupid to use the IP stack for an internal connection, in term of performance
    And now I'm more convinced there's an issue with the socket parameter in PHP but I don't know how to fix it ???!!!!


    Note 2 : if the Mysql Server is remonte to Zabbix Server (or Apache Server), you have to change the zabbix user in Zabbix MySQL instance : from 'zabbix'@'localhost' to 'zabbix'@'[host IP]' (or more generally 'zabbix'@'%', but less secure). And if you feel around to find the right parameters, your MySQL connection could be blocked. Use the tool 'mysqladmin flush-hosts' to unblock it and restart Zabbix-server or Apache service.

    Comment

    • FMJ
      Junior Member
      • Aug 2021
      • 7

      #3
      Today I tried again. I changed $DB['SERVER'] to localhost in /etc/zabbix/web/zabbix.conf.php and pdo_mysql.default_socket and mysqli.default_socket to /var/run/mysqld/mysqld1.sock + restart apache2. End this time it works ! But don't know why ?!
      Note1 : Zabbix only uses the mysqli.default_socket parameter (not the pdo_mysql one).
      Note2 : I tried to activate error logging with php.ini but this generates none log !
      Last edited by FMJ; 30-08-2021, 10:47.

      Comment

      Working...