The MU forums have moved to WordPress.org

Adding a database? (7 posts)

  1. andrea_r
    Moderator
    Posted 17 years ago #

    Is there any documentation anywhere about adding a second database to your MU install? Any tips on where to begin to look?

    How big a database are admins seeing? My host has a limit of 250 megs on the db size and we're a quater of the way there, so I want to figure out how to do this before it's an emergency.

  2. andrewbillits
    Member
    Posted 17 years ago #

    wpmu does not support multiple dbs out of the box. It's sort of a "Do it yourself" concept at the moment.

  3. andrea_r
    Moderator
    Posted 17 years ago #

    Yeah I figured. We just haven't had the time to sit down and muck about with it. I was hoping maybe someone had done it already and wrote about it somewhere. :D

  4. samchng
    Member
    Posted 17 years ago #

    Remembered andrew did it before. He managed to have two database working with MU. Read it somewhere before the big forum shutdown and was pretty interested. As I wanted to have uploaded files on one database and the rest on one database.

  5. andrewbillits
    Member
    Posted 17 years ago #

    Yeah, it's fairly easy to implement multiple dbs. the db class which is located in wp=db.php handles all of the db requiests. All you have to do is modify the class to direct the query to which ever db you wish.

    In my cluster setup I had one main DB (Dilbert) which held the main blog a few stats tables and the user table that I modified to keep track of which cluster a user is on. I then had three clusters (Ratbert, Catbert, and Dogbert) which were a master database and a few slaves depending on the size of the cluster. The whole idea with the "clusters" is that I could take one cluster offline for maintenance and still have ~75% of the site running.

    I also had a table on the main cluster that kept track of each cluster. Users, load, and cluster status. If something went wrong on a cluster of if it was down for maintenance the cluster would be given the status of read only. I then made a nice little plugin that checked the cluster status and made each blog "Read Only". Basicly the idead here is that if something is wrong with a server or database I don't want users messing around in their control panels or adding content in case I had to revert to a backup.

  6. andrewbillits
    Member
    Posted 17 years ago #

    Oh, if you get stuck trying to figure out how to route different requests to different databases here's a little hint. Each user table has a number as a prefix. Just use regular expressions to strip the number and then you have the blog ID and you can check tnat against other tables to get user ID etc.

  7. arlob
    Member
    Posted 17 years ago #

    Nice....

    Could you have like a...
    "Adding a Database in WordPress MU for the rest of us"
    kinda tutorial..

    Would be greatly appreciated =)

About this Topic