<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[张宴的博客]]></title> 
<link>http://zyan.cc/index.php</link> 
<description><![CDATA[Web系统架构与底层研发]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[张宴的博客]]></copyright>
<item>
<link>http://zyan.cc/mysql-udf-http/</link>
<title><![CDATA[为 MySQL 增加 HTTP/REST 客户端：MySQL UDF 函数 mysql-udf-http 1.0 发布]]></title> 
<author>张宴 &lt;net@s135.com&gt;</author>
<category><![CDATA[数据库技术]]></category>
<pubDate>Wed, 08 Sep 2010 10:43:04 +0000</pubDate> 
<guid>http://zyan.cc/mysql-udf-http/</guid> 
<description>
<![CDATA[ 
	　　[文章作者：张宴 本文版本：v1.0 最后修改：2010.09.08 转载请注明原文链接：<a href="http://blog.zyan.cc/mysql-udf-http/" target="_blank">http://blog.zyan.cc/mysql-udf-http/</a>]<br/><br/>　　Mysql-udf-http 是一款简单的MySQL用户自定义函数（UDF, User-Defined Functions），具有http_get()、http_post()、http_put()、http_delete()四个函数，可以在MySQL数据库中利用HTTP协议进行REST相关操作。<br/><br/>　　<span style="font-size: 14px;"><span style="color: #FF0000;">项目网址</span>：<a href="http://code.google.com/p/mysql-udf-http/" target="_blank">http://code.google.com/p/mysql-udf-http/</a></span><br/>　　<span style="font-size: 14px;"><span style="color: #FF0000;">中文说明</span>：<a href="http://blog.zyan.cc/mysql-udf-http/" target="_blank">http://blog.zyan.cc/mysql-udf-http/</a></span><br/>　　<span style="font-size: 14px;">使用环境：</span>Linux操作系统，支持的MySQL版本：5.1.x 和 5.5.x。5.0.x未经测试。<br/>　　<span style="font-size: 14px;">软件作者：</span>张宴<br/><br/><hr/><br/>　　<span style="font-size: 14px;"><strong>一、REST架构风格：</strong></span><br/><br/>　　REST（Representational State Transfer）是一种轻量级的Web Service架构风格，其实现和操作明显比SOAP和XML-RPC更为简洁，可以完全通过HTTP协议实现，还可以利用缓存Cache来提高响应速度，性能、效率和易用性上都优于SOAP协议。REST最早是由 Roy Thomas Fielding 博士2000年在论文《<a href="http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm" target="_blank">Architectural Styles and the Design of Network-based Software Architectures</a>》中提出的，<a href="http://mysql-udf-http.googlecode.com/files/REST_cn.pdf" target="_blank">中文译文全文PDF点此下载</a>。另外，<a href="http://www.infoq.com/cn/articles/rest-introduction" target="_blank">有篇译文</a>对REST做了一个简化说明。<br/><br/>　　目前，REST架构风格的常见实现是基于HTTP协议及其四种基本方法（如POST、GET、PUT和DELETE）的。有人将HTTP协议的四种方法与CRUD原则相对应，CRUD原则对于资源只需要四种行为：Create（创建）、Read（读取）、Update（更新）和Delete（删除）就可以完成对其操作和处理。<br/><br/>　　<a href="http://zyan.cc//attachment/201009/crud.png" target="_blank"><img src="http://zyan.cc//attachment/201009/crud.png" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/><br/>　　<a href="http://zyan.cc//attachment/201009/rest.jpg" target="_blank"><img src="http://zyan.cc//attachment/201009/rest.jpg" class="insertimage" alt="点击在新窗口中浏览此图片" title="点击在新窗口中浏览此图片" border="0"/></a><br/><br/>　　在Mysql-udf-http中，四个函数http_post()、http_get()、http_put()、http_delete()分别对应HTTP协议的POST、GET、PUT、DELETE四种方法。<br/><br/>　　REST是一种架构风格，而不是协议或标准。HTTP协议“POST、GET、PUT、DELET”四种方法与CRUD原则“Create、Read、Update、Delete”四种行为的一一对应关系只是一种架构设计习惯，而不是规范。因此，POST方法也可以用来更新资源，PUT方法也可以用来创建资源，这就要看具体应用程序作者的定义了。例如<a href="/post/362/" target="_blank">Tokyo Tyrant</a>除了支持Memcached协议外，还支持REST方式存取，PUT代表创建和更新，GET代表读取，DELETE代表删除（<a href="/post/362/" target="_blank">关于Tokyo Tyrant的安装使用请点击这儿</a>）。<br/><br/>　　目前国内外流行的Web 2.0应用API接口中，很多都支持REST架构风格。例如：<a href="http://open.t.sina.com.cn/wiki/index.php/API%E6%96%87%E6%A1%A3" target="_blank">新浪微博开放平台</a>、<a href="http://wiki.dev.renren.com/wiki/API" target="_blank">人人网API</a>、Google OpenID、Flickr、Twitter、eBay、Facebook、Last.fm、del.icio.us、Yahoo Search、Amazon S3、Amazon EC2、Digg、Microsoft Bing、FriendFeed、PayPal、Foursquare，<a href="http://www.programmableweb.com/apis/directory/1?protocol=REST" target="_blank">更多...</a><br/><br/>　　当记录数成百上千万条时，通常采用 MySQL 分表减低数据库压力。但是，全部数据按点击数、精华、积分排序显示等功能，在MySQL 分表中则无法实现。编写 Mysql-udf-http 的最初目的，是为了在项目开发中，将 MySQL 各分表的数据自动同步到我们的 <a href="/tcsql/" target="_blank">TCSQL</a> 高速列表数据库，用来做列表查询、显示，内容页则根据ID直接查询各 MySQL 分表的内容。由于HTTP协议的通用性，通过 Mysql-udf-http 可以做更多的事情。<br/><br/>　　<strong>通过Mysql-udf-http，你可以在MySQL中利用触发器，将MySQL的数据同步到支持REST的应用上。</strong>例如你有一个独立博客，你可以在文章表创建MySQL触发器，这样，在发表文章时，就可以将文章标题、URL自动同步到新浪微博、Twitter。你想用 <a href="/post/362/" target="_blank">Tokyo Tyrant</a> 做缓存，也可以<span style="color: #FF0000;">利用MySQL触发器在发生增、删、改时，将数据自动同步到 <a href="/post/362/" target="_blank">Tokyo Tyrant</a></span>。详细配置方法本文第4节中会有介绍。<br/><br/><hr/><br/>　　<span style="font-size: 14px;"><strong>二、Mysql-udf-http的安装与使用：</strong></span><br/><br/>　　<strong>1. 在Linux系统上安装Mysql-udf-http</strong><br/><br/>　　注意：“/usr/local/webserver/mysql/”是你的MySQL安装路径，如果你的MySQL安装路径不同，请自行修改。<br/><br/>............<br/><br/>Tags - <a href="http://zyan.cc/tags/mysql-udf-http/" rel="tag">mysql-udf-http</a> , <a href="http://zyan.cc/tags/mysql/" rel="tag">mysql</a> , <a href="http://zyan.cc/tags/udf/" rel="tag">udf</a> , <a href="http://zyan.cc/tags/http/" rel="tag">http</a> , <a href="http://zyan.cc/tags/rest/" rel="tag">rest</a> , <a href="http://zyan.cc/tags/http_get/" rel="tag">http get</a> , <a href="http://zyan.cc/tags/http_post/" rel="tag">http post</a> , <a href="http://zyan.cc/tags/http_put/" rel="tag">http put</a> , <a href="http://zyan.cc/tags/http_delete/" rel="tag">http delete</a> , <a href="http://zyan.cc/tags/get/" rel="tag">get</a> , <a href="http://zyan.cc/tags/post/" rel="tag">post</a> , <a href="http://zyan.cc/tags/put/" rel="tag">put</a> , <a href="http://zyan.cc/tags/delete/" rel="tag">delete</a> , <a href="http://zyan.cc/tags/trigger/" rel="tag">trigger</a>
]]>
</description>
</item><item>
<link>http://zyan.cc/mysql-udf-http/#blogcomment6764</link>
<title><![CDATA[[评论] 为 MySQL 增加 HTTP/REST 客户端：MySQL UDF 函数 mysql-udf-http 1.0 发布]]></title> 
<author>shiny &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 08 Sep 2010 11:16:08 +0000</pubDate> 
<guid>http://zyan.cc/mysql-udf-http/#blogcomment6764</guid> 
<description>
<![CDATA[ 
	参观学习。
]]>
</description>
</item><item>
<link>http://zyan.cc/mysql-udf-http/#blogcomment6765</link>
<title><![CDATA[[评论] 为 MySQL 增加 HTTP/REST 客户端：MySQL UDF 函数 mysql-udf-http 1.0 发布]]></title> 
<author>bqrm &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 08 Sep 2010 13:15:30 +0000</pubDate> 
<guid>http://zyan.cc/mysql-udf-http/#blogcomment6765</guid> 
<description>
<![CDATA[ 
	很赞！
]]>
</description>
</item><item>
<link>http://zyan.cc/mysql-udf-http/#blogcomment6766</link>
<title><![CDATA[[评论] 为 MySQL 增加 HTTP/REST 客户端：MySQL UDF 函数 mysql-udf-http 1.0 发布]]></title> 
<author>伟伟 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 08 Sep 2010 14:43:58 +0000</pubDate> 
<guid>http://zyan.cc/mysql-udf-http/#blogcomment6766</guid> 
<description>
<![CDATA[ 
	思路挺好的，不知道数据同步的稳定性如何？毕竟是基于HTTP的
]]>
</description>
</item><item>
<link>http://zyan.cc/mysql-udf-http/#blogcomment6768</link>
<title><![CDATA[[评论] 为 MySQL 增加 HTTP/REST 客户端：MySQL UDF 函数 mysql-udf-http 1.0 发布]]></title> 
<author>太阳里的雪 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 08 Sep 2010 15:24:49 +0000</pubDate> 
<guid>http://zyan.cc/mysql-udf-http/#blogcomment6768</guid> 
<description>
<![CDATA[ 
	好象大量使用mysql触发器会出现性能问题，mysql的触发器对性能影响比较严重～～
]]>
</description>
</item><item>
<link>http://zyan.cc/mysql-udf-http/#blogcomment6770</link>
<title><![CDATA[[评论] 为 MySQL 增加 HTTP/REST 客户端：MySQL UDF 函数 mysql-udf-http 1.0 发布]]></title> 
<author>怪物宝 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Wed, 08 Sep 2010 15:41:06 +0000</pubDate> 
<guid>http://zyan.cc/mysql-udf-http/#blogcomment6770</guid> 
<description>
<![CDATA[ 
	好东西，先试试
]]>
</description>
</item><item>
<link>http://zyan.cc/mysql-udf-http/#blogcomment6772</link>
<title><![CDATA[[评论] 为 MySQL 增加 HTTP/REST 客户端：MySQL UDF 函数 mysql-udf-http 1.0 发布]]></title> 
<author>kth007 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 09 Sep 2010 01:07:24 +0000</pubDate> 
<guid>http://zyan.cc/mysql-udf-http/#blogcomment6772</guid> 
<description>
<![CDATA[ 
	好东西，，先占位！！
]]>
</description>
</item><item>
<link>http://zyan.cc/mysql-udf-http/#blogcomment6773</link>
<title><![CDATA[[评论] 为 MySQL 增加 HTTP/REST 客户端：MySQL UDF 函数 mysql-udf-http 1.0 发布]]></title> 
<author>kimi &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 09 Sep 2010 04:28:07 +0000</pubDate> 
<guid>http://zyan.cc/mysql-udf-http/#blogcomment6773</guid> 
<description>
<![CDATA[ 
	Mr，张。<br/>问一个与该文章无关的问题，如何异步从memcached中刷数据到mysql中？我crontab是一种解决方案，如果数据量太大了该如何呢？
]]>
</description>
</item><item>
<link>http://zyan.cc/mysql-udf-http/#blogcomment6774</link>
<title><![CDATA[[评论] 为 MySQL 增加 HTTP/REST 客户端：MySQL UDF 函数 mysql-udf-http 1.0 发布]]></title> 
<author>johntech &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 09 Sep 2010 05:19:23 +0000</pubDate> 
<guid>http://zyan.cc/mysql-udf-http/#blogcomment6774</guid> 
<description>
<![CDATA[ 
	宴哥，威武！
]]>
</description>
</item><item>
<link>http://zyan.cc/mysql-udf-http/#blogcomment6778</link>
<title><![CDATA[[评论] 为 MySQL 增加 HTTP/REST 客户端：MySQL UDF 函数 mysql-udf-http 1.0 发布]]></title> 
<author>starlight36 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 09 Sep 2010 12:44:50 +0000</pubDate> 
<guid>http://zyan.cc/mysql-udf-http/#blogcomment6778</guid> 
<description>
<![CDATA[ 
	啊，终于抢到第一页了~~
]]>
</description>
</item><item>
<link>http://zyan.cc/mysql-udf-http/#blogcomment6779</link>
<title><![CDATA[[评论] 为 MySQL 增加 HTTP/REST 客户端：MySQL UDF 函数 mysql-udf-http 1.0 发布]]></title> 
<author>GaoXiao &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 09 Sep 2010 13:48:30 +0000</pubDate> 
<guid>http://zyan.cc/mysql-udf-http/#blogcomment6779</guid> 
<description>
<![CDATA[ 
	Mr.Zhang又有新博文发布，先顶再研究文章
]]>
</description>
</item><item>
<link>http://zyan.cc/mysql-udf-http/#blogcomment6798</link>
<title><![CDATA[[评论] 为 MySQL 增加 HTTP/REST 客户端：MySQL UDF 函数 mysql-udf-http 1.0 发布]]></title> 
<author>shadow &lt;firegt@gmail.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sun, 12 Sep 2010 00:51:37 +0000</pubDate> 
<guid>http://zyan.cc/mysql-udf-http/#blogcomment6798</guid> 
<description>
<![CDATA[ 
	不错，学习下。最近感觉mysql的服务端查询多了压力有点大
]]>
</description>
</item><item>
<link>http://zyan.cc/mysql-udf-http/#blogcomment6799</link>
<title><![CDATA[[评论] 为 MySQL 增加 HTTP/REST 客户端：MySQL UDF 函数 mysql-udf-http 1.0 发布]]></title> 
<author>uohzoaix &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Sun, 12 Sep 2010 06:29:35 +0000</pubDate> 
<guid>http://zyan.cc/mysql-udf-http/#blogcomment6799</guid> 
<description>
<![CDATA[ 
	为什么我在创建自定义函数时出现mysql-udf-http.so:cannot open shared object file:no such file or directory.我在机器上已经找到了此文件所在的目录，并将目录都添加到了/etc/ld.so.conf文件中。怎么还是不行？
]]>
</description>
</item><item>
<link>http://zyan.cc/mysql-udf-http/#blogcomment6801</link>
<title><![CDATA[[评论] 为 MySQL 增加 HTTP/REST 客户端：MySQL UDF 函数 mysql-udf-http 1.0 发布]]></title> 
<author>ass &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Mon, 13 Sep 2010 02:53:24 +0000</pubDate> 
<guid>http://zyan.cc/mysql-udf-http/#blogcomment6801</guid> 
<description>
<![CDATA[ 
	很奇怪，我的环境下，执行 create function lib_mysqludf_json_info returns string soname &#039;lib_mysqludf_json.so&#039;;&nbsp;&nbsp;这步会让MYSQL崩溃，5.1.45及5.4.2版本均是此现象。<br/>错误日志内容：<br/>100913&nbsp;&nbsp;9:30:59 - mysqld got signal 8 ;<br/>This could be because you hit a bug. It is also possible that this binary<br/>or one of the libraries it was linked against is corrupt, improperly built,<br/>or misconfigured. This error can also be caused by malfunctioning hardware.<br/>We will try our best to scrape up some info that will hopefully help diagnose<br/>the problem, but since we have already crashed, something is definitely wrong<br/>and this may fail.<br/><br/>key_buffer_size=16777216<br/>read_buffer_size=262144<br/>max_used_connections=1<br/>max_threads=151<br/>threads_connected=1<br/>It is possible that mysqld could use up to<br/>key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 133889 K<br/>bytes of memory<br/>Hope that&#039;s ok; if not, decrease some variables in the equation.<br/><br/>thd: 0x37cf3a0<br/>Attempting backtrace. You can use the following information to find out<br/>where mysqld died. If you see no messages after this, something went<br/>terribly wrong...<br/>stack_bottom = 0x4dc971a0 thread_stack 0x40000<br/>/usr/local/mysql/bin/mysqld(my_print_stacktrace+0x2e)[0x89f80e]<br/>/usr/local/mysql/bin/mysqld(handle_segfault+0x322)[0x5c4422]<br/>/lib64/tls/libpthread.so.0[0x3977c0c430]<br/>/lib64/ld-linux-x86-64.so.2[0x3976d074d7]<br/>/lib64/ld-linux-x86-64.so.2[0x3976d0789e]<br/>/lib64/ld-linux-x86-64.so.2[0x3976d08c70]<br/>/lib64/tls/libc.so.6[0x39771f7ad8]<br/>/lib64/ld-linux-x86-64.so.2[0x3976d0aab0]<br/>/lib64/tls/libc.so.6(_dl_open+0xaa)[0x39771f846a]<br/>/lib64/libdl.so.2[0x3976f01054]<br/>/lib64/ld-linux-x86-64.so.2[0x3976d0aab0]<br/>/lib64/libdl.so.2[0x3976f01552]<br/>/lib64/libdl.so.2(dlopen+0x32)[0x3976f01092]<br/>/usr/local/mysql/bin/mysqld(_Z21mysql_create_functionP3THDP11st_udf_func+0x231)[0x6e7661]<br/>/usr/local/mysql/bin/mysqld(_Z21mysql_execute_commandP3THD+0x22c5)[0x5d69c5]<br/>/usr/local/mysql/bin/mysqld(_Z11mysql_parseP3THDPKcjPS2_+0x357)[0x5da287]<br/>/usr/local/mysql/bin/mysqld(_Z16dispatch_command19enum_server_commandP3THDPcj+0xe93)[0x5db123]<br/>/usr/local/mysql/bin/mysqld(_Z10do_commandP3THD+0xe6)[0x5db9e6]<br/>/usr/local/mysql/bin/mysqld(handle_one_connection+0x246)[0x5ce326]<br/>/lib64/tls/libpthread.so.0[0x3977c0610a]<br/>/lib64/tls/libc.so.6(__clone+0x73)[0x39771c68c3]<br/>Trying to get some variables.<br/>Some pointers may be invalid and cause the dump to abort...<br/>thd-&gt;query at 0x3822ce0 = create function lib_mysqludf_json_info returns string soname &#039;lib_mysqludf_json.so&#039;<br/>thd-&gt;thread_id=2<br/>thd-&gt;killed=NOT_KILLED<br/>The manual page at <a href="http://dev.mysql.com/doc/mysql/en/crashing.html" target="_blank">http://dev.mysql.com/doc/mysql/en/crashing.html</a> contains<br/>information that should help you find out what is causing the crash.<br/>100913 09:30:59 mysqld_safe Number of processes running now: 0<br/>100913 09:30:59 mysqld_safe mysqld restarted<br/>100913&nbsp;&nbsp;9:30:59 [Note] Plugin &#039;FEDERATED&#039; is disabled.<br/>InnoDB: The InnoDB memory heap is disabled。。<br/><br/>反复尝试，错误依旧，不知在MYSQL版本及权限有何需要注意的没？ 谢谢
]]>
</description>
</item><item>
<link>http://zyan.cc/mysql-udf-http/#blogcomment6809</link>
<title><![CDATA[[评论] 为 MySQL 增加 HTTP/REST 客户端：MySQL UDF 函数 mysql-udf-http 1.0 发布]]></title> 
<author>行人 &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Mon, 13 Sep 2010 14:29:33 +0000</pubDate> 
<guid>http://zyan.cc/mysql-udf-http/#blogcomment6809</guid> 
<description>
<![CDATA[ 
	很不错~
]]>
</description>
</item><item>
<link>http://zyan.cc/mysql-udf-http/#blogcomment6813</link>
<title><![CDATA[[评论] 为 MySQL 增加 HTTP/REST 客户端：MySQL UDF 函数 mysql-udf-http 1.0 发布]]></title> 
<author>jstfnifypm &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Tue, 14 Sep 2010 09:38:01 +0000</pubDate> 
<guid>http://zyan.cc/mysql-udf-http/#blogcomment6813</guid> 
<description>
<![CDATA[ 
	宴哥&nbsp;&nbsp;强大 顶下
]]>
</description>
</item>
</channel>
</rss>