Multisite Installation -> Converting Master Server to Slave below new Master

Discussion in 'Installation/Configuration' started by JanThiel, Jun 19, 2014.

  1. JanThiel

    JanThiel Member

    Hi guys,

    I have a Multisite Installation running with 2 installed ISPConfigs. Latest versions. All are installed following the perfect server tut for Debian 7 and nginx.

    Now our infrastructure expands and I would like to setup the Master Server on a different system and convert the existing Master to slave below the new master.

    Server A: Master (should be Slave)
    Server B: Slave
    Server C: Should be New Master

    To prevent life from being too easy, Server A is a productive system I cannot interrup (for long).

    Is there an approach that is recommended or known to work? I would love to take over the existing configs to the new master as much as possible. I already thought about reinstalling ISPConfig on "Server A" and configuring it as a Slave, but I prefered to ask first, if that's a good idea or not.

    Any feedback appreciated! And thanks for the great Work and your help :)


  2. till

    till Super Moderator Staff Member ISPConfig Developer

    This should be possible, but you will to do a lot manual changes in the databases. It would be much easier to add the new server as another slave ;) Make a good backup before you start, especially from /etc and the ispconfig databases.

    The master server in a ispconfig multiserver setup has always server_id = 1. So your new server must become server 1 and the old server must become server 3.

    1) install server C as if you would want to make a standalone server.
    2) import the dbispconfig database of server A.
    3) The record with server_id = 1 in the server table is now server C, so we have to add a new record for server A) with server_id = 3 e.g. by making a copy of the server_id = 1 record.
    4) now we have to adjust the data. Allmost all records in all tables (except of the server table) need to be changed now so that server_id = 1 becomes server_id = 3. e.g.:

    update mail_user set server_id = 3 where server_id = 1;

    and so on. Steps 3 and 4 hvae to be done on server A and server C. So you can basically do them on one server and then copy the whole db over to the other server.

    As server C is the new master, you will have to export the ispcsrv2 user from mysql "mysql" database of server A and import it on server C. Then test if serverB /which uses the ispcsrv2 user to connect to the master) is stall able to connect. Then edit the two files on server B and change the hostname of the master there.

    Now we have a 3 server system, but server A still does not know that it is server 3 now and it is not connected to the master yet.

    So we have to connect server A to server C. The connection requires a mysql user with access to the ispconfig database on server C. Take a look at the existing ispcsrv* user of server B and make a user with the same permissions for server A. Then enter the details of this user as master mysql user in the 2 files on server A. The lines are:

    $conf['dbmaster_host'] = '{mysql_master_server_host}';
    $conf['dbmaster_database'] = '{mysql_master_server_database}';
    $conf['dbmaster_user'] = '{mysql_master_server_ispconfig_user}';
    $conf['dbmaster_password'] = '{mysql_master_server_ispconfig_password}';

    Then change the server_id to 3 inside the two files on server A from 1 to 3 and download ispconfig tar.gz, unpack it and run update.php and let it reconfigure all services. this will change the ID in all other config files. If you dont want to run this forced update, then you can also edit all files manually e.g. by searching for server_id with grep in /etc/*

    I hope I havent left something out :) As you see, its quite complicated.
  3. JanThiel

    JanThiel Member

    Hi Till,

    thanks for the fast and detailed feedback :)
    Actually ... I expected worse! That sounds quite "easy" to handle, if you know what you are doing.
    So I'll give it a try and will be happy to report back next week how it worked out!

    Thanks again,

  4. JanThiel

    JanThiel Member

    Hi Till,

    good news first: Everything worked out fine. Took me an hour with all the doublechecks but went down very well.

    General Approach I would recommend:

    On old Master:
    Use phpmyadmin to COPY the dbispconfig Database to another name on the same server. Then it's quite easy to use the "Query Window" to run an UPDATE on server_id for all necessary tables.
    Afterwards Export with phpmyadmin. But(!) only export Data and use "REPLACE" instead of "INSERT" (that are both options you can chose in the Export page).

    In phpmyadmin you can also export the User from the "Rights" Tab in the Database Sever View ("localhost"). That makes life a lot easier for reimporting the existing and recreating the new ispcsrcX user.

    Now install NEW Master:
    • ISPConfig Default Standalone Installation
    • After Installation import the SQL File we exported on Old Master to new master (to avoid errors we need the "REPLACE" here, instead of simple inserts!).
    • Also run the SQL Statements from the User export on the new Master (should be 2 for each Server. One with @IP and one with @HOST). Copy the statement into a Text Editor and simply replace the ispcsrvX with ispcsrvY. The password can be changed afterwards on new Master with phpmyadmin.

    On old Slave:
    • Update both files (change the Master DB Connection Settings)
    • Run the update.php from the ISPConfig Download Package.
    • --> Done here!

    On old Master:
    • Update both files (change the Master DB Connection Settings + the new local Server ID (should be 1 and need to be something else)!)
    • Rename the dbispconfig Database to something else!
    • Import the export we created for the New Master. (Necessary to have the correct new server_id also on the old master! update.php will fail if DB and config file are not in sync)
    • Run the update.php from the ISPConfig Download Package.
    • --> Done :)

    That's it already

    You can check if everything worked by checking the "Monitoring" Tab on the new Master. If the existing Slaves are there. Everything is good :)

    So maybe someone else might be in use of this guide. But thanks alot Till. Wouldn't be able to do this without your instructions!

    Have a nice Day


Share This Page