Next: MySQL uses mysql-udf-http efficiency test notes, this time not using the rest architecture, but using: libmemcached and Memcached_functions_mysql, the test version is:
Libmemcached-0.34.tar.gz and memcached_functions_mysql-0.9.tar.gz, other versions of the pairing are problematic, and I've installed the tested version with the following problems:
Copy Code code as follows:
memcached_functions_mysql-1.1 in:
Libmemcached-0.49\libmemcached-0.48\libmemcached-0.47\libmemcached-0.30\libmemcached-0.43\\libmemcached-0.42\
There is an error installing the
Memcached_functions_mysql-0.10 in:
There are errors installed under Libmemcached-0.42\
memcached_functions_mysql-0.8 in:
Libmemcached-0.49\libmemcached-0.48\libmemcached-0.47\libmemcached-0.44\libmemcached-0.43\
There are errors installed under \libmemcached-0.42\
MySQL beta version: 5.1.55, operating system Centos5.4 64bit, memory 2G
Install libmemcached-0.34 and memcached_functions_mysql-0.9,
Copy Code code as follows:
[Root@sunss24 libmemcached-0.34]#./configure \
--with-memcached=/home/memcache/bin/memcached
[Root@sunss24 libmemcached-0.34]# make
[Root@sunss24 libmemcached-0.34]# make Install
Run the MemStat again, it's a success.
[Root@sunss24 ~]# ln-s/usr/local/lib/libmemcached.so.3/usr/lib/
[Root@sunss24 ~]# CD memcached_functions_mysql-0.9
[Root@sunss24 memcached_functions_mysql-0.9]#./configure \
--with-mysql=/usr/local/mysql/bin/mysql_config \
--libdir=/usr/local/mysql/lib/
[Root@sunss memcached_functions_mysql-0.9]# make && make install
Load the UDFs into MySQL after the installation is complete:
Copy Code code as follows:
Mysql> Show variables like "%plugin%";
+---------------+-----------------------------------+
| variable_name | Value |
+---------------+-----------------------------------+
| Plugin_dir | /usr/local/mysql/lib/mysql/plugin |
+---------------+-----------------------------------+
1 row in Set (0.00 sec)
[Root@sunss ~]# Find/-name "libmemcached_functions_mysql.so"
/usr/local/mysql/lib/libmemcached_functions_mysql.so
/root/memcached_functions_mysql-0.9/src/.libs/libmemcached_functions_mysql.so
You have new mail in/var/spool/mail/root
[Root@sunss ~]# cp/usr/local/mysql/lib/libmemcached_functions_mysql.so/usr/local/mysql/lib/mysql/plugin/
[Root@sunss ~]# CD memcached_functions_mysql-0.9/
[Root@sunss ~] #cd sql/
Mysql> source Install_functions.sql;
View various versions:
Copy Code code as follows:
Mysql> select Memc_udf_version ();
+--------------------+
| Memc_udf_version () |
+--------------------+
| 0.9 |
+--------------------+
1 row in Set (0.00 sec)
Mysql> select Memc_libmemcached_version ();
+-----------------------------+
| Memc_libmemcached_version () |
+-----------------------------+
| 0.34 |
+-----------------------------+
1 row in Set (0.00 sec)
Mysql>
Problem encountered:
Copy Code code as follows:
No package ' libmemcached ' found
Consider adjusting the PKG_CONFIG_PATH environment variable if you
Installed software in a non-standard prefix.
Alternatively, you may set the environment variables Deps_cflags
and deps_libs to avoid the need to call Pkg-config.
The Pkg-config man page is for more details.
Solution:
[Root@sunss24 memcached_functions_mysql-0.9]# Whereis Pkgconfig
[Root@sunss24 memcached_functions_mysql-0.9]# export \
Pkg_config_path=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
Export all Memcache content:
Use: Memcached-hack.zip
Efficiency test:
Insert:
Copy Code code as follows:
<?php
Include_once ("gettime.php");
$btime = Getmicrotime ();
$i = 0;
$mem = new Memcache ();
$mem->addserver (' 192.168.0.10 ', 11212);
$local _db = mysql_connect ("192.168.0.208", "Sunss", "123456");
if (! $local _db)
{
Die (' Could not connect: '. Mysql_error ());
}
$local _db_sel = mysql_select_db ("Test", $local _db);
mysql_query ("Set names UTF8", $local _db);
while ($i < 1000) {
$re _sql = "INSERT INTO URLs (Id,url) VALUES ($i, ' www.gongchang.com ')";
$res = mysql_query ($re _sql, $local _db);
$i + +;
}
Mysql_close ($local _db);
$etime = Getmicrotime ();
$runTime = Round ($etime-$btime, 4);
echo "RunTime:". $runTime. " \ r \ n ";
?>
1000, insert time: runtime:1.4072
Delete:
Copy Code code as follows:
<?php
Include_once ("gettime.php");
$btime = Getmicrotime ();
$i = 0;
$mem = new Memcache ();
$mem->addserver (' 192.168.0.10 ', 11212);
$local _db = mysql_connect ("192.168.0.208", "Sunss", "123456");
if (! $local _db)
{
Die (' Could not connect: '. Mysql_error ());
}
$local _db_sel = mysql_select_db ("Test", $local _db);
mysql_query ("Set names UTF8", $local _db);
while ($i < 1000) {
$re _sql = "INSERT INTO URLs (Id,url) VALUES ($i, ' www.gongchang.com ')";
$re _sql = "Delete from URL where id=". $i;
echo "Re_sql_1:". $re _sql. " \ n ";
$res = mysql_query ($re _sql, $local _db);
$i + +;
}
Mysql_close ($local _db);
$etime = Getmicrotime ();
$runTime = Round ($etime-$btime, 4);
echo "RunTime:". $runTime. " \ r \ n ";
?>
Delete 1000, run time: runtime:1.5534
Update Not Made
Conclusion: Query about 650 records per second, more quickly than the last Mysql-udf-http