SOLVED - Slave server can't connect to database after upgrade

Discussion in 'ISPConfig 3 Priority Support' started by felan, Jul 26, 2019.

  1. felan

    felan Member HowtoForge Supporter

    Good afternoon.

    I have an odd problem. After upgrading to the newest version of ispconfig, I get the following errors on the slave server
    Code:
    Fri Jul 26 12:45:01 CEST 2019 PHP Warning:  mysqli_real_connect(): (HY000/1129): Host '88.99.123.137' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 85
    Fri Jul 26 12:45:01 CEST 2019 PHP Warning:  mysqli_real_connect(): (HY000/1129): Host '88.99.123.137' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 91
    Fri Jul 26 12:45:01 CEST 2019 PHP Warning:  mysqli_real_connect() expects parameter 1 to be mysqli, null given in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 275
    Fri Jul 26 12:45:02 CEST 2019 PHP Warning:  mysqli_real_connect() expects parameter 1 to be mysqli, null given in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 275
    Fri Jul 26 12:45:02 CEST 2019 Database connection failedPHP Warning:  mysqli_real_connect(): (HY000/1129): Host '88.99.123.137' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 91
    Fri Jul 26 12:45:03 CEST 2019 PHP Warning:  mysqli_real_connect() expects parameter 1 to be mysqli, null given in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 275
    Fri Jul 26 12:45:04 CEST 2019 PHP Warning:  mysqli_real_connect() expects parameter 1 to be mysqli, null given in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 275
    Fri Jul 26 12:45:04 CEST 2019 Database connection failedPHP Warning:  mysqli_real_connect(): (HY000/1129): Host '88.99.123.137' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 91
    Fri Jul 26 12:45:07 CEST 2019 Database connection failedPHP Warning:  mysqli_real_connect(): (HY000/1129): Host '88.99.123.137' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 91
    Fri Jul 26 12:45:09 CEST 2019 PHP Warning:  mysqli_real_connect() expects parameter 1 to be mysqli, null given in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 275
    Fri Jul 26 12:45:11 CEST 2019 Database connection failedPHP Warning:  mysqli_real_connect(): (HY000/1129): Host '88.99.123.137' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 91
    Fri Jul 26 12:45:11 CEST 2019 Database connection failedZugriff auf Datenbankserver fehlgeschlagen! / Database server not accessible!PHP Fatal error:  Uncaught Error: Call to a member function testConnection() on bool in /usr/local/ispconfig/server/server.php:64
    Fri Jul 26 12:45:11 CEST 2019 Stack trace:
    Fri Jul 26 12:45:11 CEST 2019 #0 {main}
    Fri Jul 26 12:45:11 CEST 2019 thrown in /usr/local/ispconfig/server/server.php on line 64
    Fri Jul 26 12:45:11 CEST 2019 PHP Warning:  mysqli_real_connect(): (HY000/1129): Host '88.99.123.137' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 85
    Fri Jul 26 12:45:11 CEST 2019 PHP Warning:  mysqli_real_connect(): (HY000/1129): Host '88.99.123.137' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 91
    Fri Jul 26 12:45:13 CEST 2019 Database connection failedPHP Warning:  mysqli_real_connect(): (HY000/1129): Host '88.99.123.137' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 91
    Fri Jul 26 12:45:14 CEST 2019 PHP Warning:  mysqli_real_connect() expects parameter 1 to be mysqli, null given in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 275
    Fri Jul 26 12:45:14 CEST 2019 db::_query -> reconnectPHP Warning:  mysqli_real_connect() expects parameter 1 to be mysqli, null given in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 275
    Fri Jul 26 12:45:15 CEST 2019 Database connection failedPHP Warning:  mysqli_real_connect(): (HY000/1129): Host '88.99.123.137' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 91
    Fri Jul 26 12:45:15 CEST 2019 PHP Warning:  mysqli_real_connect() expects parameter 1 to be mysqli, null given in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 275
    Fri Jul 26 12:45:16 CEST 2019 PHP Warning:  mysqli_real_connect() expects parameter 1 to be mysqli, null given in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 275
    Fri Jul 26 12:45:17 CEST 2019 PHP Warning:  mysqli_real_connect() expects parameter 1 to be mysqli, null given in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 275
    Fri Jul 26 12:45:18 CEST 2019 Database connection failedPHP Warning:  mysqli_real_connect(): (HY000/1129): Host '88.99.123.137' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts' in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 91
    Fri Jul 26 12:45:18 CEST 2019 PHP Warning:  mysqli_real_connect() expects parameter 1 to be mysqli, null given in /usr/local/ispconfig/server/lib/classes/db_mysql.inc.php on line 275
    The master server has no problems.

    I am using SSL on the MySQL connection from the slave to the master and added:
    Code:
    $conf['dbmaster_client_flags']         = MYSQLI_CLIENT_SSL;
    to both config files (in interface and server)
    Any ideas?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Did you unblock it with the command:

    mysqladmin flush-hosts

    on the master? Did you tryb to connect manually with the mysql command from slave to master to see if the connection is working?
     
  3. felan

    felan Member HowtoForge Supporter

    I've checked and the connection works fine, but the problem is the SSL connection to the master DB that's been altered. I'll mess with it a bit after the weekend and let you know what I find.

    Thanks again Till :)
     
    till likes this.
  4. felan

    felan Member HowtoForge Supporter

    Good morning :)
    I've looked a bit at things and I still can't really figure it out.
    If I set it up to run with SSL in /usr/local/ispconfig/server/lib/config.inc.php on the client server., using
    Code:
    $conf['dbmaster_client_flags']     = MYSQLI_CLIENT_SSL;
    and set the user to require SSL in MariaDB (10.3, Debian buster), I get the above error. As soon as I remove the argument and replace it with 0 as it is by default, and remove the requirement for SSL in MariaDB, it works perfectly.
    Any other ideas?
     
  5. till

    till Super Moderator Staff Member ISPConfig Developer

    No, not really. I've not used Mariadb with SSL on Buster yet. We did not change the mysql lib in ispconfig for quite a while, so my guess is that it's more related to the new MariaDB version or new PHP version than to the ISPConfig update.
     
  6. felan

    felan Member HowtoForge Supporter

    Well I upgraded to buster before the new version of ISPConfig came out and that still worked... So that's why it's surprising me that it's giving issues.
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    Ok. Then maybe its something with the ispcsrv* user in the master database, maybe settings got lost there when the user was recreated on update?
     
  8. felan

    felan Member HowtoForge Supporter

    No I've checked that one too. It's all as is should be.
     
    Last edited: Jul 29, 2019
  9. felan

    felan Member HowtoForge Supporter

    Good afternoon.
    Now that 3.1.15 is out, I tried to set up an SSL connection again between my slave server and master server, but still not luck. Same error as before.
    Still no idea about what this could be?
     
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    No. I don't use SSL with MySQL or MariaDB on my systems.
     
  11. felan

    felan Member HowtoForge Supporter

    Oki after a while, I've gotten time to look at this again and found a solution.

    On the master server
    You can't use Letsencrypt directly with mariadb, but you have to set up a script to copy the certs in and convert the key. It looks like this:
    Code:
    #!/bin/bash
    
    cp /etc/letsencrypt/live/example.com/chain.pem /etc/mysql/ssl/ispserver.ca
    cp /etc/letsencrypt/live/example.com/fullchain.pem /etc/mysql/ssl/ispserver.crt
    cp /etc/letsencrypt/live/example.com/privkey.pem /etc/mysql/ssl/ispserver.key
    openssl rsa -in /etc/mysql/ssl/ispserver.key -out /etc/mysql/ssl/ispserverrsa.key
    chown -R mysql:mysql /etc/mysql/ssl/
    Then add these lines to /etc/mysql/mariadb.conf.d/50-server.conv
    Code:
    ssl_cert = /etc/mysql/ssl/ispserver.crt
    ssl_key = /etc/mysql/ssl/ispserverrsa.key
    ssl_ca = /etc/mysql/ssl/ispserver.ca
    Restart MariaDB.
    Optional you can set up a cron job to run this script regularly

    On the slave server
    Edit /usr/local/ispconfig/server/lib/config.lib.php and change
    Code:
    $conf['dbmaster_client_flags']         = 0;
    to
    Code:
    $conf['dbmaster_client_flags'] = MYSQLI_CLIENT_SSL;
    (Remember this has to be re-added after ispconfig upgrade!)

    Change your remote mysql user on the master server to connect via SSL.

    And that works!
     
    till likes this.

Share This Page