[文章作者:张宴 本文版本:v1.0 最后修改:2010.09.08 转载请注明原文链接:http://blog.zyan.cc/mysql-udf-http/]
Mysql-udf-http 是一款简单的MySQL用户自定义函数(UDF, User-Defined Functions),具有http_get()、http_post()、http_put()、http_delete()四个函数,可以在MySQL数据库中利用HTTP协议进行REST相关操作。
项目网址:http://code.google.com/p/mysql-udf-http/
中文说明:http://blog.zyan.cc/mysql-udf-http/
使用环境:Linux操作系统,支持的MySQL版本:5.1.x 和 5.5.x。5.0.x未经测试。
软件作者:张宴
一、REST架构风格:
REST(Representational State Transfer)是一种轻量级的Web Service架构风格,其实现和操作明显比SOAP和XML-RPC更为简洁,可以完全通过HTTP协议实现,还可以利用缓存Cache来提高响应速度,性能、效率和易用性上都优于SOAP协议。REST最早是由 Roy Thomas Fielding 博士2000年在论文《Architectural Styles and the Design of Network-based Software Architectures》中提出的,中文译文全文PDF点此下载。另外,有篇译文对REST做了一个简化说明。
目前,REST架构风格的常见实现是基于HTTP协议及其四种基本方法(如POST、GET、PUT和DELETE)的。有人将HTTP协议的四种方法与CRUD原则相对应,CRUD原则对于资源只需要四种行为:Create(创建)、Read(读取)、Update(更新)和Delete(删除)就可以完成对其操作和处理。
在Mysql-udf-http中,四个函数http_post()、http_get()、http_put()、http_delete()分别对应HTTP协议的POST、GET、PUT、DELETE四种方法。
REST是一种架构风格,而不是协议或标准。HTTP协议“POST、GET、PUT、DELET”四种方法与CRUD原则“Create、Read、Update、Delete”四种行为的一一对应关系只是一种架构设计习惯,而不是规范。因此,POST方法也可以用来更新资源,PUT方法也可以用来创建资源,这就要看具体应用程序作者的定义了。例如Tokyo Tyrant除了支持Memcached协议外,还支持REST方式存取,PUT代表创建和更新,GET代表读取,DELETE代表删除(关于Tokyo Tyrant的安装使用请点击这儿)。
目前国内外流行的Web 2.0应用API接口中,很多都支持REST架构风格。例如:新浪微博开放平台、人人网API、Google OpenID、Flickr、Twitter、eBay、Facebook、Last.fm、del.icio.us、Yahoo Search、Amazon S3、Amazon EC2、Digg、Microsoft Bing、FriendFeed、PayPal、Foursquare,更多...
当记录数成百上千万条时,通常采用 MySQL 分表减低数据库压力。但是,全部数据按点击数、精华、积分排序显示等功能,在MySQL 分表中则无法实现。编写 Mysql-udf-http 的最初目的,是为了在项目开发中,将 MySQL 各分表的数据自动同步到我们的 TCSQL 高速列表数据库,用来做列表查询、显示,内容页则根据ID直接查询各 MySQL 分表的内容。由于HTTP协议的通用性,通过 Mysql-udf-http 可以做更多的事情。
通过Mysql-udf-http,你可以在MySQL中利用触发器,将MySQL的数据同步到支持REST的应用上。例如你有一个独立博客,你可以在文章表创建MySQL触发器,这样,在发表文章时,就可以将文章标题、URL自动同步到新浪微博、Twitter。你想用 Tokyo Tyrant 做缓存,也可以利用MySQL触发器在发生增、删、改时,将数据自动同步到 Tokyo Tyrant。详细配置方法本文第4节中会有介绍。
二、Mysql-udf-http的安装与使用:
1. 在Linux系统上安装Mysql-udf-http
注意:“/usr/local/webserver/mysql/”是你的MySQL安装路径,如果你的MySQL安装路径不同,请自行修改。
2. 通过命令行登陆进入MySQL
3. 创建MySQL自定义函数
mysql>
4. 使用方法
I. 函数描述:
mysql>
II. 示例 A:
mysql>
III. 示例
通过MySQL触发器,利用mysql-udf-http和第三方UDF函数lib_mysqludf_json,自动同步数据到 Tokyo Tyrant。
(1). 下载安装 lib_mysqludf_json 修改版:
以下安装包适合32位Linux操作系统:
以下安装包适合64位Linux操作系统:
通过命令行登陆进入MySQL:
mysql> lib_mysqludf_json的详细用法请访问:http://www.mysqludf.org/lib_mysqludf_json/
(2). 创建测试表
mysql>
(3). 为测试表创建触发器:
mysql>
(4). 将 MySQL 表和 Tokyo Tyrant 关联进行查询:
mysql>
5. 如何删除mysql-udf-http UDF函数:
mysql>
Mysql-udf-http 是一款简单的MySQL用户自定义函数(UDF, User-Defined Functions),具有http_get()、http_post()、http_put()、http_delete()四个函数,可以在MySQL数据库中利用HTTP协议进行REST相关操作。
项目网址:http://code.google.com/p/mysql-udf-http/
中文说明:http://blog.zyan.cc/mysql-udf-http/
使用环境:Linux操作系统,支持的MySQL版本:5.1.x 和 5.5.x。5.0.x未经测试。
软件作者:张宴
一、REST架构风格:
REST(Representational State Transfer)是一种轻量级的Web Service架构风格,其实现和操作明显比SOAP和XML-RPC更为简洁,可以完全通过HTTP协议实现,还可以利用缓存Cache来提高响应速度,性能、效率和易用性上都优于SOAP协议。REST最早是由 Roy Thomas Fielding 博士2000年在论文《Architectural Styles and the Design of Network-based Software Architectures》中提出的,中文译文全文PDF点此下载。另外,有篇译文对REST做了一个简化说明。
目前,REST架构风格的常见实现是基于HTTP协议及其四种基本方法(如POST、GET、PUT和DELETE)的。有人将HTTP协议的四种方法与CRUD原则相对应,CRUD原则对于资源只需要四种行为:Create(创建)、Read(读取)、Update(更新)和Delete(删除)就可以完成对其操作和处理。
在Mysql-udf-http中,四个函数http_post()、http_get()、http_put()、http_delete()分别对应HTTP协议的POST、GET、PUT、DELETE四种方法。
REST是一种架构风格,而不是协议或标准。HTTP协议“POST、GET、PUT、DELET”四种方法与CRUD原则“Create、Read、Update、Delete”四种行为的一一对应关系只是一种架构设计习惯,而不是规范。因此,POST方法也可以用来更新资源,PUT方法也可以用来创建资源,这就要看具体应用程序作者的定义了。例如Tokyo Tyrant除了支持Memcached协议外,还支持REST方式存取,PUT代表创建和更新,GET代表读取,DELETE代表删除(关于Tokyo Tyrant的安装使用请点击这儿)。
目前国内外流行的Web 2.0应用API接口中,很多都支持REST架构风格。例如:新浪微博开放平台、人人网API、Google OpenID、Flickr、Twitter、eBay、Facebook、Last.fm、del.icio.us、Yahoo Search、Amazon S3、Amazon EC2、Digg、Microsoft Bing、FriendFeed、PayPal、Foursquare,更多...
当记录数成百上千万条时,通常采用 MySQL 分表减低数据库压力。但是,全部数据按点击数、精华、积分排序显示等功能,在MySQL 分表中则无法实现。编写 Mysql-udf-http 的最初目的,是为了在项目开发中,将 MySQL 各分表的数据自动同步到我们的 TCSQL 高速列表数据库,用来做列表查询、显示,内容页则根据ID直接查询各 MySQL 分表的内容。由于HTTP协议的通用性,通过 Mysql-udf-http 可以做更多的事情。
通过Mysql-udf-http,你可以在MySQL中利用触发器,将MySQL的数据同步到支持REST的应用上。例如你有一个独立博客,你可以在文章表创建MySQL触发器,这样,在发表文章时,就可以将文章标题、URL自动同步到新浪微博、Twitter。你想用 Tokyo Tyrant 做缓存,也可以利用MySQL触发器在发生增、删、改时,将数据自动同步到 Tokyo Tyrant。详细配置方法本文第4节中会有介绍。
二、Mysql-udf-http的安装与使用:
1. 在Linux系统上安装Mysql-udf-http
注意:“/usr/local/webserver/mysql/”是你的MySQL安装路径,如果你的MySQL安装路径不同,请自行修改。
ulimit -SHn 65535
wget http://curl.haxx.se/download/curl-7.21.1.tar.gz
tar zxvf curl-7.21.1.tar.gz
cd curl-7.21.1/
./configure --prefix=/usr
make && make install
cd ../
echo "/usr/local/webserver/mysql/lib/mysql/" > /etc/ld.so.conf.d/mysql.conf
/sbin/ldconfig
wget http://mysql-udf-http.googlecode.com/files/mysql-udf-http-1.0.tar.gz
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
cd ../
wget http://curl.haxx.se/download/curl-7.21.1.tar.gz
tar zxvf curl-7.21.1.tar.gz
cd curl-7.21.1/
./configure --prefix=/usr
make && make install
cd ../
echo "/usr/local/webserver/mysql/lib/mysql/" > /etc/ld.so.conf.d/mysql.conf
/sbin/ldconfig
wget http://mysql-udf-http.googlecode.com/files/mysql-udf-http-1.0.tar.gz
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
cd ../
2. 通过命令行登陆进入MySQL
/usr/local/webserver/mysql/bin/mysql -S /tmp/mysql.sock
3. 创建MySQL自定义函数
mysql>
4. 使用方法
I. 函数描述:
mysql>
II. 示例 A:
mysql>
III. 示例
通过MySQL触发器,利用mysql-udf-http和第三方UDF函数lib_mysqludf_json,自动同步数据到 Tokyo Tyrant。
(1). 下载安装 lib_mysqludf_json 修改版:
以下安装包适合32位Linux操作系统:
wget http://mysql-udf-http.googlecode.com/files/lib_mysqludf_json-i386.tar.gz
tar zxvf lib_mysqludf_json-i386.tar.gz
cd lib_mysqludf_json-i386/
# 如果你的MySQL安装路径不是/usr/local/webserver/mysql/,请修改以下路径。
cp -f lib_mysqludf_json.so /usr/local/webserver/mysql/lib/mysql/plugin/lib_mysqludf_json.so
cd ../
tar zxvf lib_mysqludf_json-i386.tar.gz
cd lib_mysqludf_json-i386/
# 如果你的MySQL安装路径不是/usr/local/webserver/mysql/,请修改以下路径。
cp -f lib_mysqludf_json.so /usr/local/webserver/mysql/lib/mysql/plugin/lib_mysqludf_json.so
cd ../
以下安装包适合64位Linux操作系统:
wget http://mysql-udf-http.googlecode.com/files/lib_mysqludf_json-x86_64.tar.gz
tar zxvf lib_mysqludf_json-x86_64.tar.gz
cd lib_mysqludf_json-x86_64/
# 如果你的MySQL安装路径不是/usr/local/webserver/mysql/,请修改以下路径。
cp -f lib_mysqludf_json.so /usr/local/webserver/mysql/lib/mysql/plugin/lib_mysqludf_json.so
cd ../
tar zxvf lib_mysqludf_json-x86_64.tar.gz
cd lib_mysqludf_json-x86_64/
# 如果你的MySQL安装路径不是/usr/local/webserver/mysql/,请修改以下路径。
cp -f lib_mysqludf_json.so /usr/local/webserver/mysql/lib/mysql/plugin/lib_mysqludf_json.so
cd ../
通过命令行登陆进入MySQL:
/usr/local/webserver/mysql/bin/mysql -S /tmp/mysql.sock
mysql> lib_mysqludf_json的详细用法请访问:http://www.mysqludf.org/lib_mysqludf_json/
(2). 创建测试表
mysql>
(3). 为测试表创建触发器:
mysql>
(4). 将 MySQL 表和 Tokyo Tyrant 关联进行查询:
mysql>
5. 如何删除mysql-udf-http UDF函数:
mysql>
seo
2023-5-14 03:34
I know your expertise on this. I must say we should have an online discussion on this. Writing only comments will close the discussion straight away! And will restrict the benefits from this information.I can see that you are an expert at your field! I am launching a website soon, and your information will be very useful for me.. Thanks for all your help and wishing you all the success in your business.Great write-up, I am a big believer in commenting on blogs to inform the blog writers know that they’ve added something worthwhile to the world wide web!..I havent any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us. figurines pokemon
seo
2023-5-15 00:31
Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us.Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post.Very informative post! There is a lot of information here that can help any business get started with a successful social networking campaign.I was reading some of your content on this website and I conceive this internet site is really informative ! Keep on putting up.This is such a great resource that you are providing and you give it away for free.Positive site, where did u come up with the information on this posting? I'm pleased I discovered it though, ill be checking back soon to find out what additional posts you include. SUV mieten Jeepvermietung 4x4 4Matic 4Motion 3500kg berlin
seoo
2023-5-17 03:45
Awesome article, it was exceptionally helpful! I simply began in this and I'm becoming more acquainted with it better! Cheers, keep doing awesome!This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value. Im glad to have found this post as its such an interesting one! I am always on the lookout for quality posts and articles so i suppose im lucky to have found this! I hope you will be adding more in the future...Thanks for taking the time to discuss this, I feel strongly that love and read more on this topic. Battery Tooth Brush
seo
2023-5-21 17:39
Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info.i never know the use of adobe shadow until i saw this post. thank you for this! this is very helpful. suede microfiber cloth
seo
2023-5-21 17:43
I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future alsoReally i am impressed from this post....the person who create this post it was a great human. roulette online
seoo
2023-5-23 06:30
I haven’t any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us.Thank you because you have been willing to share information with us. Website Design
seo
2023-5-24 03:41
I havent any word to appreciate this post.....Really i am impressed from this post....the person who create this post it was a great human..thanks for shared this with us.Hello, this weekend is good for me, since this time i am reading this enormous informative article here at my home. daftar slot168
seo
2023-5-25 04:00
I was surfing the Internet for information and came across your blog. I am impressed by the information you have on this blog. It shows how well you understand this subject.Stopping by your blog helped me to get what I was looking for. The Myst
seo
2023-5-27 13:16
This weblog is so fine to me. I will preserve on coming right here once more and once more. Visit my hyperlink as well.. สล็อต g2g
USMAKD
2023-5-28 13:16
Gratitude for posting this data. I essentially have to help you to perceive that I basically try out your webweb page and I find it exceptionally exciting and useful. I can not hold back to look at masses of your posts. brunch seminyak
Hibah
2023-6-2 12:35
لیپو غبغب یا همان لیپوماتیک غبغب که در اصطلاح پزشکی از آن با عنوان لیپوماتیک سابمنتال یاد میشود، یک نوع جراحی پلاستیک است که میتواند به کمک امواج فرانبفش و مکش دستگاه لیپوماتیک، چربی اضافی را از ناحیه چانه، خط فک و گردن حذف کند. لیپوماتیک غبغب
JANBH
2023-6-2 20:12
PT Cargo imports goods from China. The system covers all needs. Including orders, pre-orders, importing products from China, transferring money to China, exchanging yuan, top-up, deposit Alipay, Taobao, and dropshipping service. นำเข้าสินค้าจากจีน
seoo
2023-6-9 04:44
I was surfing the Internet for information and came across your blog. I am impressed by the information you have on this blog. It shows how well you understand this subject.Stopping by your blog helped me to get what I was looking for. Best Tasting Disposable Vapes
Hibbah
2023-6-9 13:41
Good to visit your blog once more, it has been a long time for me. Well this article that i've been hung tight for such a long time. I want this article to finish my task in the school, and it has same point with your article. Much obliged, incredible offer. Online Trusted Casino Malaysia
Software
2023-6-14 21:08
Business communication services should work flawlessly, not frustrate or waste time. Business software is not designed to work together and was simply pieced together. HapPhi is a comprehensive suite of tools built to work seamlessly together to rebrand and sell. <a href="https://www.happhi.com/">Best Product Led Acquisition Software</a>
Hibbah
2023-6-15 19:03
Slot Gacor, Situs slot terbaik dengan layanan deposit Gacor, tanpa potongan! Dengan minimal deposit 25.000, kamu bisa merasakan kemudahan dan kepraktisan transaksi menggunakan aplikasi Dana. Jadi, jangan khawatir jika saldo bankmu sedang kosong. Aplikasi Dana adalah solusi terbaik untuk mempermudah transaksi judi online di Indonesia. Dalam dunia perjudian online, transaksi pembayaran sangatlah penting. Nah, dengan hadirnya aplikasi Dana, para pemain judi slot online bisa menikmati kemudahan dalam bertransaksi. Cukup dengan deposit minimal 25.000, kamu bisa melakukan deposit tanpa potongan melalui aplikasi Dana. Jadi, saldo bank yang kosong bukan lagi masalah besar bagi para penggemar judi online, terutama permainan slot. <a href="https://visitorbet.dontkillmyapp.com/">situs slot</a> situs slot
Hibah
2023-6-15 19:04
Slot Gacor, Situs slot terbaik dengan layanan deposit Gacor, tanpa potongan! Dengan minimal deposit 25.000, kamu bisa merasakan kemudahan dan kepraktisan transaksi menggunakan aplikasi Dana. Jadi, jangan khawatir jika saldo bankmu sedang kosong. Aplikasi Dana adalah solusi terbaik untuk mempermudah transaksi judi online di Indonesia. Dalam dunia perjudian online, transaksi pembayaran sangatlah penting. Nah, dengan hadirnya aplikasi Dana, para pemain judi slot online bisa menikmati kemudahan dalam bertransaksi. Cukup dengan deposit minimal 25.000, kamu bisa melakukan deposit tanpa potongan melalui aplikasi Dana. Jadi, saldo bank yang kosong bukan lagi masalah besar bagi para penggemar judi online, terutama permainan slot. situs slot
MNKJI
2023-6-15 22:06
There are many myths about masturbation. In recent years, masturbation has become a less sensitive topic for discussion. The whole idea of masturbation is to overstimulate the male genitals to lead to explosive sexual orgasms. male masturbators
starvip789
2023-6-16 18:57
PG It is a new hot new game camp of the year 2021, in which this camp pg 168 is very different from other camps and one of them is clearly Pc game 168.
starvip789
2023-6-16 18:57
slot pg It is a new hot new game camp of the year 2021, in which this camp pg 168 is very different from other camps and one of them is clearly Pc game 168.
分页: 9/24 4 5 6 7 8 9 10 11 12 13