Multiserver Databases

Discussion in 'ISPConfig 3 Priority Support' started by BobGeorge, Sep 6, 2017.

  1. BobGeorge

    BobGeorge Member HowtoForge Supporter

    I've got a multi-server setup with load-balancing on the frontend (LVS-DR) and a shared storage server on the backend (NFS).

    I've set it up so that the storage server is the DB server for the cluster (this is so that the databases can be stored along with the website files and emails on a RAID array that'll get routinely backed up over the network).

    I'm transferring some websites from our old server (which was just a single PC server, set up with Webmin) and these websites use Wordpress.

    So I used the APS installer to add Wordpress to the website and then, from within Wordpress, used the "Duplicator" plugin to shift the website files and database from the old machine to the new servers.

    This didn't entirely work as the "wp-config.php" had "localhost:3306" as the db host, so it created the DB on the node that just happened to be chosen by the load balancer to handle the request. So, we had the problem that this one node would show the website correctly, but if another node was chosen by the load balancer, it wouldn't find the database tables and showed the Wordpress install page. Not good.

    Basically, when I use the APS installer to install Wordpress, it seems to always use "localhost:3306". This isn't right for my setup.

    Also, if I manually change that to the IP address of the storage server "" then I get "error connecting to database". If I go to the database settings, then I can enable "remote access" and add the IP addresses of the web servers in the cluster, then it works.

    So I can manually make this work but this procedure is a little awkward and I have to consider that we're going to have resellers - web designers - also using this system and I can't really have them jumping through these hoops every time.

    Is there a way to make the APS installer for Wordpress use the DB server's address automatically and then also automatically make the database "remote access" by the web servers in the cluster?
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    There is no setting for that but it should be possible by altering the code of the aps installer and by editing the form file of the database form and there set remote access as default.
  3. BobGeorge

    BobGeorge Member HowtoForge Supporter

    I thought it might require a hack.

    But that's probably the best long-term solution, as then I can customise it to work exactly as I need it.

    Where's the source for the APS installer stuff kept?
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    The interface code is mostly in the aps* files in /usr/local/ispconfig/interface/lib/classes/ and the server side code is in the aps plugin in /usr/local/ispconfig/server/plugins-available/

    The database form file is in /usr/local/ispconfig/interface/web/sites/form/
  5. BobGeorge

    BobGeorge Member HowtoForge Supporter

    Thanks. I'll go take a look.
  6. Turbanator

    Turbanator Member HowtoForge Supporter

    BobGeorge, your setup (front end load balancer and backend db cluster) is very interesting to me. would you mind sharing a how to , more details, or anything to elaborate on the setup and how it works with ISPC? I don't recall seeing a howto anywhere here. If it's too much work, how about just a diagram?
  7. BobGeorge

    BobGeorge Member HowtoForge Supporter

    (I will answer your question later, Turbanator, but I'm currently at work and must fix this database installer problem first.)

    Till, I've followed the code in "" - against what's in my database - and I think I see the problem.

    When I create a site, the web server is the storage server. The other web server nodes in the cluster are mirrors of the storage server and then use NFS to access the files on the storage server.

    The code, though, gets the web server for that site from the database - which is the storage server - and then checks to see if that server is also a DB server - which the storage server also is - and then presumes "localhost".

    But this presumption is subtly wrong, because though the DB server is the storage server, it should be referred to by its IP address and not by "localhost". Because, of course, on other nodes, "localhost" does not equate to the storage server, it equates to whatever host is running the code and that's different for each node.

    So instead of (at line 249):

    $settings['main_database_host'] = 'localhost';

    It should rather find the DB server's IP address and use that. Irrespective of whether the web server is or isn't a DB server. As the IP address is correct, whatever node happens to be trying to connect to the DB server - whereas "localhost" is only correct when it's the DB server itself doing that.

    So the change I'm going to make, I think, is just to remove the "web server == db server" check altogether and always use the "else" code every time, which does obtain the IP address. This "else" code remains logically correct, even when the web server and DB server are the same node (albeit that, for situations where it genuinely is "localhost" only, it's unnecessarily turning on remote access when it doesn't need to).

    I'll let you know if this change actually works, once I've tried it out.
  8. BobGeorge

    BobGeorge Member HowtoForge Supporter

    It's not as simple as just removing the check, apparently.

    It just quit the installation without an error message, which from the comments in the code suggests that it's failing the next "if" test afterwards.

    I mean, for my own purposes, I can just force the settings I need by hard-coding the IP address instead of "localhost". But it'd be nice to fix the issue more generally, so it could also benefit others who might be having a problem with this too.

    The code assumes that if the web server is also a DB server then it's "localhost", but this is not necessarily true in a multi-server setup, as there could be other web servers mirroring that one and, for them, it's not "localhost" but the IP address of the DB server. A tiny subtlety of semantics.
  9. till

    till Super Moderator Staff Member ISPConfig Developer

    Please make a post in the bug tracker so we can look itno that and improve the aps multiserver code.
  10. BobGeorge

    BobGeorge Member HowtoForge Supporter

    Will do.

    I presume you mean the one at "", yes? As that's the only one I find with a search.
    till likes this.
  11. till

    till Super Moderator Staff Member ISPConfig Developer

Share This Page