The MU forums have moved to WordPress.org

Attempt on setting up WP_USE_MULTIPLE_DB (24 posts)

  1. horiyochi
    Member
    Posted 16 years ago #

    Hi,

    Yes, this topic again.

    I'm actually trying the multiple db setting on wpmu, it seems to work, but not quite.

    Below are my code for the multi-db wpmu (reference: http://svn.automattic.com/wordpress-mu/tags/1_0-rc2/wp-config-sample.php)

    $db_list = array(
    	"write" => array(
    		array(	"db_name"	=> "DB_TWO",
    			"db_user"	=> "root1",
    			"db_password"	=> "root1",
    			"db_host"	=> "localhost"
    		)
    	),
    
    	"read" => array(
    		array(	"db_name"	=> "DB_ONE",
    			"db_user"	=> "root",
    			"db_password"	=> "root",
    			"db_host"	=> "localhost"
    		),
    		array(	"db_name"	=> "DB_TWO",
    			"db_user"	=> "root1",
    			"db_password"	=> "root1",
    			"db_host"	=> "localhost"
    		)
    	)
    );
    
    $global_db_list = array(
    	array(	"db_name"	=> "DB_ONE",
    		"db_user"	=> "root",
    		"db_password"	=> "root",
    		"db_host"	=> "localhost"
    	),
    	array(	"db_name"	=> "DB_TWO",
    		"db_user"	=> "root1",
    		"db_password"	=> "root1",
    		"db_host"	=> "localhost"
    	)
    );

    There are not many examples available, what I wrote for my setting is that:
    * DB_ONE is my main database, the main site store in DB_ONE
    * assume that DB_ONE is overloaded will loads of blogs, I have no choice but to move to another DB which is DB_TWO

    1. Now I'm going to write to database named DB_TWO
    2. The wpmu will read/ retrieve data from my database, if the data cannot be found on DB_ONE it will look into db DB_TWO
    3. $global_db_list is to store all my databases that linked to my wpmu

    I even try to list only one database in $global_db_list, and create DB_TWO with the next auto-increment number (example DB_ONE stop at 10,000), DB_TWO primary key will be start at 10,001 the tables will look something like wp_10001_options

    and it actually listed in my site admin panel (mixture of DB_ONE and DB_two data), showing that the new blog is created...
    but the page just refuse to show when I try to access the new blog as a visitor.

    After a lot of trial and error, I found something that I do not understand.
    In the wp-db.php, in the function db_connect(), line 172, 176 and 180

    • line 172: $details = $global_db_list[ mt_rand( 0, count( $global_db_list ) -1 ) ];
    • line 176: $details = $db_list[ 'write' ][ mt_rand( 0, count( $db_list[ 'write' ] ) -1 ) ];
    • line 180: $details = $db_list[ 'read' ][ mt_rand( 0, count( $db_list[ 'read' ] ) -1 ) ];

    wpmu is attempting to select a db from a random basis?? if I have a array of 10 databases, by calculation, one database will stand 10% chance to be bind.

    if blog1.some-site.com store in DB_ONE, but wpmu randomly picked DB_TWO for reading, something like this will appear:

    It doesn't look like you've installed WP yet ...

    There are really limited resources on this topic and I really couldn't find the answer, that is why am here...

    by the way, the setting on my wp-config.php might not be correct, those are my assumption.

    Is there anyone out there succeed on this setting?
    //define( "WP_USE_MULTIPLE_DB", true );

  2. lunabyte
    Member
    Posted 16 years ago #

    "Is there anyone out there succeed on this setting?"

    Yes, there is a plugin available from WPMUDEV.

  3. horiyochi
    Member
    Posted 16 years ago #

    Can anyone explain on the use of $db_list, as well as the $global_db_list. And is my setting/ assumption correct?

    Why wpmu hasn't been posting much information on this issue? Is it intended that way?

    Anyway, I'm not sitting here and wait for the answer, I'm trying to experiment it as well...

  4. ekusteve
    Member
    Posted 16 years ago #

    The link posted above actually goes to a premium site. I think they may have it working there, but you will need to subscribe to get it.

    Steve

  5. lunabyte
    Member
    Posted 16 years ago #

    It works like a champ, actually. No "thinking" that it "may" work, it works just dandy.

  6. andrea_r
    Moderator
    Posted 16 years ago #

    "Why wpmu hasn't been posting much information on this issue? Is it intended that way?"

    Why? Because if you read the code, you can figure it out if you're a programmer. Is it intended that way? Yeah. Cuz it's hard. If I could remember where it was said I'd link it.

    And the preimium plugin is totally worth it. They didn't just hack something together - it's been proven on multiple sites.

    There have been threads on doing it solo, but those are the ones that 'might" work.

  7. ekusteve
    Member
    Posted 16 years ago #

    Wow...there you have it...works like and champ and dandy :-)

    In all seriousness, this is actually a very nice feature and I have nothing against people developing improvements to OS software and making some money from it...I do it myself. So, to the owners of the premium site...well done and more power to you. I would probably subscribe myself to get this, but I can't stand the thought of actually paying to go to another site where I would actually have to read even more bs from the likes of lunabyte :-)......I can get all that I want here for free :-)

    [Unnecessary remark removed - Podz]

    Steve

  8. lunabyte
    Member
    Posted 16 years ago #

    No thanks, I won't stoop to your level. Nice try though.

    *note to mod*

    Was the above remark really necessary?

  9. podz
    Key Master
    Posted 16 years ago #

    I thought not too.

  10. ekusteve
    Member
    Posted 16 years ago #

    Podz...you're the moderator, so if you want to edit my post, I respect your right to do so, but cleaning up posts is a slippery slope. I'm not going to "whine" about whether remarks in posts like the one below were "really necessary" or not (and I could post dozens more, but I won't). If a person is big enough to throw rocks they should be big enough to take a few back...just food for thought.

    http://mu.wordpress.org/forums/topic.php?id=6421&page&replies=9

    Steve
    "The only problem with censorship is XXXXXXXXXXXXXXXXX XXXXXXXXXX XXXX XXXXXXXXX XXXXXXXXXX"

  11. andrea_r
    Moderator
    Posted 16 years ago #

    Podz - does this mean someone will actually be around to moderate now?

  12. lunabyte
    Member
    Posted 16 years ago #

    Sure, I'll comment on that.

    I'll throw fastballs all day long, I have no problem with it. However, I don't throw the first stone, and only respond in a manner dictated by the first stone.

    Oh which, I'm still not sinking to your level for this. The gutter is crowded enough as is.

  13. ekusteve
    Member
    Posted 16 years ago #

    *note to mod*

    Was the above remark really necessary?

    -----------------

    Podz...See what I mean about the slippery slope? :-) I just posted this to make a point...I'm not asking you to remove anything. Just click around and read some post like the one below and then decide whether you should be removing things at the request Lunabyte.

    http://mu.wordpress.org/forums/topic.php?id=3364&page&replies=23

    Thanks.

    Steve

  14. lunabyte
    Member
    Posted 16 years ago #

    Oh my. <roll eyes>

    Sorry to break your world up there Stevie, but most people can see through you, and (whether they want to read it or not), that I won't put up with folks who act like you.

    If that makes me bad, so be it.

    However, time and time again, you go at it, and beg for a confrontation.

    This time, however, my method of torture will be denying you the satisfaction.

    Keep trying, but you'll never reach the status of master.

  15. podz
    Key Master
    Posted 16 years ago #

    @ekusteve - it is a slippery slope and one I do not intend trying to climb. I don't take sides and I didn't look at any history. The comment seemed out of character with the thread and as such provocative. That's why I did that. Had that been in the middle of an out of control thread then lots of comments could have been deleted / edited or indeed just left.

    @andrea_r - I watch for the modlook tag. I believe that forum mods should keep things tidy, flag issues that need it to those that code the forums and deal with spam and other 'modlook' issues.
    If you use the 'modlook' tag for a thread then I'll see that in google reader and come on in.
    If it's spam, it goes.
    If it's a duped post, it goes.
    If it needs moving it will be.
    If it's something that involves an "exchange of views" then I'll look at the thread overall. Sometimes strong views are valid even if the language could be better chosen.
    If I edit a post I will always make that plain as I did above and I will answer for that.
    I will try to not delete any posts (except the spam/dupes) because sometimes doing that can disrupt the flow if people have commented after the post but referenced it. In such a case I'll edit the post and again make that plain.
    I'm not into people having the 'last word' and then asking for threads to be closed.
    I'm not into removing views that I do not agree with.

    But I'm not taking sides.
    I think all everyone wants is for the forums to run smoothly.
    Use the modlook tag when needed.

    I moderated the wp.org forums from mid 2004 and I'll do here what I did there. Hopefully without too much noise.

  16. ekusteve
    Member
    Posted 16 years ago #

    Thanks for the reply Podz.

    So, "note to mod" enclosed in "*" is a "modlook tag?". Interesting...I'll have to remember that one :-)

    Steve

  17. podz
    Key Master
    Posted 16 years ago #

    No - the tag at the top is the 'modlook' beacon :)

  18. ekusteve
    Member
    Posted 16 years ago #

    This time, however, my method of torture will be denying you the satisfaction.

    Yea...great method...keep up the good work :-)

    Steve (or Stevie if you prefer :-), but the way, since we seem to be on a "first name basis" I've been calling you Lunabyte...you don't mind if I start calling you Whineybaby do you? :-)

  19. ekusteve
    Member
    Posted 16 years ago #

    No - the tag at the top is the 'modlook' beacon :)

    Thanks...I guess I just don't understand how to use it...probably a good thing anyway :-)

  20. ekusteve
    Member
    Posted 16 years ago #

    Okay...I see the tag thing now...just never noticed that before. Thanks.

    Steve

  21. podz
    Key Master
    Posted 16 years ago #

    Tags:

    * database
    * multiple
    * modlook

    is at the top and if you are logged in you should be able to add a tag there.

  22. ekusteve
    Member
    Posted 16 years ago #

    I'm a little slow...got it now. Thanks.

    Steve

  23. GeorgeLewis
    Member
    Posted 15 years ago #

    I think you can solve this by using regular wp and using the wp-hive.com plugin!

  24. VentureMaker
    Member
    Posted 15 years ago #

    GeorgeLewis, spamming?

About this Topic

  • Started 16 years ago by horiyochi
  • Latest reply from VentureMaker