<?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>dan.thoughts &#187; Linux</title>
	<atom:link href="http://blog.sosedoff.com/category/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sosedoff.com</link>
	<description>Web-development, PHP, Ruby, Sinatra, Merb, Rails, MySQL, SQLite, Web Services.</description>
	<lastBuildDate>Sat, 03 Jul 2010 05:46:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Snippet: Cleanup your Git repository</title>
		<link>http://blog.sosedoff.com/2010/06/15/snippet-cleanup-your-git-repository/</link>
		<comments>http://blog.sosedoff.com/2010/06/15/snippet-cleanup-your-git-repository/#comments</comments>
		<pubDate>Tue, 15 Jun 2010 06:35:56 +0000</pubDate>
		<dc:creator>Dan Sosedoff</dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[cleanup]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[repository]]></category>

		<guid isPermaLink="false">http://blog.sosedoff.com/?p=240</guid>
		<description><![CDATA[Snippet (found on net) for removing files from repository that are no longer present under your project.

$ git rm $&#40;git ls-files -d&#41;

For best use add it to bash alias file: ~/.bashrc or ~/.bash-aliases (under ubuntu):

alias gitclean='git rm $(git ls-files -d)'

]]></description>
			<content:encoded><![CDATA[<p>Snippet (found on net) for removing files from repository that are no longer present under your project.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ git <span style="color: #c20cb9; font-weight: bold;">rm</span> $<span style="color: #7a0874; font-weight: bold;">&#40;</span>git ls-files -d<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

<p>For best use add it to bash alias file: ~/.bashrc or ~/.bash-aliases (under ubuntu):</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">alias</span> <span style="color: #007800;">gitclean</span>=<span style="color: #ff0000;">'git rm $(git ls-files -d)'</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.sosedoff.com/2010/06/15/snippet-cleanup-your-git-repository/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handy HTTP requests with Curb and Ruby</title>
		<link>http://blog.sosedoff.com/2010/06/13/handy-http-requests-with-curb-and-ruby/</link>
		<comments>http://blog.sosedoff.com/2010/06/13/handy-http-requests-with-curb-and-ruby/#comments</comments>
		<pubDate>Sun, 13 Jun 2010 05:43:49 +0000</pubDate>
		<dc:creator>Dan Sosedoff</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Web Services]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[crawlers]]></category>
		<category><![CDATA[curb]]></category>
		<category><![CDATA[curl]]></category>
		<category><![CDATA[http]]></category>
		<category><![CDATA[networking]]></category>
		<category><![CDATA[requests]]></category>

		<guid isPermaLink="false">http://blog.sosedoff.com/?p=232</guid>
		<description><![CDATA[While working on one of the projects, i tried to find multi-purpose HTTP request class that can use different network interfaces/ip addresses with retry option (if connection slow or server not responding for some reason). 
Here is a small class wrapper build on top of Ruby Curb implemented as a module:

module ApiRequest
  USER_AGENTS = [...]]]></description>
			<content:encoded><![CDATA[<p>While working on one of the projects, i tried to find multi-purpose HTTP request class that can use different network interfaces/ip addresses with retry option (if connection slow or server not responding for some reason). </p>
<p>Here is a small class wrapper build on top of Ruby <a href="http://curb.rubyforge.org/">Curb</a> implemented as a module:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">module</span> ApiRequest
  USER_AGENTS = <span style="color:#006600; font-weight:bold;">&#91;</span>
    <span style="color:#996600;">'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3'</span>,
    <span style="color:#996600;">'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)'</span>,
    <span style="color:#996600;">'Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3'</span>,
    <span style="color:#996600;">'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.70 Safari/533.4'</span>,
    <span style="color:#996600;">'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.2) Gecko/20100323 Namoroka/3.6.2'</span>,
    <span style="color:#996600;">'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.9) Gecko/20100401 Ubuntu/9.10 (karmic) Firefox/3.5.9'</span>
  <span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
  CONNECTION_TIMEOUT = <span style="color:#006666;">10</span>
&nbsp;
  @@interfaces = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># get random user-agent string for usage</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> random_agent
    USER_AGENTS<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC0066; font-weight:bold;">rand</span><span style="color:#006600; font-weight:bold;">&#40;</span>USER_AGENTS.<span style="color:#9900CC;">size</span><span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># get random IP/network interface specified in @@interfaces</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> random_interface
    size = @@interfaces.<span style="color:#9900CC;">size</span>
    size <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">0</span> ? @@interfaces<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#CC0066; font-weight:bold;">rand</span><span style="color:#006600; font-weight:bold;">&#40;</span>size<span style="color:#006600; font-weight:bold;">-</span><span style="color:#006666;">1</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#93;</span> : <span style="color:#0000FF; font-weight:bold;">nil</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># perform request, assign_to - specify network interface/ip</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> perform<span style="color:#006600; font-weight:bold;">&#40;</span>url, assign_to=<span style="color:#0000FF; font-weight:bold;">nil</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#CC0066; font-weight:bold;">puts</span> url
    interface = assign_to.<span style="color:#0000FF; font-weight:bold;">nil</span>? ? <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">random_interface</span> : assign_to
    req = <span style="color:#6666ff; font-weight:bold;">Curl::Easy</span>.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>url<span style="color:#006600; font-weight:bold;">&#41;</span>
    req.<span style="color:#9900CC;">timeout</span> = CONNECTION_TIMEOUT
    req.<span style="color:#9900CC;">interface</span> = interface <span style="color:#9966CC; font-weight:bold;">unless</span> interface.<span style="color:#0000FF; font-weight:bold;">nil</span>?
    req.<span style="color:#9900CC;">headers</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#996600;">'User-Agent'</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">random_agent</span>
    <span style="color:#9966CC; font-weight:bold;">begin</span>
      req.<span style="color:#9900CC;">perform</span>
      <span style="color:#9966CC; font-weight:bold;">if</span> req.<span style="color:#9900CC;">response_code</span> == <span style="color:#006666;">200</span>
        <span style="color:#0000FF; font-weight:bold;">return</span> req.<span style="color:#9900CC;">downloaded_bytes</span> <span style="color:#006600; font-weight:bold;">&gt;</span> <span style="color:#006666;">0</span> ? req.<span style="color:#9900CC;">body_str</span> : <span style="color:#0000FF; font-weight:bold;">nil</span>
      <span style="color:#9966CC; font-weight:bold;">else</span>
        <span style="color:#0000FF; font-weight:bold;">nil</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#CC00FF; font-weight:bold;">Exception</span>
      <span style="color:#0000FF; font-weight:bold;">return</span> <span style="color:#0000FF; font-weight:bold;">nil</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># perform request by number of attempts</span>
  <span style="color:#9966CC; font-weight:bold;">def</span> fetch<span style="color:#006600; font-weight:bold;">&#40;</span>url, attempts=<span style="color:#006666;">3</span><span style="color:#006600; font-weight:bold;">&#41;</span>
    result = <span style="color:#0000FF; font-weight:bold;">nil</span>
    1.<span style="color:#9900CC;">upto</span><span style="color:#006600; font-weight:bold;">&#40;</span>attempts<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>a<span style="color:#006600; font-weight:bold;">|</span>
      result = <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">perform</span><span style="color:#006600; font-weight:bold;">&#40;</span>url<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#9966CC; font-weight:bold;">break</span> <span style="color:#9966CC; font-weight:bold;">unless</span> result.<span style="color:#0000FF; font-weight:bold;">nil</span>?
    <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#0000FF; font-weight:bold;">return</span> result
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>And sample usage:</p>

<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> TestRequest
  <span style="color:#9966CC; font-weight:bold;">include</span> ApiRequest
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> foo
     body = <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">fetch</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'http://google.com'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>If module variable &#8220;<em>@@interfaces</em>&#8221; is array of ip addresses or network interfaces then one of them (randomly selected) will be used to perform request. Also, function &#8220;<em>fetch</em>&#8221; has parameter &#8220;<em>attempts</em>&#8221; which set to 3 by default. It means that operation will be invoked n times until result is downloaded from url. Otherwise &#8211; it returns nil.<br />
Function perform has a parameter &#8220;<em>assign_to</em>&#8221; (which it not used in &#8220;<em>fetch</em>&#8221; function) that allows to bind request to specified interface.  It is useful if you have situation when you might use different workers that bound to exact interface or just one that uses random ip`s. Also, class <em>ApiRequest</em> has a list of user agents which it uses randomly for each performed request.</p>
<p>Pastie: <a href="http://pastie.org/private/j19j3hbebte9bjqaydslmg">http://pastie.org/private/j19j3hbebte9bjqaydslmg</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sosedoff.com/2010/06/13/handy-http-requests-with-curb-and-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setting processor affinity for a certain task or process in Linux</title>
		<link>http://blog.sosedoff.com/2010/06/06/setting-processor-affinity-for-a-certain-task-or-process-in-linux/</link>
		<comments>http://blog.sosedoff.com/2010/06/06/setting-processor-affinity-for-a-certain-task-or-process-in-linux/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 01:43:37 +0000</pubDate>
		<dc:creator>Dan Sosedoff</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[cores]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[smp]]></category>

		<guid isPermaLink="false">http://blog.sosedoff.com/?p=218</guid>
		<description><![CDATA[When you are using SMP you might want to override the kernel&#8217;s process scheduling and bind a certain process to a specific CPU(s).
What is this?
CPU affinity is nothing but a scheduler property that &#8220;bonds&#8221; a process to a given set of CPUs on the SMP system. The Linux scheduler will honor the given CPU affinity [...]]]></description>
			<content:encoded><![CDATA[<p>When you are using <a href="http://en.wikipedia.org/wiki/Symmetric_multiprocessing">SMP</a> you might want to override the kernel&#8217;s process scheduling and bind a certain process to a specific CPU(s).</p>
<h4>What is this?</h4>
<p>CPU affinity is nothing but a scheduler property that &#8220;bonds&#8221; a process to a given set of CPUs on the SMP system. The Linux scheduler will honor the given CPU affinity and the process will not run on any other CPUs. Note that the Linux scheduler also supports natural CPU affinity:</p>
<blockquote><p>The scheduler attempts to keep processes on the same CPU as long as practical for performance reasons. Therefore, forcing a specific CPU affinity is useful only in certain applications. For example, application such as Oracle (ERP apps) use # of cpus per instance licensed. You can bound Oracle to specific CPU to avoid license problem. This is a really useful on large server having 4 or 8 CPUS</p></blockquote>
<h4>Setting processor affinity for a certain task or process using taskset command</h4>
<p>taskset is used to set or retrieve the CPU affinity of a running process given its PID or to launch a new COMMAND with a given CPU affinity. However taskset is not installed by default. You need to install schedutils (Linux scheduler utilities) package.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> shedutils</pre></div></div>

<p>Under latest version of Debian / Ubuntu Linux taskset is installed by default using util-linux package.</p>
<p>The CPU affinity is represented as a bitmask, with the lowest order bit corresponding to the first logical CPU and the highest order bit corresponding to the last logical CPU. For example:</p>
<ul>
<li>0&#215;00000001 is processor #0 (1st processor)</li>
<li>0&#215;00000003 is processors #0 and #1</li>
<li>0&#215;00000004 is processors #2 (3rd processor)</li>
</ul>
<p>To set the processor affinity of process 13545 to processor #0 (1st processor) type following command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ taskset 0x00000001 <span style="color: #660033;">-p</span> <span style="color: #000000;">13545</span></pre></div></div>

<p>If you find a bitmask hard to use, then you can specify a numerical list of processors instead of a bitmask using -c flag:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ taskset <span style="color: #660033;">-c</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-p</span> <span style="color: #000000;">13545</span>
$ taskset <span style="color: #660033;">-c</span> <span style="color: #000000;">3</span>,<span style="color: #000000;">4</span> <span style="color: #660033;">-p</span> <span style="color: #000000;">13545</span></pre></div></div>

<p>where  -p : Operate on an existing PID and not launch a new task (default is to launch a new task)</p>
<p><small>via <a href="http://www.cyberciti.biz/tips/setting-processor-affinity-certain-task-or-process.html">http://www.cyberciti.biz/tips/setting-processor-affinity-certain-task-or-process.html</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sosedoff.com/2010/06/06/setting-processor-affinity-for-a-certain-task-or-process-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Install Git on CentOS 5.2</title>
		<link>http://blog.sosedoff.com/2009/06/28/install-git-on-centos-52/</link>
		<comments>http://blog.sosedoff.com/2009/06/28/install-git-on-centos-52/#comments</comments>
		<pubDate>Sun, 28 Jun 2009 03:28:19 +0000</pubDate>
		<dc:creator>Dan Sosedoff</dc:creator>
				<category><![CDATA[Git]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[centos]]></category>

		<guid isPermaLink="false">http://blog.sosedoff.com/?p=151</guid>
		<description><![CDATA[First, we need to install all dependencies:

# yum install gettext-devel expat-devel curl-devel zlib-devel openssl-devel

Next, get the git 1.6.x sources:

# wget http://kernel.org/pub/software/scm/git/git-1.6.3.3.tar.gz

Then, unpack and cd into git sources folder and install it:

# make &#38;&#38; make install &#38; make clean

That`s it, now you`ll have git system ready to go.
]]></description>
			<content:encoded><![CDATA[<p>First, we need to install all dependencies:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># yum install gettext-devel expat-devel curl-devel zlib-devel openssl-devel</span></pre></div></div>

<p>Next, get the git 1.6.x sources:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># wget http://kernel.org/pub/software/scm/git/git-1.6.3.3.tar.gz</span></pre></div></div>

<p>Then, unpack and cd into git sources folder and install it:</p>

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

<p>That`s it, now you`ll have git system ready to go.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sosedoff.com/2009/06/28/install-git-on-centos-52/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Useless filesystem over MySQL</title>
		<link>http://blog.sosedoff.com/2009/04/06/useless-filesystem-over-mysql/</link>
		<comments>http://blog.sosedoff.com/2009/04/06/useless-filesystem-over-mysql/#comments</comments>
		<pubDate>Mon, 06 Apr 2009 04:10:28 +0000</pubDate>
		<dc:creator>Dan Sosedoff</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[fuse]]></category>
		<category><![CDATA[mysqlfuse]]></category>
		<category><![CDATA[over]]></category>

		<guid isPermaLink="false">http://blog.sosedoff.com/?p=121</guid>
		<description><![CDATA[Here is a completely useless filesystem based on MySQL database storage &#8211; mysqlfuse, implemented with Fuse.
I didnt find any way how i can use it, but meanwhile, this fs working. Not perfect of course, in that case its not maintained for a long time. Doesnt support information about free drive space, so any filemanager keeps [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a completely useless filesystem based on MySQL database storage &#8211; mysqlfuse, implemented with Fuse.<br />
I didnt find any way how i can use it, but meanwhile, this fs working. Not perfect of course, in that case its not maintained for a long time. Doesnt support information about free drive space, so any filemanager keeps saying &#8216;Error: No space left on device&#8217;. Such case making it more useless. </p>
<p>It`s really easy to set it up. </p>
<p>First, we need to install developer headers for fuse:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> libfuse-dev</pre></div></div>

<p>Next, getting sources (32bit only, not working in 64bit):</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>voxel.dl.sourceforge.net<span style="color: #000000; font-weight: bold;">/</span>sourceforge<span style="color: #000000; font-weight: bold;">/</span>mysqlfs<span style="color: #000000; font-weight: bold;">/</span>mysqlfs-0.4.0-rc1.tar.bz2</pre></div></div>

<p>Unpack it, and compile:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xjvf</span> mysqlfs-0.4.0-rc1.tar.bz2
$ <span style="color: #7a0874; font-weight: bold;">cd</span> mysqlfs-0.4.0-rc1
$ .<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>Next, we need to setup the database</p>

<div class="wp_syntax"><div class="code"><pre class="mysql" style="font-family:monospace;"><span style="color: #990099; font-weight: bold;">CREATE</span> <span style="color: #990099; font-weight: bold;">DATABASE</span> mysqlfs<span style="color: #000033;">;</span>
<span style="color: #990099; font-weight: bold;">GRANT</span> <span style="color: #990099; font-weight: bold;">SELECT</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">INSERT</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">UPDATE</span><span style="color: #000033;">,</span> <span style="color: #990099; font-weight: bold;">DELETE</span> <span style="color: #990099; font-weight: bold;">ON</span> mysqlfs.<span style="color: #CC0099;">*</span> <span style="color: #990099; font-weight: bold;">TO</span> mysqlfs@<span style="color: #008000;">&quot;<span style="color: #008080; font-weight: bold;">%</span>&quot;</span> IDENTIFIED BY <span style="color: #008000;">'password'</span><span style="color: #000033;">;</span>
FLUSH <span style="color: #990099; font-weight: bold;">PRIVILEGES</span><span style="color: #000033;">;</span></pre></div></div>

<p>And create database schema. SQL file located in root folder of the sources</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ mysql <span style="color: #660033;">-uroot</span> <span style="color: #660033;">-p</span> mysqlfs <span style="color: #000000; font-weight: bold;">&lt;</span> schema.sql</pre></div></div>

<p>And finally, mount filesystem to some folder:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ mysqlfs <span style="color: #660033;">-ohost</span>=MYSQLHOST <span style="color: #660033;">-ouser</span>=MYSQLUSER <span style="color: #660033;">-opassword</span>=MYSQLPASS <span style="color: #660033;">-odatabase</span>=mysqlfs MOUNT_DIR</pre></div></div>

<p>Now, its gonna be working. To use automatic configuration parameters you can create section [mysqlfs] in your mysql configuration file (my.cnf)</p>
<p>Parameters:</p>
<pre>
-ohost=<hostname>
    MySQL server host

  -ouser=<username>
    MySQL username

  -opassword=
<password>
    MySQL password

  -odatabase=<db>
    MySQL database name
</pre>
<p>That`s it. Anyway, using FUSE there is a way to create so weird filesystems proxy. For example, there is SQLite over FUSE. And it is too old. Next time i`ll write about Amazon S3 over FUSE projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sosedoff.com/2009/04/06/useless-filesystem-over-mysql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
