mysql - 使用 memcache_functions_mysql UDF 处理 memcache 和 mysql

标签 mysql memcached libmemcached libmemcache

我已经安装了以下软件包 --

  1. libevent-2.0.21
  2. memcached-1.4.17
  3. libmemcached-0.34
  4. memcached_functions_mysql_1.1

以上全部已安装成功。 ldconfig -v 命令的输出(显示 libmemcached 库已包含的部分)如下:

$ldconfig -v

/usr/local/libmemcached/lib:
        libmemcached.so.3 -> libmemcached.so.3.0.0
        libmemcachedprotocol.so.0 -> libmemcachedprotocol.so.0.0.0
        libmemcachedutil.so.0 -> libmemcachedutil.so.0.0.0

但是当我尝试使用 memcache_functions 附带的 install_functions.sql 将 UDF 加载到 mysql 中时,它会抛出以下错误:

ERROR 1126 (HY000) at line 38: Can't open shared library 'libmemcached_functions_mysql.so' (errno: 0 libmemcached.so.3: cannot open shared object file: No such file or directory)

插件目录的内容为:

-rw-r--r-- 1 root root 6.1K Jan 21 13:49 adt_null.so
-rw-r--r-- 1 root root  11K Jan 21 13:49 auth.so
-rw-r--r-- 1 root root 6.0K Jan 21 13:49 auth_socket.so
-rw-r--r-- 1 root root 6.2K Jan 21 13:49 auth_test_plugin.so
-rw-r--r-- 1 root root  35K Jan 21 13:49 ha_example.so
-rw-r--r-- 1 root root  10K Jan 21 13:49 libdaemon_example.so
-rw-r--r-- 1 root root 361K Feb 13 02:47 libmemcached_functions_mysql.a
-rwxr-xr-x 1 root root 1.1K Feb 13 02:47 libmemcached_functions_mysql.la
-rwxr-xr-x 1 root root 167K Feb 13 02:47 libmemcached_functions_mysql.so
-rwxr-xr-x 1 root root 167K Feb 13 02:47 libmemcached_functions_mysql.so.0
-rwxr-xr-x 1 root root 167K Feb 13 02:47 libmemcached_functions_mysql.so.0.0.0
-rw-r--r-- 1 root root  11K Jan 21 13:49 mypluglib.so
-rw-r--r-- 1 root root 5.9K Jan 21 13:49 qa_auth_client.so
-rw-r--r-- 1 root root  11K Jan 21 13:49 qa_auth_interface.so
-rw-r--r-- 1 root root 6.0K Jan 21 13:49 qa_auth_server.so
-rw-r--r-- 1 root root  39K Jan 21 13:49 semisync_master.so
-rw-r--r-- 1 root root  15K Jan 21 13:49 semisync_slave.so

最佳答案

Installing memcached on Ubuntu 12.04.1 LTS (64 bit)

 Python - 2.6.8
 MySQL – 5.5.28
 Zope – 2.12.19

1.  Install memcached

    apt-get install memcached

2.  Install libmemcached -0 .34 (Version is very important. May or may not work with other versions).

    Download it from https://launchpad.net/libmemcached/

    tar xvf libmemcached-0.34.tar.gz
    sudo ./configure  --prefix=/usr/lib/libmemcached  --with-memcached=/usr/bin/memcached
    sudo make
    sudo make install.

3.  Install memcached_functions_mysql (Version 1.1 used at the time of the installation. (To create UDF’s that are invoked by triggers to manipulate the cache).

    Downloading from https://launchpad.net/memcached-udfs

    sudo ./configure  --prefix=/usr/local/memcached_mysql  --libdir=/usr/lib/mysql/plugin  --with-mysql=/usr/bin/mysql_config  --with-libmemcached=/usr/lib/libmemcached
    sudo make
    sudo make install

    Navigate to the “sql” folder inside the memcached_mysql_functions directory.

    mysql –u <username> -p < install_functions.sql

4.  For Zope users

    Install python-memcached-1.53

    Download it from https://pypi.python.org/pypi/python-memcached/
    Navigate to the extracted python-memcached directory.

    /home/zope/zope/bin/python setup.py install

5.  Edit the script containing which imports the modules.

    allow_module('memcache')

    from memcache import Client
    allow_class(Client)
    allow_module('memcache.Client.get')
    allow_module('memcache.Client.set')

This is done so that memcache can be imported and used in your Restricted Python scripts.
If an external method is used to handle the above case, then the file does need to be updated with the above content.

关于mysql - 使用 memcache_functions_mysql UDF 处理 memcache 和 mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21752591/

相关文章:

php - 带有脚本标签的 tinyMCE 发布代码?

php - 如何让用户只提交一票?

c - 在 Mac OSX(以及 Mint 和 CentOS)上构建 libmemcached 时出现问题

c - libmemcached - memcached_mget 似乎阻塞

php - 安装 PECL Memcached 报错

MySQL 过程显示 "select"语句两次

php - 无法使用 PHP 将文件上传到服务器上

php - 600+ memcache req/s 问题 - 帮助!

memcached - 使用哪个数据存储来存储与内存缓存中的键对应的元数据?

django - 在 Django 中优化(和缓存?)postgreSQL 写入