<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
<channel>
	<title>flyinweb's blog</title>
	<link>http://www.517sou.net/</link>
	<language>zh-CN</language>
	<webMaster>shanyiwan@msn.com(flyinweb)</webMaster>
	<pubDate>Mon, 15 Jun 2009 19:31:16 GMT</pubDate>
	<copyright>Copyright 2007-2009. All rights reserved.</copyright>
	<generator>Bitrac Free Version</generator>
	<description>桃李无言，下自成蹊</description>
	<image>
		<title>flyinweb&apos;s blog</title>
		<url>http://www.517sou.net/Client/Banner.gif</url>
		<link>http://www.517sou.net/</link>
		<description>桃李无言，下自成蹊</description>
	</image>
	<item>
		<link>http://www.517sou.net/Article/TTserver-application-and-deployment.aspx</link>
		<title>ttserver 应用与部署</title>
		<author>shanyiwan@live.com(flyinweb)</author>
		<category>数据库技术</category>
		<pubDate>Fri, 18 May 2012 06:36:12 GMT</pubDate>
		<description>&lt;p&gt;&lt;b&gt;第一部分 应用篇 -- 利用Tokyo Tyrant构建兼容Memcached协议、支持故障转移、高并发的分布式key-value持久存储系统&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://www.1978th.net/tokyocabinet/&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Tokyo Cabinet&lt;/font&gt;&lt;/u&gt;&lt;/a&gt; 是日本人 平林幹雄 开发的一款 DBM 数据库，该数据库读写非常快，哈希模式写入100万条数据只需0.643秒，读取100万条数据只需0.773秒，是 Berkeley DB 等 DBM 的几倍。&lt;br /&gt;&lt;br /&gt;&lt;img class=&quot;Image&quot; title=&quot;点击在新窗口中浏览此图片&quot; border=&quot;0&quot; alt=&quot;点击在新窗口中浏览此图片&quot; src=&quot;http://www.517sou.net/Attach/month_1205/qqdxed_tokyocabinet.gif&quot; width=&quot;656&quot; height=&quot;417&quot; /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;&lt;br /&gt;&lt;a href=&quot;http://www.1978th.net/tokyotyrant/&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Tokyo Tyrant&lt;/font&gt;&lt;/u&gt;&lt;/a&gt; 是由同一作者开发的 Tokyo Cabinet 数据库网络接口。它拥有Memcached兼容协议，也可以通过HTTP协议进行数据交换。&lt;br /&gt;&lt;br /&gt;　　Tokyo Tyrant 加上 Tokyo Cabinet，构成了一款支持高并发的分布式持久存储系统，对任何原有Memcached客户端来讲，可以将Tokyo Tyrant看成是一个Memcached，但是，它的数据是可以持久存储的。这一点，跟新浪的&lt;a href=&quot;http://memcachedb.org/&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Memcachedb&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;性质一样。&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;相比Memcachedb而言，Tokyo Tyrant具有以下优势：&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;　　1、故障转移：Tokyo Tyrant支持双机互为主辅模式，主辅库均可读写，而Memcachedb目前支持类似MySQL主辅库同步的方式实现读写分离，支持“主服务器可读写、辅助服务器只读”模式。&lt;br /&gt;&lt;br /&gt;&lt;img class=&quot;Image&quot; title=&quot;点击在新窗口中浏览此图片&quot; border=&quot;0&quot; alt=&quot;点击在新窗口中浏览此图片&quot; src=&quot;http://www.517sou.net/Attach/month_1205/8eyqzg_addserver.gif&quot; width=&quot;311&quot; height=&quot;288&quot; /&gt;&lt;br /&gt;&lt;br /&gt;　　这里使用 $memcache-&amp;gt;addServer 而不是 $memcache-&amp;gt;connect 去连接 Tokyo Tyrant 服务器，是因为当 Memcache 客户端使用 addServer 服务器池时，是根据“crc32(key) % current_server_num”哈希算法将 key 哈希到不同的服务器的，PHP、C 和 python 的客户端都是如此的算法。Memcache 客户端的 addserver 具有故障转移机制，当 addserver 了2台 Memcached 服务器，而其中1台宕机了，那么 current_server_num 会由原先的2变成1。&lt;br /&gt;&lt;br /&gt;　　引用 memcached 官方网站和 PHP 手册中的两段话： &lt;br /&gt;&lt;/p&gt;&lt;div class=&quot;quote&quot;&gt;&lt;div class=&quot;quote-title&quot;&gt;引用&lt;/div&gt;&lt;div class=&quot;quote-content&quot;&gt;http://www.danga.com/memcached/ &lt;br /&gt;If a host goes down, the API re-maps that dead host&apos;s requests onto the servers that are available. &lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;http://cn.php.net/manual/zh/function.Memcache-addServer.php&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;http://cn.php.net/manual/zh/function.Memcache-addServer.php&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;Failover may occur at any stage in any of the methods, as long as other servers are available the request the user won&apos;t notice. Any kind of socket or Memcached server level errors (except out-of-memory) may trigger the failover. Normal client errors such as adding an existing key will not trigger a failover.&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;&lt;br /&gt;　　2、日志文件体积小：Tokyo Tyrant用于主辅同步的日志文件比较小，大约是数据库文件的1.3倍，而Memcachedb的同步日志文件非常大，如果不定期清理，很容易将磁盘写满。&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;&lt;br /&gt;　　3、超大数据量下表现出色：&lt;br /&gt;&lt;br /&gt;&lt;img class=&quot;Image&quot; title=&quot;点击在新窗口中浏览此图片&quot; border=&quot;0&quot; alt=&quot;点击在新窗口中浏览此图片&quot; src=&quot;http://www.517sou.net/Attach/month_1205/xs0j4t_tokyotyrant.gif&quot; width=&quot;644&quot; height=&quot;786&quot; /&gt;&lt;br /&gt;&lt;br /&gt;　　但是，Tokyo Tyrant 也有缺点：&lt;span style=&quot;color: rgb(255,0,0)&quot;&gt;在32位操作系统下，作为 Tokyo Tyrant 后端存储的 Tokyo Cabinet 数据库单个文件不能超过2G，而64位操作系统则不受这一限制。&lt;/span&gt;所以，如果使用 Tokyo Tyrant，推荐在64位CPU、操作系统上安装运行。&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;一、安装&lt;/strong&gt;&lt;br /&gt;　　1、首先编译安装tokyocabinet数据库&lt;br /&gt;&lt;/p&gt;&lt;div style=&quot;border-bottom: rgb(0,160,198) 1px dashed; border-left: rgb(0,160,198) 1px dashed; padding-bottom: 3px; background-color: rgb(255,255,255); margin: 5px 5px 0px; padding-left: 3px; padding-right: 3px; border-top: rgb(0,160,198) 1px dashed; border-right: rgb(0,160,198) 1px dashed; padding-top: 3px&quot;&gt;wget &lt;a href=&quot;http://www.1978th.net/tokyocabinet/tokyocabinet-1.4.45.tar.gz&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;http://www.1978th.net/tokyocabinet/tokyocabinet-1.4.45.tar.gz&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;tar zxvf tokyocabinet-1.4.45.tar.gz&lt;br /&gt;cd tokyocabinet-1.4.45/&lt;br /&gt;./configure&lt;br /&gt;#注：在32位Linux操作系统上编译Tokyo cabinet，请使用./configure --enable-off64代替./configure，可以使数据库文件突破2GB的限制。&lt;br /&gt;#./configure --enable-off64&lt;br /&gt;make&lt;br /&gt;make install&lt;br /&gt;cd ../&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;　　2、然后编译安装tokyotyrant&lt;br /&gt;&lt;/p&gt;&lt;div style=&quot;border-bottom: rgb(0,160,198) 1px dashed; border-left: rgb(0,160,198) 1px dashed; padding-bottom: 3px; background-color: rgb(255,255,255); margin: 5px 5px 0px; padding-left: 3px; padding-right: 3px; border-top: rgb(0,160,198) 1px dashed; border-right: rgb(0,160,198) 1px dashed; padding-top: 3px&quot;&gt;wget &lt;a href=&quot;http://www.1978th.net/tokyotyrant/tokyotyrant-1.1.40.tar.gz&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;http://www.1978th.net/tokyotyrant/tokyotyrant-1.1.40.tar.gz&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;br /&gt;tar zxvf tokyotyrant-1.1.40.tar.gz&lt;br /&gt;cd tokyotyrant-1.1.40/&lt;br /&gt;./configure&lt;br /&gt;make&lt;br /&gt;make install&lt;br /&gt;cd ../&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;二、配置&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;1、创建tokyotyrant数据文件存放目录&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style=&quot;border-bottom: rgb(0,160,198) 1px dashed; border-left: rgb(0,160,198) 1px dashed; padding-bottom: 3px; background-color: rgb(255,255,255); margin: 5px 5px 0px; padding-left: 3px; padding-right: 3px; border-top: rgb(0,160,198) 1px dashed; border-right: rgb(0,160,198) 1px dashed; padding-top: 3px&quot;&gt;mkdir -p /ttserver/&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2、启动tokyotyrant的主进程（ttserver）&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;(1)、单机模式&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style=&quot;border-bottom: rgb(0,160,198) 1px dashed; border-left: rgb(0,160,198) 1px dashed; padding-bottom: 3px; background-color: rgb(255,255,255); margin: 5px 5px 0px; padding-left: 3px; padding-right: 3px; border-top: rgb(0,160,198) 1px dashed; border-right: rgb(0,160,198) 1px dashed; padding-top: 3px&quot;&gt;ulimit -SHn 51200&lt;br /&gt;ttserver -host 127.0.0.1 -port 11211 -thnum 8 -dmn -pid /ttserver/ttserver.pid -log /ttserver/ttserver.log -le -ulog /ttserver/ -ulim 128m -sid 1 -rts /ttserver/ttserver.rts /ttserver/database.tcb#lmemb=1024#nmemb=2048#bnum=10000000&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;(2)、双机互为主辅模式&lt;/strong&gt;&lt;br /&gt;　　服务器192.168.1.91：&lt;br /&gt;&lt;/p&gt;&lt;div style=&quot;border-bottom: rgb(0,160,198) 1px dashed; border-left: rgb(0,160,198) 1px dashed; padding-bottom: 3px; background-color: rgb(255,255,255); margin: 5px 5px 0px; padding-left: 3px; padding-right: 3px; border-top: rgb(0,160,198) 1px dashed; border-right: rgb(0,160,198) 1px dashed; padding-top: 3px&quot;&gt;ulimit -SHn 51200&lt;br /&gt;ttserver -host 192.168.1.91 -port 11211 -thnum 8 -dmn -pid /ttserver/ttserver.pid -log /ttserver/ttserver.log -le -ulog /ttserver/ -ulim 128m -sid 91 -mhost 192.168.1.92 -mport 11211 -rts /ttserver/ttserver.rts /ttserver/database.tcb#lmemb=1024#nmemb=2048#bnum=10000000&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;　　服务器192.168.1.92：&lt;br /&gt;&lt;/p&gt;&lt;div style=&quot;border-bottom: rgb(0,160,198) 1px dashed; border-left: rgb(0,160,198) 1px dashed; padding-bottom: 3px; background-color: rgb(255,255,255); margin: 5px 5px 0px; padding-left: 3px; padding-right: 3px; border-top: rgb(0,160,198) 1px dashed; border-right: rgb(0,160,198) 1px dashed; padding-top: 3px&quot;&gt;ulimit -SHn 51200&lt;br /&gt;ttserver -host 192.168.1.92 -port 11211 -thnum 8 -dmn -pid /ttserver/ttserver.pid -log /ttserver/ttserver.log -le -ulog /ttserver/ -ulim 128m -sid 92 -mhost 192.168.1.91 -mport 11211 -rts /ttserver/ttserver.rts /ttserver/database.tcb#lmemb=1024#nmemb=2048#bnum=10000000&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;(3)、参数说明&lt;/strong&gt;&lt;br /&gt;　　ttserver [-host name] [-port num] [-thnum num] [-tout num] [-dmn] [-pid path] [-log path] [-ld|-le] [-ulog path] [-ulim num] [-uas] [-sid num] [-mhost name] [-mport num] [-rts path] [dbname] &lt;br /&gt;&lt;br /&gt;　　-host name : 指定需要绑定的服务器域名或IP地址。默认绑定这台服务器上的所有IP地址。&lt;br /&gt;　　-port num : 指定需要绑定的端口号。默认端口号为1978 &lt;br /&gt;　　-thnum num : 指定线程数。默认为8个线程。 &lt;br /&gt;　　-tout num : 指定每个会话的超时时间（单位为秒）。默认永不超时。 &lt;br /&gt;　　-dmn : 以守护进程方式运行。&lt;br /&gt;　　-pid path : 输出进程ID到指定文件（这里指定文件名）。&lt;br /&gt;　　-log path : 输出日志信息到指定文件（这里指定文件名）。&lt;br /&gt;　　-ld : 在日志文件中还记录DEBUG调试信息。&lt;br /&gt;　　-le : 在日志文件中仅记录错误信息。&lt;br /&gt;　　-ulog path : 指定同步日志文件存放路径（这里指定目录名）。&lt;br /&gt;　　-ulim num : 指定每个同步日志文件的大小（例如128m）。&lt;br /&gt;　　-uas : 使用异步IO记录更新日志（使用此项会减少磁盘IO消耗，但是数据会先放在内存中，不会立即写入磁盘，如果重启服务器或ttserver进程被kill掉，将导致部分数据丢失。一般情况下不建议使用）。&lt;br /&gt;　　-sid num : 指定服务器ID号（当使用主辅模式时，每台ttserver需要不同的ID号） &lt;br /&gt;　　-mhost name : 指定主辅同步模式下，主服务器的域名或IP地址。&lt;br /&gt;　　-mport num : 指定主辅同步模式下，主服务器的端口号。&lt;br /&gt;　　-rts path : 指定用来存放同步时间戳的文件名。&lt;br /&gt;&lt;br /&gt;　　如果使用的是哈希数据库，可以指定参数“#bnum=xxx”来提高性能。它可以指定bucket存储桶的数量。例如指定“#bnum=1000000”，就可以将最新最热的100万条记录缓存在内存中：&lt;br /&gt;&lt;/p&gt;&lt;div style=&quot;border-bottom: rgb(0,160,198) 1px dashed; border-left: rgb(0,160,198) 1px dashed; padding-bottom: 3px; background-color: rgb(255,255,255); margin: 5px 5px 0px; padding-left: 3px; padding-right: 3px; border-top: rgb(0,160,198) 1px dashed; border-right: rgb(0,160,198) 1px dashed; padding-top: 3px&quot;&gt;ttserver -host 127.0.0.1 -port 11211 -thnum 8 -dmn -pid /ttserver/ttserver.pid -log /ttserver/ttserver.log -le -ulog /ttserver/ -ulim 128m -sid 1 -rts /ttserver/ttserver.rts /ttserver/database.tch#bnum=1000000&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;　　如果大量的客户端访问ttserver，请确保文件描述符够用。许多服务器的默认文件描述符为1024，可以在启动ttserver前使用ulimit命令提高这项值。例如：&lt;br /&gt;&lt;/p&gt;&lt;div style=&quot;border-bottom: rgb(0,160,198) 1px dashed; border-left: rgb(0,160,198) 1px dashed; padding-bottom: 3px; background-color: rgb(255,255,255); margin: 5px 5px 0px; padding-left: 3px; padding-right: 3px; border-top: rgb(0,160,198) 1px dashed; border-right: rgb(0,160,198) 1px dashed; padding-top: 3px&quot;&gt;ulimit -SHn 51200&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;3、停止tokyotyrant（ttserver）&lt;/strong&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style=&quot;border-bottom: rgb(0,160,198) 1px dashed; border-left: rgb(0,160,198) 1px dashed; padding-bottom: 3px; background-color: rgb(255,255,255); margin: 5px 5px 0px; padding-left: 3px; padding-right: 3px; border-top: rgb(0,160,198) 1px dashed; border-right: rgb(0,160,198) 1px dashed; padding-top: 3px&quot;&gt;ps -ef | grep ttserver&lt;/div&gt;&lt;p&gt;&lt;br /&gt;　　找到ttserver的进程号并kill，例如：&lt;br /&gt;&lt;/p&gt;&lt;div style=&quot;border-bottom: rgb(0,160,198) 1px dashed; border-left: rgb(0,160,198) 1px dashed; padding-bottom: 3px; background-color: rgb(255,255,255); margin: 5px 5px 0px; padding-left: 3px; padding-right: 3px; border-top: rgb(0,160,198) 1px dashed; border-right: rgb(0,160,198) 1px dashed; padding-top: 3px&quot;&gt;kill -TERM 2159&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;&lt;br /&gt;&lt;strong&gt;三、调用&lt;/strong&gt;&lt;br /&gt;&lt;strong&gt;1、任何Memcached客户端均可直接调用tokyotyrant。&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;2、还可以通过HTTP方式调用，下面以Linux的curl命令为例，介绍如何操作tokyotyrant：&lt;/strong&gt;&lt;br /&gt;　　(1)、写数据，将数据“value”写入到“key”中：&lt;br /&gt;&lt;/p&gt;&lt;div style=&quot;border-bottom: rgb(0,160,198) 1px dashed; border-left: rgb(0,160,198) 1px dashed; padding-bottom: 3px; background-color: rgb(255,255,255); margin: 5px 5px 0px; padding-left: 3px; padding-right: 3px; border-top: rgb(0,160,198) 1px dashed; border-right: rgb(0,160,198) 1px dashed; padding-top: 3px&quot;&gt;curl -X PUT &lt;a href=&quot;http://127.0.0.1:11211/key&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;http://127.0.0.1:11211/key&lt;/font&gt;&lt;/u&gt;&lt;/a&gt; -d &amp;quot;value&amp;quot;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;　　(2)、读数据，读取“key”中数据：&lt;br /&gt;&lt;/p&gt;&lt;div style=&quot;border-bottom: rgb(0,160,198) 1px dashed; border-left: rgb(0,160,198) 1px dashed; padding-bottom: 3px; background-color: rgb(255,255,255); margin: 5px 5px 0px; padding-left: 3px; padding-right: 3px; border-top: rgb(0,160,198) 1px dashed; border-right: rgb(0,160,198) 1px dashed; padding-top: 3px&quot;&gt;curl &lt;a href=&quot;http://127.0.0.1:11211/key&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;http://127.0.0.1:11211/key&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;　　(3)、删数据，删除“key”：&lt;br /&gt;&lt;/p&gt;&lt;div style=&quot;border-bottom: rgb(0,160,198) 1px dashed; border-left: rgb(0,160,198) 1px dashed; padding-bottom: 3px; background-color: rgb(255,255,255); margin: 5px 5px 0px; padding-left: 3px; padding-right: 3px; border-top: rgb(0,160,198) 1px dashed; border-right: rgb(0,160,198) 1px dashed; padding-top: 3px&quot;&gt;curl -X DELETE &lt;a href=&quot;http://127.0.0.1:11211/key&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;http://127.0.0.1:11211/key&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;附：文章修改历史&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;　　● [2008年08月07日] [Version 1.0] 撰写本文&lt;br /&gt;&lt;br /&gt;　　● [2008年10月16日] [Version 1.1] Tokyo Cabinet 版本升级到 1.3.12；Tokyo Tyrant 版本升级到 1.1.5&lt;br /&gt;&lt;br /&gt;　　● [2008年12月04日] [Version 1.2] Tokyo Cabinet 版本升级到 1.3.22；Tokyo Tyrant 版本升级到 1.1.8&lt;br /&gt;&lt;br /&gt;　　● [2008年07月06日] [Version 1.3] Tokyo Cabinet 版本升级到 1.4.28；Tokyo Tyrant 版本升级到 1.1.29&lt;br /&gt;&lt;br /&gt;　　● [2010年06月11日] [Version 1.4] Tokyo Cabinet 版本升级到 1.4.45；Tokyo Tyrant 版本升级到 1.1.40；默认示例改为B+Tree数据库；增加32位Linux操作系统上编译Tokyo cabinet的configue配置。&lt;/p&gt;&lt;hr /&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;第二部分 部署篇 -- ttserver的几种部署方式 &lt;/b&gt;&lt;/p&gt;&lt;p&gt;可以把ttserver理解成一种key-value形式的数据库，在运营中就像管理数据库一样去管理ttserver，使得性能和数据安全都能得到较好的保障。&lt;br /&gt;部署ttserver的方式，可以根据访问量和数据规模循序渐进地这样部署：&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1、单机：数据量不大，访问量不大&lt;br /&gt;&lt;/b&gt;ttserver -host 192.168.0.100 -port 20001 -thnum 128 -dmn -ulim 1024m -ulog /home/ahfu/temp/test_data/test_ulog_01 -log /home/ahfu/temp/test_data/log/test_data_01.log -pid /home/ahfu/temp/test_data/log/test_data_01.pid -sid 1 /home/ahfu/temp/test_data/test_data_01.tch#bnum=10000000#rcnum=100000#xmsiz=256m&lt;br /&gt;如果希望提高查询的性能，可以把hash的桶设置得再大些，然后缓存的记录多一些。&lt;br /&gt;同时，设置-uas参数异步写入日志，可提高写入的性能。不过这样可能导致日志丢失，降低了数据安全性。&lt;br /&gt;&lt;br /&gt;&lt;b&gt;2、一主一备：数据量不大，访问量不大，且对数据安全性有要求&lt;/b&gt;&lt;br /&gt;主服务器：(与上面一致)&lt;br /&gt;ttserver -host 192.168.0.100 -port 20001 -thnum 128 -dmn -ulim 1024m -ulog /home/ahfu/temp/test_data/test_ulog_01 -log /home/ahfu/temp/test_data/log/test_data_01.log -pid /home/ahfu/temp/test_data/log/test_data_01.pid -sid 1 /home/ahfu/temp/test_data/test_data_01.tch#bnum=10000000#rcnum=100000#xmsiz=256m&lt;br /&gt;备份服务器：在另一个机器上启动，不需要缓存&lt;br /&gt;ttserver -host 192.168.0.101 -port 20002 -mhost 192.168.0.100 -mport 20001 -rcc -rts /home/ahfu/temp/test_data/test_data_01.rts -thnum 5 -dmn -ulim 1024m -ulog /home/ahfu/temp/test_data/test_ulog_02 -log /home/ahfu/temp/test_data/log/test_data_02.log -pid /home/ahfu/temp/test_data/log/test_data_02.pid -sid 2 /home/ahfu/temp/test_data/test_data_02.tch#bnum=10000000#rcnum=0#xmsiz=0m&lt;br /&gt;备份服务器可以找性能不高的旧服务器，这种设置也只是为了保障数据安全而做的设置。&lt;br /&gt;&lt;br /&gt;&lt;b&gt;3、互为主备：数据量增大，访问量也增大，对数据安全有要求，且希望避免单点故障&lt;/b&gt;&lt;br /&gt;第一个服务器：&lt;br /&gt;ttserver -host 192.168.0.100 -port 20001 -mhost 192.168.0.101 -mport 20002 -rcc -rts /home/ahfu/temp/test_data/test_data_01.rts -thnum 128 -dmn -ulim 1024m -ulog /home/ahfu/temp/test_data/test_ulog_01 -log /home/ahfu/temp/test_data/log/test_data_01.log -pid /home/ahfu/temp/test_data/log/test_data_01.pid -sid 1 /home/ahfu/temp/test_data/test_data_01.tch#bnum=10000000#rcnum=100000#xmsiz=256m&lt;br /&gt;第二个服务器：&lt;br /&gt;ttserver -host 192.168.0.101 -port 20002 -mhost 192.168.0.100 -mport 20001 -rcc -rts /home/ahfu/temp/test_data/test_data_02.rts -thnum 128 -dmn -ulim 1024m -ulog /home/ahfu/temp/test_data/test_ulog_02 -log /home/ahfu/temp/test_data/log/test_data_02.log -pid /home/ahfu/temp/test_data/log/test_data_02.pid -sid 2 /home/ahfu/temp/test_data/test_data_02.tch#bnum=10000000#rcnum=100000#xmsiz=256m&lt;br /&gt;应用程序可以访问任意一个服务器进行读写，且应用程序发现某服务器不能访问后，可立即转到另一台服务器。&lt;br /&gt;&lt;br /&gt;&lt;b&gt;4、读写分离：写量猛增，读量猛增&lt;br /&gt;&lt;/b&gt;TokyoCabinet支持六种数据引擎，其中on-memory hash database和on-memory b+ database两种是将数据存放在内存中的，不对数据做持久化。&lt;br /&gt;因此，可以使用on-memory hash database引擎的ttserver作为写服务器，然后采用复制的方式将on-memory hash database上的数据复制到hash database的多个ttserver上去，然后将多个hash database ttserver作为读服务器。这实际上是通过降低一致性来提高性能。&lt;br /&gt;on-memory hash database的配置： 缓存的记录数和内存都配置得很小&lt;br /&gt;ttserver -host 192.168.0.99 -port 20000 -thnum 128 -dmn -ulim 1024m -ulog /data/home/game/temp/test_data/test_ulog_01 -log /data/home/game/temp/test_data/log/test_data_01.log -pid /data/home/game/temp/test_data/log/test_data_01.pid -sid 0 &amp;quot;*#bnum=10000000#capnum=100#capsiz=10m&amp;quot;&lt;br /&gt;hash database ttserver 1 的配置： 从on-memory hash database复制数据&lt;br /&gt;ttserver -host 192.168.0.100 -port 20001 -mhost 192.168.0.99 -mport 20000 -rcc -rts /home/ahfu/temp/test_data/test_data_01.rts -thnum 128 -dmn -ulim 1024m -ulog /home/ahfu/temp/test_data/test_ulog_01 -log /home/ahfu/temp/test_data/log/test_data_01.log -pid /home/ahfu/temp/test_data/log/test_data_01.pid -sid 1 &amp;quot;/home/ahfu/temp/test_data/log/test_data_01.tch#bnum=10000000#rcnum=100000#xmsiz=256m&amp;quot;&lt;br /&gt;hash database ttserver 2 的配置： 从on-memory hash database复制数据&lt;br /&gt;ttserver -host 192.168.0.101 -port 20002 -mhost 192.168.0.99 -mport 20000 -rcc -rts /home/ahfu/temp/test_data/test_data_02.rts -thnum 128 -dmn -ulim 1024m -ulog /home/ahfu/temp/test_data/test_ulog_02 -log /home/ahfu/temp/test_data/log/test_data_02.log -pid /home/ahfu/temp/test_data/log/test_data_02.pid -sid 2 &amp;quot;/home/ahfu/temp/test_data/log/test_data_02.tch#bnum=10000000#rcnum=100000#xmsiz=256m&amp;quot;&lt;br /&gt;配置为读写分离后，客户端写入的时候连接on-memory hash database，读取的时候连接其他的ttserver。&lt;br /&gt;&lt;br /&gt;&lt;b&gt;5、客户端实现分布，分库：海量数据&lt;/b&gt;&lt;br /&gt;数据量再大，靠几台服务器已经无法支撑的时候，分库仍然是无奈的选择。将数据按照业务划分，或者按照某一数值划分，存在在多个ttserver群集中去。&lt;br /&gt;客户端程序在写入或者读取的时候，自动根据业务规则去访问对应的群集即可。&lt;/p&gt;</description>
		<guid>http://www.517sou.net/Article/TTserver-application-and-deployment.aspx</guid>
		<trackback:ping>http://www.517sou.net/Article/790/Trackback.ashx</trackback:ping>
		<comments>http://www.517sou.net/Article/TTserver-application-and-deployment.aspx#CommentPostAnchor</comments>
		<wfw:commentRss>http://www.517sou.net/Article/790/Feeds.ashx</wfw:commentRss>
	</item>
	<item>
		<link>http://www.517sou.net/Article/Name-Based-SSL-VHosts.aspx</link>
		<title>Name-Based VirtualHosts and SSL</title>
		<author>shanyiwan@live.com(flyinweb)</author>
		<category>WEB服务器</category>
		<pubDate>Fri, 18 May 2012 03:33:23 GMT</pubDate>
		<description>&lt;h2 id=&quot;Name-Based_VirtualHosts_and_SSL&quot;&gt;&lt;a href=&quot;http://wiki.apache.org/httpd/NameBasedSSLVHosts&quot; target=&quot;_blank&quot;&gt;Name-Based VirtualHosts and SSL&lt;/a&gt;&lt;/h2&gt;&lt;p class=&quot;line874&quot;&gt;As a rule, it is impossible to host more than one SSL virtual host on the same IP address and port. This is because Apache needs to know the name of the host in order to choose the correct certificate to setup the encryption layer. But the name of the host being requested is contained only in the HTTP request headers, which are part of the encrypted content. It is therefore not available until after the encryption is already negotiated. This means that the correct certificate cannot be selected, and clients will receive certificate mismatch warnings and be vulnerable to man-in-the-middle attacks. &lt;/p&gt;&lt;p class=&quot;line874&quot;&gt;In reality, Apache will allow you to configure name-based SSL virtual hosts, but it will always use the configuration from the first-listed virtual host (on the selected IP address and port) to setup the encryption layer. In certain specific circumstances, it is acceptable to use a single SSL configuration for several virtual hosts. In particular, this will work if the SSL certificate applies to all the virtual hosts. For example, this will work if:&lt;/p&gt;&lt;ol type=&quot;1&quot;&gt;&lt;li&gt;&lt;p class=&quot;line862&quot;&gt;All the VirtualHosts are within the same domain, eg: one.example.com and two.example.com.&lt;/p&gt;&lt;/li&gt;&lt;li&gt;&lt;p class=&quot;line862&quot;&gt;You have a wildcard SSL certificate for that domain (one where the Common Name begins with an asterix: i.e &lt;tt&gt;*.example.com&lt;/tt&gt;)&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;p class=&quot;line862&quot;&gt;Here is the config snippet for two SSL NameVirtualHost&apos;s, using a single wildcard SSL certificate. Remember that the SSL directives from the second virtual host will be ignored when setting up the initial SSL connection.&lt;/p&gt;&lt;pre&gt;
