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
- Now I'm going to write to database named DB_TWO
- 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
- $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 );