The second method with shardb is more preferable, added below.
/* , . ! */ define('WP_ALLOW_MULTISITE', true);
CREATE DATABASE `dbname_0` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE DATABASE `dbname_1` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE DATABASE `dbname_2` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE DATABASE `dbname_3` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE DATABASE `dbname_4` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE DATABASE `dbname_5` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE DATABASE `dbname_6` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE DATABASE `dbname_7` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE DATABASE `dbname_8` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE DATABASE `dbname_9` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE DATABASE `dbname_a` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE DATABASE `dbname_b` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE DATABASE `dbname_c` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE DATABASE `dbname_d` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE DATABASE `dbname_e` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE DATABASE `dbname_f` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci; CREATE DATABASE `dbname_global` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
define ('DB_SCALING', '16'); //------------------------------------------------------------------------// //---DC IPs---------------------------------------------------------------// //------------------------------------------------------------------------// // Usage: add_dc_ip(IP, DC) // EX: add_dc_ip('123.123.123.', 'dc1'); add_dc_ip('127.0.0.', 'dc1');
//------------------------------------------------------------------------// //---Global Tables--------------------------------------------------------// //------------------------------------------------------------------------// // Do not include default global tables // Leave off base prefix (eg: wp_) // You don't really have to register these, they will work fine without. // However registering at least your busiest ones might shave a few milliseconds off by avoiding some regexes. // // Usage: add_global_table(TABLE_NAME) // EX: add_global_table('something'); add_global_table('dbname_global'); add_global_table('affiliatedata'); add_global_table('affiliatereferrers'); add_global_table('am_actions'); add_global_table('am_queue'); add_global_table('am_schedule'); add_global_table('autoblog'); add_global_table('bp_activity'); add_global_table('bp_activity_meta'); add_global_table('bp_friends'); add_global_table('bp_groups'); add_global_table('bp_groups_groupmeta'); add_global_table('bp_groups_members'); add_global_table('bp_messages_messages'); add_global_table('bp_messages_notices'); add_global_table('bp_messages_recipients'); add_global_table('bp_notifications'); add_global_table('bp_user_blogs'); add_global_table('bp_user_blogs_blogmeta'); add_global_table('bp_xprofile_data'); add_global_table('bp_xprofile_fields'); add_global_table('bp_xprofile_groups'); add_global_table('domain_mapping');
//------------------------------------------------------------------------// //---DB Servers-----------------------------------------------------------// //------------------------------------------------------------------------// // Database servers grouped by dataset. // R can be 0 (no reads) or a positive integer indicating the order // in which to attempt communication (all locals, then all remotes) // // Usage: add_db_server(DS, DC, READ, WRITE, HOST, LAN_HOST, NAME, USER, PASS) // EX: add_db_server('global', 'dc1', 1, 1,'global.mysql.example.com:3509','global.mysql.example.lan:3509', 'global-db', 'globaluser', 'globalpassword'); // // Note: you can also place this section in a file called db-list.php in wp-content // EX: add_db_server('global', 'dc1', 1, 1,'global.mysql.example.com:3509','global.mysql.example.lan:3509', 'global-db', 'globaluser', 'globalpassword'); add_db_server('global', 'dc1', 1, 1,'localhost','localhost', 'dbname_global', 'root', '1'); add_db_server('0', 'dc1', 1, 1,'localhost','localhost', 'dbname_0', 'root', '1'); add_db_server('1', 'dc1', 1, 1,'localhost','localhost', 'dbname_1', 'root', '1'); add_db_server('2', 'dc1', 1, 1,'localhost','localhost', 'dbname_2', 'root', '1'); add_db_server('3', 'dc1', 1, 1,'localhost','localhost', 'dbname_3', 'root', '1'); add_db_server('4', 'dc1', 1, 1,'localhost','localhost', 'dbname_4', 'root', '1'); add_db_server('5', 'dc1', 1, 1,'localhost','localhost', 'dbname_5', 'root', '1'); add_db_server('6', 'dc1', 1, 1,'localhost','localhost', 'dbname_6', 'root', '1'); add_db_server('7', 'dc1', 1, 1,'localhost','localhost', 'dbname_7', 'root', '1'); add_db_server('8', 'dc1', 1, 1,'localhost','localhost', 'dbname_8', 'root', '1'); add_db_server('9', 'dc1', 1, 1,'localhost','localhost', 'dbname_9', 'root', '1'); add_db_server('a', 'dc1', 1, 1,'localhost','localhost', 'dbname_a', 'root', '1'); add_db_server('b', 'dc1', 1, 1,'localhost','localhost', 'dbname_b', 'root', '1'); add_db_server('c', 'dc1', 1, 1,'localhost','localhost', 'dbname_c', 'root', '1'); add_db_server('d', 'dc1', 1, 1,'localhost','localhost', 'dbname_d', 'root', '1'); add_db_server('e', 'dc1', 1, 1,'localhost','localhost', 'dbname_e', 'root', '1'); add_db_server('f', 'dc1', 1, 1,'localhost','localhost', 'dbname_f', 'root', '1');
$dbname = "multi"; //This is your current database $blog_table_prefix = 'wp_'; //Prefix of your wpmu blog tables, most likely this won't need to be changed $newdb_prefix = 'dbname_'; //This is the prefix of the db's you're moving your tables into - we assume they are all the same, if not, you're in trouble //We need info to connect to the databases $dbhost = 'localhost'; $dbuname = 'root'; $dbpass = '1'; //How many db's are you moving into (16, 256, or 4096)? $db_scaling = '16';
By consumption is meant the consumption of space? Why only 50%?
(16, 256, 4096) Brad.
define ('DB_SCALING', '16'); - And if then there will be 32 bases, then everything will go? :)
Saved on css / js, and took the cut base. I do not see the logic. :)
/* , . ! */ ... ... ... ... ... ... require_once('db-settings.php');
// If you have multiple datacenters you can come up with your own datacenter // detection logic (php_uname?). This helps ensure the web servers try to // connect to the nearest database servers first, then distant ones. define( 'DATACENTER', '' ); function add_slave($read, $host, $lhost = '', $user = DB_USER, $password = DB_PASSWORD) { global $slaves; $slaves[] = compact('read', 'host', 'lhost', 'user', 'password'); } /* Add your configuration here */ // how many characters of hexidecimal hash $shardb_hash_length = 2; // what is the prefix of your blog database shards (everything before the hexidecimal hash) // $shardb_prefix = 'set'; // set a string to be used as an internal identifier for the dataset $shardb_dataset = 'abc'; // do you want to put your primary blog (blog_id 1) in its own 'home' database? $enable_home_db = true; // how many, if any, VIP databases do you have? $num_vipdbs = 5; // add this to set the write master read priority (default 1) $shardb_master_read = 99; // add this if all of your databases are on a local server // , $shardb_local_db = true; // use this function to add a read slave host add_slave($read_priority, $hostname, $local_hostname, $user, $password); // instructions for adding vip blogs at the bottom of this confg filei /* That's all, stop editing! Happy blogging. */
Source: https://habr.com/ru/post/306992/