<?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>Case &#187; Uncategorized</title>
	<atom:link href="http://case.net.ru/category/uncategorized/feed/" rel="self" type="application/rss+xml" />
	<link>http://case.net.ru</link>
	<description>Just another technical weblog</description>
	<lastBuildDate>Sun, 29 Jan 2012 08:48:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Сжатие данных для стандартных протоколов</title>
		<link>http://case.net.ru/2011/01/23/zlib/</link>
		<comments>http://case.net.ru/2011/01/23/zlib/#comments</comments>
		<pubDate>Sun, 23 Jan 2011 11:17:01 +0000</pubDate>
		<dc:creator>Case</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://case.net.ru/?p=830</guid>
		<description><![CDATA[Что имеется: два сервера, соединенных сетью. Эти сервера обмениваются данными по стандартному протоколу, например SMTP/LMTP, сжатие в которых (в отличии от HTTP) не предусмотрено. Что случилось: сеть между машинами перестает справляться. Что сделали: прокинули между машинами тунель с помощью stunnel, который не только зашифровал наш трафик но еще и сжал его zlib&#8217;ом. Что получили: все [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Что имеется:</strong> два сервера, соединенных сетью. Эти сервера обмениваются данными по стандартному протоколу, например SMTP/LMTP, сжатие в которых (в отличии от HTTP) не предусмотрено.</p>
<p><strong>Что случилось:</strong> сеть между машинами перестает справляться.</p>
<p><strong>Что сделали:</strong> прокинули между машинами тунель с помощью stunnel, который не только зашифровал наш трафик но еще и сжал его zlib&#8217;ом.</p>
<p><strong>Что получили:</strong> все зависи от данных и протокола. В некоторых случаях &#8211; трафик уменьшается в 10 раз.</p>
]]></content:encoded>
			<wfw:commentRss>http://case.net.ru/2011/01/23/zlib/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Принудительная очистка системных кэшей &#8211; drop_caches</title>
		<link>http://case.net.ru/2011/01/21/drop-caches/</link>
		<comments>http://case.net.ru/2011/01/21/drop-caches/#comments</comments>
		<pubDate>Fri, 21 Jan 2011 19:29:47 +0000</pubDate>
		<dc:creator>Case</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://case.net.ru/?p=825</guid>
		<description><![CDATA[Начиная с Linux ядра 2.6.16 появилась возможность принудительной очистки системных кэшей: Чистим pagecache: echo 1 &#62; /proc/sys/vm/drop_caches Чистим dentrie и inode кэши: echo 2 &#62; /proc/sys/vm/drop_caches Чистим pagecache, dentrie и inode кэши: echo 3 &#62; /proc/sys/vm/drop_caches После выполнения операции необходимо запустить команду sync http://linux-mm.org/Drop_Caches http://www.opennet.ru/tips/info/1455.shtml Оригинал: http://linsovet.com/content/linux-flush-system-caches]]></description>
			<content:encoded><![CDATA[<p>Начиная с Linux ядра 2.6.16 появилась возможность принудительной очистки системных кэшей:</p>
<p>Чистим pagecache:</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: #000000;">1</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>vm<span style="color: #000000; font-weight: bold;">/</span>drop_caches</pre></div></div>

<p>Чистим dentrie и inode кэши:</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: #000000;">2</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>vm<span style="color: #000000; font-weight: bold;">/</span>drop_caches</pre></div></div>

<p>Чистим pagecache, dentrie и inode кэши:</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: #000000;">3</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>vm<span style="color: #000000; font-weight: bold;">/</span>drop_caches</pre></div></div>

<p>После выполнения операции необходимо запустить команду sync</p>
<p><a href="http://linux-mm.org/Drop_Caches">http://linux-mm.org/Drop_Caches</a><br />
<a href="http://www.opennet.ru/tips/info/1455.shtml">http://www.opennet.ru/tips/info/1455.shtml</a></p>
<p>Оригинал: <a href="http://linsovet.com/content/linux-flush-system-caches">http://linsovet.com/content/linux-flush-system-caches</a></p>
]]></content:encoded>
			<wfw:commentRss>http://case.net.ru/2011/01/21/drop-caches/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Keyspace</title>
		<link>http://case.net.ru/2011/01/16/keyspace/</link>
		<comments>http://case.net.ru/2011/01/16/keyspace/#comments</comments>
		<pubDate>Sun, 16 Jan 2011 15:11:23 +0000</pubDate>
		<dc:creator>Case</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[keyspace]]></category>

		<guid isPermaLink="false">http://case.net.ru/?p=806</guid>
		<description><![CDATA[About Keyspace is a replicated key-value database, a product of Scalien, available at http://scalien.com. Keyspace is set apart from other key-value database because it uses so-called consistent replication, which means that all nodes see the database going through the same states. In other words, no split-brain scenario can occur, where different nodes see different versions [...]]]></description>
			<content:encoded><![CDATA[<p><strong>About</strong><br />
Keyspace is a replicated key-value database, a product of Scalien, available at <a href="http://scalien.com">http://scalien.com</a>.</p>
<p>Keyspace is set apart from other key-value database because it uses so-called consistent replication, which means that all nodes see the database going through the same states. In other words, no split-brain scenario can occur, where different nodes see different versions of the database.</p>
<p><strong>Установка</strong><br />
Требует Berkeley DB &gt;= 4.6.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>scalien.com<span style="color: #000000; font-weight: bold;">/</span>releases<span style="color: #000000; font-weight: bold;">/</span>keyspace<span style="color: #000000; font-weight: bold;">/</span>keyspace-1.9.0.tgz
$ <span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf keyspace-1.9.0.tgz
$ <span style="color: #7a0874; font-weight: bold;">cd</span> keyspace-1.9.0
$ <span style="color: #c20cb9; font-weight: bold;">make</span></pre></div></div>

<p><strong>Генерация конфига</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> keyspace-1.9.0
$ keyspace-config
&nbsp;
Спросит несколько вопросов, а потом нарисует схему репликации.
<span style="color: #000000; font-weight: bold;">&lt;</span>pre <span style="color: #007800;">lang</span>=<span style="color: #ff0000;">&quot;bash&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>client<span style="color: #7a0874; font-weight: bold;">&#40;</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span>                         client<span style="color: #7a0874; font-weight: bold;">&#40;</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span>                         client<span style="color: #7a0874; font-weight: bold;">&#40;</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
^                                 ^                                 ^
<span style="color: #000000; font-weight: bold;">|</span>                                 <span style="color: #000000; font-weight: bold;">|</span>                                 <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000; font-weight: bold;">|</span>            node <span style="color: #000000;">0</span>               <span style="color: #000000; font-weight: bold;">|</span>            node <span style="color: #000000;">1</span>               <span style="color: #000000; font-weight: bold;">|</span>            node <span style="color: #000000;">2</span>
<span style="color: #000000; font-weight: bold;">|</span>     +-------------------+       <span style="color: #000000; font-weight: bold;">|</span>     +-------------------+       <span style="color: #000000; font-weight: bold;">|</span>     +-------------------+
<span style="color: #000000; font-weight: bold;">|</span>     +     127.0.0.1     <span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">|</span>     +     127.0.0.1     <span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">|</span>     +     127.0.0.1     <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000; font-weight: bold;">|</span>     +  <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>keyspace<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span>  <span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">|</span>     +  <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>keyspace<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1</span>  <span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">|</span>     +  <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>keyspace<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">2</span>  <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000;">7080</span> --+ Keyspace          <span style="color: #000000; font-weight: bold;">|</span>      <span style="color: #000000;">7081</span> --+ Keyspace          <span style="color: #000000; font-weight: bold;">|</span>      <span style="color: #000000;">7082</span> --+ Keyspace          <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000;">8080</span> --+ HTTP              <span style="color: #000000; font-weight: bold;">|</span>      <span style="color: #000000;">8081</span> --+ HTTP              <span style="color: #000000; font-weight: bold;">|</span>      <span style="color: #000000;">8082</span> --+ HTTP              <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>             <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>             <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>             <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>             <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>             <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>             <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000;">10000</span> --+ Paxos             <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000;">10010</span> --+ Paxos             <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000;">10020</span> --+ Paxos             <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000;">10001</span> --+ PaxosLease        <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000;">10011</span> --+ PaxosLease        <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000;">10021</span> --+ PaxosLease        <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000;">10002</span> --+ Catchup           <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000;">10012</span> --+ Catchup           <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000;">10022</span> --+ Catchup           <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>       <span style="color: #000000; font-weight: bold;">|</span>     <span style="color: #000000; font-weight: bold;">|</span>                   <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000; font-weight: bold;">|</span>     +-------------------+       <span style="color: #000000; font-weight: bold;">|</span>     +-------------------+       <span style="color: #000000; font-weight: bold;">|</span>     +-------------------+
<span style="color: #000000; font-weight: bold;">|</span>                                 <span style="color: #000000; font-weight: bold;">|</span>                                 <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000; font-weight: bold;">|</span>                                 <span style="color: #000000; font-weight: bold;">|</span>                                 <span style="color: #000000; font-weight: bold;">|</span>
<span style="color: #000000; font-weight: bold;">|</span>                                 <span style="color: #000000; font-weight: bold;">|</span>                                 <span style="color: #000000; font-weight: bold;">|</span>
----+-------- <span style="color: #7a0874; font-weight: bold;">&#91;</span>replication<span style="color: #7a0874; font-weight: bold;">&#93;</span> ----------+-------- <span style="color: #7a0874; font-weight: bold;">&#91;</span>replication<span style="color: #7a0874; font-weight: bold;">&#93;</span> ----------+-------- <span style="color: #7a0874; font-weight: bold;">&#91;</span>replication<span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #660033;">------</span></pre></div></div>

<p><strong>Запуск нод</strong></p>
<p>Создаем каталоги для баз:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>keyspace<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>0..2<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>Запускаем демонов:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ .<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>keyspaced keyspace.0.conf <span style="color: #000000; font-weight: bold;">&amp;</span>amp;
$ .<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>keyspaced keyspace.1.conf <span style="color: #000000; font-weight: bold;">&amp;</span>amp;
$ .<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>keyspaced keyspace.2.conf <span style="color: #000000; font-weight: bold;">&amp;</span>amp;</pre></div></div>

<p><strong>База данных</strong></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>keyspace<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>keyspace<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">/</span>
<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>keyspace<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">/</span>log.0000000001
<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>keyspace<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0</span><span style="color: #000000; font-weight: bold;">/</span>keyspace</pre></div></div>

<p><strong>HTTP интерфейс</strong></p>
<p>Вывод инфомарции о ноде:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ curl http:<span style="color: #000000; font-weight: bold;">//</span>localhost:<span style="color: #000000;">8080</span>
Keyspace v1.9.0
&nbsp;
Running <span style="color: #000000; font-weight: bold;">in</span> replicated mode with <span style="color: #000000;">3</span> nodes
&nbsp;
I am node <span style="color: #000000;">0</span>
&nbsp;
Master is node <span style="color: #000000;">1</span>
&nbsp;
I am <span style="color: #000000; font-weight: bold;">in</span> replication round <span style="color: #000000;">2</span>
&nbsp;
Last replication round was <span style="color: #000000;">32</span> bytes, took <span style="color: #000000;">497264</span> msec, thruput was <span style="color: #000000;">1</span> KB<span style="color: #000000; font-weight: bold;">/</span>sec</pre></div></div>

<p>Установка значения (на мастера)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ curl <span style="color: #ff0000;">'http://localhost:8081/set?key=testkey&amp;amp;value=testvalue'</span>
OK</pre></div></div>

<p>Чтение значения (с мастера)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ curl <span style="color: #ff0000;">'http://localhost:8081/get?key=testkey'</span>
testvalue</pre></div></div>

<p>Чтение значения (с слейва)</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ curl <span style="color: #ff0000;">'http://localhost:8080/dirtyget?key=testkey'</span>
testvalue
$ curl <span style="color: #ff0000;">'http://localhost:8082/dirtyget?key=testkey'</span>
testvalue</pre></div></div>

<p><strong>Репликация</strong></p>
<p>Писать можно только в мастер<br />
Читать методом get можно только с мастера<br />
Читать методом dirtyget можно со всех</p>
<p>Если остается одна нода из трех &#8211; с неё можно только читать, но мастером она не становится</p>
<p>Каждая нода пишет номер цикла репликации, сравнивая которые можно судить о синхронизации нод.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">I am <span style="color: #000000; font-weight: bold;">in</span> replication round <span style="color: #000000;">29</span></pre></div></div>

<p>Интерфейс на Си например сам ищет мастера, для http это надо делать самостоятельно.</p>
<p><strong>Производительность</strong></p>
<p>Скорость записи с sync после каждой операции: 30-35 операций записи в секунду</p>
<p>Проведенный тест db4 подтвердил низкую скорость записи. Псевдокод теста:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">dba_open<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">for</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$i</span>=<span style="color: #000000;">0</span>;<span style="color: #007800;">$i</span><span style="color: #000000; font-weight: bold;">&amp;</span>lt;=<span style="color: #000000;">100</span>;<span style="color: #007800;">$i</span>++<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
dba_replace<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
dba_sync<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
db_close<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>Отключение sync после записи приводит к увеличение скорости записи и возможности потери данных при востановлении БД.</p>
<p><strong>Ошибки</strong></p>
<p>При выходе демон подвис и ушел в бесконечный цикл. Strace ничего не показал. ltrace показал:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">memcpy<span style="color: #7a0874; font-weight: bold;">&#40;</span>0x7fffebd290ef, <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>, <span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>                                                                  = 0x7fffebd290ef vsnprintf<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span>, <span style="color: #000000;">4406034</span>, <span style="color: #ff0000;">&quot;&quot;</span>, 0x1f<span style="color: #7a0874; font-weight: bold;">&#41;</span>                                                                 = <span style="color: #000000;">47</span> memcpy<span style="color: #7a0874; font-weight: bold;">&#40;</span>0x7fffebd290ef, <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>, <span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>                                                                  = 0x7fffebd290ef vsnprintf<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">&quot;&quot;</span>, <span style="color: #000000;">4406034</span>, <span style="color: #ff0000;">&quot;&quot;</span>, 0x1f<span style="color: #7a0874; font-weight: bold;">&#41;</span>                                                                 = <span style="color: #000000;">47</span> memcpy<span style="color: #7a0874; font-weight: bold;">&#40;</span>0x7fffebd290ef, <span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>, <span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>                                                                  = 0x7fffebd290ef</pre></div></div>

<p>Непонятки с базой данных:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ .<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>keyspaced keyspace.0.conf  Encountered zero length records <span style="color: #000000; font-weight: bold;">while</span> traversing backwards PANIC: DB_RUNRECOVERY: Fatal error, run database recovery PANIC: DB_RUNRECOVERY: Fatal error, run database recovery process-private: unable to <span style="color: #c20cb9; font-weight: bold;">find</span> environment Cannot initialize database<span style="color: #000000; font-weight: bold;">!</span></pre></div></div>

<p> Опять ошибки с базой данных:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">DB_LOGC-<span style="color: #000000; font-weight: bold;">&amp;</span>gt;get: LSN: <span style="color: #000000;">39</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">9324792</span>: short <span style="color: #c20cb9; font-weight: bold;">read</span>
log <span style="color: #c20cb9; font-weight: bold;">file</span> auto-remove: Input<span style="color: #000000; font-weight: bold;">/</span>output error</pre></div></div>

<p>И еще:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">PANIC: fatal region error detected; run recovery</pre></div></div>

<p>И еще&#8230;:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ .<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>keyspaced keyspace.1.conf
Ignoring log <span style="color: #c20cb9; font-weight: bold;">file</span>: <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>shm<span style="color: #000000; font-weight: bold;">/</span>keyspace<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">/</span>log.0000000019: magic number <span style="color: #000000;">29</span>, not <span style="color: #000000;">40988</span>
Invalid log <span style="color: #c20cb9; font-weight: bold;">file</span>: log.0000000019: Invalid argument
PANIC: Invalid argument
process-private: unable to <span style="color: #c20cb9; font-weight: bold;">find</span> environment
Cannot initialize database<span style="color: #000000; font-weight: bold;">!</span></pre></div></div>

<p><strong>Вывод</strong></p>
<ul>
<li>Отсутствие мастера до 7 секунд (база пребыват в режиме read only)</li>
<li>Много багов, продукт еще сырой</li>
<li>Быстрая, работающая репликация</li>
<li>Хорошая документация</li>
<li>Множество готовых интерфейсов, включая HTTP</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://case.net.ru/2011/01/16/keyspace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tor, Polipo</title>
		<link>http://case.net.ru/2011/01/15/tor-polipo/</link>
		<comments>http://case.net.ru/2011/01/15/tor-polipo/#comments</comments>
		<pubDate>Sat, 15 Jan 2011 13:43:04 +0000</pubDate>
		<dc:creator>Case</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[polipo]]></category>
		<category><![CDATA[tor]]></category>

		<guid isPermaLink="false">http://case.net.ru/?p=796</guid>
		<description><![CDATA[Задача: научить браузер выходить в Интернет через Tor. Tor is free software and an open network that helps you defend against a form of network surveillance that threatens personal freedom and privacy, confidential business activities and relationships, and state security known as traffic analysis. http://www.torproject.org/ Установка Tor: $ wget http://www.torproject.org/dist/tor-0.2.1.28.tar.gz $ tar zxvf tor-0.2.1.28.tar.gz $ [...]]]></description>
			<content:encoded><![CDATA[<p>Задача: научить браузер выходить в Интернет через Tor.</p>
<p>Tor is free software and an open network that helps you defend against a form of network surveillance that threatens personal freedom and privacy, confidential business activities and relationships, and state security known as traffic analysis.</p>
<p><a href="http://www.torproject.org/">http://www.torproject.org/</a></p>
<p>Установка Tor:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$  <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>www.torproject.org<span style="color: #000000; font-weight: bold;">/</span>dist<span style="color: #000000; font-weight: bold;">/</span>tor-0.2.1.28.tar.gz
$ <span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf tor-0.2.1.28.tar.gz 
$ <span style="color: #7a0874; font-weight: bold;">cd</span> tor-0.2.1.28
$ .<span style="color: #000000; font-weight: bold;">/</span>configure 
$ <span style="color: #c20cb9; font-weight: bold;">make</span></pre></div></div>

<p>Запускаем:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ .<span style="color: #000000; font-weight: bold;">/</span>src<span style="color: #000000; font-weight: bold;">/</span>or<span style="color: #000000; font-weight: bold;">/</span>tor</pre></div></div>

<p>Проверяем netstat&#8217;ом что запустилось:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">tcp        <span style="color: #000000;">0</span>      <span style="color: #000000;">0</span> 127.0.0.1:<span style="color: #000000;">9050</span>              0.0.0.0:<span style="color: #000000; font-weight: bold;">*</span>                   LISTEN      <span style="color: #000000;">6212</span><span style="color: #000000; font-weight: bold;">/</span>tor</pre></div></div>

<p>Теперь на порт 9050 у нас висит sock5 прокси, но т.к. Opera не умеет socks5, поставим еще одну софтинку &#8211; polipo:</p>
<p>Polipo is a lightweight caching web proxy that was designed as a personal cache. It is able to cache incomplete objects and will complete them using range requests. It will use HTTP/1.1 pipelining if supported by the remote<br />
server.</p>
<p>Установка:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum install polipo</span></pre></div></div>

<p>Настройка производится в файле /etc/polipo/config:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">daemonise = <span style="color: #c20cb9; font-weight: bold;">true</span>
pidFile = <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>polipo<span style="color: #000000; font-weight: bold;">/</span>polipo.pid
socksParentProxy = <span style="color: #ff0000;">&quot;localhost:9050&quot;</span>
socksProxyType = socks5</pre></div></div>

<p>Запускаем:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># /etc/init.d/polipo start</span></pre></div></div>

<p>Проверяем:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># netstat -nap|fgrep polipo</span>
tcp        <span style="color: #000000;">0</span>      <span style="color: #000000;">0</span> 127.0.0.1:<span style="color: #000000;">8123</span>              0.0.0.0:<span style="color: #000000; font-weight: bold;">*</span>                   LISTEN      <span style="color: #000000;">6333</span><span style="color: #000000; font-weight: bold;">/</span>polipo</pre></div></div>

<p>Осталось указать браузеру использовать HTTP-proxy по адресу 127.0.0.1:8123.</p>
<p>Проверяем, что вышли в сеть через Tor на странице: <a href="https://check.torproject.org/">https://check.torproject.org/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://case.net.ru/2011/01/15/tor-polipo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>KVM (Kernel Based Virtual Machine)</title>
		<link>http://case.net.ru/2011/01/13/kernel-based-virtual-machine/</link>
		<comments>http://case.net.ru/2011/01/13/kernel-based-virtual-machine/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 16:26:30 +0000</pubDate>
		<dc:creator>Case</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[kvm]]></category>

		<guid isPermaLink="false">http://case.net.ru/?p=793</guid>
		<description><![CDATA[KVM (for Kernel-based Virtual Machine) is a full virtualization solution for Linux on x86 hardware containing virtualization extensions (Intel VT or AMD-V). It consists of a loadable kernel module, kvm.ko, that provides the core virtualization infrastructure and a processor specific module, kvm-intel.ko or kvm-amd.ko. KVM also requires a modified QEMU although work is underway to [...]]]></description>
			<content:encoded><![CDATA[<p>KVM (for Kernel-based Virtual Machine) is a full virtualization solution for Linux on x86 hardware containing virtualization extensions (Intel VT or AMD-V). It consists of a loadable kernel module, kvm.ko, that provides the core virtualization infrastructure and a processor specific module, kvm-intel.ko or kvm-amd.ko. KVM also requires a modified QEMU although work is underway to get the required changes upstream. </p>
<p>Using KVM, one can run multiple virtual machines running unmodified Linux or Windows images. Each virtual machine has private virtualized hardware: a network card, disk, graphics adapter, etc. </p>
<p>The kernel component of KVM is included in mainline Linux, as of 2.6.20. </p>
<p>KVM is open source software.</p>
<p>Проверяем, поддерживает ли процессор аппаратную виртуализацию:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">grep</span> vmx <span style="color: #000000; font-weight: bold;">/</span>proc<span style="color: #000000; font-weight: bold;">/</span>cpuinfo</pre></div></div>

<p>Устанавливаем пакеты:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum install bridge-utils qemu-kvm virt-manager libvirt</span></pre></div></div>

<p>Проверяем что модули подгрузились:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># lsmod | fgrep kvm</span>
kvm_intel              <span style="color: #000000;">45674</span>  <span style="color: #000000;">0</span> 
kvm                   <span style="color: #000000;">291811</span>  <span style="color: #000000;">1</span> kvm_intel</pre></div></div>

<p>Запускаем демона:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># /etc/init.d/libvirtd start</span></pre></div></div>

<p>Поднимаем br0 интерфейс:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># ifconfig eth0 0.0.0.0</span>
<span style="color: #666666; font-style: italic;"># brctl addbr br0</span>
<span style="color: #666666; font-style: italic;"># brctl addif br0 eth0</span>
<span style="color: #666666; font-style: italic;"># ifconfig br0 192.168.1.200/24</span></pre></div></div>

<p><a href="http://hrafn.me/2010/01/kak-nastroit-bridzh-dlya-kvm-na-red-hat-enterprise-linux-5-4/">Как настроить бридж для KVM на Red Hat Enterprise Linux 5.4</a></p>
<p>Не забыть включить форвардинг пакетов:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">sysctl net.ipv4.ip_forward=<span style="color: #000000;">1</span></pre></div></div>

<p>И поправить правила iptables:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ iptables <span style="color: #660033;">-A</span> FORWARD <span style="color: #660033;">-m</span> physdev <span style="color: #660033;">--physdev-is-bridged</span> <span style="color: #660033;">-j</span> ACCEPT 
$ iptables <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> PREROUTING <span style="color: #660033;">-d</span> IP<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">32</span> <span style="color: #660033;">-p</span> tcp <span style="color: #660033;">-m</span> tcp <span style="color: #660033;">--dport</span> <span style="color: #000000;">222</span> <span style="color: #660033;">-j</span> DNAT <span style="color: #660033;">--to-destination</span> 192.168.122.2:<span style="color: #000000;">22</span>
$ iptables <span style="color: #660033;">-t</span> nat <span style="color: #660033;">-A</span> POSTROUTING <span style="color: #660033;">-s</span> 192.168.122.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">24</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-d</span> 192.168.122.0<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">24</span> <span style="color: #660033;">-j</span> SNAT <span style="color: #660033;">--to-source</span> IP</pre></div></div>

<p>Работаем:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># virt-manager</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://case.net.ru/2011/01/13/kernel-based-virtual-machine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IPVS</title>
		<link>http://case.net.ru/2011/01/13/ipvs/</link>
		<comments>http://case.net.ru/2011/01/13/ipvs/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 14:47:37 +0000</pubDate>
		<dc:creator>Case</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ipvs]]></category>

		<guid isPermaLink="false">http://case.net.ru/?p=791</guid>
		<description><![CDATA[IPVS (IP Virtual Server) implements transport-layer load balancing inside the Linux kernel, so called Layer-4 switching. IPVS running on a host acts as a load balancer at the front of a cluster of real servers, it can direct requests for TCP/UDP based services to the real servers, and makes services of the real servers to [...]]]></description>
			<content:encoded><![CDATA[<p>IPVS (IP Virtual Server) implements transport-layer load balancing inside the Linux kernel, so called Layer-4 switching. IPVS running on a host acts as a load balancer at the front of a cluster of real servers, it can direct requests for TCP/UDP based services to the real servers, and makes services of the real servers to appear as a virtual service on a single IP address.</p>
]]></content:encoded>
			<wfw:commentRss>http://case.net.ru/2011/01/13/ipvs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Keepalived</title>
		<link>http://case.net.ru/2011/01/13/keepalived/</link>
		<comments>http://case.net.ru/2011/01/13/keepalived/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 14:46:59 +0000</pubDate>
		<dc:creator>Case</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[keepalived]]></category>

		<guid isPermaLink="false">http://case.net.ru/?p=789</guid>
		<description><![CDATA[keepalived is used for monitoring real servers within a Linux Virtual Server (LVS) cluster. keepalived can be configured to remove real servers from the cluster pool if it stops responding, as well as send a notification email to make the admin aware of the service failure. In addition, keepalived implements an independent Virtual Router Redundancy [...]]]></description>
			<content:encoded><![CDATA[<p>keepalived is used for monitoring real servers within a Linux Virtual Server (LVS) cluster. keepalived can be configured to remove real servers from the cluster pool if it stops responding, as well as send a notification email to make the admin aware of the service failure. </p>
<p>In addition, keepalived implements an independent Virtual Router Redundancy Protocol (VRRPv2; see rfc2338 for additional info) framework for director failover.</p>
]]></content:encoded>
			<wfw:commentRss>http://case.net.ru/2011/01/13/keepalived/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HAProxy</title>
		<link>http://case.net.ru/2011/01/13/haproxy/</link>
		<comments>http://case.net.ru/2011/01/13/haproxy/#comments</comments>
		<pubDate>Thu, 13 Jan 2011 12:58:37 +0000</pubDate>
		<dc:creator>Case</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[haproxy]]></category>

		<guid isPermaLink="false">http://case.net.ru/?p=786</guid>
		<description><![CDATA[HAProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications. It is particularly suited for web sites crawling under very high loads while needing persistence or Layer7 processing. Supporting tens of thousands of connections is clearly realistic with todays hardware. http://haproxy.1wt.eu/]]></description>
			<content:encoded><![CDATA[<p>HAProxy is a free, very fast and reliable solution offering high availability, load balancing, and proxying for TCP and HTTP-based applications. It is particularly suited for web sites crawling under very high loads while needing persistence or Layer7 processing. Supporting tens of thousands of connections is clearly realistic with todays hardware.</p>
<p><a href="http://haproxy.1wt.eu/">http://haproxy.1wt.eu/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://case.net.ru/2011/01/13/haproxy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ngx_http_secure_download</title>
		<link>http://case.net.ru/2011/01/06/ngx_http_secure_download/</link>
		<comments>http://case.net.ru/2011/01/06/ngx_http_secure_download/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 13:40:16 +0000</pubDate>
		<dc:creator>Case</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://case.net.ru/?p=781</guid>
		<description><![CDATA[Задача: обеспечить возможность скачивать контент с сервера. только посетителям вашего сайта. Реализация: использование специальных ссылок, которые содержат ключ и дату протухания. Модуль к nginx &#8211; ngx_http_secure_download Сборка nginx: $ cd nginx-0.8.53 $ ./configure --add-module=../ngx_http_secure_download/ Конфиг nginx: location /somefolder &#123; secure_download on; secure_download_secret IAmSalt$remote_addr; secure_download_path_mode file; &#160; if &#40;$secure_download = &#34;-1&#34;&#41; &#123; rewrite /expired.html break; &#125; [...]]]></description>
			<content:encoded><![CDATA[<p>Задача: обеспечить возможность скачивать контент с сервера. только посетителям вашего сайта.</p>
<p>Реализация: использование специальных ссылок, которые содержат ключ и дату протухания.</p>
<p>Модуль к nginx &#8211; <a href="https://github.com/replay/ngx_http_secure_download">ngx_http_secure_download</a></p>
<p>Сборка nginx:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> nginx-0.8.53
$ .<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #660033;">--add-module</span>=..<span style="color: #000000; font-weight: bold;">/</span>ngx_http_secure_download<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Конфиг nginx:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">        location <span style="color: #000000; font-weight: bold;">/</span>somefolder <span style="color: #7a0874; font-weight: bold;">&#123;</span>
            secure_download on;
            secure_download_secret IAmSalt<span style="color: #007800;">$remote_addr</span>;
            secure_download_path_mode <span style="color: #c20cb9; font-weight: bold;">file</span>;
&nbsp;
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$secure_download</span> = <span style="color: #ff0000;">&quot;-1&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
                rewrite <span style="color: #000000; font-weight: bold;">/</span>expired.html <span style="color: #7a0874; font-weight: bold;">break</span>;
            <span style="color: #7a0874; font-weight: bold;">&#125;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$secure_download</span> = <span style="color: #ff0000;">&quot;-2&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
                rewrite <span style="color: #000000; font-weight: bold;">/</span>bad_hash.html <span style="color: #7a0874; font-weight: bold;">break</span>;
            <span style="color: #7a0874; font-weight: bold;">&#125;</span>
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$secure_download</span> = <span style="color: #ff0000;">&quot;-3&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>
                <span style="color: #7a0874; font-weight: bold;">return</span> <span style="color: #000000;">500</span>;
            <span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
            rewrite ^<span style="color: #7a0874; font-weight: bold;">&#40;</span>.<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">0</span>-9a-zA-Z<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">*/</span><span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">0</span>-9a-zA-Z<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">*</span>$ $<span style="color: #000000;">1</span> <span style="color: #7a0874; font-weight: bold;">break</span>; <span style="color: #000000; font-weight: bold;">//</span> crop all the <span style="color: #000000; font-weight: bold;">/</span>hash<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000; font-weight: bold;">time</span> stuff off the url
        <span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>

<p>Генерация ссылки средствами php:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> secure_url<span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$ts</span> <span style="color: #339933;">=</span> <span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">3600</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$ts_in_hex</span> <span style="color: #339933;">=</span> <span style="color: #990000;">dechex</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$ts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$secret</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'IAmSalt'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'REMOTE_ADDR'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$hash</span> <span style="color: #339933;">=</span> <span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$secret</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$ts_in_hex</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span>  <span style="color: #000088;">$url</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$hash</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$ts_in_hex</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Использованы материалы статьи: <a href="http://habrahabr.ru/blogs/video/111249/">Видеохостинг своими руками</a></p>
<p>PS: Так же, есть модуль <a href="http://sysoev.ru/nginx/docs/http/ngx_http_secure_link_module.html">ngx_http_secure_link_module</a>, но у него все ссылки перманентные.</p>
]]></content:encoded>
			<wfw:commentRss>http://case.net.ru/2011/01/06/ngx_http_secure_download/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Router Advertisement Daemon (radvd)</title>
		<link>http://case.net.ru/2011/01/05/router-advertisement-daemon-radvd/</link>
		<comments>http://case.net.ru/2011/01/05/router-advertisement-daemon-radvd/#comments</comments>
		<pubDate>Wed, 05 Jan 2011 12:31:35 +0000</pubDate>
		<dc:creator>Case</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ipv6]]></category>
		<category><![CDATA[radvd]]></category>

		<guid isPermaLink="false">http://case.net.ru/?p=779</guid>
		<description><![CDATA[Собственно, если подключать IPv6 через tunnelbroker.net, то он выделяет по умолчанию две сети /64. Одну из которых мы задействуем для раздачи IPv6 адресов внутри сети. Раздавать адреса будем через протокол Stateless Address Autoconfiguration. Устанавливаем демон radvd и настраиваем его тут /etc/radvd.conf. В настройки надо как минимум прописать интерфейс внутренней сети и префикс ipv6 сети, который [...]]]></description>
			<content:encoded><![CDATA[<p>Собственно, если подключать IPv6 через tunnelbroker.net, то он выделяет по умолчанию две сети /64. Одну из которых мы задействуем для раздачи IPv6 адресов внутри сети.</p>
<p>Раздавать адреса будем через протокол Stateless Address Autoconfiguration.</p>
<p>Устанавливаем демон radvd и настраиваем его тут /etc/radvd.conf. В настройки надо как минимум прописать интерфейс внутренней сети и префикс ipv6 сети, который будем раздавать.</p>
<p>Сеть должна быть размером /64.</p>
<p>Конфиг:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">interface eth0
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
	AdvSendAdvert on;
	MinRtrAdvInterval <span style="color: #000000;">30</span>;
	MaxRtrAdvInterval <span style="color: #000000;">100</span>;
	prefix <span style="color: #000000;">2001</span>:<span style="color: #000000;">719</span>:1f09:f4::<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">64</span>
	<span style="color: #7a0874; font-weight: bold;">&#123;</span>
		AdvOnLink on;
		AdvAutonomous on;
		AdvRouterAddr on;
	<span style="color: #7a0874; font-weight: bold;">&#125;</span>;
&nbsp;
<span style="color: #7a0874; font-weight: bold;">&#125;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://case.net.ru/2011/01/05/router-advertisement-daemon-radvd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
