We need to make an urgent request today,Algorithm4 million of the data is calculated (only Nick is included), and a customized database needs to be imported.
32 databases on MySQL (icluster_1 to icluster_32, calculate the remainder Based on Nick's MD5 value and then shard)
Table Structure:
Create Table 'preferences '('Nick' char (32) Character Set GBK collate gbk_bin not null, 'enable' tinyint (1) default '1', 'preference 'varchar (1024) default '', primary key ('Nick ') engine = MyISAM default charset = GBK
Because of the sub-database service. It seems that the MySQL load command or mysqldump cannot be used to import data. You can only write a PHP script to execute the insert loop.
<? Phpheader ("Content-Type: text/html; charset = GBK"); set_time_limit (0); ini_set ('memory _ limit ', '1122m '); $ con = mysql_connect ('IP', 'username', 'Password'); If (! $ Con) Exit ("fail"); mysql_query ("set names 'gbk'"); $ arr = array (); $ file = fopen ("/home/admin/personal_combo_nick_gbk", "R"); $ I = 0; while (! Feof ($ file) {$ line = trim (fgets ($ file); If ($ line) {$ I ++; $ nk_md5 = MD5 ($ line ); $ Signature = hexdec (substr ($ nk_md5,-2); $ dbname = (1 + ($ signature % 32); mysql_select_db ("icluster _". $ dbname, $ con); $ result = mysql_query ("insert into preferences (Nick, enable, preference) values ('{$ line}', 1, 'ur data; Switch: 1 ') on duplicate key update enable = 1, preference = Concat (preference,'; Switch: 1') ");} If (In_array ($ I, array (1, 1000,100 00, 50000,100 000, 1000000,300 0000 ))) {shell_exec ("/home/admin/mail/bin/email-v-SMTP-server server_ip-SMTP-port 25-HTML-from-ADDR your_mail-from-name taozi-No -encoding-subject \ "processed {$ I} \" your_mail <today.html ");}} fclose ($ file); mysql_close ($ con);?>
The time is still relatively long. It took 40 minutes :(