Listen 192.168.1.1:443
LoadModule ssl_module   modules/mod_ssl.so
SSLPassPhraseDialog     builtin
AcceptMutex             flock
SSLSessionCache         shmcb:/var/cache/httpd/mod_ssl/ssl_scache(512000)
SSLSessionCacheTimeout  300
SSLMutex                default
SSLRandomSeed           startup /dev/urandom  256
SSLRandomSeed           connect builtin
NameVirtualHost 192.168.1.1:443
&amp;lt;VirtualHost 192.168.1.1:443&amp;gt;
        SSLEngine on
        SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP
        SSLCertificateFile      /etc/ssl/star.example.com.crt
        SSLCertificateKeyFile   /etc/ssl/star.example.com.key
        ServerName      &amp;quot;one.example.com&amp;quot;
        DocumentRoot    &amp;quot;/var/www/html/one&amp;quot;
        CustomLog       &amp;quot;/var/log/httpd/one-access.log&amp;quot; combined
        ErrorLog        &amp;quot;/var/log/httpd/one-error.log&amp;quot;
        &amp;lt;Directory /var/www/html&amp;gt;
                AllowOverride none
                Order Allow,Deny
                Allow from all
        &amp;lt;/Directory&amp;gt;
&amp;lt;/VirtualHost&amp;gt;
&amp;lt;VirtualHost 192.168.1.1:443&amp;gt;
        SSLEngine on
        SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP
        SSLCertificateFile      /etc/ssl/star.example.com.crt
        SSLCertificateKeyFile   /etc/ssl/star.example.com.key
        ServerName      &amp;quot;two.example.com&amp;quot;
        DocumentRoot    &amp;quot;/var/www/html/two&amp;quot;
        CustomLog       &amp;quot;/var/log/httpd/two-access.log&amp;quot; combined
        ErrorLog        &amp;quot;/var/log/httpd/two-error.log&amp;quot;
        &amp;lt;Directory /var/www/html&amp;gt;
                AllowOverride none
                Order Allow,Deny
                Allow from all
        &amp;lt;/Directory&amp;gt;
