因为项目需要,数据库表更新后要实时推送消息给用户,想到用mysql-udf-http插件来给mysql提供http请求。
开始安装:
按照http://zyan.cc/mysql-udf-http/2/1/的方法安装,
执行到
./configure --prefix=/usr/local/webserver/mysql --with-mysql=/usr/local/webserver/mysql/bin/mysql_config
的时候发现本机的mysql不是统一的目录(当前mysql是rpm的方式安装),目录比较乱,安装不成功。好吧,重装一个编译方式安装的mysql。
编译方式安装mysql:
按照http://www.cnblogs.com/xiongpq/p/3384681.html方法安装。
Mysql安装路径为
/usr/local/mysql
继续安装mysql-udf-http
tar zxvf curl-7.21.1.tar.gz cd curl-7.21.1/ ./configure --prefix=/usr
执行到这步的时候报错:
No package ‘libcurl‘ 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. See the pkg-config man page for more details.
网上找到解决办法:
[root@iZ940ox5pn5Z mysql-udf-http-1.0]# whereis pkgconfig pkgconfig: /usr/lib/pkgconfig /usr/lib64/pkgconfig /usr/local/lib/pkgconfig /usr/share/pkgconfig [root@iZ940ox5pn5Z mysql-udf-http-1.0]# export > PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
继续安装
tar zxvf mysql-udf-http-1.0.tar.gz cd mysql-udf-http-1.0/ ./configure --prefix=/usr/local/webserver/mysql --with-mysql=/usr/local/webserver/mysql/bin/mysql_config make && make install
到这里的时候想知道是否安装成功,到mysql命令执行
create function http_get returns string soname ‘mysql-udf-http.so‘; create function http_post returns string soname ‘mysql-udf-http.so‘; create function http_put returns string soname ‘mysql-udf-http.so‘; create function http_delete returns string soname ‘mysql-udf-http.so‘;
报错:找不到mysql-udf-http.so,命令行输入
find /-name “mysql-udf-http.so”
也早不到该文件,看样子是没装成功,回头看安装日记,发现错误:
gcc: /usr/local/lib/libcurl.so: No such file or directory make[2]: *** [mysql-udf-http.la] Error 1 make[2]: Leaving directory `/usr/local/att/mysql-udf-http-1.0/src‘ make[1]: *** [all] Error 2 make[1]: Leaving directory `/usr/local/att/mysql-udf-http-1.0/src‘ make: *** [all-recursive] Error 1
再看前面
[root@iZ940ox5pn5Z mysql-udf-http-1.0]# export > PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:/usr/lib/pkgconfig
怀疑是前面设置的环境变量路径错了,改成:
[root@iZ940ox5pn5Z mysql-udf-http-1.0]# whereis pkgconfig pkgconfig: /usr/lib/pkgconfig /usr/lib64/pkgconfig /usr/local/lib/pkgconfig /usr/share/pkgconfig [root@iZ940ox5pn5Z mysql-udf-http-1.0]# export PKG_CONFIG_PATH=/usr/lib64/pkgconfig:/usr/lib/pkgconfig
重新执行:
cd mysql-udf-http-1.0/ ./configure --prefix=/usr/local/webserver/mysql --with-mysql=/usr/local/webserver/mysql/bin/mysql_config make && make install
这次没报错,不过在/usr/local/mysql/lib/plugin目录下找不到mysql-udf-http.so,而是在/usr/local/mysql/lib目录下找到mysql-udf-http.so,拷贝到/usr/local/mysql/lib/plugin后,执行
create function http_get returns string soname ‘mysql-udf-http.so‘; create function http_post returns string soname ‘mysql-udf-http.so‘; create function http_put returns string soname ‘mysql-udf-http.so‘; create function http_delete returns string soname ‘mysql-udf-http.so‘;
添加自定义函数成功。经测试,成功发送请求到web服务。
原文:http://www.cnblogs.com/yudaxian/p/5020747.html