T086学习网 | 站长学院 | 技术文档 | 成语 | 歇后语 | 帝国时代 | 代码收藏 | IP地址查询 | 生活百科 | 生日密码 | CSS压缩 | 用户评论 | 欣欣百宝箱

mysql memcached UDF 安装详解

【 更新时间:2013-04-21 | 字体:
[导读]1:mysql memcached UDF 其实就是通过libmemcached来使用memcache的一系列函数,通过这些函数,你能 对memcache进行get, set, cas, append, prepend, delete, increment, decrement objects操作,如果我们通过mysql ...

1:mysql memcached UDF 其实就是通过libmemcached来使用memcache的一系列函数,通过这些函数,你能 对memcache进行get, set, cas, append, prepend, delete, increment, decrement objects操作,如果我们通过mysql trigger来使用这些函数,那么就能通过mysql更好的,更自动的管理memcache!

2:安装方法:

1)安装memcache

2)安装libmemcached

shell> cd libmemcached-0.35
shell> ./configure --with-memcached=/usr/local/bin/memcached
shell> make && make install
shell> echo "/usr/local/lib" >> /etc/ld.so.conf
shell> ldconfig

3)安装memcached_functions_mysql
shell> tar zxvf memcached_functions_mysql-0.9.tar.gz
shell> cd memcached_functions_mysql-0.9
shell> ./configure --with-mysql=/usr/local/mysql51/bin/mysql_config --with-libmemcached =/usr/local/
shell> make && make install

4)拷贝lib文件到mysql的plugin下面
shell> cp -R /usr/local/lib/libmemcached_functions_mysql.* /usr/local/mysql51/lib/mysql/plugin/

5)添加memcache UDF 函数

在mysql里执行 source install_functions.sql

这样我们就可以使用mysql memcached UDF 了,我们可以通过下面语句查看是否已经正常安装

1)查看mysql.func,有很多函数

mysql> select * from mysql.func;
+------------------------------+-----+---------------------------------+----------+
| name                         | ret | dl                              | type     |
+------------------------------+-----+---------------------------------+----------+
| memc_add                     |   2 | libmemcached_functions_mysql.so | function |
| memc_add_by_key              |   2 | libmemcached_functions_mysql.so | function |
| memc_servers_set             |   2 | libmemcached_functions_mysql.so | function |

2)添加trigger,看是否向memcache里insert、update等

具体的语句,我们可以参照:

1)memcached_functions_mysql-0.9/sql 目录下的trigger_fun.sql

2)使用参照文档:http://dev.mysql.com/doc/refman/5.1/en/ha-memcached-interfaces-mysqludf.html


我们还必须注意以下几点:

1)mysql 编译时一定不要带'--with-mysqld-ldflags=-all-static' 这个参数,因为这样就限制了mysql 的动态安装功能了

2)使用时,要观察mysql.err日志,不知道是有意还是无意,udf更新memcache都会记录在err日志里,注意清理该日志,否则一下就爆满了

3)mysql 官网有这样一句话:

The list of servers used by the memcached UDFs is not persistent over restarts of the MySQL server. If the MySQL server fails, then you must re-set the list of memcached servers.

所以,当我们重启mysql,我们必须通过select  memc_servers_set('192.168.0.1:11211,192.168.0.2:11211');语句重新注册memcache服务器!

参考:http://dev.mysql.com/doc/refman/5.0/en/ha-memcached-interfaces.html

原文:http://blog.163.com/lgh_2002/blog/static/44017526201123121912959/

  • 转载请注明来源:IT学习网 网址:http://www.t086.com/ 向您的朋友推荐此文章
  • 特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系我们,我们会尽快予以更正。
更多
留言建议ASP探针PHP探针站长Enjoy的Blog
© 2017 T086学习网 - T086.com(原itlearner.com)
RunTime:7.67ms QueryTime:7