&amp;lt;/VirtualHost&amp;gt;&lt;/pre&gt;&lt;p class=&quot;line874&quot;&gt;In addition to this configuration, you should still be able to do the following:&lt;/p&gt;&lt;ol type=&quot;1&quot;&gt;&lt;li&gt;&lt;p class=&quot;line862&quot;&gt;SSL VirtualHost for a different domain (example2.com), as long as you use a different IP Address or port (i.e. one that is not used by the wildcard sites):&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;pre&gt;
&amp;lt;VirtualHost 192.168.1.2:443&amp;gt;
ServerName www.example2.com
...
&amp;lt;/VirtualHost&amp;gt;&lt;/pre&gt;&lt;ol start=&quot;2&quot;&gt;&lt;li&gt;&lt;p class=&quot;line891&quot;&gt;&lt;tt&gt;NameVirtualHost &amp;lt;IP&amp;gt;:443&lt;/tt&gt; for a different domain (*.example2.com), where &lt;tt&gt;&amp;lt;IP&amp;gt;&lt;/tt&gt; is different from the IP Address used for *.example.com&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;pre&gt;
NameVirtualHost 192.168.1.2:443
&amp;lt;VirtualHost 192.168.1.2:443&amp;gt;
ServerName one.example2.com
...
&amp;lt;/VirtualHost&amp;gt;
&amp;lt;VirtualHost 192.168.1.2:443&amp;gt;
ServerName two.example2.com
...
&amp;lt;/VirtualHost&amp;gt;&lt;/pre&gt;&lt;p class=&quot;line874&quot;&gt;However you cannot do the following:&lt;/p&gt;&lt;p class=&quot;line862&quot;&gt;SSL VirtualHost for a different ServerName (three.example2.com), where the IP address is the same as that used for *.example.com.&lt;/p&gt;&lt;pre&gt;
&amp;lt;VirtualHost 192.168.1.1:443&amp;gt;
ServerName three.example2.com
...
&amp;lt;/VirtualHost&amp;gt;&lt;/pre&gt;</description>
		<guid>http://www.517sou.net/Article/Name-Based-SSL-VHosts.aspx</guid>
		<trackback:ping>http://www.517sou.net/Article/789/Trackback.ashx</trackback:ping>
		<comments>http://www.517sou.net/Article/Name-Based-SSL-VHosts.aspx#CommentPostAnchor</comments>
		<wfw:commentRss>http://www.517sou.net/Article/789/Feeds.ashx</wfw:commentRss>
	</item>
	<item>
		<link>http://www.517sou.net/Article/SSL-self-signed-certificate-generated-script.aspx</link>
		<title>SSL自签署证书生成脚本</title>
		<author>shanyiwan@live.com(flyinweb)</author>
		<category>WEB服务器</category>
		<pubDate>Fri, 18 May 2012 03:29:30 GMT</pubDate>
		<description>&lt;p&gt;启用 apache 的 mod_ssl 之后需要有证书才能正常运作。写了个脚本来操作。首先要确定机器上已经有 openssl 。&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;#!/bin/sh&lt;br /&gt;#&lt;/p&gt;&lt;p&gt;# ssl 证书输出的根目录。&lt;br /&gt;sslOutputRoot=&amp;quot;/etc/apache_ssl&amp;quot;&lt;br /&gt;if [ $# -eq 1 ]; then&lt;br /&gt;&amp;nbsp;sslOutputRoot=$1&lt;br /&gt;fi&lt;br /&gt;if [ ! -d ${sslOutputRoot} ]; then&lt;br /&gt;&amp;nbsp;mkdir -p ${sslOutputRoot}&lt;br /&gt;fi&lt;/p&gt;&lt;p&gt;cd ${sslOutputRoot}&lt;/p&gt;&lt;p&gt;echo &amp;quot;开始创建CA根证书...&amp;quot;&lt;br /&gt;#&lt;br /&gt;# 创建CA根证书，稍后用来签署用于服务器的证书。如果是通过商业性CA如&lt;br /&gt;# Verisign 或 Thawte 签署证书，则不需要自己来创建根证书，而是应该&lt;br /&gt;# 把后面生成的服务器 csr 文件内容贴入一个web表格，支付签署费用并&lt;br /&gt;# 等待签署的证书。关于商业性CA的更多信息请参见： &lt;br /&gt;# Verisign - &lt;a href=&quot;http://digitalid.verisign.com/server/apacheNotice.htm&quot; target=&quot;_blank&quot;&gt;http://digitalid.verisign.com/server/apacheNotice.htm&lt;/a&gt;&lt;br /&gt;# Thawte Consulting - &lt;a href=&quot;http://www.thawte.com/certs/server/request.html&quot; target=&quot;_blank&quot;&gt;http://www.thawte.com/certs/server/request.html&lt;/a&gt;&lt;br /&gt;# CertiSign Certificadora Digital Ltda. - &lt;a href=&quot;http://www.certisign.com.br&quot; target=&quot;_blank&quot;&gt;http://www.certisign.com.br&lt;/a&gt;&lt;br /&gt;# IKS GmbH - &lt;a href=&quot;http://www.iks-jena.de/produkte/ca&quot; target=&quot;_blank&quot;&gt;http://www.iks-jena.de/produkte/ca&lt;/a&gt; / &lt;br /&gt;# Uptime Commerce Ltd. - &lt;a href=&quot;http://www.uptimecommerce.com&quot; target=&quot;_blank&quot;&gt;http://www.uptimecommerce.com&lt;/a&gt;&lt;br /&gt;# BelSign NV/SA - &lt;a href=&quot;http://www.belsign.be&quot; target=&quot;_blank&quot;&gt;http://www.belsign.be&lt;/a&gt;&lt;br /&gt;# 生成CA根证书私钥&lt;br /&gt;openssl genrsa -des3 -out ca.key 1024&lt;/p&gt;&lt;p&gt;# 生成CA根证书&lt;br /&gt;# 根据提示填写各个字段, 但注意 Common Name 最好是有效根域名(如 zeali.net ),&lt;br /&gt;# 并且不能和后来服务器证书签署请求文件中填写的 Common Name 完全一样，否则会&lt;br /&gt;# 导致证书生成的时候出现 &lt;br /&gt;# error 18 at 0 depth lookup:self signed certificate 错误&lt;br /&gt;openssl req -new -x509 -days 365 -key ca.key -out ca.crt &lt;br /&gt;echo &amp;quot;CA根证书创建完毕。&amp;quot;&lt;/p&gt;&lt;p&gt;echo &amp;quot;开始生成服务器证书签署文件及私钥 ...&amp;quot;&lt;br /&gt;#&lt;br /&gt;# 生成服务器私钥&lt;br /&gt;openssl genrsa -des3 -out server.key 1024 &lt;br /&gt;# 生成服务器证书签署请求文件, Common Name 最好填写使用该证书的完整域名&lt;br /&gt;# (比如: security.zeali.net )&lt;br /&gt;openssl req -new -key server.key -out server.csr&amp;nbsp; &lt;br /&gt;ls -altrh&amp;nbsp; ${sslOutputRoot}/server.*&lt;br /&gt;echo &amp;quot;服务器证书签署文件及私钥生成完毕。&amp;quot;&lt;/p&gt;&lt;p&gt;echo &amp;quot;开始使用CA根证书签署服务器证书签署文件 ...&amp;quot;&lt;br /&gt;#&lt;br /&gt;# 签署服务器证书，生成server.crt文件&lt;br /&gt;# 参见 &lt;a href=&quot;http://www.faqs.org/docs/securing/chap24sec195.html&quot; target=&quot;_blank&quot;&gt;http://www.faqs.org/docs/securing/chap24sec195.html&lt;/a&gt;&lt;br /&gt;#&amp;nbsp; sign.sh START&lt;br /&gt;#&lt;br /&gt;#&amp;nbsp; Sign a SSL Certificate Request (CSR)&lt;br /&gt;#&amp;nbsp; Copyright (c) 1998-1999 Ralf S. Engelschall, All Rights Reserved. &lt;br /&gt;#&lt;/p&gt;&lt;p&gt;CSR=server.csr&lt;/p&gt;&lt;p&gt;case $CSR in&lt;br /&gt;*.csr ) CERT=&amp;quot;`echo $CSR | sed -e &apos;s/\.csr/.crt/&apos;`&amp;quot; ;;&lt;br /&gt;* ) CERT=&amp;quot;$CSR.crt&amp;quot; ;;&lt;br /&gt;esac&lt;/p&gt;&lt;p&gt;#&amp;nbsp;&amp;nbsp; make sure environment exists&lt;br /&gt;if [ ! -d ca.db.certs ]; then&lt;br /&gt;&amp;nbsp;mkdir ca.db.certs&lt;br /&gt;fi&lt;br /&gt;if [ ! -f ca.db.serial ]; then&lt;br /&gt;&amp;nbsp;echo &apos;01&apos; &amp;gt;ca.db.serial&lt;br /&gt;fi&lt;br /&gt;if [ ! -f ca.db.index ]; then&lt;br /&gt;&amp;nbsp;cp /dev/null ca.db.index&lt;br /&gt;fi&lt;/p&gt;&lt;p&gt;#&amp;nbsp;&amp;nbsp; create an own SSLeay config&lt;br /&gt;# 如果需要修改证书的有效期限，请修改下面的 default_days 参数.&lt;br /&gt;# 当前设置为10年.&lt;br /&gt;cat &amp;gt;ca.config &amp;lt;&amp;lt;EOT&lt;br /&gt;[ ca ]&lt;br /&gt;default_ca&amp;nbsp;= CA_own&lt;br /&gt;[ CA_own ]&lt;br /&gt;dir&amp;nbsp;= .&lt;br /&gt;certs&amp;nbsp;= ./certs&lt;br /&gt;new_certs_dir&amp;nbsp;= ./ca.db.certs&lt;br /&gt;database&amp;nbsp;= ./ca.db.index&lt;br /&gt;serial&amp;nbsp;= ./ca.db.serial&lt;br /&gt;RANDFILE&amp;nbsp;= ./ca.db.rand&lt;br /&gt;certificate&amp;nbsp;= ./ca.crt&lt;br /&gt;private_key&amp;nbsp;= ./ca.key&lt;br /&gt;default_days&amp;nbsp;= 3650&lt;br /&gt;default_crl_days&amp;nbsp;= 30&lt;br /&gt;default_md&amp;nbsp;= md5&lt;br /&gt;preserve&amp;nbsp;= no&lt;br /&gt;policy&amp;nbsp;= policy_anything&lt;br /&gt;[ policy_anything ]&lt;br /&gt;countryName&amp;nbsp;= optional&lt;br /&gt;stateOrProvinceName&amp;nbsp;= optional&lt;br /&gt;localityName&amp;nbsp;= optional&lt;br /&gt;organizationName&amp;nbsp;= optional&lt;br /&gt;organizationalUnitName&amp;nbsp;= optional&lt;br /&gt;commonName&amp;nbsp;= supplied&lt;br /&gt;emailAddress&amp;nbsp;= optional&lt;br /&gt;EOT&lt;/p&gt;&lt;p&gt;#&amp;nbsp; sign the certificate&lt;br /&gt;echo &amp;quot;CA signing: $CSR -&amp;gt; $CERT:&amp;quot;&lt;br /&gt;openssl ca -config ca.config -out $CERT -infiles $CSR&lt;br /&gt;echo &amp;quot;CA verifying: $CERT &amp;lt;-&amp;gt; CA cert&amp;quot;&lt;br /&gt;openssl verify -CAfile ./certs/ca.crt $CERT&lt;/p&gt;&lt;p&gt;#&amp;nbsp; cleanup after SSLeay &lt;br /&gt;rm -f ca.config&lt;br /&gt;rm -f ca.db.serial.old&lt;br /&gt;rm -f ca.db.index.old&lt;br /&gt;#&amp;nbsp; sign.sh END&lt;br /&gt;echo &amp;quot;使用CA根证书签署服务器证书签署文件完毕。&amp;quot;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;# 使用了 ssl 之后，每次启动 apache 都要求输入 server.key 的口令，&lt;br /&gt;# 你可以通过下面的方法去掉口令输入(如果不希望去掉请注释以下几行代码)：&lt;br /&gt;echo &amp;quot;去除 apache 启动时必须手工输入密钥密码的限制:&amp;quot;&lt;br /&gt;cp -f server.key server.key.org&lt;br /&gt;openssl rsa -in server.key.org -out server.key&lt;br /&gt;echo &amp;quot;去除完毕。&amp;quot;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;# 修改 server.key 的权限，保证密钥安全&lt;br /&gt;chmod 400 server.key&lt;/p&gt;&lt;p&gt;echo &amp;quot;Now u can configure apache ssl with following:&amp;quot;&lt;br /&gt;echo -e &amp;quot;\tSSLCertificateFile ${sslOutputRoot}/server.crt&amp;quot;&lt;br /&gt;echo -e &amp;quot;\tSSLCertificateKeyFile ${sslOutputRoot}/server.key&amp;quot;&lt;/p&gt;&lt;p&gt;#&amp;nbsp; die gracefully&lt;br /&gt;exit 0&lt;br /&gt;&lt;/p&gt;</description>
		<guid>http://www.517sou.net/Article/SSL-self-signed-certificate-generated-script.aspx</guid>
		<trackback:ping>http://www.517sou.net/Article/788/Trackback.ashx</trackback:ping>
		<comments>http://www.517sou.net/Article/SSL-self-signed-certificate-generated-script.aspx#CommentPostAnchor</comments>
		<wfw:commentRss>http://www.517sou.net/Article/788/Feeds.ashx</wfw:commentRss>
	</item>
	<item>
		<link>http://www.517sou.net/Article/adding-vista-sidebar-and-aero-to-windows-server-2008-desktop.aspx</link>
		<title>Adding Vista Sidebar and Aero to Windows Server 2008 Desktop</title>
		<author>shanyiwan@live.com(flyinweb)</author>
		<category>Windows</category>
		<pubDate>Wed, 02 May 2012 05:56:06 GMT</pubDate>
		<description>&lt;p&gt;&lt;b&gt;Windows Sidebar &lt;/b&gt;&lt;br /&gt;There are a number of cool gadgets for the Windows Sidebar that are useful on a server, so I really wanted to get the sidebar working on my Windows Server 2008 boxes. The solution is as follows. &lt;br /&gt;1.Copy the &amp;quot;Windows Sidebar&amp;quot; folder from a Windows Vista SP1 installations Program Files folder that is the same architecture as the Windows Server 2008 box you intend to enable Windows Sidebar on. (i.e., if I&apos;m running Windows Server 2008 64-bit, then I need to copy from a 64-bit Windows Vista SP1 installation.) &lt;br /&gt;2.Copy the &amp;quot;Windows Sidebar&amp;quot; copy into the Program Files folder of the Windows Server 2008 installation. (If 64-bit Windows Server 2008, copy to the &amp;quot;Program Files&amp;quot; folder and NOT the &amp;quot;Program Files (x86)&amp;quot; folder.) &lt;br /&gt;3.Run the following commands from a prompt with administrative credentials &lt;br /&gt;o &lt;span style=&quot;color: #ff0000&quot;&gt;Regsvr32 atl.dll (如果引组件未注册，在注册下面的组件时，可能会出现类似错误：模块“C:\Program Files\windows sidebar\sbdrop.dll”已加载，但对 DllRegisterServer 的调用失败，错误代码为 0x8007007e。)&lt;/span&gt;&lt;br /&gt;o regsvr32 &amp;quot;C:\Program Files\Windows Sidebar\sbdrop.dll&amp;quot; &lt;br /&gt;o regsvr32 &amp;quot;C:\Program Files\Windows Sidebar\wlsrvc.dll&amp;quot; &lt;br /&gt;o &amp;quot;C:\Program Files\Windows Sidebar\sidebar.exe&amp;quot; /RegServer &lt;br /&gt;4.Copy the content of the Sidebar registry area from your Vista box to the 2008 box (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Sidebar). The registry content is the same for 32-bit and 64-bit, so you can just paste the following into sidebar.reg and execute (by double clicking) to save any copying between machines.&lt;/p&gt;&lt;p&gt;Windows Registry Editor Version 5.00&lt;br /&gt;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Sidebar]&lt;br /&gt;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Sidebar\Compatibility]&lt;br /&gt;[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Sidebar\Settings] &lt;br /&gt;&amp;quot;SidebarDockedPartsOrder&amp;quot;=&amp;quot;0x1,0x2,0x3,0x4&lt;/p&gt;&lt;p&gt;5.We can now launch sidebar with the &amp;quot;C:\Program Files\Windows Sidebar\sidebar.exe&amp;quot; command. &lt;br /&gt;6.Sidebar will launch, and now access the Properties of Sidebar (right click on a blank area of sidebar and select Properties) and check the &amp;quot;State Sidebar when Windows starts&amp;quot; option. &lt;br /&gt;&lt;/p&gt;&lt;p mce_keep=&quot;true&quot;&gt;&lt;b&gt;&lt;a href=&quot;http://blogs.technet.com/b/yungchou/archive/2008/06/25/adding-vista-sidebar-and-aero-to-windows-server-2008-desktop.aspx&quot; target=&quot;_blank&quot;&gt;Adding Vista Sidebar and Aero to Windows Server 2008 Desktop&lt;/a&gt;&lt;/b&gt;&lt;/p&gt;&lt;p mce_keep=&quot;true&quot;&gt;Do the following steps in your target Windows Server 2008 x64 box.&lt;/p&gt;&lt;p&gt;To get the sidebar,&lt;/p&gt;&lt;ol&gt;&lt;li&gt;From a Vista SP1 x64, copy in the content of C:\Program Files\Windows Sidebar. And place the folder in the same location.&lt;/li&gt;&lt;li&gt;Run sidebar.exe /regserver&lt;/li&gt;&lt;li&gt;Register (regsvr32) the 2 sidebar dlls, sbdrop.dll and wlsrvc.dll&lt;/li&gt;&lt;li&gt;Clone the sidebar registry settings of the Vista box, HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Sidebar\Settings, to the target Windows Server 2008 registry.&lt;/li&gt;&lt;li&gt;Run C:\Program Files\Windows Sidebar\Sidebar.exe to bring up the sidebar and set the properties to start Siderbar when Windows starts.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Now to get the Aero, assuming your graphic card is sufficient&lt;/p&gt;&lt;ol&gt;&lt;li&gt;In Server Manager, add Desktop Experience feature.&lt;/li&gt;&lt;li&gt;In Services applet, set the service, Themes, to autostart.&lt;/li&gt;&lt;li&gt;In Personalization, set Theme to Windows Vista and Windows Colors and Appearance to Aero.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;Then spend the next hour to add/remove all the gadgets you like/dislike, which is the fun part. After all is done, here&apos;s what a Windows Server 2008 desktop may look like.&lt;/p&gt;&lt;p&gt;&lt;img class=&quot;Image&quot; alt=&quot;&quot; src=&quot;http://www.517sou.net/Attach/month_1205/y4nbga_sidebar.jpg&quot; width=&quot;877&quot; height=&quot;549&quot; mce_src=&quot;http://uh9peq.blu.livefilestore.com/y1pG6b2wJhhMeK1txuuGzMzf3-P-SA2Tky39biyuF8ryCwpof3jPTxzPPPizcm89U-8_cgcvlAmObk&quot; /&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://www.win2008workstation.com/win2008/installing-the-vista-sidebar&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Convert your Windows Server 2008 to a Workstation!&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;1. Download the zip-package with files needed to use the Vista Sidebar. If you use the 32bit version of Server 2008, download &lt;em&gt;Windows Sidebar.zip&lt;/em&gt; from &lt;a class=&quot;external external_icon&quot; href=&quot;http://rapidshare.com/files/97968988/WindowsSidebar.zip&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Rapidshare&lt;/font&gt;&lt;/u&gt;&lt;/a&gt; or &lt;a class=&quot;external external_icon&quot; href=&quot;http://www.4shared.com/file/40156538/d05a969c/WindowsSidebar.html&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;4shared&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;. If you use the 64bit version of Server 2008 download &lt;em&gt;Windows Sidebar x64.zip &lt;/em&gt;from &lt;a class=&quot;external external_icon&quot; href=&quot;http://rapidshare.com/files/101530532/Windows_Sidebar_x64.zip&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Rapidshare&lt;/font&gt;&lt;/u&gt;&lt;/a&gt; or &lt;a class=&quot;external external_icon&quot; href=&quot;http://www.4shared.com/file/41573244/e31ab005/Windows_Sidebar_x64.html&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;4shared&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;. The files inside this package are taken from a clean installation of Windows Server 2008 x86/x64 BETA 3 where the Windows Sidebar is still included when installing the Desktop Experience Feature. It is also possible to just copy the &lt;strong&gt;C:\Program Files\Windows Sidebar\&lt;/strong&gt; folder from an other Vista SP1 installation.&lt;/p&gt;&lt;p&gt;2. Open &lt;strong&gt;Windows Sidebar (x64).zip&lt;/strong&gt; and in the toolbar click &lt;strong&gt;Extract all files&lt;/strong&gt;. Click the Browse button, expand &lt;strong&gt;Computer&lt;/strong&gt; –&amp;gt; &lt;strong&gt;Local Disk (C:)&lt;/strong&gt;, and click &lt;strong&gt;Program Files&lt;/strong&gt;. Select your destination by clicking &lt;strong&gt;OK&lt;/strong&gt;.&lt;/p&gt;&lt;p&gt;&lt;img class=&quot;Image&quot; alt=&quot;SideBar1.jpg&quot; src=&quot;http://www.517sou.net/Attach/month_1205/fczhbn_1.png&quot; width=&quot;1024&quot; height=&quot;768&quot; /&gt;&lt;/p&gt;&lt;p&gt;3. Your &lt;strong&gt;Extract Compressed (Zipped) Folders&lt;/strong&gt; window will now look like this. Click &lt;strong&gt;Extract&lt;/strong&gt; to extract the files and folders of &lt;strong&gt;Windows Sidebar (x64).zip&lt;/strong&gt; to your &lt;strong&gt;C:\Program Files&lt;/strong&gt; directory.&lt;/p&gt;&lt;p&gt;&lt;img class=&quot;Image&quot; alt=&quot;SideBar2.jpg&quot; src=&quot;http://www.517sou.net/Attach/month_1205/lmauu2_2.png&quot; /&gt;&lt;/p&gt;&lt;p&gt;4. After the extraction has completed, click &lt;strong&gt;Run&lt;/strong&gt; in the &lt;strong&gt;Start&lt;/strong&gt; menu and enter the following command: &lt;strong&gt;&amp;quot;C:\Program Files\Windows Sidebar\sidebar.exe&amp;quot; /RegServer&lt;/strong&gt;. You won’t see anything happen but in the background the SideBar is being installed. To enable the automatic installation of custom gadgets, also run the commands &lt;strong&gt;regsvr32 &amp;quot;C:\Program Files\Windows Sidebar\sbdrop.dll&amp;quot;&lt;/strong&gt; and &lt;strong&gt;regsvr32 &amp;quot;C:\Program Files\Windows Sidebar\wlsrvc.dll&amp;quot;&lt;/strong&gt;.&lt;/p&gt;&lt;p&gt;&lt;img class=&quot;Image&quot; alt=&quot;SideBar3.jpg&quot; src=&quot;http://www.517sou.net/Attach/month_1205/3bhyuo_3.png&quot; width=&quot;1024&quot; height=&quot;768&quot; /&gt;&lt;/p&gt;&lt;p&gt;5. Once again open the &lt;strong&gt;Run&lt;/strong&gt; dialog by clicking &lt;strong&gt;Start &lt;/strong&gt;–&amp;gt; &lt;strong&gt;Run&lt;/strong&gt;, now enter: &lt;strong&gt;&amp;quot;C:\Program Files\Windows Sidebar\sidebar.exe&amp;quot;&lt;/strong&gt;, and click &lt;strong&gt;OK&lt;/strong&gt;. The taskbar will now show up! Let’s configure that it will automatically start with Windows Server 2008!&lt;/p&gt;&lt;p&gt;&lt;img class=&quot;Image&quot; alt=&quot;SideBar4.jpg&quot; src=&quot;http://www.517sou.net/Attach/month_1205/ojxud6_4.png&quot; /&gt;&lt;/p&gt;&lt;p&gt;6. To configure it to automatically start with Windows &lt;strong&gt;right click&lt;/strong&gt; the &lt;strong&gt;SideBar icon&lt;/strong&gt; in the system tray and click &lt;strong&gt;Properties&lt;/strong&gt;.&lt;/p&gt;&lt;p&gt;&lt;img class=&quot;Image&quot; alt=&quot;SideBar5.jpg&quot; src=&quot;http://www.517sou.net/Attach/month_1205/hu0o3m_5.png&quot; width=&quot;1024&quot; height=&quot;768&quot; /&gt;&lt;/p&gt;&lt;p&gt;7. Check the box &lt;strong&gt;Start Sidebar when Windows starts&lt;/strong&gt;, then click &lt;strong&gt;OK&lt;/strong&gt;. Your taskbar is now fully functioning! You can add Gadgets by right clicking &lt;strong&gt;Add Gadgets&lt;/strong&gt; in the &lt;strong&gt;systemtray icon menu&lt;/strong&gt; or remove them by clicking &lt;strong&gt;Close Gadget&lt;/strong&gt; in the contextmenu of a Gadget. To get help with installing gadgets go to the post &lt;a href=&quot;http://www.win2008workstation.com/wordpress/2008/03/08/installing-custom-gadgets/&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Installing Custom Gadgets&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;&lt;img class=&quot;Image&quot; alt=&quot;SideBar6.jpg&quot; src=&quot;http://www.517sou.net/Attach/month_1205/bjiikb_6.png&quot; width=&quot;1024&quot; height=&quot;768&quot; /&gt;&lt;/p&gt;&lt;h2&gt;Troubleshooting&lt;/h2&gt;&lt;p&gt;&lt;strong&gt;Question:&lt;/strong&gt; I get a &lt;strong&gt;Open File- Security Warning&lt;/strong&gt; message dialog every time I start Windows.&lt;/p&gt;&lt;p&gt;&lt;img class=&quot;Image&quot; alt=&quot;&quot; src=&quot;http://www.517sou.net/Attach/month_1205/fkl9s0_7.png&quot; width=&quot;414&quot; height=&quot;308&quot; /&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Answer: &lt;/strong&gt;Follow these steps to remove this message.&lt;/p&gt;&lt;p&gt;1. Browse via &lt;strong&gt;My Computer&lt;/strong&gt; to &lt;strong&gt;C:\Program Files\Windows Sidebar\&lt;/strong&gt;, &lt;em&gt;right click&lt;/em&gt;&lt;strong&gt;sidebar.exe&lt;/strong&gt; and click &lt;strong&gt;Properties&lt;/strong&gt;.&lt;/p&gt;&lt;p&gt;&lt;img class=&quot;Image&quot; alt=&quot;&quot; src=&quot;http://www.517sou.net/Attach/month_1205/vzm8qh_8.png&quot; width=&quot;798&quot; height=&quot;598&quot; /&gt;&lt;/p&gt;&lt;p&gt;2. In the &lt;strong&gt;General &lt;/strong&gt;tab click &lt;strong&gt;Unblock&lt;/strong&gt;, then click &lt;strong&gt;Apply&lt;/strong&gt; and/or &lt;strong&gt;OK&lt;/strong&gt;. Now you won’t see that message again!&lt;/p&gt;&lt;p&gt;&lt;img class=&quot;Image&quot; alt=&quot;&quot; src=&quot;http://www.517sou.net/Attach/month_1205/pgafk2_9.png&quot; width=&quot;377&quot; height=&quot;513&quot; /&gt;&lt;/p&gt;</description>
		<guid>http://www.517sou.net/Article/adding-vista-sidebar-and-aero-to-windows-server-2008-desktop.aspx</guid>
		<trackback:ping>http://www.517sou.net/Article/787/Trackback.ashx</trackback:ping>
		<comments>http://www.517sou.net/Article/adding-vista-sidebar-and-aero-to-windows-server-2008-desktop.aspx#CommentPostAnchor</comments>
		<wfw:commentRss>http://www.517sou.net/Article/787/Feeds.ashx</wfw:commentRss>
	</item>
	<item>
		<link>http://www.517sou.net/Article/Coreseek-installation-and-test-documentation.aspx</link>
		<title>coreseek 安装测试说明文档</title>
		<author>shanyiwan@live.com(flyinweb)</author>
		<category>Linux</category>
		<pubDate>Wed, 02 May 2012 02:34:54 GMT</pubDate>
		<description>&lt;div class=&quot;titlepage&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;h2 style=&quot;clear: both&quot; class=&quot;title&quot;&gt;简介&lt;/h2&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;sect2&quot; title=&quot;1.1.&quot; 什么是sphinx=&quot;&quot; coreseek=&quot;&quot;&gt;&lt;div class=&quot;titlepage&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;h3 class=&quot;title&quot;&gt;1.1 什么是Sphinx/Coreseek&lt;/h3&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Sphinx是一个在GPLv2下分发的全文检索引擎；Coreseek 是一个可供企业使用的、基于Sphinx（可独立于Sphinx原始版本运行）的中文全文检索引擎，按照GPLv2协议发行，商业使用（例如, 嵌入到其他程序中）需要获得商业授权。&lt;/p&gt;&lt;p&gt;一般而言，Sphinx是一个独立的全文搜索引擎；而Coreseek是一个支持中文的全文搜索引擎，意图为其他应用提供高速、低空间占用、高结果相关度的中文全文搜索能力。Sphinx/Coreseek可以非常容易的与SQL数据库和脚本语言集成。&lt;/p&gt;&lt;p&gt;当前系统内置MySQL和PostgreSQL 数据库数据源的支持，也支持从管道标准输入读取入特定格式的XML数据。通过修改源代码，用户可以自行增加新的数据源（例如：其他类型的DBMS的原生支持）。在最新的版本中，用户还可以使用Python脚本作为数据源来获取任何已知世界和未知世界的数据，这极大的扩展了数据源的来源。&lt;/p&gt;&lt;p&gt;搜索API支持PHP、Python、Perl、Rudy和Java，并且也可以用作MySQL存储引擎。搜索API非常简单，可以在若干个小时之内移植到新的语言上。&lt;/p&gt;&lt;p&gt;Sphinx 是SQL Phrase Index的缩写，但不幸的和CMU的Sphinx项目重名。&lt;/p&gt;&lt;/div&gt;&lt;div class=&quot;sect2&quot; title=&quot;1.2. Sphinx/Coreseek 的特性&quot;&gt;&lt;div class=&quot;titlepage&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;h3 class=&quot;title&quot;&gt;1.2. Sphinx/Coreseek 的特性&lt;/h3&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;itemizedlist&quot;&gt;&lt;ul class=&quot;itemizedlist&quot; type=&quot;disc&quot;&gt;&lt;li class=&quot;listitem&quot;&gt;高速的建立索引(在当代CPU上，峰值性能可达到10 MB/秒);&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;高性能的搜索(在2 – 4GB 的文本数据上，平均每次检索响应时间小于0.1秒);&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;可处理海量数据(目前已知可以处理超过100 GB的文本数据, 在单一CPU的系统上可处理100 M 文档);&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;提供了优秀的相关度算法，基于短语相似度和统计（BM25）的复合Ranking方法;&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;支持分布式搜索;&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;提供文档片段（摘要以及高亮）生成功能;&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;可作为MySQL的存储引擎提供搜索服务;&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;支持布尔、短语、词语相似度等多种检索模式;&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;文档支持多个全文检索字段(缺省配置下，最大不超过32个);&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;文档支持多个额外的属性信息(例如：分组信息，时间戳等);&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;停止词查询;&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;支持单一字节编码和UTF-8编码，以及对GBK和BIG5的完善支持;&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;支持英语、俄语词词干化和Soundex，以便进行词形学处理;&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;原生的MySQL支持(同时支持MyISAM 和InnoDB );&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;原生的PostgreSQL 支持;&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;支持直接模拟为MySQL服务端运行;&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;支持MMSeg分词引擎，用户可自定义词典;&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;Python数据源支持，得以获取任何已知世界和未知世界的数据.&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;sect2&quot; title=&quot;1.3.&quot; coreseek=&quot;&quot; 如何得到sphinx=&quot;&quot;&gt;&lt;div class=&quot;titlepage&quot;&gt;&lt;div&gt;&lt;div&gt;&lt;h3 class=&quot;title&quot;&gt;1.3. 如何得到Sphinx/Coreseek&lt;/h3&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Sphinx原始版本可以从Sphinx官方网站 &lt;a class=&quot;ulink&quot; href=&quot;http://www.sphinxsearch.com/&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;http://www.sphinxsearch.com/&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;，Coreseek可以从Coreseek官方网站 &lt;a class=&quot;ulink&quot; href=&quot;http://www.coreseek.cn/&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;http://www.coreseek.cn/&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;下载.&lt;/p&gt;&lt;p&gt;目前，Sphinx/Coreseek的发布包包括如下软件:&lt;/p&gt;&lt;div class=&quot;itemizedlist&quot;&gt;&lt;ul class=&quot;itemizedlist&quot; type=&quot;disc&quot;&gt;&lt;li class=&quot;listitem&quot;&gt;&lt;code class=&quot;filename&quot;&gt;indexer&lt;/code&gt;: 用于创建全文索引;&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;&lt;code class=&quot;filename&quot;&gt;search&lt;/code&gt;: 一个简单的命令行(CLI) 的测试程序，用于测试全文索引;&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;&lt;code class=&quot;filename&quot;&gt;searchd&lt;/code&gt;: 一个守护进程，其他软件可以通过这个守护进程进行全文检索;&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;&lt;code class=&quot;filename&quot;&gt;sphinxapi&lt;/code&gt;: 一系列searchd 的客户端API 库，用于流行的Web脚本开发语言(PHP, Python, Perl, Ruby, Java).&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;&lt;code class=&quot;filename&quot;&gt;spelldump&lt;/code&gt;: 一个简单的命令行工具，用于从 &lt;code class=&quot;filename&quot;&gt;ispell&lt;/code&gt; 或 &lt;code class=&quot;filename&quot;&gt;MySpell&lt;/code&gt; (OpenOffice内置绑定) 格式的字典中提取词条。当使用 &lt;a class=&quot;link&quot; title=&quot;9.2.9.&quot; href=&quot;http://www.coreseek.cn/docs/coreseek_3.2-sphinx_0.9.9.html#conf-wordforms&quot; wordforms=&quot;&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;wordforms&lt;/font&gt;&lt;/u&gt;&lt;/a&gt; 时可用这些词条对索引进行定制.&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;&lt;code class=&quot;filename&quot;&gt;indextool&lt;/code&gt;: 工具程序，用来转储关于索引的多项调试信息。 此工具是从版本Coreseek 3.1(Sphinx 0.9.9-rc2)开始加入的。&lt;/li&gt;&lt;li class=&quot;listitem&quot;&gt;&lt;code class=&quot;filename&quot;&gt;mmseg&lt;/code&gt;: 工具程序和库，Coreseek用于提供中文分词和词典处理。&lt;/li&gt;&lt;/ul&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;&lt;span style=&quot;color: #ff0000&quot;&gt;注：以下安装测试在Cent OS 5.x(5.4/5.6/5.8)x86、x86_64下环境测试通过&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;一、基础安装：&lt;/b&gt;&lt;br /&gt;##完成后：提供xml数据源支持，中文检索支持&lt;br /&gt;##&lt;br /&gt;# wget &lt;a href=&quot;http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.13.tar.gz&quot; target=&quot;_blank&quot;&gt;http://www.coreseek.cn/uploads/csft/3.2/coreseek-3.2.13.tar.gz&lt;/a&gt;&lt;br /&gt;# tar xzvf coreseek-3.2.13.tar.gz&lt;/p&gt;&lt;p&gt;#cd coreseek-3.2.13&lt;br /&gt;##确保可以正常显示，否则请检查当前环境的locale配置，以及当前环境或者客户端已设置好支持UTF-8中文字符显示&lt;br /&gt;# cat testpack/var/test/test.xml&lt;/p&gt;&lt;p&gt;*******************************************************************************************&lt;br /&gt;##安装coreseek开发的mmseg，为coreseek提供中文分词功能&lt;br /&gt;# cd mmseg-3.2.13&lt;br /&gt;[root@localhost mmseg-3.2.13]# ./bootstrap &lt;br /&gt;+ aclocal -I config&lt;br /&gt;config/sys_siglist.m4:20: warning: underquoted definition of SIC_VAR_SYS_SIGLIST&lt;br /&gt;&amp;nbsp; run info &apos;(automake)Extending aclocal&apos;&lt;br /&gt;&amp;nbsp; or see &lt;a href=&quot;http://sources.redhat.com/automake/automake.html#Extending-aclocal&quot; target=&quot;_blank&quot;&gt;http://sources.redhat.com/automake/automake.html#Extending-aclocal&lt;/a&gt;&lt;br /&gt;config/sys_errlist.m4:20: warning: underquoted definition of SIC_VAR_SYS_ERRLIST&lt;br /&gt;config/readline.m4:20: warning: underquoted definition of SIC_WITH_READLINE&lt;br /&gt;aclocal:configure.in:26: warning: macro `AM_PROG_LIBTOOL&apos; not found in library&lt;br /&gt;+ libtoolize --force --copy&lt;br /&gt;./bootstrap: line 24: libtoolize: command not found&lt;br /&gt;+ autoheader&lt;br /&gt;+ automake --add-missing --copy&lt;br /&gt;src/Makefile.am:37: Libtool library used but `LIBTOOL&apos; is undefined&lt;br /&gt;src/Makefile.am:37: &lt;br /&gt;src/Makefile.am:37: The usual way to define `LIBTOOL&apos; is to add `AC_PROG_LIBTOOL&apos;&lt;br /&gt;src/Makefile.am:37: to `configure.in&apos; and run `aclocal&apos; and `autoconf&apos; again.&lt;br /&gt;+ autoconf&lt;br /&gt;configure.in:26: error: possibly undefined macro: AM_PROG_LIBTOOL&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If this token and others are legitimate, please use m4_pattern_allow.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; See the Autoconf documentation.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;上面出错&lt;br /&gt;./bootstrap: line 24: libtoolize: command not found&lt;br /&gt;*******************************************************************************************&lt;br /&gt;[root@localhost mmseg-3.2.13]# yum install libtool&lt;br /&gt;[root@localhost mmseg-3.2.13]# ./bootstrap &lt;br /&gt;[root@localhost mmseg-3.2.13]# ./configure --prefix=/usr/local/mmseg3&lt;br /&gt;...&lt;/p&gt;&lt;p&gt;------------------------------------------------------------------------&lt;br /&gt;Configuration:&lt;/p&gt;&lt;p&gt;&amp;nbsp; Source code location:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .&lt;br /&gt;&amp;nbsp; Compiler:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gcc&lt;br /&gt;&amp;nbsp; Compiler flags:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -g -O2&lt;br /&gt;&amp;nbsp; Host System Type:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; x86_64-redhat-linux-gnu&lt;br /&gt;&amp;nbsp; Install path:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /usr/local/mmseg3&lt;/p&gt;&lt;p&gt;&amp;nbsp; See config.h for further configuration information.&lt;br /&gt;------------------------------------------------------------------------&lt;/p&gt;&lt;p&gt;[root@localhost mmseg-3.2.13]# make&lt;br /&gt;[root@localhost mmseg-3.2.13]# make install&lt;/p&gt;&lt;p&gt;&lt;br /&gt;##安装完成后，mmseg使用的词典和配置文件，将自动安装到/usr/local/mmseg3/etc中&lt;/p&gt;&lt;p&gt;##中文分词测试，如果显示不正常，请检查当前环境下的locale和UTF-8中文字符显示设置&lt;br /&gt;[root@localhost mmseg-3.2.13]# /usr/local/mmseg3/bin/mmseg -d /usr/local/mmseg3/etc src/t1.txt&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 中文/x 分/x 词/x 测试/x &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 中国人/x 上海市/x&lt;/p&gt;&lt;p&gt;Word Splite took: 1 ms.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;#安装coreseek：&lt;br /&gt;# cd ../csft-3.2.13&lt;br /&gt;***************************************************************************************************&lt;br /&gt;##执行configure，进行编译配置：&lt;br /&gt;# ./configure --prefix=/usr/local/coreseek --without-python --without-mysql --with-mmseg --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg3/lib/&lt;br /&gt;# make&lt;br /&gt;# make install&lt;/p&gt;&lt;p&gt;&lt;br /&gt;##配置测试，测试是否可以正确运行&lt;br /&gt;# /usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx-min.conf.dist&lt;br /&gt;##以下为正常测试时的提示信息：&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Copyright (c) 2007-2010,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Beijing Choice Software Technologies Inc (&lt;a href=&quot;http://www.coreseek.com&quot; target=&quot;_blank&quot;&gt;http://www.coreseek.com&lt;/a&gt;)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; using config file &apos;/usr/local/coreseek/etc/sphinx-min.conf.dist&apos;...&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg&lt;/p&gt;&lt;p&gt;##至此，coreseek基础环境可以正常安装，我们可以开始后续的工作啦。&lt;br /&gt;***************************************************************************************************&lt;/p&gt;&lt;p&gt;&lt;b&gt;二、数据源支持：支持MySQL数据源&lt;br /&gt;&lt;/b&gt;##重新编译安装coreseek，以支持mysql数据源和xml数据源&lt;br /&gt;# make clean&lt;br /&gt;[root@localhost csft-3.2.13]# yum install libxml2-devel expat-devel&lt;br /&gt;# ./configure --prefix=/usr/local/coreseek --with-mmseg --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg3/lib/ --with-mysql&lt;br /&gt;# ./configure --prefix=/usr/local/coreseek --with-mmseg --with-mmseg-includes=/usr/local/mmseg3/include/mmseg/ --with-mmseg-libs=/usr/local/mmseg3/lib/ --with-mysql --with-mysql-includes=/usr/local/mysql/include/mysql/ --with-mysql-libs=/usr/local/mysql/lib/mysql/&lt;br /&gt;##以上configure参数请正确拷贝，不要遗漏或者随意修改&lt;/p&gt;&lt;p&gt;# make过程中如果出现如下错误（方法二通过）&lt;br /&gt;#如果出现undefined reference to `libiconv&apos;的类似错误，可以按照如下方法处理：&lt;br /&gt;方法一：（Linux使用）&lt;br /&gt;#直接执行：export LIBS=&amp;quot;-liconv&amp;quot;&lt;br /&gt;##然后再次configure后，进行编译安装&lt;br /&gt;#方法二：&lt;br /&gt;#首先configure，然后vim src/makefile&lt;br /&gt;#在其中搜索lexpat，在其后加上 -liconv&lt;br /&gt;#修改后该行应该为：-lexpat -liconv -L/usr/local/lib&lt;br /&gt;#然后再次make&lt;br /&gt;#方法三：&lt;br /&gt;#首先configure，然后vim config/config.h&lt;br /&gt;#在其中搜索USE_LIBICONV，将其后的1修改为0&lt;br /&gt;#然后再次make&lt;br /&gt;#&lt;/p&gt;&lt;p&gt;# make&lt;br /&gt;# make install&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;b&gt;三、coreseek中文全文检索测试&lt;br /&gt;&lt;/b&gt;[root@localhost csft-3.2.13]# cd ../testpack/&lt;br /&gt;*******************************************************************************************&lt;br /&gt;[root@localhost testpack]# /usr/local/coreseek/bin/indexer -c etc/csft.conf&lt;br /&gt;/usr/local/coreseek/bin/indexer: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory&lt;/p&gt;&lt;p&gt;[root@localhost csft-3.2.13]# /usr/local/coreseek/bin/indexer -c /usr/local/coreseek/etc/sphinx-min.conf.dist&lt;br /&gt;/usr/local/coreseek/bin/indexer: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory&lt;br /&gt;*******************************************************************************************&lt;br /&gt;# 连接对应的文件（注意操作系统版本）&lt;br /&gt;# cd /usr/lib64&lt;br /&gt;[root@localhost lib64]# ln -s /usr/local/mysql/lib/mysql/libmysqlclient.so.16&lt;br /&gt;[root@localhost lib64]# ln -s /usr/local/lib/libiconv.so.2&lt;/p&gt;&lt;p&gt;[root@localhost testpack]# /usr/local/coreseek/bin/indexer -c etc/csft.conf&lt;br /&gt;Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]&lt;br /&gt;Copyright (c) 2007-2010,&lt;br /&gt;Beijing Choice Software Technologies Inc (&lt;a href=&quot;http://www.coreseek.com&quot; target=&quot;_blank&quot;&gt;http://www.coreseek.com&lt;/a&gt;)&lt;/p&gt;&lt;p&gt;&amp;nbsp;using config file &apos;etc/csft.conf&apos;...&lt;br /&gt;total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg&lt;br /&gt;total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg&lt;/p&gt;&lt;p&gt;&lt;br /&gt;[root@localhost testpack]# /usr/local/coreseek/bin/indexer -c etc/csft.conf --all&lt;br /&gt;Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]&lt;br /&gt;Copyright (c) 2007-2010,&lt;br /&gt;Beijing Choice Software Technologies Inc (&lt;a href=&quot;http://www.coreseek.com&quot; target=&quot;_blank&quot;&gt;http://www.coreseek.com&lt;/a&gt;)&lt;/p&gt;&lt;p&gt;&amp;nbsp;using config file &apos;etc/csft.conf&apos;...&lt;br /&gt;indexing index &apos;xml&apos;...&lt;br /&gt;WARNING: source &apos;xml&apos;: xmlpipe2 support NOT compiled in. To use xmlpipe2, install missing XML libraries, reconfigure, and rebuild Sphinx&lt;br /&gt;ERROR: index &apos;xml&apos;: failed to configure some of the sources, will not index.&lt;br /&gt;total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg&lt;br /&gt;total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg&lt;br /&gt;没有安装一些依赖包&lt;/p&gt;&lt;p&gt;[root@localhost testpack]# /usr/local/coreseek/bin/indexer -c etc/csft.conf xml&lt;br /&gt;Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]&lt;br /&gt;Copyright (c) 2007-2010,&lt;br /&gt;Beijing Choice Software Technologies Inc (&lt;a href=&quot;http://www.coreseek.com&quot; target=&quot;_blank&quot;&gt;http://www.coreseek.com&lt;/a&gt;)&lt;/p&gt;&lt;p&gt;&amp;nbsp;using config file &apos;etc/csft.conf&apos;...&lt;br /&gt;indexing index &apos;xml&apos;...&lt;br /&gt;collected 3 docs, 0.0 MB&lt;br /&gt;sorted 0.0 Mhits, 100.0% done&lt;br /&gt;total 3 docs, 7585 bytes&lt;br /&gt;total 0.010 sec, 699723 bytes/sec, 276.75 docs/sec&lt;br /&gt;total 2 reads, 0.000 sec, 4.2 kb/call avg, 0.0 msec/call avg&lt;br /&gt;total 7 writes, 0.000 sec, 3.1 kb/call avg, 0.0 msec/call avg&lt;/p&gt;&lt;p&gt;[root@localhost testpack]# /usr/local/coreseek/bin/search -c etc/csft.conf&lt;br /&gt;Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]&lt;br /&gt;Copyright (c) 2007-2010,&lt;br /&gt;Beijing Choice Software Technologies Inc (&lt;a href=&quot;http://www.coreseek.com&quot; target=&quot;_blank&quot;&gt;http://www.coreseek.com&lt;/a&gt;)&lt;/p&gt;&lt;p&gt;&amp;nbsp;using config file &apos;etc/csft.conf&apos;...&lt;br /&gt;index &apos;xml&apos;: query &apos;&apos;: returned 3 matches of 3 total in 0.006 sec&lt;/p&gt;&lt;p&gt;displaying matches:&lt;br /&gt;1. document=1, weight=1, published=Thu Apr&amp;nbsp; 1 22:20:07 2010, author_id=1&lt;br /&gt;2. document=2, weight=1, published=Thu Apr&amp;nbsp; 1 23:25:48 2010, author_id=1&lt;br /&gt;3. document=3, weight=1, published=Thu Apr&amp;nbsp; 1 12:01:00 2010, author_id=2&lt;/p&gt;&lt;p&gt;words:&lt;/p&gt;&lt;p&gt;&lt;br /&gt;[root@localhost testpack]# /usr/local/coreseek/bin/search -c etc/csft.conf -a Twittter和Opera都提供了搜索服务&lt;br /&gt;Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]&lt;br /&gt;Copyright (c) 2007-2010,&lt;br /&gt;Beijing Choice Software Technologies Inc (&lt;a href=&quot;http://www.coreseek.com&quot; target=&quot;_blank&quot;&gt;http://www.coreseek.com&lt;/a&gt;)&lt;/p&gt;&lt;p&gt;&amp;nbsp;using config file &apos;etc/csft.conf&apos;...&lt;br /&gt;index &apos;xml&apos;: query &apos;Twittter和Opera都提供了搜索服务 &apos;: returned 3 matches of 3 total in 0.021 sec&lt;/p&gt;&lt;p&gt;displaying matches:&lt;br /&gt;1. document=3, weight=24, published=Thu Apr&amp;nbsp; 1 12:01:00 2010, author_id=2&lt;br /&gt;2. document=1, weight=4, published=Thu Apr&amp;nbsp; 1 22:20:07 2010, author_id=1&lt;br /&gt;3. document=2, weight=3, published=Thu Apr&amp;nbsp; 1 23:25:48 2010, author_id=1&lt;/p&gt;&lt;p&gt;words:&lt;br /&gt;1. &apos;twittter&apos;: 1 documents, 3 hits&lt;br /&gt;2. &apos;和&apos;: 3 documents, 15 hits&lt;br /&gt;3. &apos;opera&apos;: 1 documents, 25 hits&lt;br /&gt;4. &apos;都&apos;: 2 documents, 4 hits&lt;br /&gt;5. &apos;提供&apos;: 0 documents, 0 hits&lt;br /&gt;6. &apos;了&apos;: 3 documents, 18 hits&lt;br /&gt;7. &apos;搜索&apos;: 2 documents, 5 hits&lt;br /&gt;8. &apos;服务&apos;: 1 documents, 1 hits&lt;/p&gt;&lt;p&gt;&lt;br /&gt;# /usr/local/coreseek/bin/searchd -c etc/csft.conf&lt;br /&gt;##以下为正常开启搜索服务时的提示信息：&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Coreseek Fulltext 3.2 [ Sphinx 0.9.9-release (r2117)]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Copyright (c) 2007-2010,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Beijing Choice Software Technologies Inc (&lt;a href=&quot;http://www.coreseek.com&quot; target=&quot;_blank&quot;&gt;http://www.coreseek.com&lt;/a&gt;)&lt;/p&gt;&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; using config file &apos;etc/csft.conf&apos;...&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; listening on all interfaces, port=9312&lt;br /&gt;##如要停止搜索服务，请使用/usr/local/coreseek/bin/searchd -c etc/csft.conf --stop&lt;br /&gt;##如要已启动服务，要更新索引，请使用/usr/local/coreseek/bin/indexer -c etc/csft.conf --all --rotate&lt;/p&gt;&lt;p&gt;&lt;b&gt;四、 参考资源：&lt;br /&gt;&lt;/b&gt;1. &lt;a href=&quot;http://www.coreseek.cn/products/products-install/install_on_bsd_linux/&quot; target=&quot;_blank&quot;&gt;http://www.coreseek.cn/products/products-install/install_on_bsd_linux/&lt;/a&gt;&lt;/p&gt;&lt;p&gt;2. &lt;a href=&quot;http://www.coreseek.cn/docs/coreseek_3.2-sphinx_0.9.9.html&quot; target=&quot;_blank&quot;&gt;Sphinx 0.9.9/Coreseek 3.2 参考手册&lt;/a&gt;&lt;/p&gt;</description>
		<guid>http://www.517sou.net/Article/Coreseek-installation-and-test-documentation.aspx</guid>
		<trackback:ping>http://www.517sou.net/Article/786/Trackback.ashx</trackback:ping>
		<comments>http://www.517sou.net/Article/Coreseek-installation-and-test-documentation.aspx#CommentPostAnchor</comments>
		<wfw:commentRss>http://www.517sou.net/Article/786/Feeds.ashx</wfw:commentRss>
	</item>
	<item>
		<link>http://www.517sou.net/Article/httpd-configure-error-APR-not-found.aspx</link>
		<title>httpd configure error: APR not found</title>
		<author>shanyiwan@live.com(flyinweb)</author>
		<category>WEB服务器</category>
		<pubDate>Mon, 23 Apr 2012 07:28:45 GMT</pubDate>
		<description>&lt;p&gt;症状：&lt;/p&gt;&lt;p&gt;Cent OS安装httpd-2.4.2时出错：&lt;/p&gt;&lt;p&gt;configure: error: APR not found&lt;/p&gt;&lt;p&gt;&lt;b&gt;背景：&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://httpd.apache.org/docs/2.4/install.html&quot; target=&quot;_blank&quot;&gt;&lt;b&gt;Compiling and Installing &lt;font color=&quot;#000000&quot;&gt;Requirements&lt;/font&gt;&lt;/b&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;dt&gt;&lt;p&gt;The following requirements exist for building Apache httpd:&lt;/p&gt;&lt;dl&gt;&lt;dt&gt;&lt;b&gt;APR and APR-Util&lt;/b&gt;&lt;/dt&gt;&lt;dd&gt;Make sure you have APR and APR-Util already installed on your system. If you don&apos;t, or prefer to not use the system-provided versions, download the latest versions of both APR and APR-Util from &lt;a href=&quot;http://apr.apache.org/&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Apache APR&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;, unpack them into &lt;code&gt;./srclib/apr&lt;/code&gt; and &lt;code&gt;./srclib/apr-util&lt;/code&gt; (be sure the domain names do not have version numbers; for example, the APR distribution must be under ./srclib/apr/) and use &lt;code&gt;./configure&lt;/code&gt;&apos;s &lt;code&gt;--with-included-apr&lt;/code&gt; option. On some platforms, you may have to install the corresponding &lt;code&gt;-dev&lt;/code&gt; packages to allow httpd to build against your installed copy of APR and APR-Util.&lt;/dd&gt;&lt;dt&gt;&lt;b&gt;Perl-Compatible Regular Expressions Library (PCRE)&lt;/b&gt;&lt;/dt&gt;&lt;dd&gt;This library is required but not longer bundled with httpd. Download the source code from &lt;a href=&quot;http://www.pcre.org/&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;http://www.pcre.org&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;, or install a Port or Package. If your build system can&apos;t find the pcre-config script installed by the PCRE build, point to it using the &lt;code&gt;--with-pcre&lt;/code&gt; parameter. On some platforms, you may have to install the corresponding &lt;code&gt;-dev&lt;/code&gt; package to allow httpd to build against your installed copy of PCRE.&lt;/dd&gt;&lt;dt&gt;&lt;b&gt;Disk Space&lt;/b&gt;&lt;/dt&gt;&lt;dd&gt;Make sure you have at least 50 MB of temporary free disk space available. After installation the server occupies approximately 10 MB of disk space. The actual disk space requirements will vary considerably based on your chosen configuration options, any third-party modules, and, of course, the size of the web site or sites that you have on the server.&lt;/dd&gt;&lt;dt&gt;&lt;b&gt;ANSI-C Compiler and Build System&lt;/b&gt;&lt;/dt&gt;&lt;dd&gt;Make sure you have an ANSI-C compiler installed. The &lt;a href=&quot;http://gcc.gnu.org/&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;GNU C compiler (GCC)&lt;/font&gt;&lt;/u&gt;&lt;/a&gt; from the &lt;a href=&quot;http://www.gnu.org/&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Free Software Foundation (FSF)&lt;/font&gt;&lt;/u&gt;&lt;/a&gt; is recommended. If you don&apos;t have GCC then at least make sure your vendor&apos;s compiler is ANSI compliant. In addition, your &lt;code&gt;PATH&lt;/code&gt; must contain basic build tools such as &lt;code&gt;make&lt;/code&gt;.&lt;/dd&gt;&lt;dt&gt;&lt;b&gt;Accurate time keeping&lt;/b&gt;&lt;/dt&gt;&lt;dd&gt;Elements of the HTTP protocol are expressed as the time of day. So, it&apos;s time to investigate setting some time synchronization facility on your system. Usually the &lt;code&gt;ntpdate&lt;/code&gt; or &lt;code&gt;xntpd&lt;/code&gt; programs are used for this purpose which are based on the Network Time Protocol (NTP). See the &lt;a href=&quot;http://www.ntp.org/&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;NTP homepage&lt;/font&gt;&lt;/u&gt;&lt;/a&gt; for more details about NTP software and public time servers.&lt;/dd&gt;&lt;dt&gt;&lt;b&gt;&lt;a href=&quot;http://www.perl.org/&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;Perl 5&lt;/font&gt;&lt;/u&gt;&lt;/a&gt; [OPTIONAL]&lt;/b&gt;&lt;/dt&gt;&lt;dd&gt;For some of the support scripts like &lt;code class=&quot;program&quot;&gt;&lt;a href=&quot;http://httpd.apache.org/docs/2.4/programs/apxs.html&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;apxs&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/code&gt; or &lt;code class=&quot;program&quot;&gt;&lt;a href=&quot;http://httpd.apache.org/docs/2.4/programs/dbmmanage.html&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;dbmmanage&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/code&gt; (which are written in Perl) the Perl 5 interpreter is required (versions 5.003 or newer are sufficient). If you have multiple Perl interpreters (for example, a systemwide install of Perl 4, and your own install of Perl 5), you are advised to use the &lt;code&gt;--with-perl&lt;/code&gt; option (see below) to make sure the correct one is used by &lt;code class=&quot;program&quot;&gt;&lt;a href=&quot;http://httpd.apache.org/docs/2.4/programs/configure.html&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;configure&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/code&gt;. If no Perl 5 interpreter is found by the &lt;code class=&quot;program&quot;&gt;&lt;a href=&quot;http://httpd.apache.org/docs/2.4/programs/configure.html&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;configure&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/code&gt; script, you will not be able to use the affected support scripts. Of course, you will still be able to build and use Apache httpd.&lt;/dd&gt;&lt;/dl&gt;&lt;p&gt;&lt;b&gt;解决办法：&lt;/b&gt;&lt;/p&gt;&lt;p&gt;1、下载软件&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://apr.apache.org/download.cgi&quot; target=&quot;_blank&quot;&gt;http://apr.apache.org/download.cgi&lt;/a&gt;&lt;/p&gt;&lt;p&gt;# wget &lt;a href=&quot;http://apache.etoak.com//apr/apr-1.4.6.tar.gz&quot; target=&quot;_blank&quot;&gt;http://apache.etoak.com//apr/apr-1.4.6.tar.gz&lt;/a&gt;&lt;br /&gt;# wget &lt;a href=&quot;http://apache.etoak.com//apr/apr-util-1.4.1.tar.gz&quot; target=&quot;_blank&quot;&gt;http://apache.etoak.com//apr/apr-util-1.4.1.tar.gz&lt;/a&gt;&lt;/p&gt;&lt;p&gt;2、安装&lt;/p&gt;&lt;p&gt;1） apr&lt;/p&gt;&lt;p&gt;#&amp;nbsp;tar zxvf apr-1.4.6.tar.gz &lt;br /&gt;# cd apr-1.4.6&lt;br /&gt;# ./configure --prefix=/usr&lt;br /&gt;# make&lt;br /&gt;#&amp;nbsp;make install&lt;br /&gt;&lt;/p&gt;&lt;p&gt;2） apr-util&lt;/p&gt;&lt;p&gt;# tar zxvf apr-util-1.4.1.tar.gz&amp;nbsp;&lt;br /&gt;# cd apr-util-1.4.1&lt;br /&gt;#&amp;nbsp; ./configure --prefix=/usr --with-apr=/usr/bin/apr-1-config &lt;br /&gt;# make &amp;amp;&amp;amp; make install&lt;/p&gt;&lt;/dt&gt;&lt;/p&gt;</description>
		<guid>http://www.517sou.net/Article/httpd-configure-error-APR-not-found.aspx</guid>
		<trackback:ping>http://www.517sou.net/Article/785/Trackback.ashx</trackback:ping>
		<comments>http://www.517sou.net/Article/httpd-configure-error-APR-not-found.aspx#CommentPostAnchor</comments>
		<wfw:commentRss>http://www.517sou.net/Article/785/Feeds.ashx</wfw:commentRss>
	</item>
	<item>
		<link>http://www.517sou.net/Article/PowerShell--How-to-Batch-Change-File-Extensions.aspx</link>
		<title>PowerShell:How to Batch Change File Extensions</title>
		<author>shanyiwan@live.com(flyinweb)</author>
		<category>Windows</category>
		<pubDate>Mon, 16 Apr 2012 14:10:49 GMT</pubDate>
		<description>&lt;p&gt;&lt;code&gt;#Rename-FileExtension.ps1&lt;br /&gt;Function Rename-FileExtension($path,$oldExtension, $newExtension)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;Get-ChildItem -path $path -Filter $oldExtension | &lt;br /&gt;&amp;nbsp;Foreach-Object { &lt;br /&gt;&amp;nbsp;&amp;nbsp; if($_.extension.length -gt 0)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $baseName = $_.name.remove($_.name.length - $_.extension.length)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; ELSE&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; { $baseName = $_.name }&lt;br /&gt;&amp;nbsp;Rename-Item -Path $_.fullname -newname ($baseName + $newExtension) &lt;br /&gt;&amp;nbsp;}&lt;br /&gt;} #end functionp&lt;br /&gt;Rename-FileExtension -path &amp;quot;C:\download\&amp;quot; -oldExtension &amp;quot;*.php&amp;quot; -newExtension &amp;quot;.htm&amp;quot;&lt;/code&gt;&lt;/p&gt;</description>
		<guid>http://www.517sou.net/Article/PowerShell--How-to-Batch-Change-File-Extensions.aspx</guid>
		<trackback:ping>http://www.517sou.net/Article/784/Trackback.ashx</trackback:ping>
		<comments>http://www.517sou.net/Article/PowerShell--How-to-Batch-Change-File-Extensions.aspx#CommentPostAnchor</comments>
		<wfw:commentRss>http://www.517sou.net/Article/784/Feeds.ashx</wfw:commentRss>
	</item>
	<item>
		<link>http://www.517sou.net/Article/How-to-free-memory-and-drop-caches.aspx</link>
		<title>How to free memory and drop caches</title>
		<author>shanyiwan@live.com(flyinweb)</author>
		<category>Linux</category>
		<pubDate>Mon, 16 Apr 2012 03:05:09 GMT</pubDate>
		<description>&lt;p class=&quot;line874&quot;&gt;Kernels 2.6.16 and newer provide a mechanism to have the kernel drop the page cache and/or inode and dentry caches on command, which can help free up a lot of memory. Now you can throw away that script that allocated a ton of memory just to get rid of the cache…&lt;/p&gt;&lt;p class=&quot;line862&quot;&gt;To use &lt;strong&gt;&lt;tt class=&quot;backtick&quot;&gt;/proc/sys/vm/drop_caches&lt;/tt&gt;&lt;/strong&gt;, just echo a number to it.&lt;/p&gt;&lt;p&gt;To free pagecache:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;# echo 1 &amp;gt; /proc/sys/vm/drop_caches&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;To free dentries and inodes:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;# echo 2 &amp;gt; /proc/sys/vm/drop_caches&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;To free pagecache, dentries and inodes:&lt;/p&gt;&lt;p&gt;&lt;strong&gt;echo 3 &amp;gt; /proc/sys/vm/drop_caches&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;As this is a non-destructive operation and dirty objects are not freeable, the user should run “sync” command first!&lt;/p&gt;</description>
		<guid>http://www.517sou.net/Article/How-to-free-memory-and-drop-caches.aspx</guid>
		<trackback:ping>http://www.517sou.net/Article/783/Trackback.ashx</trackback:ping>
		<comments>http://www.517sou.net/Article/How-to-free-memory-and-drop-caches.aspx#CommentPostAnchor</comments>
		<wfw:commentRss>http://www.517sou.net/Article/783/Feeds.ashx</wfw:commentRss>
	</item>
	<item>
		<link>http://www.517sou.net/Article/Unshielded-Twisted-Paired.aspx</link>
		<title>正确识别五类双绞线</title>
		<author>shanyiwan@live.com(flyinweb)</author>
		<category>技术文摘</category>
		<pubDate>Fri, 13 Apr 2012 07:43:47 GMT</pubDate>
		<description>&lt;p&gt;随着快速以太网标准的推出和实施，五类双绞线开始广泛地应用于网络布线。但是由于个别厂商和网络公司在宣传上的误导，以及部分网络用户对有关标准缺 乏必要的了解，致使在选用五类双绞线时真假难辨，不知所措。然而，一旦选用了不符合标准的五类双绞线，一方面会使网络整体性能下降，另一方面为将来网络的 升级埋下了隐患。本文结合技术和应用，介绍标准五类双绞线的正确识别方法。&lt;/p&gt;&lt;p&gt;为了让大家对双绞线有个较全面的了解，我们先来介绍双绞线的常见类型及特性。计算机&lt;font color=&quot;#ff0000&quot;&gt;局域网中的双绞线可分为非屏蔽双绞线(UTP)和屏蔽双绞线(STP) 两大&lt;/font&gt;类：STP外面由一层金属材料包裹，以减小辐射，防止信息被窃听，同时具有较高的数据传输速率，但价格较高，安装也比较复杂;UTP无金属屏蔽材料， 只有一层绝缘胶皮包裹，价格相对便宜，组网灵活。除某些特殊场合(如受电磁辐射严重、对传输质量要求较高等)在布线中使用STP外，一般情况下我们都采用 UTP。&lt;font color=&quot;#ff0000&quot;&gt;现在使用的UTP可分为3类、4类、五类和超五类四种&lt;/font&gt;。其中：3类UTP适应了以太网(10Mbps)对传输介质的要求，是早期网络中重要的传输 介质;4类UTP因标准的推出比3类晚，而传输性能与3类UTP相比并没有提高多少，所以一般较少使用;&lt;font color=&quot;#ff0000&quot;&gt;五类UTP因价廉质优而成为快速以太网 (100Mbps)的首选介质;超五类UTP的用武之地是千兆位以太网(1000Mbps)&lt;/font&gt;。根据目前网络布线的实际需要，本文主要介绍五类UTP的正确 识别和选择方法。&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;font face=&quot;楷体_GB2312&quot;&gt;1.传输速度&lt;br /&gt;&lt;/font&gt;&lt;/b&gt;&lt;font face=&quot;楷体_GB2312&quot;&gt;&lt;font color=&quot;#ff0000&quot;&gt;双绞线质量的优劣是决定局域网带宽的关键因素之一&lt;/font&gt;。某些厂商在五类UTP电缆中所包裹的是3类或4类UTP中所使用的线对，这种制假方法对一般用户来说很 难辨别。这种所谓的“五类UTP”无法达到100Mbps的数据传输率，最大为10Mbps或16Mbps。一个简单的鉴别办法是用一条双绞线连接两台 100Mbps的设备(网卡到网卡或网卡到HUB)，通信时用Windows 95/98自带的monitor检测工具对其数据传输率进行监测。方法为:①选择“开始→程序→附件→系统工具→系统监视器”，将出现“系统监视器”窗 口。如果在“系统工具”中没有“系统监视器”工具时，可通过“我的电脑→添加/删除程序→Windows安装程序→系统工具→系统监视器”建立。②在“系 统监视器”窗口中设置监视对象。选择“编辑”菜单中的“添加项目”选项，在出现的对话框的“类别”列表中选择“Microsoft网络服务器”或 “Microsoft网络客户”(注意:在保证网络连接正常的情况下)，在下一个对话框中选择“写入的字节数/秒”或“读取的字节数/秒”。至于选择 “Microsoft网络服务器”或“Microsoft网络客户”，还是“写入的字节数/秒”或“读取的字节数/秒”，读者可任意选择，因为在网络中一 个节点发送出的数据应该等于另一个节点接收到的数据。③设置测试数据的输出方式。系统提供了折线图、条形图和数字图三种输出方式，可通过窗口工具栏内的按 钮来选择。④进行测试。最有效的办法是从服务器向你进行测试的工作站上拷贝大量的文件(为了测试的准确性，所拷贝的内容一定要足够多)。一般来说，显示的 峰值数值在4M/s以上，就基本可以肯定是五类网线了(3类线所能达到的峰值数值大约为2.5M/s)。&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;font face=&quot;楷体_GB2312&quot;&gt;2.电缆中双绞线对的扭绕应符合要求&lt;/font&gt;&lt;/b&gt;&lt;font face=&quot;楷体_GB2312&quot;&gt;&lt;br /&gt;为了降低信号的干扰，双绞线电缆中的每一线对都是由两根绝缘的铜导线相互扭绕而成，而且同一电缆中的不同线对具有不同的扭绕度(就是扭绕线圈的数量多 少)，如图3所示。同时，标准双绞线电缆中的线对是按逆时针方向进行扭绕。但某些非正规厂商生产的电缆线却存在许多问题:①为了简化制造工艺，电缆中所有 线对的扭绕密度相同;②线对中两根绝缘导线的扭绕密度不符合技术要求;③线对的扭绕方向不符合要求。如果存在以上问题，将会引起双绞线的近端串扰(指 UTP中两线对之间的信号干扰程度)，从而使传输距离达不到要求。双绞线的扭绕度在生产中都有较严格的标准，实际选购时，在有条件的情况下可用一些专业设 备进行测量，但一般用户只能凭肉眼来观察。需说明的是，五类UTP中线对的扭绕度要比三类密，超五类要比五类密。&lt;br /&gt;除组成双绞线线对的两条绝缘铜导线要按要求进行扭绕外，标准双绞线电缆中的线对之间也要按逆时针方向进行扭绕。否则将会引起电缆电阻的不匹配，限制了传输 距离。这一点一般用户很少注意到。有关五类双绞线电缆的扭绕度和其他相关参数，有兴趣的读者可查阅TIA/EIA 568A(TIA/EIA 568是ANSI于1996年制定的布线标准，该标准给出了网络布线时有关基础设施，包括线缆、连接设备等的内容。字母“A”表示为&lt;a title=&quot;IBM&quot; href=&quot;http://product.pchome.net/pc_notebook/list__60_13.html&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;IBM&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;的布线标准，而AT&amp;amp;T公司用字母“B”表示。)中的具体规定。&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;font face=&quot;楷体_GB2312&quot;&gt;3.五类双绞线应该是多少对？&lt;br /&gt;&lt;/font&gt;&lt;/b&gt;&lt;font face=&quot;楷体_GB2312&quot;&gt;以太网在使用双绞线作为传输介质时只需要2对(4芯)线就可以完成信号的发送和接收。在使用双绞线作为传输介质的快速以太网中存在着三个标准： 100Base-TX、100Base-T2和100Base-T4。其中：100Base-T4标准要求使用全部的4对线进行信号传输，另外两个标准只 要求2对线。而在快速以太网中最普及的是100Base-TX标准，所以你在购买100M网络中使用的双绞线时，不要为图一点小便宜去使用只有2个线对的 双绞线。在美国线缆标准(AWG)中对3类、4类、五类和超五类双绞线都定义为4对，在千兆位以太网中更是要求使用全部的4对线进行通信。所以，标准五类 线缆中应该有4对线。&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;&lt;font face=&quot;楷体_GB2312&quot;&gt;4.仔细观察&lt;br /&gt;&lt;/font&gt;&lt;/b&gt;&lt;font face=&quot;楷体_GB2312&quot;&gt;在具备了以上知识后，识别五类UTP时还应注意以下几点：①查看电缆外面的说明信息。在双绞线电缆的外面包皮上应该印有像“AMP SYSTEMS CABLE……24AWG……CAT5”的字样，表示该双绞线是AMP公司(最具声誉的双绞线品牌)的五类双绞线，其中24AWG表示是局域网中所使用的 双绞线，CAT5表示为五类；此外还有一种NORDX/CDT公司的IBDN标准五类网线，上面的字样就是“IBDN PLUS NORDX/CDX……24 AWG……CATEGORY 5”，这里的“CATEGORY 5”也表示五类线(CATEGORY是英文“种类”的意思)。笔者曾经用过一箱没有标明类别的所谓五类线，经实测只能达到3类线的标准;②是否易弯曲。双 绞线应弯曲自然，以方便布线;③电缆中的铜芯是否具有较好的韧性。为了使双绞线在移动中不致于断线，除外皮保护层外，内部的铜芯还要具有一定的韧性。同时 为便于接头的制作和连接可靠，铜芯既不能太软，也不能太硬，太软不易接头的制作，太硬则容易产生接头处断裂;④是否具有阻燃性。为了避免受高温或起火而引 起的线缆损坏，双绞线最外面的一层包皮除应具有很好的抗拉特性外，还应具有阻燃性(可以用火来烧一下测试:如果是正品，胶皮会受热松软，不会起火;如果是 假货，一点就着)。为了降低制造成本，非标准双绞线电缆一般采用不符合要求的材料制作电缆的包皮，不利于通信安全。&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;楷体_GB2312&quot;&gt;双绞线分为屏蔽双绞线STP（Shielded Twisted-Pair）和非屏蔽双绞线UTP（Unshielded wisted-Pair）。屏蔽双绞线STP与非屏蔽双绞线UTP 的差异在于在双绞线和外皮之间增加了一个铅箔屏蔽层，目的是提高双绞线的抗干扰性能，其价格是非屏蔽双绞线UTP的一倍以上，主要是用于安全性要求比较高 的网络环境中， 如军事网络、&lt;a title=&quot;股票&quot; href=&quot;http://club.pchome.net/forum_1_15___443_md.html&quot; target=&quot;_blank&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;股票&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;网 络等，而且使用屏蔽双绞线STP的网络为了达到屏蔽的效果，要求所有的插口和配套设施均需使用屏蔽的设否则就达不到真正的屏蔽效果，所以整个网络的造价会 比使用非屏蔽双绞线UTP的网络高出很多，因此从性价比和可维护性出发，大多数局域网使用非屏蔽双绞线UTP。UTP是最普通的一种铜质电话线，用于连接 家庭、公司和电话公司之间的普通铜线。UTP非屏蔽双绞线具有如下特点： &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;楷体_GB2312&quot;&gt;(1) 无屏蔽外套,直径小,节省所占用的空间 &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;楷体_GB2312&quot;&gt;(2) 重量轻、易弯曲、易安装 &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;楷体_GB2312&quot;&gt;(3) 将串扰减至最小或加以消除 &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;楷体_GB2312&quot;&gt;(4) 具有阻燃性 &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;楷体_GB2312&quot;&gt;(5) 具有独立性和灵活性,适用于结构化综合布线 &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;楷体_GB2312&quot;&gt;为了降低信号的干扰程度（使电磁辐射和外部电磁干扰减到最小），电缆中的每一对双绞线一般是由两根绝缘铜导线相互扭绕而成，每根线加绝缘层并有色标 来标记，双绞线也因此而得名。在EIA／TIA－568标准中，将UTP按电气特性分为3类、4类、5类、超5类、6类、7类线，5类以下的双绞线传输速 度较慢已经很少用了，一般购买5类以上的线。5类线 &lt;br /&gt;上标有CAT5字样，而超5类线上标有5e字样。3类线里的线是二对四根，5类线里的线是 四对八根。 目前局域网中常用到的双绞线一般都是非屏蔽的5类4对（即8根导线）的电缆线。随着传输介质的发展，近年来在局域网中又出现了超5类双绞线。超5类双绞线 属非屏蔽双绞线，与普通5类双绞线比较，超5类双绞线在传送信号时衰减更小，抗干扰能力更强，所以被认为是“为将来应用提供的解决方案”。双绞线视频传输 一般采用非屏蔽双绞线UTP中的5类线或超5类双绞线。 &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;楷体_GB2312&quot;&gt;双绞线由8种（橙白、橙、绿白、蓝、蓝白、绿、棕白、棕）不同颜色的线分成4对绞合在一起。成对扭绞的作用是尽可能减少电磁辐射与外部电磁干扰的影响。在EIA／TIA布线标准中规定了双绞线的两种线序568A与568B。 &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;楷体_GB2312&quot;&gt;568A标准：　　绿白—１，绿—２，橙白—３，蓝—４，蓝白—５，橙—６，棕白—７，棕—８ 　　 &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font size=&quot;4&quot; face=&quot;楷体_GB2312&quot;&gt;568B标准：　　橙白—１，橙—２，绿白—３，蓝—４，蓝白—５，绿—６，棕白—７，棕—８ &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;楷体_GB2312&quot;&gt;（注：这里的1、2、3、4、5、6、7、8分别是指RJ-45水晶头上引脚序号） &lt;/font&gt;&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;楷体_GB2312&quot;&gt;　 为了保证最佳的兼容性，普遍采用EIA／TIA 568B标准来制作网线。当然，在两端都有RJ-45插口的网络中，连线无论是采用568A标准，还是568B标准，在网络中都是可行的。但双绞线的线序与RJ-45水晶头的引脚序号要一一对应。&lt;br /&gt;&lt;/font&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&lt;font face=&quot;楷体_GB2312&quot;&gt;&lt;strong&gt;直通线与交叉线的区别&lt;br /&gt;&lt;/strong&gt;&lt;table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td valign=&quot;top&quot; width=&quot;584&quot;&gt;&lt;p align=&quot;left&quot;&gt;　　正线，即&lt;b&gt;直通线，（标准568B）：&lt;/b&gt;两端线序一样，从左至右线序是：白橙，橙，白绿，蓝，白蓝，绿，白棕，棕。&lt;br /&gt;　　反线，即&lt;b&gt;交叉线，（标准568A）：&lt;/b&gt;一端为正线的线序，另一端为从左至右：白绿，绿，白橙，蓝，白蓝，橙，白棕，棕。&lt;br /&gt;　　以下是各种设备的连接情况下，正线和反线的正确选择。其中HUB代表集线器，SWITCH代表交换机，ROUTER代表路由器：&lt;br /&gt;　　PC-PC:反线&lt;br /&gt;　　PC-HUB:正线&lt;br /&gt;　　HUB-HUB普通口:反线&lt;br /&gt;　　HUB-HUB级连口-级连口：反线&lt;br /&gt;　　HUB-HUB普通口-级连口：正线&lt;br /&gt;　　HUB-SWITCH:反线&lt;br /&gt;　　HUB(级联口）-SWITCH:正线&lt;br /&gt;　　SWITCH-SWITCH:反线&lt;br /&gt;　　SWITCH-ROUTER:正线&lt;br /&gt;　　ROUTER-ROUTER:反线&lt;br /&gt;　　100BaseT连接双绞线，以100Mb/S的EIA/TIA 568B作为标准规格。&lt;br /&gt;&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/font&gt;&lt;/p&gt;</description>
		<guid>http://www.517sou.net/Article/Unshielded-Twisted-Paired.aspx</guid>
		<trackback:ping>http://www.517sou.net/Article/782/Trackback.ashx</trackback:ping>
		<comments>http://www.517sou.net/Article/Unshielded-Twisted-Paired.aspx#CommentPostAnchor</comments>
		<wfw:commentRss>http://www.517sou.net/Article/782/Feeds.ashx</wfw:commentRss>
	</item>
	<item>
		<link>http://www.517sou.net/Article/Informix-dbaccess-and-shell.aspx</link>
		<title>Informix dbaccess 常用执行方式及常见技巧</title>
		<author>shanyiwan@live.com(flyinweb)</author>
		<category>数据库技术</category>
		<pubDate>Fri, 13 Apr 2012 06:37:25 GMT</pubDate>
		<description>&lt;div&gt;&lt;div&gt;&lt;strong&gt;假设：&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;A.数据库servername： testserver&lt;/div&gt;&lt;div&gt;B.数据库名：testdb&lt;/div&gt;&lt;div&gt;C.SQL脚本文件：&lt;/div&gt;&lt;div&gt;sqlfile.sql&lt;/div&gt;&lt;pre&gt;&lt;ol class=&quot;dp-sql&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span class=&quot;keyword&quot;&gt;create&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;table&lt;/span&gt;&lt;span&gt;&amp;nbsp;test_table(c1&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;integer&lt;/span&gt;&lt;span&gt;); &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;keyword&quot;&gt;insert&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;into&lt;/span&gt;&lt;span&gt;&amp;nbsp;test_table(c1)&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;values&lt;/span&gt;&lt;span&gt;(12); &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span class=&quot;keyword&quot;&gt;update&lt;/span&gt;&lt;span&gt;&amp;nbsp;test_table&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;set&lt;/span&gt;&lt;span&gt;&amp;nbsp;c1=0; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;keyword&quot;&gt;delete&lt;/span&gt;&lt;span&gt;&amp;nbsp;test_table&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;where&lt;/span&gt;&lt;span&gt;&amp;nbsp;1=1; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span class=&quot;keyword&quot;&gt;drop&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;table&lt;/span&gt;&lt;span&gt;&amp;nbsp;test_table;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;div&gt;sqlfile2.sql&lt;/div&gt;&lt;pre&gt;&lt;ol class=&quot;dp-sql&quot;&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span&gt;&lt;span class=&quot;keyword&quot;&gt;create&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;table&lt;/span&gt;&lt;span&gt;&amp;nbsp;test_table(c1&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;integer&lt;/span&gt;&lt;span&gt;); &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;keyword&quot;&gt;insert&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;into&lt;/span&gt;&lt;span&gt;&amp;nbsp;test_table(c2)&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;values&lt;/span&gt;&lt;span&gt;(12); &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span class=&quot;keyword&quot;&gt;insert&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;into&lt;/span&gt;&lt;span&gt;&amp;nbsp;test_table(c1)&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;values&lt;/span&gt;&lt;span&gt;(12); &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;keyword&quot;&gt;update&lt;/span&gt;&lt;span&gt;&amp;nbsp;test_table&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;set&lt;/span&gt;&lt;span&gt;&amp;nbsp;c1=0; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li class=&quot;alt&quot;&gt;&lt;span class=&quot;keyword&quot;&gt;delete&lt;/span&gt;&lt;span&gt;&amp;nbsp;test_table&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;where&lt;/span&gt;&lt;span&gt;&amp;nbsp;1=1; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;keyword&quot;&gt;drop&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;span class=&quot;keyword&quot;&gt;table&lt;/span&gt;&lt;span&gt;&amp;nbsp;test_table; &amp;nbsp;&lt;/span&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/pre&gt;&lt;div&gt;--------------------------------------------------------------------------------&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;strong&gt;一、执行SQL脚本文件方式&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;strong&gt;1.调用dbaccess执行SQL脚本文件&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;strong&gt;A、简单执行SQL文件&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;$ dbaccess testdb sqlfile.sql&lt;/div&gt;&lt;div&gt;或者&lt;/div&gt;&lt;div&gt;$ dbaccess &lt;a href=&quot;mailto:testdb@testserver&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;testdb@testserver&lt;/font&gt;&lt;/u&gt;&lt;/a&gt; sqlfile.sql&lt;/div&gt;&lt;div&gt;Database selected.&lt;br /&gt;Table created.&lt;br /&gt;1 row(s) inserted.&lt;br /&gt;1 row(s) updated.&lt;br /&gt;1 row(s) deleted.&lt;br /&gt;Table dropped.&lt;br /&gt;Database closed.&lt;/div&gt;&lt;div&gt;&lt;b&gt;B、执行输出打印执行语句及执行结果&lt;/b&gt;&lt;/div&gt;&lt;div&gt;$ dbaccess -e testdb sqlfile.sql&lt;/div&gt;&lt;div&gt;create table test_table(c1 integer);&lt;br /&gt;Table created.&lt;br /&gt;insert into test_table(c1) values(12);&lt;br /&gt;1 row(s) inserted.&lt;br /&gt;update test_table set c1=0;&lt;br /&gt;1 row(s) updated.&lt;/div&gt;&lt;div&gt;delete test_table where 1=1;&lt;br /&gt;1 row(s) deleted.&lt;/div&gt;&lt;div&gt;drop table test_table;&lt;br /&gt;Table dropped.&lt;br /&gt;Database closed.&lt;/div&gt;&lt;div&gt;&lt;strong&gt;C、将执行结果重定向到文件(shell: bash)&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;$ dbaccess -e testdb sqlfile.sql &amp;gt; output.log &amp;gt; 2&amp;amp;1&lt;/div&gt;&lt;div&gt;$ cat output.log&lt;/div&gt;&lt;div&gt;create table test_table(c1 integer);&lt;br /&gt;Table created.&lt;br /&gt;insert into test_table(c1) values(12);&lt;br /&gt;1 row(s) inserted.&lt;br /&gt;update test_table set c1=0;&lt;br /&gt;1 row(s) updated.&lt;/div&gt;&lt;div&gt;delete test_table where 1=1;&lt;br /&gt;1 row(s) deleted.&lt;/div&gt;&lt;div&gt;drop table test_table;&lt;br /&gt;Table dropped.&lt;br /&gt;Database closed.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;strong&gt;二、交互模式执行语句&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;$ dbaccess - -&lt;br /&gt;&amp;gt; database testdb;&lt;/div&gt;&lt;div&gt;Database selected.&lt;/div&gt;&lt;div&gt;&amp;gt; create table test_table(c1 integer);&lt;br /&gt;Table created.&lt;/div&gt;&lt;div&gt;&amp;gt; insert into test_table(c1) values(12);&lt;br /&gt;1 row(s) inserted.&lt;br /&gt;&amp;gt; update test_table set c1=0;&lt;br /&gt;1 row(s) updated.&lt;/div&gt;&lt;div&gt;&amp;gt; delete test_table where 1=1;&lt;br /&gt;1 row(s) deleted.&lt;/div&gt;&lt;div&gt;&amp;gt; drop table test_table;&lt;br /&gt;Table dropped.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&amp;gt;^D&lt;/div&gt;&lt;div&gt;$ dbaccess dbname &amp;lt;&amp;lt; !&lt;/div&gt;&lt;div&gt;select count(*) from systables ;&lt;/div&gt;&lt;div&gt;select count(*) from systables;&lt;/div&gt;&lt;div&gt;!&lt;/div&gt;&lt;div&gt;&lt;strong&gt;三、菜单模式执行&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;进入数据库&lt;/div&gt;&lt;div&gt;dbaccess 选择数据库&lt;/div&gt;&lt;div&gt;或者&lt;/div&gt;&lt;div&gt;dbaccess testdb&lt;/div&gt;&lt;div&gt;dbaccess &lt;a href=&quot;mailto:testdb@testserver&quot;&gt;&lt;u&gt;&lt;font color=&quot;#0066cc&quot;&gt;testdb@testserver&lt;/font&gt;&lt;/u&gt;&lt;/a&gt;&lt;/div&gt;&lt;div&gt;按菜单操作执行SQL语句,其中可以使用vi进行脚本文件的编辑&lt;/div&gt;&lt;div&gt;&lt;strong&gt;四、几个小技巧&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;&lt;strong&gt;1、执行SQL脚本文件时，当出错时打印详细的错误信息&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;dbaccess -e -m testdb sqlfile2.sql&lt;/div&gt;&lt;div&gt;Database selected.&lt;br /&gt;&lt;br /&gt;create table test_table(c1 integer);&lt;br /&gt;Table created&lt;/div&gt;&lt;div&gt;&lt;br /&gt;insert into test_table(c2) values(1212);&lt;br /&gt;217: Column (c2) not found in any table in the query (or SLV is undefined).&lt;br /&gt;Error in line 2&lt;br /&gt;Near character position 26&lt;br /&gt;&lt;br /&gt;insert into test_table(c1) values(12);&lt;br /&gt;1 row(s) inserted.&lt;br /&gt;update test_table set c1=0;&lt;br /&gt;1 row(s) updated.&lt;br /&gt;delete test_table where 1=1;&lt;br /&gt;1 row(s) deleted.&lt;br /&gt;drop table test_table;&lt;br /&gt;Table dropped.&lt;br /&gt;Database closed.&lt;/div&gt;&lt;div&gt;&lt;strong&gt;2、执行SQL脚本文件时，当出错时打印详细的错误信息并在出现第一个错误时，停止继续执行后续的语句&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;$ dbaccess -e -m -a testdb sqlfile2.sql&lt;/div&gt;&lt;div&gt;Database selected.&lt;br /&gt;&lt;br /&gt;create table test_table(c1 integer);&lt;br /&gt;Table created.&lt;br /&gt;&lt;br /&gt;insert into test_table(c2) values(1212);&lt;br /&gt;217: Column (c2) not found in any table in the query (or SLV is undefined).&lt;br /&gt;Error in line 2&lt;br /&gt;Near character position 26&lt;br /&gt;&lt;br /&gt;Database closed.&lt;/div&gt;&lt;p&gt;&lt;b&gt;3、使用shell操作dbaccess&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;$ cat IfxSQLGet.sh&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;code&gt;##################################################&lt;br /&gt;#功能:执行 Informix SQL语句并返回一行结果&lt;br /&gt;#参数:&amp;lt;数据库名称&amp;gt; &amp;lt;SQL语句&amp;gt; &lt;br /&gt;#返回:查询结果的第一列第一行&lt;br /&gt;#说明:如果运行过程有错误会打印错误信息&lt;br /&gt;##################################################&lt;br /&gt;if [ $# -ne 2 ]&lt;br /&gt;then&lt;br /&gt;&amp;nbsp;&amp;nbsp; echo &amp;quot;[$0][参数:&amp;lt;数据库名称&amp;gt; &amp;lt;SQL语句&amp;gt;]&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp; return&lt;br /&gt;fi&lt;br /&gt;DB=$1&lt;br /&gt;SQL=$2&lt;br /&gt;DBAccessPath=~informix/bin/dbaccess&lt;br /&gt;#产生消息临时文件名&lt;br /&gt;TmpName=`date +%Y%m%d%H%M%S`&lt;br /&gt;TmpName=`echo $TmpName|awk &apos;BEGIN{srand(int(rand()*1000000))} {print $0&amp;quot;_&amp;quot;int(rand()*100000000)}&apos;`&lt;br /&gt;MsgFile=&amp;quot;/tmp/&amp;quot;$TmpName&amp;quot;_Msg.txt&amp;quot;&lt;br /&gt;OutFile=&amp;quot;/tmp/&amp;quot;$TmpName&amp;quot;_Out.txt&amp;quot;&lt;br /&gt;#执行SQL语句&lt;br /&gt;echo $SQL | $DBAccessPath $DB 1&amp;gt;$OutFile 2&amp;gt;$MsgFile&lt;br /&gt;#判断执行是否成功&lt;br /&gt;ConnDBOK=`awk &apos;BEGIN{cnt=0} !/^$/{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if($0==&amp;quot;Database selected.&amp;quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cnt++; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if($0==&amp;quot;Database closed.&amp;quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cnt++;} &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; END{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(cnt==2)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&apos; $MsgFile`&lt;br /&gt;if [ $ConnDBOK -eq 0 ]&lt;br /&gt;then #连接数据库不成功，打印错误信息&lt;br /&gt;&amp;nbsp;&amp;nbsp; ConnDBErr=`awk &apos;!/^$/{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if($0!=&amp;quot;Database selected.&amp;quot; || $0==&amp;quot;Database closed.&amp;quot;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print &amp;quot;(&amp;quot; $0 &amp;quot;)&amp;quot;; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&apos; $MsgFile`&lt;br /&gt;&amp;nbsp;&amp;nbsp; echo &amp;quot;[&amp;quot;$0&amp;quot;][&amp;quot;$DB&amp;quot;][&amp;quot;$SQL&amp;quot;][&amp;quot;$ConnDBErr&amp;quot;]&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp; rm -f $MsgFile&lt;br /&gt;&amp;nbsp;&amp;nbsp; rm -f $OutFile&lt;br /&gt;&amp;nbsp;&amp;nbsp; return&lt;br /&gt;else&lt;br /&gt;&amp;nbsp;&amp;nbsp; ExecDBOK=`awk &apos;BEGIN{cnt=0} $1~/[0-9]:/{cnt++;} END{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(cnt==0)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 1;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print 0;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&apos; $MsgFile`&lt;br /&gt;&amp;nbsp;&amp;nbsp; if [ $ExecDBOK -eq 0 ]&lt;br /&gt;&amp;nbsp;&amp;nbsp; then #执行语句不成功，打印错误信息&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ExecDBErr=`awk &apos;$1~/[0-9]:/{print &amp;quot;(&amp;quot; $0 &amp;quot;)&amp;quot;}&apos; $MsgFile`&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;[&amp;quot;$0&amp;quot;][&amp;quot;$DB&amp;quot;][&amp;quot;$SQL&amp;quot;][&amp;quot;$ExecDBErr&amp;quot;]&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rm -f $MsgFile&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; rm -f $OutFile&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;br /&gt;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;fi&lt;br /&gt;#判断返回数据的格式&lt;br /&gt;HeadRows=`head -3 $OutFile|awk &apos;BEGIN{Rows=0} /^$/{Rows+=1} END{print Rows}&apos;`&lt;br /&gt;case $HeadRows in&lt;br /&gt;2) #垂直显示&lt;br /&gt;&amp;nbsp;&amp;nbsp; awk &apos;NR==5{print $1}&apos; $OutFile&lt;br /&gt;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;3) #水平显示&lt;br /&gt;&amp;nbsp;&amp;nbsp; awk &apos;NR==4{print $2}&apos; $OutFile&lt;br /&gt;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;*)&lt;br /&gt;&amp;nbsp;&amp;nbsp; echo &amp;quot;[&amp;quot;$0&amp;quot;][&amp;quot;$DB&amp;quot;][&amp;quot;$SQL&amp;quot;][无法识别查询结果]&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp; cat $OutFile&lt;br /&gt;&amp;nbsp;&amp;nbsp; ;;&lt;br /&gt;esac&lt;br /&gt;rm -f $MsgFile&lt;br /&gt;rm -f $OutFile&lt;/code&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;$ cat OptLogInf.sh &lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;code&gt;&lt;font face=&quot;Tahoma&quot;&gt;##################################################&lt;br /&gt;#功能:打印操作日志&lt;br /&gt;#参数:&amp;lt;日志文件名&amp;gt; &amp;lt;日志内容&amp;gt;&lt;br /&gt;##################################################&lt;br /&gt;if [ $# -ne 2 ]&lt;br /&gt;then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;[$0][参数:&amp;lt;日志文件名&amp;gt; &amp;lt;日志内容&amp;gt;]&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return&lt;br /&gt;fi&lt;br /&gt;StrNow=`date &amp;quot;+%Y-%m-%d %H:%M:%S&amp;quot;`&lt;br /&gt;echo &amp;quot;[&amp;quot;$StrNow&amp;quot;]&amp;quot;$2 &amp;gt;&amp;gt; $1&lt;/font&gt;&lt;/code&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;b&gt;$ cat demo.sh&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;code&gt;#[demo.sh]&lt;br /&gt;#一般来讲，在shell dbaccess代码段中不能象存储过程中那样使用判断语句，因此只能顺&lt;br /&gt;#序执行&lt;br /&gt;#以下示例通过调用IfxSQLGet.sh实现在Shell中调用 dbaccess 也可以使用判断语句，则时&lt;br /&gt;#调用 ./OptLogInf.sh 记录操作日志&lt;br /&gt;LogFile=./demo.log&lt;br /&gt;OutFile=./demo.unl&lt;br /&gt;DB=&amp;quot;test&amp;quot;&lt;br /&gt;SQL=&amp;quot;select count(*) from systables where tabname=&apos;tabtest&apos;&amp;quot;&lt;br /&gt;Tabs=`./IfxSQLGet.sh &amp;quot;$DB&amp;quot; &amp;quot;$SQL&amp;quot;`&lt;br /&gt;./OptLogInf.sh &amp;quot;$LogFile&amp;quot; &amp;quot;[demo.sh示例开始]\n\n&amp;quot;&lt;br /&gt;#注意，在 dbaccess 代码段中的!不能缩进&lt;br /&gt;if [ $Tabs -eq 0 ]&lt;br /&gt;then&amp;nbsp; #表未创建&lt;br /&gt;&amp;nbsp;&amp;nbsp; dbaccess $DB 1&amp;gt;&amp;gt;$LogFile 2&amp;gt;&amp;gt;$LogFile &amp;lt;&amp;lt;!&lt;br /&gt;!./OptLogInf.sh &amp;quot;$LogFile&amp;quot; &amp;quot;未创建表，现在创建...&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table tabtest&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f1 int,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; f2 char(10)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;br /&gt;!./OptLogInf.sh &amp;quot;$LogFile&amp;quot; &amp;quot;创建表完毕&amp;quot;&lt;br /&gt;!&lt;br /&gt;else&amp;nbsp; #表已创建&lt;br /&gt;&amp;nbsp;&amp;nbsp; dbaccess $DB 1&amp;gt;&amp;gt;$LogFile 2&amp;gt;&amp;gt;$LogFile &amp;lt;&amp;lt;!&lt;br /&gt;!./OptLogInf.sh &amp;quot;$LogFile&amp;quot; &amp;quot;表已创建，删除数据...&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delete from tabtest;&lt;br /&gt;!./OptLogInf.sh &amp;quot;$LogFile&amp;quot; &amp;quot;删除数据完毕&amp;quot;&lt;br /&gt;!&lt;br /&gt;fi&lt;br /&gt;dbaccess $DB 1&amp;gt;&amp;gt;$LogFile 2&amp;gt;&amp;gt;$LogFile &amp;lt;&amp;lt;!&lt;br /&gt;!./OptLogInf.sh &amp;quot;$LogFile&amp;quot; &amp;quot;插入数据...&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp; insert into tabtest(f1,f2) values(1,&apos;aaa&apos;);&lt;br /&gt;&amp;nbsp;&amp;nbsp; insert into tabtest(f1,f2) values(2,&apos;bbb&apos;);&lt;br /&gt;&amp;nbsp;&amp;nbsp; insert into tabtest(f1,f2) values(3,&apos;ccc&apos;);&lt;br /&gt;!./OptLogInf.sh &amp;quot;$LogFile&amp;quot; &amp;quot;导出数据到[$OutFile]...&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp; unload to $OutFile&lt;br /&gt;&amp;nbsp;&amp;nbsp; select * from tabtest;&lt;br /&gt;!./OptLogInf.sh &amp;quot;$LogFile&amp;quot; &amp;quot;导出结束&amp;quot;&lt;br /&gt;!&lt;br /&gt;./OptLogInf.sh &amp;quot;$LogFile&amp;quot; &amp;quot;[Demo4.sh示例结束]\n\n&amp;quot;&lt;/code&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;4、 截取dbaccess操作日志&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;code&gt;dbaccess -e test &amp;lt;&amp;lt;! &amp;gt; logfile.log 2&amp;gt;&amp;amp;1&lt;br /&gt;select * from table;&lt;br /&gt;!&lt;/code&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;5、 informix的shll函数及其使用示例&lt;/b&gt;&lt;br /&gt;&lt;code&gt;#!/bin/sh&lt;br /&gt;#查数据库的函数selectDB，及其使用示例&lt;br /&gt;nameDB=&amp;quot;nameDB&amp;quot; #数据库名&lt;br /&gt;logDir=&amp;quot;$HOME/log&amp;quot; #日志文件目录&lt;br /&gt;if [ ! -d &amp;quot;$logDir&amp;quot; ];then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mkdir -p $logDir&lt;br /&gt;fi&lt;br /&gt;logFile=&amp;quot;$logDir/selectDB.log&amp;quot; #日志文件名&lt;br /&gt;:&amp;gt;$logFile #清日志&lt;br /&gt;#查数据库的函数&lt;br /&gt;#input:sqlStr&lt;br /&gt;#output: dataFile 数据文件名&lt;br /&gt;# 0 -- OK&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1 -- ERROR&lt;br /&gt;#注意:&lt;br /&gt;# 1.需要informix的dbaccess支持&lt;br /&gt;# 2.需要定义外部变量nameDB(数据库名)、logFile(日志文件名)并赋值&lt;br /&gt;# 3.取数据是从文件[dataFile=`selectDB $sqlStr`]读取，一行数据为一条记录，字段以&amp;quot;|&amp;quot;分隔&lt;br /&gt;selectDB()&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #检查相关变量有没有值&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [ &amp;quot;$nameDB&amp;quot; = &amp;quot;&amp;quot; ];then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;&amp;lt;ERROR&amp;gt;数据库名nameDB=[$nameDB]外部变量没有赋值!&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit 1;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [ &amp;quot;$logFile&amp;quot; = &amp;quot;&amp;quot; ];then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;&amp;lt;ERROR&amp;gt;日志文件名logFile=[$logFile]外部变量没有赋值!&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit 1;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _sqlStr=&amp;quot;$*&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [ &amp;quot;$_sqlStr&amp;quot; = &amp;quot;&amp;quot; ];then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;&amp;lt;ERROR&amp;gt;[$0]没有传入参数SQL查询语句![示例: $0 SQLstring]&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit 1;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #临时目录&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _tmpDir=&amp;quot;$HOME/tmp/selectDB&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [ ! -d &amp;quot;$_tmpDir&amp;quot; ];then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mkdir -p $_tmpDir&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #将双引号替换成单引号&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _sqlStr=`echo $_sqlStr | sed &amp;quot;s/\&amp;quot;/\&apos;/g&amp;quot;`&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _nowDir=&amp;quot;`pwd`&amp;quot; #保存当前路径&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cd $_tmpDir&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _dataFile=&amp;quot;data&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; #取唯一文件名&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; i=0&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _tmpStr=&amp;quot;$_dataFile&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while [ -f &amp;quot;${_tmpStr}_$$.txt&amp;quot; ]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; do&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; i=`expr $i + 1`&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; _tmpStr=&amp;quot;${_dataFile}$i&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; done&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _dataFile=&amp;quot;${_tmpStr}_$$.txt&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;\n\n==================查数据库===================&amp;quot; &amp;gt;&amp;gt; $logFile&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;sqlStr:[$_sqlStr]\ndataFile:[$_dataFile]&amp;quot; &amp;gt;&amp;gt; $logFile&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;unload to $_dataFile $_sqlStr&amp;quot; | dbaccess $nameDB&amp;gt;&amp;gt; $logFile 2&amp;gt;&amp;amp;1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; _dataFile=&amp;quot;$_tmpDir/$_dataFile&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [ ! -f $_dataFile ];then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;&amp;lt;ERROR&amp;gt;数据文件[$_dataFile]不存在!&amp;quot; &amp;gt;&amp;gt; $logFile&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;-------------------------------------------&amp;quot; &amp;gt;&amp;gt; $logFile&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; OVER--------------------dbaccess-----------------------OVER&amp;quot; &amp;gt;&amp;gt; $logFile&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; cd $_nowDir&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;$_dataFile&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return 0&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;#SQL语句&lt;br /&gt;sqlStr=&amp;quot;select first 10 unique id,name from tableName where name like &apos;429006%&apos;;&amp;quot;&lt;br /&gt;dataFile=&amp;quot;`selectDB $sqlStr`&amp;quot;&lt;br /&gt;if [ $? -ne 0 ];then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;&amp;lt;ERROR&amp;gt;程序运行出错!请查看日志[$logFile]&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; exit 1;&lt;br /&gt;fi&lt;br /&gt;lineNum=`cat $dataFile | wc -l`&lt;br /&gt;lineNum=`expr $lineNum` #去空格&lt;br /&gt;echo &amp;quot;查出的数据条数[$lineNum]&amp;quot;&lt;br /&gt;#列出数据&lt;br /&gt;i=0&lt;br /&gt;while [ $i -lt $lineNum ]&lt;br /&gt;do&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; i=`expr $i + 1`&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lineData=`sed -n &amp;quot;${i}p&amp;quot; $dataFile`&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [ &amp;quot;$lineData&amp;quot; = &amp;quot;&amp;quot; ];then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;&amp;lt;ERROR&amp;gt;第($i)行数据是空的!&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; break;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; id=`echo $lineData | awk -F&amp;quot;|&amp;quot; &apos;{print $1}&apos;`&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; name=`echo $lineData | awk -F&amp;quot;|&amp;quot; &apos;{print $2}&apos;`&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo &amp;quot;第[$i]条记录: 保单号=[$id],险种=[$name]&amp;quot;&lt;br /&gt;done&lt;br /&gt;echo &amp;quot;&amp;lt;日志&amp;gt;[$logFile]&amp;quot;&lt;/code&gt;&lt;/p&gt;</description>
		<guid>http://www.517sou.net/Article/Informix-dbaccess-and-shell.aspx</guid>
		<trackback:ping>http://www.517sou.net/Article/781/Trackback.ashx</trackback:ping>
		<comments>http://www.517sou.net/Article/Informix-dbaccess-and-shell.aspx#CommentPostAnchor</comments>
		<wfw:commentRss>http://www.517sou.net/Article/781/Feeds.ashx</wfw:commentRss>
	</item>
</channel>
</rss>
