<?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:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hello, SA &#187; technology</title>
	<atom:link href="http://blog.helosa.org/category/technology/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.helosa.org</link>
	<description>Linux System Administrator</description>
	<lastBuildDate>Tue, 31 Jan 2012 08:28:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>HAproxy 代理redis</title>
		<link>http://blog.helosa.org/2012/01/31/haproxy-redis-proxy.html</link>
		<comments>http://blog.helosa.org/2012/01/31/haproxy-redis-proxy.html#comments</comments>
		<pubDate>Tue, 31 Jan 2012 08:27:51 +0000</pubDate>
		<dc:creator>Chan Cham Chung</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[haproxy]]></category>
		<category><![CDATA[redis]]></category>

		<guid isPermaLink="false">http://blog.helosa.org/?p=493</guid>
		<description><![CDATA[转眼2012 的1 月要过去了。。。还是不要空着一个月吧，随便写点什么记录一下。 1 月实践了一下haproxy  作为redis 的代理，统一了所有的redis 入口，对于应用来说，其实最好还是有一个全局的队列，这个中间层完全接管了mysql 和nosql 的写入读取。大工程啊，这里还是说一下简单的。 直接上配置吧： global log 127.0.0.1  local3 notice ulimit-n 40960 maxconn 10240 user haproxy group haproxy nbproc  4 daemon quiet defaults log     global mode    http option tcplog balance roundrobin stats uri /redis-proxy stats auth hello:123 contimeout 5000 clitimeout 30000 srvtimeout 30000 listen monitor mode [...]]]></description>
			<content:encoded><![CDATA[<p>转眼2012 的1 月要过去了。。。还是不要空着一个月吧，随便写点什么记录一下。</p>
<p>1 月实践了一下haproxy  作为redis 的代理，统一了所有的redis 入口，对于应用来说，其实最好还是有一个全局的队列，这个中间层完全接管了mysql 和nosql 的写入读取。大工程啊，这里还是说一下简单的。</p>
<p>直接上配置吧：</p>
<div id="_mcePaste">global</div>
<div id="_mcePaste">log 127.0.0.1  local3 notice</div>
<div id="_mcePaste">ulimit-n 40960</div>
<div id="_mcePaste">maxconn 10240</div>
<div id="_mcePaste">user haproxy</div>
<div id="_mcePaste">group haproxy</div>
<div id="_mcePaste">nbproc  4</div>
<div id="_mcePaste">daemon</div>
<div id="_mcePaste">quiet</div>
<div></div>
<div id="_mcePaste">defaults</div>
<div id="_mcePaste">log     global</div>
<div id="_mcePaste">mode    http</div>
<div id="_mcePaste">option tcplog</div>
<div id="_mcePaste">balance roundrobin</div>
<div id="_mcePaste">stats uri /redis-proxy</div>
<div id="_mcePaste">stats auth hello:123</div>
<div id="_mcePaste">contimeout 5000</div>
<div id="_mcePaste">clitimeout 30000</div>
<div id="_mcePaste">srvtimeout 30000</div>
<div></div>
<div>listen monitor</div>
<div id="_mcePaste">mode http</div>
<div id="_mcePaste">bind 0.0.0.0:2000</div>
<div></div>
<div>listen redis</div>
<div id="_mcePaste">bind 0.0.0.0:6379</div>
<div id="_mcePaste">mode   tcp</div>
<div id="_mcePaste">option tcpka</div>
<div id="_mcePaste">server redis1 192.168.100.1:6379 check inter 5000 fall 3</div>
<div id="_mcePaste">server redis2 192.168.100.2:6379 check inter 5000 fall 3 backup</div>
<p>我这里两个redis ，一个是active 状态对外服务，另一个是热备。</p>
<p>用redis-benchmark 来随便打了一下压力，和redis-cli 直连性能上差不多。</p>
<p>timeout 一定要配置，之前就是忘了配置，其中一个down 了以后很久都不切。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.helosa.org/2012/01/31/haproxy-redis-proxy.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>velocity 2011</title>
		<link>http://blog.helosa.org/2011/12/11/velocity-2011.html</link>
		<comments>http://blog.helosa.org/2011/12/11/velocity-2011.html#comments</comments>
		<pubDate>Sat, 10 Dec 2011 18:08:22 +0000</pubDate>
		<dc:creator>Chan Cham Chung</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[velocity]]></category>

		<guid isPermaLink="false">http://blog.helosa.org/?p=484</guid>
		<description><![CDATA[总的来说，有点失望，含金量不高。 老外的好几个都是在卖广告。。。门票的大头就是他们吧。。。还有一些是说自己的产品如何好如何好，连技术原理都不说，就说你使用了我们的产品呢，能怎么样怎么样的。 简单理一下我的一些笔记吧。略去广告。 ====================== 第一天，含金量最高，而且都在下午。 Steve Souders 的《高性能移动互联网》。这个Steve 大有来历，简单用熟悉一点的东西去介绍，就是 Yslow 和 Firebug 的开创者。可惜。。。我迟到了。。。前面那部分没听到。后面大概就是说一些与移动互联网相关的参数，Yahoo! 的14 条铁律在移动互联网已经不再完全适用，更多的是依靠app 自身，例如cache 。 章文嵩的《低功耗服务器定制与绿色计算》。上一年SACC 上分享淘宝CDN 的时候就已经提及的话题，今年就展开来说一下。大概就是，在最外层的squid cache 层，cpu 完全不是瓶颈，磁盘IO 和网络IO 才是，在这些地方用低功耗服务器可以节省很大一笔钱呢。然后我惊奇地发现，他们在定制低功耗服务器中测试过的三款CPU ，其中两个intel E5620 和 Atom D525 都是我们正在用或者将会试用的cpu。到现在，他们已经优化到cpu 快成为瓶颈了，真可怕。除了低功耗服务器，淘宝CDN 他就简单带过了，无非就是上一年的内容。混合使用各类不同的磁盘再次提到，无非就是SAS , SATA , SSD 三种不同成本的硬盘用来存放大中小文件，及冷热数据。然后我发现。。。他每次的ppt 介绍的都是这些内容啊。。。是不是每次分享都是一两年前的东西。。。现在内部用的已经是很成熟的一套了？？ Percona 的季海东（http://www.haidongji.com/ ）的《Innodb/Xtradb 性能优化与诊断》。他喜欢配合着DEMO 来说ppt ，这个其实很好。。。但是当时间不足的时候。。。他连Xtradb 都完全没有提及就已经没有时间了。其中演示了一些MySQL 的操作，技巧等。。。重点的调优说得不多，尤其是，innodb 的最重要参数 buffer_pool_size ，竟然武断地说，一般设置为物理内存的80% 。。。没有考虑到NUMA 架构的机器？？ 米聊陈臻的《开源工具选型》。这个分享其实不错。米聊同样是一年左右的创业时间，但他们在开源软件的经验上，对比我们还是多了不少。由于他们也是创业公司，注重点还是在产品上面，所以一般都是用开源软件。他们的原则：用大公司正在用的工具，用大公司不用但自己能在代码层级搞掂的工具。他们对于一些软件的选型，其实也没有太多的道理，例如java 容器的选型，resin 和tomcat [...]]]></description>
			<content:encoded><![CDATA[<p>总的来说，有点失望，含金量不高。</p>
<p>老外的好几个都是在卖广告。。。门票的大头就是他们吧。。。还有一些是说自己的产品如何好如何好，连技术原理都不说，就说你使用了我们的产品呢，能怎么样怎么样的。</p>
<p>简单理一下我的一些笔记吧。略去广告。</p>
<p>======================</p>
<p>第一天，含金量最高，而且都在下午。</p>
<p>Steve Souders 的《高性能移动互联网》。这个Steve 大有来历，简单用熟悉一点的东西去介绍，就是 Yslow 和 Firebug 的开创者。可惜。。。我迟到了。。。前面那部分没听到。后面大概就是说一些与移动互联网相关的参数，Yahoo! 的14 条铁律在移动互联网已经不再完全适用，更多的是依靠app 自身，例如cache 。</p>
<p>章文嵩的《低功耗服务器定制与绿色计算》。上一年SACC 上分享淘宝CDN 的时候就已经提及的话题，今年就展开来说一下。大概就是，在最外层的squid cache 层，cpu 完全不是瓶颈，磁盘IO 和网络IO 才是，在这些地方用低功耗服务器可以节省很大一笔钱呢。然后我惊奇地发现，他们在定制低功耗服务器中测试过的三款CPU ，其中两个intel E5620 和 Atom D525 都是我们正在用或者将会试用的cpu。到现在，他们已经优化到cpu 快成为瓶颈了，真可怕。除了低功耗服务器，淘宝CDN 他就简单带过了，无非就是上一年的内容。混合使用各类不同的磁盘再次提到，无非就是SAS , SATA , SSD 三种不同成本的硬盘用来存放大中小文件，及冷热数据。然后我发现。。。他每次的ppt 介绍的都是这些内容啊。。。是不是每次分享都是一两年前的东西。。。现在内部用的已经是很成熟的一套了？？</p>
<p>Percona 的季海东（http://www.haidongji.com/ ）的《Innodb/Xtradb 性能优化与诊断》。他喜欢配合着DEMO 来说ppt ，这个其实很好。。。但是当时间不足的时候。。。他连Xtradb 都完全没有提及就已经没有时间了。其中演示了一些MySQL 的操作，技巧等。。。重点的调优说得不多，尤其是，innodb 的最重要参数 buffer_pool_size ，竟然武断地说，一般设置为物理内存的80% 。。。没有考虑到NUMA 架构的机器？？</p>
<p>米聊陈臻的《开源工具选型》。这个分享其实不错。米聊同样是一年左右的创业时间，但他们在开源软件的经验上，对比我们还是多了不少。由于他们也是创业公司，注重点还是在产品上面，所以一般都是用开源软件。他们的原则：用大公司正在用的工具，用大公司不用但自己能在代码层级搞掂的工具。他们对于一些软件的选型，其实也没有太多的道理，例如java 容器的选型，resin 和tomcat ，没什么原因，因为初始的那一批人就是用resin 的，而且也没什么毛病，就一直选用resin 了。</p>
<p>奇异李刚的《NoSQL 选型与实践》。也蛮不错的，虽然Sean 一直不推荐去听这个分享@@ 奇异用mongodb 相对于redis 多一点，他们甚至用mongodb 来存放图片。。。这个我实在不能理解。。。不过既然他们用了，而且用得挺欢，那也就参考一下吧。或者是有点数量级了吧，他们对细节的优化很到位，没办法，mongodb 对内存是很贪婪的，他们不优化不行。他们在使用中发现了一些bug ，还主动hack 了。</p>
<p>淘宝的tengine 。其实这个也是不错的。包括两部分，第一部分是朱照远说说淘宝正在如何使用nginx 和tengine 的一些特性吧。第二部分是chaoslawful 的分享，其实就是这个ppt ：https://docs.google.com/present/view?id=dddqrph4_23gmctkmcg&amp;pli=1 。tengine 的很多特性还是挺不错的，但是不知道为啥。。。就是不想用。。。唉。。。难道是洁癖作怪？？我之前一直徘徊于nginx module 和 nginx_lua 之间挣扎，听完chaoslawful 的分享，不矛盾了，luajit 完胜啊！</p>
<p>第二天，早上第一场据说已经很少人去听了。。。我前一天晚上工作到3 点多，也没能起来。。。也就算了。。。迟到吧</p>
<p>整个早上。。。也是要工作的。。。结果错过了几个分享，只听到半个分享，就是 来自OmniTI 的 Theo Schlossnagle 的运维生涯。分享了一些有趣的故事吧，由于我进场的时候已经说到一半了，就不用同声传译了，直接英语听力吧，所以一些地方可能没有catch 到他的本意。facebook 的infrastructure team 与业务没有关系，专门从事架构类的一些工作，而且还是允许错误发生的，不过不能在同一个错误上犯错两次而已。也说到了所谓的 DevOps ，不过我认为，如果不懂开发的运维，就会沦为操作者，使用着一些别人开发好的工具，严格依照着操作文档去操作而已，在腾讯，叫做一线运维，地位是比较低下的。所以一个合格的运维必须一定懂编程。</p>
<p>百度的《大规模集群控制系统与自动运维》。意义不大，其实就是自己开发的一套运维系统嘛。与sohu 的sagent 差不多，各自都根据自己的业务自己完全开发了一套。其实原理就那些，实现细节虽然可能会麻烦，但也就那些，重点还是有没有人力去做这回事。在我当前无法做到的情况下，我只能用用开源的puppet 了。所以这个分享我听了一半就去听 Yahoo! 的《大型网站性能监控、测量和故障排除》</p>
<p>Yahoo! 的是一个可爱的mm 分享的，主要介绍了yslow 这个command line tool . http://developer.yahoo.com/yslow/commandline/ ，貌似是最近才开源的。反正就是根据Yahoo! 的14 条铁律写出来的一个命令行工具，还可以生成漂亮的web 报表之类的。和 http://www.showslow.com/ 配合就能很好的分析网站的瓶颈了。虽然这个工具对web1.0 网站似乎用途会大一点，但如果能加入 cookie 的话，那也可以适用我们的网站了。据说是支持的。。。空了试用下。</p>
<p>去哪儿分享的《机票实时搜索引擎的优化》。这个是完全偏题的分享！！。。。但内容还ok 。。。根本没有实时搜索引擎相关的什么优化。。。只是说了去哪儿在前端和后端的优化。他们的前端开始的时候使用了 trimpath 这个框架，后来实在有性能问题了，就自己写了一套，我的前端很烂，就不说了。后端的优化说了几个实例。有一个trick ， 就是xml 的解析，如果只是需要一个xml 的某些标签的content ，可以不用xml 解析器去把整个xml 解析出来，而是直接用正则把需要的字段抽出来即可，效率相差数量级啊！！还有一个就是memcache 的使用经验，我也曾经犯过这个错，就是分配给memcache 的内存，并不是都可以用于存储的，例如100k data block 会分配一定数目的桶，200k 300k 亦然，当大量小object 占满了100k 的桶子时，memcache 就会根据算法置换一些旧object 出去，也就会出现，分配的512M 内存都没有用完，但就经常miss cache 的情况了。他们说了一点：优化重视细节，但切忌过早过度优化，一开始设计很大，但其实最先出现问题的往往没有考虑过的地方。我也曾经一度陷入这个怪圈，但其实真的没有必要一开始考虑得太多，有时候船到桥头自然直。我现在多数关注的是瓶颈的方面了。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.helosa.org/2011/12/11/velocity-2011.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Configure FreeRadius with MySQL on Gentoo</title>
		<link>http://blog.helosa.org/2011/10/22/configure-freeradius-mysql-gentoo.html</link>
		<comments>http://blog.helosa.org/2011/10/22/configure-freeradius-mysql-gentoo.html#comments</comments>
		<pubDate>Sat, 22 Oct 2011 04:07:34 +0000</pubDate>
		<dc:creator>Chan Cham Chung</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[gentoo]]></category>

		<guid isPermaLink="false">http://blog.helosa.org/?p=478</guid>
		<description><![CDATA[安装支持MySQL 的FreeRadius ，默认是不支持的： USE=&#8221;mysql&#8221; emerge freeradius 或者 echo &#8220;=net-dialup/freeradius-2.0.5 mysql&#8221; &#62;&#62; /etc/portage/package.use emerge freeradius radius 的配置都在 /etc/raddb/ 里，我们需要修改的有 radiusd.conf , clients.conf , users , sql.conf , /site-enabled/default，分别对应服务器端，客户端，用户，数据库的配置，验证方式。其实由于这里使用了MySQL 记录用户的密码，所以其实不用修改users 也行。 我尽量在默认配置的基础上修改配置，可以不修改就不修改默认的配置。 radiusd.conf : 这里可以不修改，但最好修改一下，listen 的ipaddr 修改为内网吧。log 方面也可以适当开启一下。 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; clients.conf : 客户机的配置，我这里其实是Airport Extreme。 client 192.168.1.10 { secret = testing shortname = AP nastype = other } &#8212;&#8212;&#8212;&#8212;- [...]]]></description>
			<content:encoded><![CDATA[<p>安装支持MySQL 的FreeRadius ，默认是不支持的：</p>
<p>USE=&#8221;mysql&#8221; emerge freeradius</p>
<p>或者</p>
<p>echo &#8220;=net-dialup/freeradius-2.0.5 mysql&#8221; &gt;&gt; /etc/portage/package.use</p>
<p>emerge freeradius</p>
<p>radius 的配置都在 /etc/raddb/ 里，我们需要修改的有 radiusd.conf , clients.conf , users , sql.conf , /site-enabled/default，分别对应服务器端，客户端，用户，数据库的配置，验证方式。其实由于这里使用了MySQL 记录用户的密码，所以其实不用修改users 也行。</p>
<p>我尽量在默认配置的基础上修改配置，可以不修改就不修改默认的配置。</p>
<p>radiusd.conf :</p>
<p>这里可以不修改，但最好修改一下，listen 的ipaddr 修改为内网吧。log 方面也可以适当开启一下。</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>clients.conf :</p>
<p>客户机的配置，我这里其实是Airport Extreme。</p>
<div id="_mcePaste">client 192.168.1.10 {</div>
<div id="_mcePaste">secret = testing</div>
<div id="_mcePaste">shortname = AP</div>
<div id="_mcePaste">nastype = other</div>
<div id="_mcePaste">}</div>
<div>&#8212;&#8212;&#8212;&#8212;-</div>
<div>sql.conf:</div>
<div>先准备好MySQL 环境。</div>
<div>mysql&gt; create database radius ;</div>
<div>mysql&gt; grant all on radius.* to radius@localhost identfied by &#8216;testing&#8217; ;</div>
<div>$ mysql -uradius -ptesting radius &lt; /etc/raddb/sql/mysql/schema.sql</div>
<p>添加一个用户：</p>
<p>INSERT INTO radcheck (UserName, Attribute, Value) VALUES (&#8216;test&#8217;, &#8216;Password&#8217;, &#8217;123456&#8242;);</p>
<p>修改一下sql.conf 相应的配置：</p>
<p>login=&#8221;radius&#8221;</p>
<p>passsword=&#8221;testing&#8221;</p>
<p>radius_db=&#8221;radius&#8221;</p>
<p>&#8212;&#8212;&#8212;&#8211;</p>
<p>/etc/raddb/sites-enabled/default:</p>
<p>把 authorize 里的sql uncomment 了，这样才能启用sql 验证。</p>
<p>当然，有洁癖的话可以把其它没用的comment 了。</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>测试下：</p>
<p>进入debug 模式：radiusd -X</p>
<p>测试命令：</p>
<p>语法：Usage: radtest user passwd radius-server[:port] nas-port-number secret</p>
<p>radtest test 123456 192.168.1.1 0 testing</p>
<p>如果是Access-Reject 就是失败了，Access-Accept 就是成功了。</p>
<p>===============</p>
<p>配置到此完毕，算是可用了，但还不完善。不过我在想，用MySQL 还不如用LDAP 吧。。。下回再弄弄。</p>
<p>Reference:</p>
<p>http://en.gentoo-wiki.com/wiki/Chillispot_with_FreeRadius_and_MySQL</p>
<p>http://www.gentoo-wiki.info/HOWTO_WPA_Enterprise_with_MySQL</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.helosa.org/2011/10/22/configure-freeradius-mysql-gentoo.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>在PowerEdge R410 下安装Debian6</title>
		<link>http://blog.helosa.org/2011/10/20/poweredge-r410-debian6.html</link>
		<comments>http://blog.helosa.org/2011/10/20/poweredge-r410-debian6.html#comments</comments>
		<pubDate>Thu, 20 Oct 2011 05:22:03 +0000</pubDate>
		<dc:creator>Chan Cham Chung</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[debian]]></category>

		<guid isPermaLink="false">http://blog.helosa.org/?p=476</guid>
		<description><![CDATA[昨天第一次在一台 R410 上装了Debian 6 ，想不到还出问题了。。。竟然不能直接就用netinst 安装好Debian，居然还是缺驱动。 安装的过程中，它会检测硬件，但是竟然出错了，“load missing firmware file” ，驱动也指出来了，是这个：bnx2/bnx2-mips-09-5.0.0.j3.fw 。原因在于，这个网卡驱动在Debian6 时变成了non-free 的驱动了，Debian installer 也告诉我了，需要把这个firmware 下载到一个removable media ，然后插入即可。问题就在这里开始解决吧。 弄来一个U 盘，格式化为FAT 吧，然后到这里下载两个firmware ： http://194.95.9.96/debian-installer/amd64/temp/lib/firmware/bnx2/ bnx2-mips-09-5.0.0.j3.fw bnx2-rv2p-09-5.0.0.j3.fw 下载回来，放在U 盘的根目录的 bnx2/ 目录里面。 在出现load missing firmware file ，让你插入removable media 的时候，ctrl + alt + F2 跳转到另一个终端，然后把U 盘挂载上去。我当时是/dev/sdb4 ，mount /dev/sdb4 /mnt 。 这个时候，那两个firmware 应该在 /mnt/bnx2/bnx2-mips-09-5.0.0.j3.fw /mnt/bnx2/bnx2-rv2p-09-5.0.0.j3.fw 然后ctrl + alt + [...]]]></description>
			<content:encoded><![CDATA[<p>昨天第一次在一台 R410 上装了Debian 6 ，想不到还出问题了。。。竟然不能直接就用netinst 安装好Debian，居然还是缺驱动。</p>
<p>安装的过程中，它会检测硬件，但是竟然出错了，“load missing firmware file” ，驱动也指出来了，是这个：bnx2/bnx2-mips-09-5.0.0.j3.fw 。原因在于，这个网卡驱动在Debian6 时变成了non-free 的驱动了，Debian installer 也告诉我了，需要把这个firmware 下载到一个removable media ，然后插入即可。问题就在这里开始解决吧。</p>
<p>弄来一个U 盘，格式化为FAT 吧，然后到这里下载两个firmware ：</p>
<p>http://194.95.9.96/debian-installer/amd64/temp/lib/firmware/bnx2/</p>
<p>bnx2-mips-09-5.0.0.j3.fw<br />
bnx2-rv2p-09-5.0.0.j3.fw</p>
<p>下载回来，放在U 盘的根目录的 bnx2/ 目录里面。</p>
<p>在出现load missing firmware file ，让你插入removable media 的时候，ctrl + alt + F2 跳转到另一个终端，然后把U 盘挂载上去。我当时是/dev/sdb4 ，mount /dev/sdb4 /mnt 。</p>
<p>这个时候，那两个firmware 应该在</p>
<p>/mnt/bnx2/bnx2-mips-09-5.0.0.j3.fw</p>
<p>/mnt/bnx2/bnx2-rv2p-09-5.0.0.j3.fw</p>
<p>然后ctrl + alt + F1 回到安装的终端，按 YES 吧。</p>
<p>然后就过去了，继续如常安装吧。</p>
<p>我参考自这个页面：http://bbs.chinaunix.net/archiver/tid-2312139.html ，只是记录一下自己的经历，和他的做法稍有不同。</p>
<p>Debian 6 刚发布的时候，在我的老东家，机房的同事就说装Debian 6 有点问题，结果帮我们装了个Debian 5 ，让我们自己升，够坑爹的。我就在想，会不会就是因为这个驱动的问题导致的呢？或者，在FAI 下还真不好解决，下回我也试试FAI 安装Debian6 .</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.helosa.org/2011/10/20/poweredge-r410-debian6.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>gource is so cool !!</title>
		<link>http://blog.helosa.org/2011/09/29/gource-is-so-cool.html</link>
		<comments>http://blog.helosa.org/2011/09/29/gource-is-so-cool.html#comments</comments>
		<pubDate>Wed, 28 Sep 2011 18:56:40 +0000</pubDate>
		<dc:creator>Chan Cham Chung</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://blog.helosa.org/?p=466</guid>
		<description><![CDATA[我竟然今天才发现这个cool 极了的东西！！！ http://code.google.com/p/gource/ 项目主页在这里，里面有视频。 读取版本管理的日志，然后通过很炫的动画，将版本的变动表现出来，cool 啊！！支持多种版本管理软件，包括我熟悉的svn 和不算太熟悉的git 。 homebrew 下很方便，brew install gource ，安装完成后，在代码的根目录，直接运行 gource 就行了！！ 然后，就欣赏很炫的动画吧！！]]></description>
			<content:encoded><![CDATA[<p>我竟然今天才发现这个cool 极了的东西！！！</p>
<p>http://code.google.com/p/gource/</p>
<p>项目主页在这里，里面有视频。</p>
<p>读取版本管理的日志，然后通过很炫的动画，将版本的变动表现出来，cool 啊！！支持多种版本管理软件，包括我熟悉的svn 和不算太熟悉的git 。</p>
<p>homebrew 下很方便，brew install gource ，安装完成后，在代码的根目录，直接运行 gource 就行了！！</p>
<p>然后，就欣赏很炫的动画吧！！</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.helosa.org/2011/09/29/gource-is-so-cool.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>HOWTO Configure L2TP VPN server on Linode Gentoo VPS</title>
		<link>http://blog.helosa.org/2011/09/25/howto-config-l2tp-vpn-linode-gentoo.html</link>
		<comments>http://blog.helosa.org/2011/09/25/howto-config-l2tp-vpn-linode-gentoo.html#comments</comments>
		<pubDate>Sun, 25 Sep 2011 10:31:08 +0000</pubDate>
		<dc:creator>Chan Cham Chung</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[gentoo]]></category>
		<category><![CDATA[linode]]></category>
		<category><![CDATA[vpn]]></category>

		<guid isPermaLink="false">http://blog.helosa.org/?p=430</guid>
		<description><![CDATA[Linode announced a new facility in Tokyo, Japan at September 20, 2011. It&#8217;s a big good news for us inside the wall. The download speed, and latency, is pretty awesome!! I migrated my linode(actually it belongs to my boss) from USA to Tokyo with no doubt. And rebuild it from Ubuntu to Gentoo. As a [...]]]></description>
			<content:encoded><![CDATA[<p>Linode announced a new facility in <strong>Tokyo, Japan</strong> at September 20, 2011. It&#8217;s a big good news for us inside the <strong>wall</strong>. The download speed, and latency, is pretty <strong>awesome</strong>!!</p>
<p>I migrated my linode(actually it belongs to my boss) from USA to Tokyo with no doubt. And rebuild it from <strong>Ubuntu</strong> to <strong>Gentoo</strong>. As a desktop, <strong>Ubuntu</strong> plays so good so far.But as a server, <strong>Ubuntu sucks </strong>!!</p>
<p>OK, everything is ready, all we need is a <strong>L2TP VPN</strong> server.</p>
<p>Here is my L2TP VPN configuration.</p>
<p>First of all, choose a faster mirror server, this is my selection: <strong>gentoo.channelx.biz</strong>, chosen from <strong>mirrorselect </strong>(<strong>emerge mirrorselect</strong>). And add it to <strong>/etc/make.conf</strong>, replace the original one.</p>
<p>U can run this command if u don&#8217;t have an original <strong>GENTOO_MIRRORS</strong> config in <strong>/etc/make.conf</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'GENTOO_MIRRORS=&quot;http://gentoo.channelx.biz/&quot; '</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>make.conf</pre></div></div>

<p>The software we need: <strong>openswan</strong> , <strong>xl2tpd</strong> , <strong>ppp</strong>. We can install them all with the &#8216;emerge&#8217; command, but I found there&#8217;s something wrong with the <strong>openswan</strong> (<strong>v2.4.15-r2</strong>), we must upgrade <strong>openswan</strong> to version <strong>2.6.31</strong>, even though this version is masked.</p>
<p>Solve the masked problem:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'EMERGE_DEFAULT_OPTS=&quot;--autounmask=n&quot; '</span>  <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>make.conf
&nbsp;
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'=net-misc/openswan-2.6.31 '</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>portage<span style="color: #000000; font-weight: bold;">/</span>package.accept_keywords</pre></div></div>

<p>OK, install it:</p>
<p>emerge =net-misc/openswan-2.6.31</p>
<p>Let&#8217;s do some copy and paste.</p>
<p>Configure the <strong>ipsec</strong>.</p>
<p>copy the content of <strong>/etc/ipsec.d/examples/sysctl.conf</strong> to<strong> /etc/sysctl.conf </strong>,and make sure the <strong>rp_filter</strong> options are commented.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Enables source route verification</span>
<span style="color: #666666; font-style: italic;">#net.ipv4.conf.default.rp_filter = 1</span>
<span style="color: #666666; font-style: italic;"># Enable reverse path</span>
<span style="color: #666666; font-style: italic;">#net.ipv4.conf.all.rp_filter = 1</span></pre></div></div>

<p>u can run this command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ipsec.d<span style="color: #000000; font-weight: bold;">/</span>examples<span style="color: #000000; font-weight: bold;">/</span>sysctl.conf <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>sysctl.conf</pre></div></div>

<p>and active the sysctl.conf:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">sysctl <span style="color: #660033;">-p</span></pre></div></div>

<p>Edit the <strong>/etc/ipsec.conf</strong> :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'include /etc/ipsec.d/examples/l2tp-psk.conf'</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ipsec.conf</pre></div></div>

<p>when ignore the commented line:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#cat /etc/ipsec.conf | egrep -v &quot;^[[:space:]]*#&quot; | grep -v &quot;^$&quot;</span>
&nbsp;
conn L2TP-PSK-NAT
	<span style="color: #007800;">rightsubnet</span>=vhost:<span style="color: #000000; font-weight: bold;">%</span>priv
	<span style="color: #007800;">also</span>=L2TP-PSK-noNAT
conn L2TP-PSK-noNAT
	<span style="color: #007800;">authby</span>=secret
	<span style="color: #007800;">pfs</span>=no
	<span style="color: #007800;">auto</span>=add
	<span style="color: #007800;">keyingtries</span>=<span style="color: #000000;">3</span>
	<span style="color: #007800;">rekey</span>=no
	<span style="color: #007800;">ikelifetime</span>=8h
	<span style="color: #007800;">keylife</span>=1h
	<span style="color: #007800;"><span style="color: #7a0874; font-weight: bold;">type</span></span>=transport
	<span style="color: #007800;">left</span>=YourPublicIP 
	<span style="color: #007800;">leftprotoport</span>=<span style="color: #000000;">17</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1701</span>
	<span style="color: #007800;">right</span>=<span style="color: #000000; font-weight: bold;">%</span>any
	<span style="color: #007800;">rightprotoport</span>=<span style="color: #000000;">17</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>
conn passthrough-for-non-l2tp
        <span style="color: #007800;"><span style="color: #7a0874; font-weight: bold;">type</span></span>=passthrough
        <span style="color: #007800;">left</span>=YourPublicIP
        <span style="color: #007800;">leftnexthop</span>=YourGatewayIP
        <span style="color: #007800;">right</span>=0.0.0.0
        <span style="color: #007800;">rightsubnet</span>=0.0.0.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>
        <span style="color: #007800;">auto</span>=route</pre></div></div>

<p>and remember to replace the &#8220;<strong>YourPublicIP</strong>&#8221; , &#8220;<strong>YourGatewayIP</strong>&#8221; to the correct value.</p>
<p>edit <strong>/etc/ipsec.secrets</strong> :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">YourIPAddress  <span style="color: #000000; font-weight: bold;">%</span>any: PSK <span style="color: #ff0000;">&quot;sharedsecret&quot;</span></pre></div></div>

<p>do the same replacement.</p>
<p>Configure the <strong>iptables</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">iptables <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> POSTROUTING <span style="color: #660033;">-j</span> MASQUERADE
&nbsp;
<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>iptables save
&nbsp;
rc-updat add iptables default</pre></div></div>

<p>Configure <strong>xl2tpd</strong> :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># cat /etc/xl2tpd/xl2tpd.conf</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>global<span style="color: #7a0874; font-weight: bold;">&#93;</span> 
ipsec saref = <span style="color: #c20cb9; font-weight: bold;">yes</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#91;</span>lns default<span style="color: #7a0874; font-weight: bold;">&#93;</span> 
ip range = 172.16.80.128-172.16.80.254 
<span style="color: #7a0874; font-weight: bold;">local</span> ip = 172.16.80.1
require chap = <span style="color: #c20cb9; font-weight: bold;">yes</span> 
refuse pap = <span style="color: #c20cb9; font-weight: bold;">yes</span> 
require authentication = <span style="color: #c20cb9; font-weight: bold;">yes</span> 
name = xl2tpd
ppp debug = <span style="color: #c20cb9; font-weight: bold;">yes</span> 
pppoptfile = <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>ppp<span style="color: #000000; font-weight: bold;">/</span>options.xl2tpd
length bit = <span style="color: #c20cb9; font-weight: bold;">yes</span></pre></div></div>

<p>Configure <strong>PPP</strong> :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># cat /etc/ppp/options.xl2tpd</span>
&nbsp;
ipcp-accept-local
ipcp-accept-remote
ms-dns  8.8.8.8
ms-dns  8.8.4.4
noccp
auth
crtscts
idle <span style="color: #000000;">1800</span>
mtu <span style="color: #000000;">1410</span>
mru <span style="color: #000000;">1410</span>
nodefaultroute
debug
lock
proxyarp
connect-delay <span style="color: #000000;">5000</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># cat /etc/ppp/chap-secrets</span>
&nbsp;
Username        xl2tpd      Password        <span style="color: #000000; font-weight: bold;">*</span></pre></div></div>

<p>do some replacement here.</p>
<p>start the services:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>ipsec start
<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>init.d<span style="color: #000000; font-weight: bold;">/</span>xl2tpd start</pre></div></div>

<p>Have fun .</p>
<p>PS: <strong>ipsec verify</strong> failed ?</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">Pluto listening <span style="color: #000000; font-weight: bold;">for</span> IKE on udp <span style="color: #000000;">500</span>                          	<span style="color: #7a0874; font-weight: bold;">&#91;</span>FAILED<span style="color: #7a0874; font-weight: bold;">&#93;</span>
  Cannot execute <span style="color: #7a0874; font-weight: bold;">command</span> <span style="color: #ff0000;">&quot;lsof -i UDP:500&quot;</span>: No such <span style="color: #c20cb9; font-weight: bold;">file</span> or directory
Pluto listening <span style="color: #000000; font-weight: bold;">for</span> NAT-T on udp <span style="color: #000000;">4500</span>                       	<span style="color: #7a0874; font-weight: bold;">&#91;</span>FAILED<span style="color: #7a0874; font-weight: bold;">&#93;</span>
  Cannot execute <span style="color: #7a0874; font-weight: bold;">command</span> <span style="color: #ff0000;">&quot;lsof -i UDP:4500&quot;</span>: No such <span style="color: #c20cb9; font-weight: bold;">file</span> or directory</pre></div></div>

<p>it&#8217;s all right, because the command &#8216;<strong>lsof</strong>&#8216; is missing, just &#8216;<strong>emerge lsof</strong>&#8216;</p>
<p><strong>Reference: </strong></p>
<p><a href="http://riobard.com/blog/2010-04-30-l2tp-over-ipsec-ubuntu/" target="_blank">http://riobard.com/blog/2010-04-30-l2tp-over-ipsec-ubuntu/</a><br />
<a href="http://apple4.us/2010/05/setting-up-l2tp-vpn-on-debian-ubuntu.html" target="_blank">http://apple4.us/2010/05/setting-up-l2tp-vpn-on-debian-ubuntu.html</a><br />
<a href="http://forums.gentoo.org/viewtopic-t-324500-highlight-openswan.html" target="_blank">http://forums.gentoo.org/viewtopic-t-324500-highlight-openswan.html</a> (the ppp configuration part, it&#8217;s different between gentoo and ubuntu)</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br />
update: 2011-09-26<br />
If u can connect successfully at the first time, but failed at the second. Here&#8217;s the solution.<br />
Add the following lines to your L2TP-PSK-noNAT connection and restart ipsec (/etc/init.d/ipsec restart )</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #007800;">dpddelay</span>=<span style="color: #000000;">40</span>
<span style="color: #007800;">dpdtimeout</span>=<span style="color: #000000;">130</span>
<span style="color: #007800;">dpdaction</span>=<span style="color: #c20cb9; font-weight: bold;">clear</span></pre></div></div>

<p><strong>Reference: </strong><br />
<a href="http://lists.openswan.org/pipermail/users/2011-January/019945.html" target="_blank">http://lists.openswan.org/pipermail/users/2011-January/019945.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.helosa.org/2011/09/25/howto-config-l2tp-vpn-linode-gentoo.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>小折腾几天dd-wrt</title>
		<link>http://blog.helosa.org/2011/09/10/dd-wrt.html</link>
		<comments>http://blog.helosa.org/2011/09/10/dd-wrt.html#comments</comments>
		<pubDate>Sat, 10 Sep 2011 06:28:11 +0000</pubDate>
		<dc:creator>Chan Cham Chung</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[dd-wrt]]></category>

		<guid isPermaLink="false">http://blog.helosa.org/?p=426</guid>
		<description><![CDATA[这几天晚上回来都在折腾我家的路由，写下我的折腾小结。 刷DD-WRT 当然要看看固件支不支持啦，看下这个：http://www.dd-wrt.com/wiki/index.php/Supported_Devices 之前我还刷过一个baffulo 的，才4m 闪存，32m 内存，最大的好处是，官方提供DD-WRT firmware standard 版，不怕刷坏。 我自己淘了一个二手 belkin F7D4302 ，强大的地方是，64m 内存，8m 闪存，而且支持2.4GHz 5Ghz 双频，有usb 接口，硬件配置超爽！！缺点无自己的天线，信号不是那么好，发热量据说很大，我初用，感觉还不深。 刷的过程就不说了，反正我是参考google 一搜就出来的那篇文章刷的。说说中间的折腾吧。 belkin 的路由在supported devices 里，会有以下warning: WARNING: Always use TFTP to flash Belkin routers if at all possible! Upgrading dd-wrt from the web interface can lead to a bricked (nonfunctional) unit! 不过我的那个有一个note: use CFE mini Web Server [...]]]></description>
			<content:encoded><![CDATA[<p>这几天晚上回来都在折腾我家的路由，写下我的折腾小结。</p>
<p>刷DD-WRT 当然要看看固件支不支持啦，看下这个：http://www.dd-wrt.com/wiki/index.php/Supported_Devices</p>
<p>之前我还刷过一个baffulo 的，才4m 闪存，32m 内存，最大的好处是，官方提供DD-WRT firmware standard 版，不怕刷坏。</p>
<p>我自己淘了一个二手 belkin F7D4302 ，强大的地方是，64m 内存，8m 闪存，而且支持2.4GHz 5Ghz 双频，有usb 接口，硬件配置超爽！！缺点无自己的天线，信号不是那么好，发热量据说很大，我初用，感觉还不深。</p>
<p>刷的过程就不说了，反正我是参考google 一搜就出来的那篇文章刷的。说说中间的折腾吧。</p>
<p>belkin 的路由在supported devices 里，会有以下warning:</p>
<p><span style="text-decoration: underline;">WARNING</span>: Always use TFTP to flash Belkin routers if at all possible! Upgrading dd-wrt from the web interface can lead to a bricked (nonfunctional) unit!</p>
<p>不过我的那个有一个note: use CFE mini Web Server for first flash. 第一次貌似可以用web gui 来刷，于是我就刷了一个专门为 F7D4302 定制的（ http://www.dd-wrt.com/dd-wrtv2/downloads/others/eko/BrainSlayer-V24-preSP2/2011/06-14-11-r17201/broadcom_K26/dd-wrt.v24-17201_NEWD-2_K2.6_mini_f7d4302.bin） 固件。</p>
<p>貌似一定要用ie 来刷，反正mac 下的safari , chrome , firefox 都不行，不知道linux 下的firefox chrome 行不行。</p>
<p>这个是mini 版，如果真的想把路由用起来，mini 是远远不够的，mini standard mega 之间的区别看这里：http://en.wikipedia.org/wiki/DD-WRT#Features</p>
<p>mega 的固件可以在这里下载：http://www.dd-wrt.com/dd-wrtv2/down.php?path=downloads%2Fothers%2Feko%2FV24_TNG%2Fsvn17084/</p>
<p>我就在mini 的web gui 下刷的mega ，貌似也没有变砖，只是有时候不那么灵光了。</p>
<p>配置好openvpn 后，这里的vpn 不要push gateway ，就是路由的配置了。一般来说，有两种方式，</p>
<p>1，国内ip 走默认路由，国外ip 即使没有被认证，也走vpn 。这里需要维护一份国内ip 的列表，不过ipv4 都分完了，这个估计变动不大了。</p>
<p>2，只有被认证的ip 走vpn ，其它都走默认路由。这里需要维护一份被认证的ip 列表，这里的ip ，其实可以从gfwlist 里把那些ip 都抽取出来。</p>
<p>然后，使用以下两个命令，自己写个脚本吧。</p>
<p>ip route add $gfwip via $vpntunip table 163</p>
<p>ip rule add from 192.168.1.0/24 table 163</p>
<p>前者是加路由，并把规则写入 163 号表，后者是将所有 192.168.1.0/24 的ip 都应用163 号表的规则。（kernel 必须支持 CONFIG_IP_MULTIPLE_TABLES ，这里的DD-WRT 当然是带的，不过gentoo 的livecd 的kernel 是没有的！！）</p>
<p>DD-WRT 的包管理系统ipkg 弱爆了，建议安装ipkg-opt 。看这里：http://www.dd-wrt.com/wiki/index.php/Optware , 或者简单一句话：</p>
<p>wget http://www.3iii.dk/linux/optware/optware-install-ddwrt.sh -O &#8211; | tr -d &#8216;\r&#8217; &gt; /tmp/optware-install.sh</p>
<div id="_mcePaste">sh /tmp/optware-install.sh</div>
<p>本人初玩DD-WRT ，或许这些都有问题，日后遇到问题再修正了。</p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>update: 2011-09-24</p>
<p>对于我这个型号的路由。。。不能使用其自带的openvpn client ，貌似会有各种问题，例如不能保存配置，重启就回复了之前的配置，没有了5G 网络之类的。用ipkg-opt 装一个screen ，然后自己跑openvpn client 吧。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.helosa.org/2011/09/10/dd-wrt.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ubuntu 下的lvs tunnel real server 配置注意</title>
		<link>http://blog.helosa.org/2011/09/03/ubuntu-lvs-tunnel-rs.html</link>
		<comments>http://blog.helosa.org/2011/09/03/ubuntu-lvs-tunnel-rs.html#comments</comments>
		<pubDate>Fri, 02 Sep 2011 17:03:55 +0000</pubDate>
		<dc:creator>Chan Cham Chung</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[lvs]]></category>

		<guid isPermaLink="false">http://blog.helosa.org/?p=423</guid>
		<description><![CDATA[来个速记。 以前就因为一次内网调整，使用了一次lvs 的tunnel 模式，后来都没有配置过了，今天因为要配置外网的lvs ，再次弄了一下，才发现要注意一下了。 DR 模式下的rs 配置一般如下： /sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up echo &#8220;1&#8243; &#62;/proc/sys/net/ipv4/conf/lo/arp_ignore echo &#8220;2&#8243; &#62;/proc/sys/net/ipv4/conf/lo/arp_announce echo &#8220;1&#8243; &#62;/proc/sys/net/ipv4/conf/all/arp_ignore echo &#8220;2&#8243; &#62;/proc/sys/net/ipv4/conf/all/arp_announce tunnel 的话，可以改成这样： /sbin/ifconfig tunl0 $VIP broadcast $VIP netmask 255.255.255.255 up echo &#8220;1&#8243; &#62;/proc/sys/net/ipv4/conf/lo/arp_ignore echo &#8220;2&#8243; &#62;/proc/sys/net/ipv4/conf/lo/arp_announce echo &#8220;1&#8243; &#62;/proc/sys/net/ipv4/conf/all/arp_ignore echo &#8220;2&#8243; &#62;/proc/sys/net/ipv4/conf/all/arp_announce 直接执行的话，可能会出现以下错误（反正那个死人坑爹的ubuntu 出现了！！！还是得找机会换了它。。。） SIOCSIFADDR: No such [...]]]></description>
			<content:encoded><![CDATA[<p>来个速记。</p>
<p>以前就因为一次内网调整，使用了一次lvs 的tunnel 模式，后来都没有配置过了，今天因为要配置外网的lvs ，再次弄了一下，才发现要注意一下了。</p>
<p>DR 模式下的rs 配置一般如下：</p>
<div id="_mcePaste">/sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up</div>
<div id="_mcePaste"></div>
<div id="_mcePaste">echo &#8220;1&#8243; &gt;/proc/sys/net/ipv4/conf/lo/arp_ignore</div>
<div id="_mcePaste">echo &#8220;2&#8243; &gt;/proc/sys/net/ipv4/conf/lo/arp_announce</div>
<div id="_mcePaste">echo &#8220;1&#8243; &gt;/proc/sys/net/ipv4/conf/all/arp_ignore</div>
<div id="_mcePaste">echo &#8220;2&#8243; &gt;/proc/sys/net/ipv4/conf/all/arp_announce</div>
<div></div>
<div>tunnel 的话，可以改成这样：</div>
<div>
<div>/sbin/ifconfig tunl0 $VIP broadcast $VIP netmask 255.255.255.255 up</div>
<div></div>
<div>echo &#8220;1&#8243; &gt;/proc/sys/net/ipv4/conf/lo/arp_ignore</div>
<div>echo &#8220;2&#8243; &gt;/proc/sys/net/ipv4/conf/lo/arp_announce</div>
<div>echo &#8220;1&#8243; &gt;/proc/sys/net/ipv4/conf/all/arp_ignore</div>
<div>echo &#8220;2&#8243; &gt;/proc/sys/net/ipv4/conf/all/arp_announce</div>
</div>
<div></div>
<div>直接执行的话，可能会出现以下错误（反正那个死人坑爹的ubuntu 出现了！！！还是得找机会换了它。。。）</div>
<div>
<div>SIOCSIFADDR: No such device</div>
<div>tunl0: ERROR while getting interface flags: No such device</div>
<div>SIOCSIFNETMASK: No such device</div>
</div>
<div></div>
<div>竟然不能建立tun 设备！！</div>
<div></div>
<div>好吧，tun 设备作为module 了，没有编译进去内核@@</div>
<div></div>
<div>modprobe ipip 即可。</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.helosa.org/2011/09/03/ubuntu-lvs-tunnel-rs.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>haproxy 简单配置一个tcp 代理</title>
		<link>http://blog.helosa.org/2011/08/16/haproxy-tcp-proxy.html</link>
		<comments>http://blog.helosa.org/2011/08/16/haproxy-tcp-proxy.html#comments</comments>
		<pubDate>Tue, 16 Aug 2011 09:21:48 +0000</pubDate>
		<dc:creator>Chan Cham Chung</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[haproxy]]></category>

		<guid isPermaLink="false">http://blog.helosa.org/?p=418</guid>
		<description><![CDATA[haproxy 的tcp 应用，我实操过两次，一次是svn ，一次是openfile 。 最近一次就是openfire 了，因为忘了当时做svn tcp 代理时的配置，弄得焦头烂额的。。。mark 下，以免以后再次需要的时候忘记了。 global log 127.0.0.1  local3 notice ulimit-n 40960 maxconn 10240 user haproxy group haproxy nbproc  4 daemon quiet defaults log     global mode    tcp option tcplog listen mm bind 0.0.0.0:5222 balance roundrobin mode   tcp server test 192.168.50.148:5222 当时的需求很简单，就是把访问到本机的5222 端口的所有请求代理到 148 的5222 。用iptables 其实也可以，却发现那台机器是openvz [...]]]></description>
			<content:encoded><![CDATA[<p>haproxy 的tcp 应用，我实操过两次，一次是svn ，一次是openfile 。</p>
<p>最近一次就是openfire 了，因为忘了当时做svn tcp 代理时的配置，弄得焦头烂额的。。。mark 下，以免以后再次需要的时候忘记了。</p>
<div id="_mcePaste">global</div>
<div id="_mcePaste">log 127.0.0.1  local3 notice</div>
<div id="_mcePaste">ulimit-n 40960</div>
<div id="_mcePaste">maxconn 10240</div>
<div id="_mcePaste">user haproxy</div>
<div id="_mcePaste">group haproxy</div>
<div id="_mcePaste">nbproc  4</div>
<div id="_mcePaste">daemon</div>
<div id="_mcePaste">quiet</div>
<div id="_mcePaste">defaults</div>
<div id="_mcePaste">log     global</div>
<div id="_mcePaste">mode    tcp</div>
<div id="_mcePaste">option tcplog</div>
<div>listen mm</div>
<div id="_mcePaste">bind 0.0.0.0:5222</div>
<div id="_mcePaste">balance roundrobin</div>
<div id="_mcePaste">mode   tcp</div>
<div id="_mcePaste">server test 192.168.50.148:5222</div>
<div>当时的需求很简单，就是把访问到本机的5222 端口的所有请求代理到 148 的5222 。用iptables 其实也可以，却发现那台机器是openvz （BS 一下卖这个虚拟机给我朋友的某国内某大公司），用 iptables nat 的话，貌似要提权。</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.helosa.org/2011/08/16/haproxy-tcp-proxy.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>基于wp 的blog 遭遇一次自杀式攻击</title>
		<link>http://blog.helosa.org/2011/07/03/blog-wordpress.html</link>
		<comments>http://blog.helosa.org/2011/07/03/blog-wordpress.html#comments</comments>
		<pubDate>Sun, 03 Jul 2011 08:58:04 +0000</pubDate>
		<dc:creator>Chan Cham Chung</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://blog.helosa.org/?p=414</guid>
		<description><![CDATA[微博的名人确实有杀伤力啊，周五的时候，Kaifu 老师的微博转了一下公司的博客地址，结果访问一下子涌过来了。5000 的访问里有3000+ 是访问 / ，wp 的 / 是动态的啊，难怪撑不住，load1m 飙到50 ，20 个php-fpm 忙得不行。我把这类都归结于自杀式攻击，其实，很多时候，弄死我们的，都是自己啊。 解决也不是很难，静态化吧。curl 一个首页放到wp 的文件夹里，命名为 index.htm ，顺便改改 nginx 的配置： if ($uri = &#8220;/&#8221;){ rewrite &#8220;^/$&#8221; /index.htm break ; } 完事，load1m 迅速下降到1 以下了。 处理这个事情的时候我正在打火锅呢，其实还想做得更完美一点的，静态化的首页，也能定时更新一下，但发现没那么简单，就放弃了。就放下去吃火锅了，天杀的谁想出来在这么热的天时吃火锅的！！ 其实最好的做法就是，用 wp 的 wp super cache 插件。]]></description>
			<content:encoded><![CDATA[<p>微博的名人确实有杀伤力啊，周五的时候，Kaifu 老师的微博转了一下公司的博客地址，结果访问一下子涌过来了。5000 的访问里有3000+ 是访问 / ，wp 的 / 是动态的啊，难怪撑不住，load1m 飙到50 ，20 个php-fpm 忙得不行。我把这类都归结于自杀式攻击，其实，很多时候，弄死我们的，都是自己啊。</p>
<p>解决也不是很难，静态化吧。curl 一个首页放到wp 的文件夹里，命名为 index.htm ，顺便改改 nginx 的配置：</p>
<div id="_mcePaste">if ($uri = &#8220;/&#8221;){</div>
<div id="_mcePaste">rewrite &#8220;^/$&#8221; /index.htm break ;</div>
<div id="_mcePaste">}</div>
<div></div>
<div>完事，load1m 迅速下降到1 以下了。</div>
<p>处理这个事情的时候我正在打火锅呢，其实还想做得更完美一点的，静态化的首页，也能定时更新一下，但发现没那么简单，就放弃了。就放下去吃火锅了，天杀的谁想出来在这么热的天时吃火锅的！！</p>
<p>其实最好的做法就是，用 wp 的 wp super cache 插件。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.helosa.org/2011/07/03/blog-wordpress.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

