<?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>SDpower</title>
	<atom:link href="http://blog.sd.idv.tw/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.sd.idv.tw</link>
	<description>史迪 MY~ALL</description>
	<lastBuildDate>Thu, 10 May 2012 07:13:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Gearman 不一樣的用法～～</title>
		<link>http://blog.sd.idv.tw/archives/572</link>
		<comments>http://blog.sd.idv.tw/archives/572#comments</comments>
		<pubDate>Thu, 10 May 2012 07:13:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP & MYSQL]]></category>

		<guid isPermaLink="false">http://blog.sd.idv.tw/?p=572</guid>
		<description><![CDATA[Gearman 你所知道的Gearman 可以導入大量數據、發送許多電子郵件、編碼視頻文件、挖據數據並構建一個中央日誌設施 — 所有這些均不會影響站點的體驗和響應性。可以並行地處理數據。而且，由於 Gearman 協議是獨立於語言和平台的，所以您可以在解決方案中混合編程語言。比如，可以用 PHP 編寫一個 producer，用 C、Ruby 或其他任何支持 Gearman 庫的語言編寫 worker。 你所應用Gearman 來自官網的範例: Client:發送工作需求給Server 1 2 3 4 5 6 7 8 9 10 11 12 13 &#60;?php # Create our client object. $client= new GearmanClient&#40;&#41;; &#160; # Add default server (localhost). $client-&#62;addServer&#40;&#41;; &#160; echo &#34;Sending job\n&#34;; &#160; # Send reverse [...]]]></description>
			<content:encoded><![CDATA[<h2>Gearman</h2>
<h3>你所知道的Gearman</h3>
<p>可以導入大量數據、發送許多電子郵件、編碼視頻文件、挖據數據並構建一個中央日誌設施 — 所有這些均不會影響站點的體驗和響應性。可以並行地處理數據。而且，由於 Gearman 協議是獨立於語言和平台的，所以您可以在解決方案中混合編程語言。比如，可以用 PHP 編寫一個 producer，用 C、Ruby 或其他任何支持 Gearman 庫的語言編寫 worker。</p>
<h3>你所應用Gearman</h3>
<p><a href="http://blog.sd.idv.tw/wp-content/uploads/2012/05/gearman1.png"><img src="http://blog.sd.idv.tw/wp-content/uploads/2012/05/gearman1-300x185.png" alt="" title="gearman1" width="300" height="185" class="alignnone size-medium wp-image-579" /></a><br />
<span id="more-572"></span><br />
來自官網的範例:</p>
<h4>Client:發送工作需求給Server</h4>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;"># Create our client object.
</span><span style="color: #000088;">$client</span><span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GearmanClient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Add default server (localhost).
</span><span style="color: #000088;">$client</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addServer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Sending job<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Send reverse job
</span><span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$client</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">do</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;reverse&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Hello!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$result</span><span style="color: #009900;">&#41;</span>
  <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Success: <span style="color: #006699; font-weight: bold;">$result</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h3>Worker:接手處理Server工作</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Create our worker object.
</span><span style="color: #000088;">$worker</span><span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> GearmanWorker<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Add default server (localhost).
</span><span style="color: #000088;">$worker</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addServer</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Register function &quot;reverse&quot; with the server.
</span><span style="color: #000088;">$worker</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">addFunction</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;reverse&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;reverse_fn&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">print</span> <span style="color: #0000ff;">&quot;Waiting for job...<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000088;">$ret</span><span style="color: #339933;">=</span> <span style="color: #000088;">$worker</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">work</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$worker</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">returnCode</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> GEARMAN_SUCCESS<span style="color: #009900;">&#41;</span>
    <span style="color: #b1b100;">break</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># A much simple reverse function
</span><span style="color: #000000; font-weight: bold;">function</span> reverse_fn<span style="color: #009900;">&#40;</span><span style="color: #000088;">$job</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$workload</span><span style="color: #339933;">=</span> <span style="color: #000088;">$job</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">workload</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Received job: &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$job</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">handle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Workload: <span style="color: #006699; font-weight: bold;">$workload</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span> 
  <span style="color: #000088;">$result</span><span style="color: #339933;">=</span> <span style="color: #990000;">strrev</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$workload</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Result: <span style="color: #006699; font-weight: bold;">$result</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> <span style="color: #000088;">$result</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<h3>實際上!!</h3>
<p>所遇到狀況可能是&#8230;</p>
<ul>
<li>PHP Worker寫了一大堆.(發信一支,轉檔一支&#8230;)</li>
<li>PHP Worker跑了一大堆.(沒事的時候SLEEP 100&#8230;..但是現在很忙阿！！馬上調整程式嗎？)</li>
<li>PHP Worker跑了又沒做.(PHP開成常駐程式在跑.有很多狀況要處裡,很多狀況多到要ON CALL!!)</li>
<li>程式碼更新後又要重新開啟常駐程式.(一個就算啦.但是幾百個會怎樣？)</li>
</ul>
<h3>路不轉人轉!!</h3>
<p>有沒有辦法克服上述問題?!<br />
有～～</p>
<h4>看一下系統架構:</h4>
<p><a href="http://blog.sd.idv.tw/wp-content/uploads/2012/05/gearmn2.png"><img src="http://blog.sd.idv.tw/wp-content/uploads/2012/05/gearmn2-300x201.png" alt="" title="gearmn2" width="300" height="201" class="alignnone size-medium wp-image-582" /></a><br />
說明：<br />
一般來說,Client發送的是工作.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$client</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">do</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;reverse&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Hello!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>這行看起來是要叫Worker處理<strong>reverse</strong> 這項工作 而工作內容為<strong>Hello!</strong>.<br />
現在我們用.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$result</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$client</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">do</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Group1bgs&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;php TestGearman.php D3 123231 adsadasdq&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>你可以看到我改變了原本作法.<br />
<strong>php TestGearman.php PARMS1 PARMS2 PARMS3</strong> 工作作內容變成這樣.<br />
這時你一定有疑問？？搞啥這樣Worker怎摸接?<br />
以下是我啟動的Work的方式:<br />
GetGearman.php 回傳我的Aplication設定值.</p>
<ul>
<li>Server:Jobs Server ip（可以連線多台SERVER）</li>
<li>Localname:此範例Group1</li>
<li>Threads:啟動幾個Worker</li>
</ul>
<p>檔案：work.sh</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;">PWD</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #7a0874; font-weight: bold;">pwd</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">BASEDIR</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${PWD}</span>/<span style="color: #007800;">$(dirname $0)</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #007800;">$PATH</span>:<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #800000;">${BASEDIR}</span>
<span style="color: #007800;">SERVER_HOT</span>=<span style="color: #000000; font-weight: bold;">`</span>php <span style="color: #800000;">${BASEDIR}</span><span style="color: #000000; font-weight: bold;">/</span>GetGearman.php Server<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">LOCAL_NAME</span>=<span style="color: #000000; font-weight: bold;">`</span>php <span style="color: #800000;">${BASEDIR}</span><span style="color: #000000; font-weight: bold;">/</span>GetGearman.php Localname<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #7a0874; font-weight: bold;">declare</span> <span style="color: #007800;">THREADS</span>=<span style="color: #000000; font-weight: bold;">`</span>php <span style="color: #800000;">${BASEDIR}</span><span style="color: #000000; font-weight: bold;">/</span>GetGearman.php Threads<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">LOG_DIR</span>=<span style="color: #000000; font-weight: bold;">`</span>php <span style="color: #800000;">${BASEDIR}</span><span style="color: #000000; font-weight: bold;">/</span>GetGearman.php LOG_DIR<span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">WORK</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${2}</span>&quot;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$WORK</span>&quot;</span> = <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #007800;">WORK</span>=<span style="color: #ff0000;">&quot;bgs&quot;</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
__start<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;">&#123;</span>
    <span style="color: #7a0874; font-weight: bold;">declare</span> <span style="color: #007800;">a</span>=<span style="color: #000000;">0</span>
    <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$a</span> <span style="color: #660033;">-lt</span> <span style="color: #007800;">$THREADS</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> a++ <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #007800;">PIDFILE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG_DIR}</span>/GearmanWork<span style="color: #007800;">${WORK}</span><span style="color: #007800;">${a}</span>.pid&quot;</span>
        <span style="color: #007800;">PROMPT</span>=<span style="color: #ff0000;">&quot;-i <span style="color: #007800;">${PIDFILE}</span> -h <span style="color: #007800;">${SERVER_HOT}</span> -nw -f <span style="color: #007800;">${LOCAL_NAME}</span><span style="color: #007800;">${WORK}</span> xargs <span style="color: #007800;">${BASEDIR}</span>/<span style="color: #007800;">${WORK}</span>.sh&quot;</span>
        gearman <span style="color: #800000;">${PROMPT}</span> <span style="color: #000000; font-weight: bold;">&amp;</span>
    <span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
__stop<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;">&#123;</span>
    <span style="color: #7a0874; font-weight: bold;">declare</span> <span style="color: #007800;">a</span>=<span style="color: #000000;">0</span>
    <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$a</span> <span style="color: #660033;">-lt</span> <span style="color: #007800;">$THREADS</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">do</span>
        <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span> a++ <span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #007800;">PIDFILE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOG_DIR}</span>/GearmanWork<span style="color: #007800;">${WORK}</span><span style="color: #007800;">${a}</span>.pid&quot;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-r</span> <span style="color: #007800;">$PIDFILE</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span> ; <span style="color: #000000; font-weight: bold;">then</span>
            <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;warning, no pid<span style="color: #007800;">${a}</span> file found - gearman is not running ?&quot;</span>
            <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
        <span style="color: #000000; font-weight: bold;">fi</span>
        <span style="color: #c20cb9; font-weight: bold;">kill</span> <span style="color: #660033;">-TERM</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #007800;">$PIDFILE</span><span style="color: #000000; font-weight: bold;">`</span>
        <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-f</span> <span style="color: #007800;">$PIDFILE</span>
    <span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
__show_usage<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;">&#123;</span>
&nbsp;
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Usage: {start|stop|restart}&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #007800;">testing1</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${SERVER_HOT}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;ERROR&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${testing1}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${SERVER_HOT}</span>&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #007800;">testing2</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOCAL_NAME}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #ff0000;">&quot;ERROR&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${testing2}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOCAL_NAME}</span>&quot;</span>
    <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">1</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000; font-weight: bold;">in</span>
    start<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Starting GearmanWork... <span style="color: #007800;">${WORK}</span>&quot;</span>
        __start
        <span style="color: #000000; font-weight: bold;">;;</span>
    stop<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Stoping GearmanWork... <span style="color: #007800;">${WORK}</span>&quot;</span>
        __stop
        <span style="color: #000000; font-weight: bold;">;;</span>
    restart<span style="color: #7a0874; font-weight: bold;">&#41;</span>
        <span style="color: #007800;">$0</span> stop <span style="color: #800000;">${WORK}</span>
        <span style="color: #007800;">$0</span> start <span style="color: #800000;">${WORK}</span>
        <span style="color: #000000; font-weight: bold;">;;</span>
    <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
        __show_usage
        <span style="color: #000000; font-weight: bold;">;;</span>
  <span style="color: #000000; font-weight: bold;">esac</span></pre></td></tr></table></div>

<p>使用方式：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ .<span style="color: #000000; font-weight: bold;">/</span>work.sh start 啟動
$ .<span style="color: #000000; font-weight: bold;">/</span>work.sh stop 停止</pre></td></tr></table></div>

<p>運作:<br />
<a href="http://blog.sd.idv.tw/wp-content/uploads/2012/05/gearman3.png"><img src="http://blog.sd.idv.tw/wp-content/uploads/2012/05/gearman3-289x300.png" alt="" title="gearman3" width="289" height="300" class="alignnone size-medium wp-image-587" /></a><br />
檔案bgs.sh:<br />
負責執行工作 直接跑命令 以php來說已經不是常駐狀態下運作.還有輸出log以便錯誤狀況查測.(如果你的程式有錯誤也可以看到輸出的錯誤訊息)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
<span style="color: #007800;">RED</span>=$<span style="color: #ff0000;">'\e[1;31m'</span>
<span style="color: #007800;">GREEN</span>=$<span style="color: #ff0000;">'\e[1;32m'</span>
<span style="color: #007800;">YELLOW</span>=$<span style="color: #ff0000;">'\e[1;33m'</span>
<span style="color: #007800;">BLUE</span>=$<span style="color: #ff0000;">'\e[1;34m'</span>
<span style="color: #007800;">PURPLE</span>=$<span style="color: #ff0000;">'\e[1;35m'</span>
<span style="color: #007800;">CYAN</span>=$<span style="color: #ff0000;">'\e[1;36m'</span>
<span style="color: #007800;">WHITE</span>=$<span style="color: #ff0000;">'\e[1;37m'</span>
<span style="color: #007800;">GREY</span>=$<span style="color: #ff0000;">'\e[1;30m'</span>
<span style="color: #007800;">NOR</span>=$<span style="color: #ff0000;">'\e[m'</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">export</span> <span style="color: #007800;">PATH</span>=<span style="color: #007800;">$PATH</span>:<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin:<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin:$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">dirname</span> <span style="color: #007800;">$0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">PWD</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #7a0874; font-weight: bold;">eval</span> <span style="color: #7a0874; font-weight: bold;">pwd</span><span style="color: #000000; font-weight: bold;">`</span>
<span style="color: #007800;">BASEDIR</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">$(dirname $0)</span>/../&quot;</span>
<span style="color: #007800;">LOGDIR</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span>php GetGearman.php LOG_DIR<span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">LOGFILE</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${LOGDIR}</span>/bgs.log&quot;</span>
<span style="color: #007800;">time</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #ff0000;">&quot;+%Y/%m/%d %H:%M:%S&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">time2</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">date</span> <span style="color: #ff0000;">&quot;+%Y_%m_%d_%H_%M_%S&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #007800;">logkey</span>=<span style="color: #800000;">${LOGDIR}</span><span style="color: #000000; font-weight: bold;">/</span>bgs<span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${time2}</span>$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${*}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">|</span> md5sum <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">cut</span> <span style="color: #660033;">-c</span> <span style="color: #000000;">1</span>-<span style="color: #000000;">5</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>.log
<span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> <span style="color: #800000;">${LOGDIR}</span><span style="color: #000000; font-weight: bold;">/</span>bgs
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$time</span> $* <span style="color: #007800;">${logkey}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #800000;">${LOGFILE}</span>
<span style="color: #666666; font-style: italic;">## cd ${BASEDIR}</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${YELLOW}</span>***  <span style="color: #007800;">${RED}</span>Running <span style="color: #007800;">${CYAN}</span><span style="color: #007800;">${*}</span> <span style="color: #007800;">${RED}</span>...<span style="color: #007800;">${NOR}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;&gt;</span> <span style="color: #800000;">${logkey}</span>
<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">bash</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${*}</span>&quot;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">tee</span> <span style="color: #660033;">-a</span> <span style="color: #800000;">${logkey}</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;&amp;</span><span style="color: #000000;">1</span></pre></td></tr></table></div>

<p>每次Worker執行的工作都是一次性的呼叫php,<strong>沒有常駐</strong>.<br />
以我來說我的專案會以git做版本控管,在正式機器上會在crontab裡加入簡單的shell script每次更新 product的branch.<br />
而我的Worker並不需要重起.因為每次都是獨立呼叫php,自然而然專案由git更新後執行的也是最新的程式碼.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sd.idv.tw/archives/572/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Phalcon !! 以C開發的php freamwork!!</title>
		<link>http://blog.sd.idv.tw/archives/567</link>
		<comments>http://blog.sd.idv.tw/archives/567#comments</comments>
		<pubDate>Sun, 06 May 2012 04:43:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[未分類]]></category>

		<guid isPermaLink="false">http://blog.sd.idv.tw/?p=567</guid>
		<description><![CDATA[Phalcon is a C extension so you need to download a binary for your platform or compile it from source code. 看完這句,再去看 官方的數據. Framework Benchmark 這完全拋開PHP!!!的包袱. 安裝方式 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ##Ubuntu必須先確認 安裝下列套件 # sudo apt-get install php5-dev php5-mysql gcc cd /tmp # git [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Phalcon is a C extension so you need to download a binary for your platform or compile it from source code.</strong></p>
<p>看完這句,再去看 官方的數據. <a href="http://phalconphp.com/documentation/benchmark">Framework Benchmark</a><br />
這完全拋開PHP!!!的包袱.</p>
<h3>安裝方式</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">##Ubuntu必須先確認 安裝下列套件</span>
<span style="color: #666666; font-style: italic;"># sudo apt-get install php5-dev php5-mysql gcc</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>tmp
<span style="color: #666666; font-style: italic;"># git clone git://github.com/phalcon/cphalcon.git</span>
Cloning into <span style="color: #ff0000;">'cphalcon'</span>...
remote: Counting objects: <span style="color: #000000;">1856</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">700</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">700</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">1856</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">1277</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">1552</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">973</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Receiving objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1856</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1856</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">1.76</span> MiB <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">460</span> KiB<span style="color: #000000; font-weight: bold;">/</span>s, done.
Resolving deltas: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1277</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1277</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
<span style="color: #666666; font-style: italic;"># cd /tmp/cphalcon/release</span>
<span style="color: #666666; font-style: italic;"># ./configure</span>
<span style="color: #666666; font-style: italic;"># make;make install;</span>
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php<span style="color: #000000; font-weight: bold;">/</span>extensions.ini
<span style="color: #007800;">extension</span>=phalcon.so</pre></td></tr></table></div>

<p>待續&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sd.idv.tw/archives/567/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP extension Redis 安裝使用</title>
		<link>http://blog.sd.idv.tw/archives/561</link>
		<comments>http://blog.sd.idv.tw/archives/561#comments</comments>
		<pubDate>Sun, 18 Mar 2012 16:15:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP & MYSQL]]></category>

		<guid isPermaLink="false">http://blog.sd.idv.tw/?p=561</guid>
		<description><![CDATA[PHP extension Redis 安裝使用 安裝 PHP extension for Redis 使PHP可以與Redis運作. 安裝 1 2 3 4 5 6 7 8 9 $ cd /tmp $ git clone git://github.com/nicolasff/phpredis.git $ cd /tmp/phpredis $ phpize $ ./configure $ make $ make install clean #編輯 php.ini加入 extension=redis.so 當 SESSION storge使用 如果要將SESSION 存入redis 只需要在php.ini做以下設定： 1 2 session.save_handler = redis session.save_path [...]]]></description>
			<content:encoded><![CDATA[<h1>PHP extension Redis 安裝使用</h1>
<p>安裝 <a href="https://github.com/nicolasff/phpredis" target="_blank">PHP extension for Redis</a> 使PHP可以與Redis運作.</p>
<h3>安裝</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>tmp
$ <span style="color: #c20cb9; font-weight: bold;">git</span> clone <span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>nicolasff<span style="color: #000000; font-weight: bold;">/</span>phpredis.git
$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>phpredis
$ phpize
$ .<span style="color: #000000; font-weight: bold;">/</span>configure
$ <span style="color: #c20cb9; font-weight: bold;">make</span>
$ <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span> clean
<span style="color: #666666; font-style: italic;">#編輯 php.ini加入</span>
<span style="color: #007800;">extension</span>=redis.so</pre></td></tr></table></div>

<p><span id="more-561"></span></p>
<h3>當 SESSION storge使用</h3>
<p>如果要將SESSION 存入redis 只需要在php.ini做以下設定：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="ini" style="font-family:monospace;">session.save_handler <span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> redis</span>
session.save_path <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;tcp://host1:6379?weight=1, tcp://host2:6379?weight=2&amp;timeout=2.5, tcp://host3:6379?weight=2&quot;</span></pre></td></tr></table></div>

<p>weight: 權重依照上方設定範例 host1:為5/1 host1:為5/2 host1:為5/2 <br/><br />
timeout:喻时以秒為單位 最大86400.<br/><br />
persistent:持久連線.預設為開啟.<br/><br />
prefix:前置字.儲存於Redis的前置字 預設<strong>PHPREDIS_SESSION:</strong><br/><br />
auth:認證.預設無<br/></p>
<h3>一般存取</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$redis</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Redis<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$redis</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'127.0.0.1'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">6379</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//一般連線</span>
<span style="color: #000088;">$redis</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">pconnect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'127.0.0.1'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">6379</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//持久連線</span>
<span style="color: #000088;">$redis</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'key'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//取得</span>
<span style="color: #000088;">$redis</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'key'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'value'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//存入</span>
<span style="color: #000088;">$redis</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setex</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'key'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3600</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'value'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//存入並且有一小時存活時間</span>
<span style="color: #000088;">$redis</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setnx</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'key'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'value'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//只有在無此key時才存入</span>
<span style="color: #000088;">$redis</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">delete</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'key1'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'key2'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//刪除</span>
<span style="color: #000088;">$redis</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">delete</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'key3'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'key4'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//刪除</span>
&nbsp;
<span style="color: #000088;">$ret</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$redis</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">multi</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">//多筆執行</span>
    <span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'key1'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'val1'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'key1'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'key2'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'val2'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'key2'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">-&gt;</span><span style="color: #004000;">exec</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//監控key值是否改變.</span>
<span style="color: #000088;">$redis</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">watch</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'x'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">/* long code here during the execution of which other clients could well modify `x` */</span>
<span style="color: #000088;">$ret</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$redis</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">multi</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">-&gt;</span><span style="color: #004000;">incr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'x'</span><span style="color: #009900;">&#41;</span>
    <span style="color: #339933;">-&gt;</span><span style="color: #004000;">exec</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">/*
$ret = FALSE if x has been modified between the call to WATCH and the call to EXEC.
*/</span>
<span style="color: #666666; font-style: italic;">//key值做遞增</span>
<span style="color: #000088;">$redis</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">incr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'key1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">/* 2 */</span>
<span style="color: #000088;">$redis</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">incr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'key1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">/* 3 */</span>
<span style="color: #000088;">$redis</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">incr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'key1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">/* 4 */</span>
<span style="color: #000088;">$redis</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">incrBy</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'key1'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">/* 14 */</span>
<span style="color: #666666; font-style: italic;">//key值做遞減</span>
<span style="color: #000088;">$redis</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">decr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'key1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">/* -2 */</span>
<span style="color: #000088;">$redis</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">decr</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'key1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">/* -3 */</span>
<span style="color: #000088;">$redis</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">decrBy</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'key1'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">/* -13 */</span>
<span style="color: #666666; font-style: italic;">//取多個key值</span>
<span style="color: #000088;">$redis</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">mGet</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'key1'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'key2'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'key3'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>大致上就這樣感覺很讚唷.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sd.idv.tw/archives/561/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redis Key-Value資料庫建置實測</title>
		<link>http://blog.sd.idv.tw/archives/547</link>
		<comments>http://blog.sd.idv.tw/archives/547#comments</comments>
		<pubDate>Wed, 14 Mar 2012 05:56:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[Mac OSX]]></category>
		<category><![CDATA[PHP & MYSQL]]></category>
		<category><![CDATA[未分類]]></category>

		<guid isPermaLink="false">http://blog.sd.idv.tw/?p=547</guid>
		<description><![CDATA[reids Redis是一個開源的使用ANSI C語言編寫、支援網路、可基於記憶體亦可持久化的日誌型、Key-Value資料庫，並提供多種語言的API。從2010年3月15日起，Redis的開發工作由VMware主持。 通常，Redis將數據存儲於記憶體，或被配置為使用虛擬記憶體。通過兩種方式可以實現數據持久：使用快照的方式，將內存中的數據不斷寫入磁碟；或使用類似MySQL的日誌方式，記錄每次更新的日誌。前者性能較高，但是可能會引起一定程度的數據遺失(後者相反)。 Mac 使用brew安裝reids 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 -&#62; % brew install redis ==&#62; Downloading http://redis.googlecode.com/files/redis-2.4.8.tar.gz ######################################################################## 100.0% ==&#62; make -C src ==&#62; Caveats If this is your first install, automatically load on login with: [...]]]></description>
			<content:encoded><![CDATA[<h1>reids</h1>
<p><a href="http://redis.io/" target="_blank">Redis</a>是一個開源的使用ANSI C語言編寫、支援網路、可基於記憶體亦可持久化的日誌型、Key-Value資料庫，並提供多種語言的API。從2010年3月15日起，Redis的開發工作由VMware主持。<br />
<br />
通常，Redis將數據存儲於記憶體，或被配置為使用虛擬記憶體。通過兩種方式可以實現數據持久：使用快照的方式，將內存中的數據不斷寫入磁碟；或使用類似MySQL的日誌方式，記錄每次更新的日誌。前者性能較高，但是可能會引起一定程度的數據遺失(後者相反)。</p>
<h3>Mac 使用brew安裝reids</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">-<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">%</span> brew <span style="color: #c20cb9; font-weight: bold;">install</span> redis
==<span style="color: #000000; font-weight: bold;">&gt;</span> Downloading http:<span style="color: #000000; font-weight: bold;">//</span>redis.googlecode.com<span style="color: #000000; font-weight: bold;">/</span>files<span style="color: #000000; font-weight: bold;">/</span>redis-2.4.8.tar.gz
<span style="color: #666666; font-style: italic;">######################################################################## 100.0%</span>
==<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #660033;">-C</span> src
==<span style="color: #000000; font-weight: bold;">&gt;</span> Caveats
If this is your first <span style="color: #c20cb9; font-weight: bold;">install</span>, automatically load on <span style="color: #c20cb9; font-weight: bold;">login</span> with:
    <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">-p</span> ~<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchAgents
    <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Cellar<span style="color: #000000; font-weight: bold;">/</span>redis<span style="color: #000000; font-weight: bold;">/</span>2.4.8<span style="color: #000000; font-weight: bold;">/</span>homebrew.mxcl.redis.plist ~<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchAgents<span style="color: #000000; font-weight: bold;">/</span>
    launchctl load <span style="color: #660033;">-w</span> ~<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchAgents<span style="color: #000000; font-weight: bold;">/</span>homebrew.mxcl.redis.plist
&nbsp;
If this is an upgrade and you already have the homebrew.mxcl.redis.plist loaded:
    launchctl unload <span style="color: #660033;">-w</span> ~<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchAgents<span style="color: #000000; font-weight: bold;">/</span>homebrew.mxcl.redis.plist
    <span style="color: #c20cb9; font-weight: bold;">cp</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Cellar<span style="color: #000000; font-weight: bold;">/</span>redis<span style="color: #000000; font-weight: bold;">/</span>2.4.8<span style="color: #000000; font-weight: bold;">/</span>homebrew.mxcl.redis.plist ~<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchAgents<span style="color: #000000; font-weight: bold;">/</span>
    launchctl load <span style="color: #660033;">-w</span> ~<span style="color: #000000; font-weight: bold;">/</span>Library<span style="color: #000000; font-weight: bold;">/</span>LaunchAgents<span style="color: #000000; font-weight: bold;">/</span>homebrew.mxcl.redis.plist
&nbsp;
  To start redis manually:
    redis-server <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>redis.conf
&nbsp;
  To access the server:
    redis-cli
==<span style="color: #000000; font-weight: bold;">&gt;</span> Summary
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>Cellar<span style="color: #000000; font-weight: bold;">/</span>redis<span style="color: #000000; font-weight: bold;">/</span>2.4.8: <span style="color: #000000;">9</span> files, 424K, built <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000;">5</span> seconds</pre></td></tr></table></div>

<p><span id="more-547"></span><br />
編輯設定檔 /usr/local/etc/redis.conf</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">-<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>databases<span style="color: #000000; font-weight: bold;">/</span>redis
-<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">%</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span> clean
===<span style="color: #000000; font-weight: bold;">&gt;</span> Correct pkg-plist sequence to create group<span style="color: #7a0874; font-weight: bold;">&#40;</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span> and user<span style="color: #7a0874; font-weight: bold;">&#40;</span>s<span style="color: #7a0874; font-weight: bold;">&#41;</span>
===<span style="color: #000000; font-weight: bold;">&gt;</span>   Registering installation <span style="color: #000000; font-weight: bold;">for</span> redis-2.4.8
===<span style="color: #000000; font-weight: bold;">&gt;</span> SECURITY REPORT: 
      This port has installed the following files <span style="color: #c20cb9; font-weight: bold;">which</span> may act <span style="color: #c20cb9; font-weight: bold;">as</span> network
      servers and may therefore pose a remote security risk to the system.
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>redis-cli
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>redis-server
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>redis-benchmark
&nbsp;
      This port has installed the following startup scripts <span style="color: #c20cb9; font-weight: bold;">which</span> may cause
      these network services to be started at boot time.
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>rc.d<span style="color: #000000; font-weight: bold;">/</span>redis
&nbsp;
      If there are vulnerabilities <span style="color: #000000; font-weight: bold;">in</span> these programs there may be a security
      risk to the system. FreeBSD makes no guarantee about the security of
      ports included <span style="color: #000000; font-weight: bold;">in</span> the Ports Collection. Please <span style="color: #7a0874; font-weight: bold;">type</span> <span style="color: #ff0000;">'make deinstall'</span>
      to deinstall the port <span style="color: #000000; font-weight: bold;">if</span> this is a concern.
&nbsp;
      For <span style="color: #c20cb9; font-weight: bold;">more</span> information, and contact details about the security
      status of this software, see the following webpage: 
http:<span style="color: #000000; font-weight: bold;">//</span>redis.io<span style="color: #000000; font-weight: bold;">/</span>
-<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">%</span></pre></td></tr></table></div>

<p><code>/etc/rc.conf 加入 redis_enable="YES"</code><br />
複製 /usr/local/etc/redis.conf.sample 到 /usr/local/etc/redis.conf <br />
編輯設定檔 /usr/local/etc/redis.conf </p>
<h3>設定檔</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;"># Redis configuration file example
&nbsp;
# Note on units: when memory size is needed, it is possible to specifiy
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k =&gt; 1000 bytes
# 1kb =&gt; 1024 bytes
# 1m =&gt; 1000000 bytes
# 1mb =&gt; 1024*1024 bytes
# 1g =&gt; 1000000000 bytes
# 1gb =&gt; 1024*1024*1024 bytes
#
# units are case insensitive so 1GB 1Gb 1gB are all the same.
&nbsp;
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /usr/local/var/run/redis.pid when daemonized.
daemonize yes
&nbsp;
# When running daemonized, Redis writes a pid file in /usr/local/var/run/redis.pid by
# default. You can specify a custom pid file location here.
pidfile /usr/local/var/run/redis.pid
&nbsp;
# Accept connections on the specified port, default is 6379.
# If port 0 is specified Redis will not listen on a TCP socket.
port 6379
&nbsp;
# If you want you can bind a single interface, if the bind option is not
# specified all the interfaces will listen for incoming connections.
# 如果你只供本機使用 請移除註解 bind 127.0.0.1 反之加上註解
# bind 127.0.0.1
&nbsp;
# Specify the path for the unix socket that will be used to listen for
# incoming connections. There is no default, so Redis will not listen
# on a unix socket when not specified.
#
# unixsocket /tmp/redis.sock
# unixsocketperm 755
&nbsp;
# Close the connection after a client is idle for N seconds (0 to disable)
timeout 0
&nbsp;
# Set server verbosity to 'debug'
# it can be one of:
# debug (a lot of information, useful for development/testing)
# verbose (many rarely useful info, but not a mess like the debug level)
# notice (moderately verbose, what you want in production probably)
# warning (only very important / critical messages are logged)
loglevel verbose
&nbsp;
# Specify the log file name. Also 'stdout' can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
logfile /var/log/redis/redis.log
&nbsp;
# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# and optionally update the other syslog parameters to suit your needs.
# syslog-enabled no
&nbsp;
# Specify the syslog identity.
# syslog-ident redis
&nbsp;
# Specify the syslog facility.  Must be USER or between LOCAL0-LOCAL7.
# syslog-facility local0
&nbsp;
# Set the number of databases. The default database is DB 0, you can select
# a different one on a per-connection basis using SELECT &lt;dbid&gt; where
# dbid is a number between 0 and 'databases'-1
databases 16
&nbsp;
################################ SNAPSHOTTING  #################################
#
# Save the DB on disk:
#
#   save &lt;seconds&gt; &lt;changes&gt;
#
#   Will save the DB if both the given number of seconds and the given
#   number of write operations against the DB occurred.
#
#   In the example below the behaviour will be to save:
#   after 900 sec (15 min) if at least 1 key changed
#   after 300 sec (5 min) if at least 10 keys changed
#   after 60 sec if at least 10000 keys changed
#
#   Note: you can disable saving at all commenting all the &quot;save&quot; lines.
&nbsp;
save 900 1
save 300 10
save 60 10000
&nbsp;
# Compress string objects using LZF when dump .rdb databases?
# For default that's set to 'yes' as it's almost always a win.
# If you want to save some CPU in the saving child set it to 'no' but
# the dataset will likely be bigger if you have compressible values or keys.
rdbcompression yes
&nbsp;
# The filename where to dump the DB
dbfilename dump.rdb
&nbsp;
# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
# 
# Also the Append Only File will be created inside this directory.
# 
# Note that you must specify a directory here, not a file name.
dir /usr/local/var/db/redis/
&nbsp;
################################# REPLICATION #################################
&nbsp;
# Master-Slave replication. Use slaveof to make a Redis instance a copy of
# another Redis server. Note that the configuration is local to the slave
# so for example it is possible to configure the slave to save the DB with a
# different interval, or to listen to another port, and so on.
#
# slaveof &lt;masterip&gt; &lt;masterport&gt;
&nbsp;
# If the master is password protected (using the &quot;requirepass&quot; configuration
# directive below) it is possible to tell the slave to authenticate before
# starting the replication synchronization process, otherwise the master will
# refuse the slave request.
#
# masterauth &lt;master-password&gt;
&nbsp;
# When a slave lost the connection with the master, or when the replication
# is still in progress, the slave can act in two different ways:
#
# 1) if slave-serve-stale-data is set to 'yes' (the default) the slave will
#    still reply to client requests, possibly with out of data data, or the
#    data set may just be empty if this is the first synchronization.
#
# 2) if slave-serve-stale data is set to 'no' the slave will reply with
#    an error &quot;SYNC with master in progress&quot; to all the kind of commands
#    but to INFO and SLAVEOF.
#
slave-serve-stale-data yes
&nbsp;
# Slaves send PINGs to server in a predefined interval. It's possible to change
# this interval with the repl_ping_slave_period option. The default value is 10
# seconds.
#
# repl-ping-slave-period 10
&nbsp;
# The following option sets a timeout for both Bulk transfer I/O timeout and
# master data or ping response timeout. The default value is 60 seconds.
#
# It is important to make sure that this value is greater than the value
# specified for repl-ping-slave-period otherwise a timeout will be detected
# every time there is low traffic between the master and the slave.
#
# repl-timeout 60
&nbsp;
################################## SECURITY ###################################
&nbsp;
# Require clients to issue AUTH &lt;PASSWORD&gt; before processing any other
# commands.  This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
# 
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
# requirepass foobared
&nbsp;
# Command renaming.
#
# It is possilbe to change the name of dangerous commands in a shared
# environment. For instance the CONFIG command may be renamed into something
# of hard to guess so that it will be still available for internal-use
# tools but not available for general clients.
#
# Example:
#
# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
#
# It is also possilbe to completely kill a command renaming it into
# an empty string:
#
# rename-command CONFIG &quot;&quot;
&nbsp;
################################### LIMITS ####################################
&nbsp;
# Set the max number of connected clients at the same time. By default there
# is no limit, and it's up to the number of file descriptors the Redis process
# is able to open. The special value '0' means no limits.
# Once the limit is reached Redis will close all the new connections sending
# an error 'max number of clients reached'.
#
# maxclients 128
&nbsp;
# Don't use more memory than the specified amount of bytes.
# When the memory limit is reached Redis will try to remove keys
# accordingly to the eviction policy selected (see maxmemmory-policy).
#
# If Redis can't remove keys according to the policy, or if the policy is
# set to 'noeviction', Redis will start to reply with errors to commands
# that would use more memory, like SET, LPUSH, and so on, and will continue
# to reply to read-only commands like GET.
#
# This option is usually useful when using Redis as an LRU cache, or to set
# an hard memory limit for an instance (using the 'noeviction' policy).
#
# WARNING: If you have slaves attached to an instance with maxmemory on,
# the size of the output buffers needed to feed the slaves are subtracted
# from the used memory count, so that network problems / resyncs will
# not trigger a loop where keys are evicted, and in turn the output
# buffer of slaves is full with DELs of keys evicted triggering the deletion
# of more keys, and so forth until the database is completely emptied.
#
# In short... if you have slaves attached it is suggested that you set a lower
# limit for maxmemory so that there is some free RAM on the system for slave
# output buffers (but this is not needed if the policy is 'noeviction').
#
# maxmemory &lt;bytes&gt;
&nbsp;
# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
# is reached? You can select among five behavior:
# 
# volatile-lru -&gt; remove the key with an expire set using an LRU algorithm
# allkeys-lru -&gt; remove any key accordingly to the LRU algorithm
# volatile-random -&gt; remove a random key with an expire set
# allkeys-&gt;random -&gt; remove a random key, any key
# volatile-ttl -&gt; remove the key with the nearest expire time (minor TTL)
# noeviction -&gt; don't expire at all, just return an error on write operations
# 
# Note: with all the kind of policies, Redis will return an error on write
#       operations, when there are not suitable keys for eviction.
#
#       At the date of writing this commands are: set setnx setex append
#       incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
#       sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
#       zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
#       getset mset msetnx exec sort
#
# The default is:
#
# maxmemory-policy volatile-lru
&nbsp;
# LRU and minimal TTL algorithms are not precise algorithms but approximated
# algorithms (in order to save memory), so you can select as well the sample
# size to check. For instance for default Redis will check three keys and
# pick the one that was used less recently, you can change the sample size
# using the following configuration directive.
#
# maxmemory-samples 3
&nbsp;
############################## APPEND ONLY MODE ###############################
&nbsp;
# By default Redis asynchronously dumps the dataset on disk. If you can live
# with the idea that the latest records will be lost if something like a crash
# happens this is the preferred way to run Redis. If instead you care a lot
# about your data and don't want to that a single record can get lost you should
# enable the append only mode: when this mode is enabled Redis will append
# every write operation received in the file appendonly.aof. This file will
# be read on startup in order to rebuild the full dataset in memory.
#
# Note that you can have both the async dumps and the append only file if you
# like (you have to comment the &quot;save&quot; statements above to disable the dumps).
# Still if append only mode is enabled Redis will load the data from the
# log file at startup ignoring the dump.rdb file.
#
# IMPORTANT: Check the BGREWRITEAOF to check how to rewrite the append
# log file in background when it gets too big.
&nbsp;
appendonly no
&nbsp;
# The name of the append only file (default: &quot;appendonly.aof&quot;)
# appendfilename appendonly.aof
&nbsp;
# The fsync() call tells the Operating System to actually write data on disk
# instead to wait for more data in the output buffer. Some OS will really flush 
# data on disk, some other OS will just try to do it ASAP.
#
# Redis supports three different modes:
#
# no: don't fsync, just let the OS flush the data when it wants. Faster.
# always: fsync after every write to the append only log . Slow, Safest.
# everysec: fsync only if one second passed since the last fsync. Compromise.
#
# The default is &quot;everysec&quot; that's usually the right compromise between
# speed and data safety. It's up to you to understand if you can relax this to
# &quot;no&quot; that will will let the operating system flush the output buffer when
# it wants, for better performances (but if you can live with the idea of
# some data loss consider the default persistence mode that's snapshotting),
# or on the contrary, use &quot;always&quot; that's very slow but a bit safer than
# everysec.
#
# If unsure, use &quot;everysec&quot;.
&nbsp;
# appendfsync always
appendfsync everysec
# appendfsync no
&nbsp;
# When the AOF fsync policy is set to always or everysec, and a background
# saving process (a background save or AOF log background rewriting) is
# performing a lot of I/O against the disk, in some Linux configurations
# Redis may block too long on the fsync() call. Note that there is no fix for
# this currently, as even performing fsync in a different thread will block
# our synchronous write(2) call.
#
# In order to mitigate this problem it's possible to use the following option
# that will prevent fsync() from being called in the main process while a
# BGSAVE or BGREWRITEAOF is in progress.
#
# This means that while another child is saving the durability of Redis is
# the same as &quot;appendfsync none&quot;, that in pratical terms means that it is
# possible to lost up to 30 seconds of log in the worst scenario (with the
# default Linux settings).
# 
# If you have latency problems turn this to &quot;yes&quot;. Otherwise leave it as
# &quot;no&quot; that is the safest pick from the point of view of durability.
no-appendfsync-on-rewrite no
&nbsp;
# Automatic rewrite of the append only file.
# Redis is able to automatically rewrite the log file implicitly calling
# BGREWRITEAOF when the AOF log size will growth by the specified percentage.
# 
# This is how it works: Redis remembers the size of the AOF file after the
# latest rewrite (or if no rewrite happened since the restart, the size of
# the AOF at startup is used).
#
# This base size is compared to the current size. If the current size is
# bigger than the specified percentage, the rewrite is triggered. Also
# you need to specify a minimal size for the AOF file to be rewritten, this
# is useful to avoid rewriting the AOF file even if the percentage increase
# is reached but it is still pretty small.
#
# Specify a precentage of zero in order to disable the automatic AOF
# rewrite feature.
&nbsp;
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
&nbsp;
################################## SLOW LOG ###################################
&nbsp;
# The Redis Slow Log is a system to log queries that exceeded a specified
# execution time. The execution time does not include the I/O operations
# like talking with the client, sending the reply and so forth,
# but just the time needed to actually execute the command (this is the only
# stage of command execution where the thread is blocked and can not serve
# other requests in the meantime).
# 
# You can configure the slow log with two parameters: one tells Redis
# what is the execution time, in microseconds, to exceed in order for the
# command to get logged, and the other parameter is the length of the
# slow log. When a new command is logged the oldest one is removed from the
# queue of logged commands.
&nbsp;
# The following time is expressed in microseconds, so 1000000 is equivalent
# to one second. Note that a negative number disables the slow log, while
# a value of zero forces the logging of every command.
slowlog-log-slower-than 10000
&nbsp;
# There is no limit to this length. Just be aware that it will consume memory.
# You can reclaim memory used by the slow log with SLOWLOG RESET.
slowlog-max-len 1024
&nbsp;
################################ VIRTUAL MEMORY ###############################
&nbsp;
### WARNING! Virtual Memory is deprecated in Redis 2.4
### The use of Virtual Memory is strongly discouraged.
&nbsp;
# Virtual Memory allows Redis to work with datasets bigger than the actual
# amount of RAM needed to hold the whole dataset in memory.
# In order to do so very used keys are taken in memory while the other keys
# are swapped into a swap file, similarly to what operating systems do
# with memory pages.
#
# To enable VM just set 'vm-enabled' to yes, and set the following three
# VM parameters accordingly to your needs.
&nbsp;
vm-enabled no
# vm-enabled yes
&nbsp;
# This is the path of the Redis swap file. As you can guess, swap files
# can't be shared by different Redis instances, so make sure to use a swap
# file for every redis process you are running. Redis will complain if the
# swap file is already in use.
#
# The best kind of storage for the Redis swap file (that's accessed at random) 
# is a Solid State Disk (SSD).
#
# *** WARNING *** if you are using a shared hosting the default of putting
# the swap file under /tmp is not secure. Create a dir with access granted
# only to Redis user and configure Redis to create the swap file there.
vm-swap-file /tmp/redis.swap
&nbsp;
# vm-max-memory configures the VM to use at max the specified amount of
# RAM. Everything that deos not fit will be swapped on disk *if* possible, that
# is, if there is still enough contiguous space in the swap file.
#
# With vm-max-memory 0 the system will swap everything it can. Not a good
# default, just specify the max amount of RAM you can in bytes, but it's
# better to leave some margin. For instance specify an amount of RAM
# that's more or less between 60 and 80% of your free RAM.
vm-max-memory 0
&nbsp;
# Redis swap files is split into pages. An object can be saved using multiple
# contiguous pages, but pages can't be shared between different objects.
# So if your page is too big, small objects swapped out on disk will waste
# a lot of space. If you page is too small, there is less space in the swap
# file (assuming you configured the same number of total swap file pages).
#
# If you use a lot of small objects, use a page size of 64 or 32 bytes.
# If you use a lot of big objects, use a bigger page size.
# If unsure, use the default :)
vm-page-size 32
&nbsp;
# Number of total memory pages in the swap file.
# Given that the page table (a bitmap of free/used pages) is taken in memory,
# every 8 pages on disk will consume 1 byte of RAM.
#
# The total swap size is vm-page-size * vm-pages
#
# With the default of 32-bytes memory pages and 134217728 pages Redis will
# use a 4 GB swap file, that will use 16 MB of RAM for the page table.
#
# It's better to use the smallest acceptable value for your application,
# but the default is large in order to work in most conditions.
vm-pages 134217728
&nbsp;
# Max number of VM I/O threads running at the same time.
# This threads are used to read/write data from/to swap file, since they
# also encode and decode objects from disk to memory or the reverse, a bigger
# number of threads can help with big objects even if they can't help with
# I/O itself as the physical device may not be able to couple with many
# reads/writes operations at the same time.
#
# The special value of 0 turn off threaded I/O and enables the blocking
# Virtual Memory implementation.
vm-max-threads 4
&nbsp;
############################### ADVANCED CONFIG ###############################
&nbsp;
# Hashes are encoded in a special way (much more memory efficient) when they
# have at max a given numer of elements, and the biggest element does not
# exceed a given threshold. You can configure this limits with the following
# configuration directives.
hash-max-zipmap-entries 512
hash-max-zipmap-value 64
&nbsp;
# Similarly to hashes, small lists are also encoded in a special way in order
# to save a lot of space. The special representation is only used when
# you are under the following limits:
list-max-ziplist-entries 512
list-max-ziplist-value 64
&nbsp;
# Sets have a special encoding in just one case: when a set is composed
# of just strings that happens to be integers in radix 10 in the range
# of 64 bit signed integers.
# The following configuration setting sets the limit in the size of the
# set in order to use this special memory saving encoding.
set-max-intset-entries 512
&nbsp;
# Similarly to hashes and lists, sorted sets are also specially encoded in
# order to save a lot of space. This encoding is only used when the length and
# elements of a sorted set are below the following limits:
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
&nbsp;
# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
# order to help rehashing the main Redis hash table (the one mapping top-level
# keys to values). The hash table implementation redis uses (see dict.c)
# performs a lazy rehashing: the more operation you run into an hash table
# that is rhashing, the more rehashing &quot;steps&quot; are performed, so if the
# server is idle the rehashing is never complete and some more memory is used
# by the hash table.
# 
# The default is to use this millisecond 10 times every second in order to
# active rehashing the main dictionaries, freeing memory when possible.
#
# If unsure:
# use &quot;activerehashing no&quot; if you have hard latency requirements and it is
# not a good thing in your environment that Redis can reply form time to time
# to queries with 2 milliseconds delay.
#
# use &quot;activerehashing yes&quot; if you don't have such hard requirements but
# want to free memory asap when possible.
activerehashing yes
&nbsp;
################################## INCLUDES ###################################
&nbsp;
# Include one or more other config files here.  This is useful if you
# have a standard template that goes to all redis server but also need
# to customize a few per-server settings.  Include files can include
# other files, so use this wisely.
#
# include /path/to/local.conf
# include /path/to/other.conf</pre></td></tr></table></div>

<h3>效能實測</h3>
<p>redis 內建效能測試工具。<br />
使用 redis-benchmark -n 100000<br />
以兩台機器比較:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
</pre></td><td class="code"><pre class="txt" style="font-family:monospace;">Mac MacBookPro 15:
處理器  2 GHz Intel Core i7
記憶體  8 GB 1333 MHz DDR3
FreeeBSD server:
Intel Core i7 920
記憶體  24 GB 1333 MHz DDR3
==============================================================================
                                        |            FreeBSD|             MAC|
==============================================================================
PING (inline)                           |          129533.68|        84245.99|
PING                                    |           93896.71|        97276.27|
MSET (10 keys)                          |           68446.27|        44822.95|
SET                                     |           92336.11|        68965.52|
GET                                     |           97847.36|        76335.88|
INCR                                    |           92592.59|        80385.85|
LPUSH                                   |           96061.48|        82101.80|
LPOP                                    |           95877.28|        81900.09|
SADD                                    |           97847.36|        71428.57|
SPOP                                    |          101729.40|        75757.57|
LPUSH (again, in order to bench LRANGE) |           90991.81|        66666.66|
LRANGE (first 100 elements)             |           42176.30|        27739.25|
LRANGE (first 300 elements)             |           15708.45|         8773.47|
LRANGE (first 450 elements)             |           10504.20|         5307.01|
LRANGE (first 600 elements)             |            9451.80|         3939.33|
==============================================================================
                                        |                requests per second |
==============================================================================</pre></td></tr></table></div>

<h3>總結</h3>
<p>Redis 因為其運作以記憶體為,真的好快!!每秒10萬次請求都不是問題,又可以保有資料.<br />
以實測來說兩台效能不致於差上兩倍但是RAM大小卻在大量的key更新存取有明顯不同.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sd.idv.tw/archives/547/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FreeBSD 9.0 架設安裝 redmine</title>
		<link>http://blog.sd.idv.tw/archives/543</link>
		<comments>http://blog.sd.idv.tw/archives/543#comments</comments>
		<pubDate>Sat, 18 Feb 2012 02:53:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[FreeBSD]]></category>

		<guid isPermaLink="false">http://blog.sd.idv.tw/?p=543</guid>
		<description><![CDATA[之前有介紹過FreeBSD 架設 redmine. 不過現在因為版本關係不相容,以無法使用. $ cd /usr/ports/www/redmine $ make install clean ===&#38;gt; redmine-1.3.1 is marked as broken: Does not work with RubyGems 1.8. *** Error code 1 &#160; Stop in /usr/ports/www/redmine. $ 現在來介紹一下如何手動安裝. 1. 首先先裝好 Ruby 1.9 與所需要相關套件 1 2 3 4 5 6 7 8 9 10 $ echo &#34;RUBY_VERSION=1.9.3&#34; &#62;&#62; /etc/make.conf $ cd [...]]]></description>
			<content:encoded><![CDATA[<p>之前有介紹過<a href="http://blog.sd.idv.tw/archives/416" target="_blank">FreeBSD 架設 redmine</a>.<br />
不過現在因為版本關係不相容,以無法使用.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>redmine
$ <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span> clean
===<span style="color: #000000; font-weight: bold;">&amp;</span>gt;  redmine-1.3.1 is marked <span style="color: #c20cb9; font-weight: bold;">as</span> broken: Does not work with RubyGems <span style="color: #000000;">1.8</span>.
<span style="color: #000000; font-weight: bold;">***</span> Error code <span style="color: #000000;">1</span>
&nbsp;
Stop <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>redmine.
$</pre></div></div>

<p><span id="more-543"></span><br />
現在來介紹一下如何手動安裝.</p>
<h2>1. 首先先裝好 Ruby 1.9 與所需要相關套件</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;RUBY_VERSION=1.9.3&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
$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>lang<span style="color: #000000; font-weight: bold;">/</span>ruby19
$ <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span> clean
$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>devel<span style="color: #000000; font-weight: bold;">/</span>ruby-gems
$ <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span> clean
$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>converters<span style="color: #000000; font-weight: bold;">/</span>ruby-iconv
$ <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span> clean
$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>ports<span style="color: #000000; font-weight: bold;">/</span>databases<span style="color: #000000; font-weight: bold;">/</span>ruby-mysql
$ <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span> clean
$ gem19 <span style="color: #c20cb9; font-weight: bold;">install</span> rails <span style="color: #660033;">--version</span>=2.3.14</pre></td></tr></table></div>

<h2>2. 拉Redmine最新版本 來安裝</h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td 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>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span> 
$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>
$ <span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">co</span> http:<span style="color: #000000; font-weight: bold;">//</span>redmine.rubyforge.org<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>trunk redmine
$ <span style="color: #7a0874; font-weight: bold;">cd</span> redmine
&nbsp;
<span style="color: #666666; font-style: italic;"># 拷貝設定檔 設定</span>
$ <span style="color: #c20cb9; font-weight: bold;">cp</span> config<span style="color: #000000; font-weight: bold;">/</span>configuration.yml.example config<span style="color: #000000; font-weight: bold;">/</span>configuration.yml
$ <span style="color: #c20cb9; font-weight: bold;">cp</span> config<span style="color: #000000; font-weight: bold;">/</span>database.yml.example config<span style="color: #000000; font-weight: bold;">/</span>database.yml
&nbsp;
<span style="color: #666666; font-style: italic;"># 編輯好相關設定</span>
$ <span style="color: #c20cb9; font-weight: bold;">vi</span> config<span style="color: #000000; font-weight: bold;">/</span>configuration.yml
$ <span style="color: #c20cb9; font-weight: bold;">vi</span> config<span style="color: #000000; font-weight: bold;">/</span>database.yml
&nbsp;
<span style="color: #666666; font-style: italic;"># 產生 session store secret.</span>
$ rake generate_session_store
&nbsp;
<span style="color: #666666; font-style: italic;"># 產生 populate database 資料庫</span>
$ rake db:migrate <span style="color: #007800;">RAILS_ENV</span>=production
$ rake redmine:load_default_data <span style="color: #007800;">RAILS_ENV</span>=production
&nbsp;
<span style="color: #666666; font-style: italic;"># 建立獨立使用者</span>
$ pw groupadd <span style="color: #660033;">-n</span> redmine <span style="color: #660033;">-g</span> <span style="color: #000000;">3000</span>
$ pw useradd <span style="color: #660033;">-n</span> redmine <span style="color: #660033;">-u</span> <span style="color: #000000;">3000</span> <span style="color: #660033;">-g</span> <span style="color: #000000;">3000</span> <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>local<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>redmine <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #660033;">-h</span> -
&nbsp;
<span style="color: #666666; font-style: italic;"># 修改好目錄權限</span>
$ <span style="color: #c20cb9; font-weight: bold;">mkdir</span> tmp public<span style="color: #000000; font-weight: bold;">/</span>plugin_assets
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> redmine:redmine files log tmp public<span style="color: #000000; font-weight: bold;">/</span>plugin_assets
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #660033;">-R</span> <span style="color: #000000;">755</span> files log tmp public<span style="color: #000000; font-weight: bold;">/</span>plugin_assets
&nbsp;
<span style="color: #666666; font-style: italic;"># Login as Redmine user</span>
$ <span style="color: #c20cb9; font-weight: bold;">su</span> - redmine
&nbsp;
<span style="color: #666666; font-style: italic;"># 啟動</span>
$ ruby19 script<span style="color: #000000; font-weight: bold;">/</span>server webrick <span style="color: #660033;">-e</span> production</pre></td></tr></table></div>

<h2>NGINX 設定 </h2>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="code"><pre class="ini" style="font-family:monospace;">upstream mongrel <span style="">&#123;</span>
    server 127.0.0.1:<span style="">3000</span><span style="color: #666666; font-style: italic;">;</span>
<span style="">&#125;</span>
server <span style="">&#123;</span>
    listen          <span style="">80</span><span style="color: #666666; font-style: italic;">;</span>
    server_name     redmine.test<span style="color: #666666; font-style: italic;">;</span>
&nbsp;
    root /usr/local/www/redmine/public<span style="color: #666666; font-style: italic;">;</span>
&nbsp;
        location / <span style="">&#123;</span>
            proxy_set_header  X-Real-IP  $remote_addr<span style="color: #666666; font-style: italic;">;</span>
            proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for<span style="color: #666666; font-style: italic;">;</span>
            proxy_set_header  Host $http_host<span style="color: #666666; font-style: italic;">;</span>
            proxy_redirect off<span style="color: #666666; font-style: italic;">;</span>
            proxy_read_timeout <span style="">30</span><span style="color: #666666; font-style: italic;">;</span>
&nbsp;
                if <span style="">&#40;</span>-f $request_filename/index.html<span style="">&#41;</span> <span style="">&#123;</span>
                    rewrite <span style="">&#40;</span>.*<span style="">&#41;</span> $1/index.html break<span style="color: #666666; font-style: italic;">;</span>
                <span style="">&#125;</span>
&nbsp;
                if <span style="">&#40;</span>-f $request_filename.html<span style="">&#41;</span> <span style="">&#123;</span>
                    rewrite <span style="">&#40;</span>.*<span style="">&#41;</span> $1.html break<span style="color: #666666; font-style: italic;">;</span>
                <span style="">&#125;</span>
&nbsp;
                if <span style="">&#40;</span>-f $request_filename.txt<span style="">&#41;</span> <span style="">&#123;</span>
                    rewrite <span style="">&#40;</span>.*<span style="">&#41;</span> $1.txt break<span style="color: #666666; font-style: italic;">;</span>
                <span style="">&#125;</span>
&nbsp;
                proxy_pass http://mongrel/<span style="color: #666666; font-style: italic;">;</span>
        <span style="">&#125;</span>
<span style="">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.sd.idv.tw/archives/543/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FuelPHP FrameWork 進入！ Enter~~</title>
		<link>http://blog.sd.idv.tw/archives/529</link>
		<comments>http://blog.sd.idv.tw/archives/529#comments</comments>
		<pubDate>Thu, 05 Jan 2012 08:40:23 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP & MYSQL]]></category>
		<category><![CDATA[FuelPHP FrameWork]]></category>

		<guid isPermaLink="false">http://blog.sd.idv.tw/?p=529</guid>
		<description><![CDATA[安裝之前有說過哩:請參考 FuelPHP FrameWork 初體驗～～ 之前說過 作者將APP 整個包在FrameWork 內的蠢話. 我可以不承認嗎XDD 其實算是給開發人員快速進入,實作體驗FrameWork用的. 如果要自行快速分離請先參考 同事強做:【程式筆記】建立一個FuelPHP的應用程式Git Repository 如果這樣不能滿足你,接下來江示範如何調整. 以下範例: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 [...]]]></description>
			<content:encoded><![CDATA[<p>安裝之前有說過哩:請參考 <a href="http://blog.sd.idv.tw/archives/520" target="_blank">FuelPHP FrameWork 初體驗～～</a><br />
之前說過 <del><strong>作者將APP 整個包在FrameWork</strong></del> 內的蠢話.<del> 我可以不承認嗎XDD</del><br />
其實算是給開發人員快速進入,實作體驗FrameWork用的.<br />
如果要自行快速分離請先參考 同事強做:<a href="http://blog.ycnets.com/2012/01/fuelphpgit-repository.html" target="_blank">【程式筆記】建立一個FuelPHP的應用程式Git Repository</a> </p>
<p>如果這樣不能滿足你,接下來江示範如何調整.<br />
<span id="more-529"></span><br />
以下範例:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#建立專案 FuelPower</span>
$ oil create FuelPower
Cloning into .<span style="color: #000000; font-weight: bold;">/</span>FuelPower...
remote: Counting objects: <span style="color: #000000;">14163</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">4889</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">4889</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">14163</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">9659</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">13347</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">9042</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Receiving objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">14163</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">14163</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">2.09</span> MiB <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">281</span> KiB<span style="color: #000000; font-weight: bold;">/</span>s, done.
Resolving deltas: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">9659</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">9659</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Submodule <span style="color: #ff0000;">'docs'</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>docs.git<span style="color: #7a0874; font-weight: bold;">&#41;</span> registered <span style="color: #000000; font-weight: bold;">for</span> path <span style="color: #ff0000;">'docs'</span>
Submodule <span style="color: #ff0000;">'fuel/core'</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>core.git<span style="color: #7a0874; font-weight: bold;">&#41;</span> registered <span style="color: #000000; font-weight: bold;">for</span> path <span style="color: #ff0000;">'fuel/core'</span>
Submodule <span style="color: #ff0000;">'fuel/packages/auth'</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>auth.git<span style="color: #7a0874; font-weight: bold;">&#41;</span> registered <span style="color: #000000; font-weight: bold;">for</span> path <span style="color: #ff0000;">'fuel/packages/auth'</span>
Submodule <span style="color: #ff0000;">'fuel/packages/email'</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>email.git<span style="color: #7a0874; font-weight: bold;">&#41;</span> registered <span style="color: #000000; font-weight: bold;">for</span> path <span style="color: #ff0000;">'fuel/packages/email'</span>
Submodule <span style="color: #ff0000;">'fuel/packages/oil'</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>oil.git<span style="color: #7a0874; font-weight: bold;">&#41;</span> registered <span style="color: #000000; font-weight: bold;">for</span> path <span style="color: #ff0000;">'fuel/packages/oil'</span>
Submodule <span style="color: #ff0000;">'fuel/packages/orm'</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>orm.git<span style="color: #7a0874; font-weight: bold;">&#41;</span> registered <span style="color: #000000; font-weight: bold;">for</span> path <span style="color: #ff0000;">'fuel/packages/orm'</span>
Submodule <span style="color: #ff0000;">'fuel/packages/parser'</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>parser.git<span style="color: #7a0874; font-weight: bold;">&#41;</span> registered <span style="color: #000000; font-weight: bold;">for</span> path <span style="color: #ff0000;">'fuel/packages/parser'</span>
Cloning into docs...
remote: Counting objects: <span style="color: #000000;">5552</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1903</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1903</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">5552</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">3710</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">5350</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">3546</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Receiving objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">5552</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5552</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">1.73</span> MiB <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">281</span> KiB<span style="color: #000000; font-weight: bold;">/</span>s, done.
Resolving deltas: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3710</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">3710</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Submodule path <span style="color: #ff0000;">'docs'</span>: checked out <span style="color: #ff0000;">'f3746d4fcda2dc12d7f1120d55c17f3b52c0550e'</span>
Cloning into fuel<span style="color: #000000; font-weight: bold;">/</span>core...
remote: Counting objects: <span style="color: #000000;">20958</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">6266</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">6266</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">20958</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">14615</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">20579</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">14278</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Receiving objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">20958</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">20958</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">3.25</span> MiB <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">283</span> KiB<span style="color: #000000; font-weight: bold;">/</span>s, done.
Resolving deltas: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">14615</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">14615</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Submodule path <span style="color: #ff0000;">'fuel/core'</span>: checked out <span style="color: #ff0000;">'d95fbfec3fe2f791fead4eeb9a37fcd631009479'</span>
Cloning into fuel<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span>auth...
remote: Counting objects: <span style="color: #000000;">541</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">384</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">384</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">541</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">240</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">453</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">157</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Receiving objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">541</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">541</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">67.77</span> KiB <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">76</span> KiB<span style="color: #000000; font-weight: bold;">/</span>s, done.
Resolving deltas: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">240</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">240</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Submodule path <span style="color: #ff0000;">'fuel/packages/auth'</span>: checked out <span style="color: #ff0000;">'7a2c479263f768b6de8bffe43b1bd00fd2bbdd6d'</span>
Cloning into fuel<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span>email...
remote: Counting objects: <span style="color: #000000;">273</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">157</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">157</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">273</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">114</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">268</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">109</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Receiving objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">273</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">273</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">42.33</span> KiB, done.
Resolving deltas: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">114</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">114</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Submodule path <span style="color: #ff0000;">'fuel/packages/email'</span>: checked out <span style="color: #ff0000;">'0113f3c6596e5b3b97408607ddc033e3a7dc833a'</span>
Cloning into fuel<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span>oil...
remote: Counting objects: <span style="color: #000000;">896</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">393</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">393</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">896</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">510</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">849</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">471</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Receiving objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">896</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">896</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">117.05</span> KiB <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">134</span> KiB<span style="color: #000000; font-weight: bold;">/</span>s, done.
Resolving deltas: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">510</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">510</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Submodule path <span style="color: #ff0000;">'fuel/packages/oil'</span>: checked out <span style="color: #ff0000;">'da74ddc023871ef54a93fdcc541cbf2db95b73f3'</span>
Cloning into fuel<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span>orm...
remote: Counting objects: <span style="color: #000000;">14408</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">4310</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">4310</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">14408</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">9975</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">14305</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">9877</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Receiving objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">14408</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">14408</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">2.07</span> MiB <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">274</span> KiB<span style="color: #000000; font-weight: bold;">/</span>s, done.
Resolving deltas: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">9975</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">9975</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Submodule path <span style="color: #ff0000;">'fuel/packages/orm'</span>: checked out <span style="color: #ff0000;">'ad18b80efcc712e02143a14d6e0902aab25da475'</span>
Cloning into fuel<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span>parser...
remote: Counting objects: <span style="color: #000000;">603</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">303</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">303</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">603</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">285</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">571</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">254</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Receiving objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">603</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">603</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">113.31</span> KiB <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">137</span> KiB<span style="color: #000000; font-weight: bold;">/</span>s, done.
Resolving deltas: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">285</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">285</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Submodule path <span style="color: #ff0000;">'fuel/packages/parser'</span>: checked out <span style="color: #ff0000;">'836c1ad77e631d47839630f3fa79b9dddc0b8091'</span>
	Made writable: <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>luosteve<span style="color: #000000; font-weight: bold;">/</span>FuelPower<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>cache
	Made writable: <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>luosteve<span style="color: #000000; font-weight: bold;">/</span>FuelPower<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>logs
	Made writable: <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>luosteve<span style="color: #000000; font-weight: bold;">/</span>FuelPower<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>tmp
	Made writable: <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>luosteve<span style="color: #000000; font-weight: bold;">/</span>FuelPower<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>config
$ <span style="color: #7a0874; font-weight: bold;">cd</span> ~<span style="color: #000000; font-weight: bold;">/</span>FuelPower
<span style="color: #666666; font-style: italic;">#移除git 資料</span>
$ <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #660033;">-rf</span> .git<span style="color: #000000; font-weight: bold;">*</span>
$ <span style="color: #c20cb9; font-weight: bold;">git</span> init
<span style="color: #666666; font-style: italic;">#接著要取捨submodule的部份，將需要的加進去</span>
<span style="color: #666666; font-style: italic;">#不需要的部份請依路徑刪除，如orm、auth</span>
$ <span style="color: #c20cb9; font-weight: bold;">git</span> submodule add <span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>core.git fuel<span style="color: #000000; font-weight: bold;">/</span>core
$ <span style="color: #c20cb9; font-weight: bold;">git</span> submodule add <span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>oil.git fuel<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span>oil
$ <span style="color: #c20cb9; font-weight: bold;">git</span> submodule add <span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>parser.git fuel<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span>parser
$ <span style="color: #c20cb9; font-weight: bold;">git</span> submodule add <span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>email.git fuel<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span>email
$ <span style="color: #c20cb9; font-weight: bold;">git</span> submodule add <span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>orm.git fuel<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span>orm
$ <span style="color: #c20cb9; font-weight: bold;">git</span> submodule add <span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>auth.git fuel<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span>auth
&nbsp;
<span style="color: #666666; font-style: italic;">#全部submodule一起切換版本的大絕，目前是1.1版</span>
$ <span style="color: #c20cb9; font-weight: bold;">git</span> submodule foreach <span style="color: #c20cb9; font-weight: bold;">git</span> checkout origin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1.1</span><span style="color: #000000; font-weight: bold;">/</span>master
$ 
&nbsp;
&nbsp;
設定.gitignore
<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: #007800;">line</span>=<span style="color: #ff0000;">&quot;1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span>
<span style="color: #000000; font-weight: bold;">*</span>~
<span style="color: #000000; font-weight: bold;">*</span>.bak
<span style="color: #000000; font-weight: bold;">*</span>.log
Thumbs.db
desktop.ini
.DS_Store
.buildpath
.project
.settings
.tmpoj
logs<span style="color: #000000; font-weight: bold;">/*</span>
cache<span style="color: #000000; font-weight: bold;">/*</span>
tmp<span style="color: #000000; font-weight: bold;">/*</span>
build
nbproject<span style="color: #000000; font-weight: bold;">/</span>
.idea
app<span style="color: #000000; font-weight: bold;">/</span>config<span style="color: #000000; font-weight: bold;">/</span>crypt.php</pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> fuel
$ <span style="color: #c20cb9; font-weight: bold;">mv</span> app ..<span style="color: #000000; font-weight: bold;">/</span></pre></td></tr></table></div>

<p>編輯public/index.php</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPPATH'</span><span style="color: #339933;">,</span> <span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span>__DIR__<span style="color: #339933;">.</span><span style="color: #0000ff;">'/../fuel/app/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//改為</span>
<span style="color: #990000;">define</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'APPPATH'</span><span style="color: #339933;">,</span> <span style="color: #990000;">realpath</span><span style="color: #009900;">&#40;</span>__DIR__<span style="color: #339933;">.</span><span style="color: #0000ff;">'/../app/'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> ..<span style="color: #000000; font-weight: bold;">/</span>
$ <span style="color: #7a0874; font-weight: bold;">cd</span> app
$ <span style="color: #c20cb9; font-weight: bold;">mv</span> cache ..<span style="color: #000000; font-weight: bold;">/</span>
$ <span style="color: #c20cb9; font-weight: bold;">mv</span> tmp ..<span style="color: #000000; font-weight: bold;">/</span>
$ <span style="color: #c20cb9; font-weight: bold;">mv</span> log ..<span style="color: #000000; font-weight: bold;">/</span>
$ <span style="color: #c20cb9; font-weight: bold;">git</span> add .
$ <span style="color: #c20cb9; font-weight: bold;">git</span> commint <span style="color: #660033;">-m</span> <span style="color: #ff0000;">'init project'</span></pre></td></tr></table></div>

<p>完成後看起來是這樣.<br />
<a href="http://blog.sd.idv.tw/wp-content/uploads/2012/01/螢幕快照-2012-01-05-下午4.37.46.png"><img src="http://blog.sd.idv.tw/wp-content/uploads/2012/01/螢幕快照-2012-01-05-下午4.37.46-173x300.png" alt="" title="螢幕快照 2012-01-05 下午4.37.46" width="173" height="300" class="alignnone size-medium wp-image-540" /></a><br />
剩下 build.xml 還不會調整.<br />
<del>剛進去不要太急</dev></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sd.idv.tw/archives/529/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FuelPHP FrameWork 初體驗～～</title>
		<link>http://blog.sd.idv.tw/archives/520</link>
		<comments>http://blog.sd.idv.tw/archives/520#comments</comments>
		<pubDate>Tue, 27 Dec 2011 08:29:25 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP & MYSQL]]></category>

		<guid isPermaLink="false">http://blog.sd.idv.tw/?p=520</guid>
		<description><![CDATA[FuelPHP is a simple, flexible, community driven PHP 5.3 web framework based on the best ideas of other frameworks with a fresh start. FuelPHP 衝著他以php 5.3 並以namespace 方式開發,輕量化FrameWork趕快來試用看看吧. 安裝 安裝方式不免俗來了,快速按裝.(不錯唷) 1 2 3 4 5 6 7 $ curl get.fuelphp.com/oil &#124; sh % Total % Received % Xferd Average Speed Time Time Time Current Dload [...]]]></description>
			<content:encoded><![CDATA[<p><strong><a href="http://fuelphp.com/">FuelPHP</a> is a simple, flexible, community driven PHP 5.3 web framework based on the best ideas of other frameworks with a fresh start.</strong><br />
FuelPHP 衝著他以php 5.3 並以namespace 方式開發,輕量化FrameWork趕快來試用看看吧.</p>
<h2>安裝</h2>
<p>安裝方式不免俗來了,快速按裝.(不錯唷)</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ curl get.fuelphp.com<span style="color: #000000; font-weight: bold;">/</span>oil <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sh</span>
  <span style="color: #000000; font-weight: bold;">%</span> Total    <span style="color: #000000; font-weight: bold;">%</span> Received <span style="color: #000000; font-weight: bold;">%</span> Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
<span style="color: #000000;">100</span>   <span style="color: #000000;">244</span>  <span style="color: #000000;">100</span>   <span style="color: #000000;">244</span>    <span style="color: #000000;">0</span>     <span style="color: #000000;">0</span>    <span style="color: #000000;">240</span>      <span style="color: #000000;">0</span>  <span style="color: #000000;">0</span>:00:01  <span style="color: #000000;">0</span>:00:01 --:--:--  <span style="color: #000000;">1257</span>
Password:
&nbsp;
$</pre></td></tr></table></div>

<p><span id="more-520"></span><br />
咦捨摸錯誤都沒有噴就是裝好了.<br />
找了一下他裝了啥鬼</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td 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>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>oil
<span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-f</span> <span style="color: #ff0000;">&quot;./oil&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
        php oil <span style="color: #ff0000;">&quot;$@&quot;</span>
<span style="color: #000000; font-weight: bold;">else</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #ff0000;">&quot;$1&quot;</span> == <span style="color: #ff0000;">&quot;create&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
&nbsp;
                    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">which</span> <span style="color: #c20cb9; font-weight: bold;">git</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span>
                         <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;For this installer to work you'll need to install Git.&quot;</span>
                     <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'        http://git-scm.com/'</span>
                    <span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
                <span style="color: #c20cb9; font-weight: bold;">git</span> clone <span style="color: #660033;">--recursive</span> <span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>fuel.git <span style="color: #ff0000;">&quot;./$2&quot;</span>
                php <span style="color: #ff0000;">&quot;./$2/oil&quot;</span> refine <span style="color: #c20cb9; font-weight: bold;">install</span>
        <span style="color: #000000; font-weight: bold;">else</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'This is not a valid Fuel installation so Oil is a bit lost.'</span>
                <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">'        http://fuelphp.com/docs/installation/instructions.html'</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">fi</span></pre></td></tr></table></div>

<p>原來是再下 create 指令時馬上用git拉下來建立好專案.（不錯<br />
例:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ oil create <span style="color: #000000; font-weight: bold;">&lt;</span>project_name<span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span><span style="color: #000000; font-weight: bold;">&gt;</span></pre></td></tr></table></div>

<p>來建一個試試</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ oil create Fuel
Cloning into .<span style="color: #000000; font-weight: bold;">/</span>Fuel…
remote: Counting objects: <span style="color: #000000;">14163</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">4884</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">4884</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">14163</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">9660</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">13351</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">9047</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Receiving objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">14163</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">14163</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">2.07</span> MiB <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">651</span> KiB<span style="color: #000000; font-weight: bold;">/</span>s, done.
Resolving deltas: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">9660</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">9660</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Submodule <span style="color: #ff0000;">'docs'</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>docs.git<span style="color: #7a0874; font-weight: bold;">&#41;</span> registered <span style="color: #000000; font-weight: bold;">for</span> path <span style="color: #ff0000;">'docs'</span>
Submodule <span style="color: #ff0000;">'fuel/core'</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>core.git<span style="color: #7a0874; font-weight: bold;">&#41;</span> registered <span style="color: #000000; font-weight: bold;">for</span> path <span style="color: #ff0000;">'fuel/core'</span>
Submodule <span style="color: #ff0000;">'fuel/packages/auth'</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>auth.git<span style="color: #7a0874; font-weight: bold;">&#41;</span> registered <span style="color: #000000; font-weight: bold;">for</span> path <span style="color: #ff0000;">'fuel/packages/auth'</span>
Submodule <span style="color: #ff0000;">'fuel/packages/email'</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>email.git<span style="color: #7a0874; font-weight: bold;">&#41;</span> registered <span style="color: #000000; font-weight: bold;">for</span> path <span style="color: #ff0000;">'fuel/packages/email'</span>
Submodule <span style="color: #ff0000;">'fuel/packages/oil'</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>oil.git<span style="color: #7a0874; font-weight: bold;">&#41;</span> registered <span style="color: #000000; font-weight: bold;">for</span> path <span style="color: #ff0000;">'fuel/packages/oil'</span>
Submodule <span style="color: #ff0000;">'fuel/packages/orm'</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>orm.git<span style="color: #7a0874; font-weight: bold;">&#41;</span> registered <span style="color: #000000; font-weight: bold;">for</span> path <span style="color: #ff0000;">'fuel/packages/orm'</span>
Submodule <span style="color: #ff0000;">'fuel/packages/parser'</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">git</span>:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>parser.git<span style="color: #7a0874; font-weight: bold;">&#41;</span> registered <span style="color: #000000; font-weight: bold;">for</span> path <span style="color: #ff0000;">'fuel/packages/parser'</span>
Cloning into docs...
remote: Counting objects: <span style="color: #000000;">5478</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1908</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">1908</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">5478</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">3664</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">5251</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">3470</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Receiving objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">5478</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5478</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">1.70</span> MiB <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">757</span> KiB<span style="color: #000000; font-weight: bold;">/</span>s, done.
Resolving deltas: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">3664</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">3664</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Submodule path <span style="color: #ff0000;">'docs'</span>: checked out <span style="color: #ff0000;">'f3746d4fcda2dc12d7f1120d55c17f3b52c0550e'</span>
Cloning into fuel<span style="color: #000000; font-weight: bold;">/</span>core...
remote: Counting objects: <span style="color: #000000;">20779</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">6318</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">6318</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">20779</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">14499</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">20306</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">14065</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Receiving objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">20779</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">20779</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">3.21</span> MiB <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">1.08</span> MiB<span style="color: #000000; font-weight: bold;">/</span>s, done.
Resolving deltas: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">14499</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">14499</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Submodule path <span style="color: #ff0000;">'fuel/core'</span>: checked out <span style="color: #ff0000;">'d95fbfec3fe2f791fead4eeb9a37fcd631009479'</span>
Cloning into fuel<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span>auth...
remote: Counting objects: <span style="color: #000000;">541</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">384</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">384</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">541</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">240</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">453</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">157</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Receiving objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">541</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">541</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">67.77</span> KiB, done.
Resolving deltas: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">240</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">240</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Submodule path <span style="color: #ff0000;">'fuel/packages/auth'</span>: checked out <span style="color: #ff0000;">'7a2c479263f768b6de8bffe43b1bd00fd2bbdd6d'</span>
Cloning into fuel<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span>email...
remote: Counting objects: <span style="color: #000000;">273</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">157</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">157</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">273</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">114</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">268</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">109</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Receiving objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">273</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">273</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">42.33</span> KiB, done.
Resolving deltas: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">114</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">114</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Submodule path <span style="color: #ff0000;">'fuel/packages/email'</span>: checked out <span style="color: #ff0000;">'0113f3c6596e5b3b97408607ddc033e3a7dc833a'</span>
Cloning into fuel<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span>oil...
remote: Counting objects: <span style="color: #000000;">869</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">370</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">370</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">869</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">491</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">837</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">467</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Receiving objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">869</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">869</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">114.39</span> KiB <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">79</span> KiB<span style="color: #000000; font-weight: bold;">/</span>s, done.
Resolving deltas: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">491</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">491</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Submodule path <span style="color: #ff0000;">'fuel/packages/oil'</span>: checked out <span style="color: #ff0000;">'da74ddc023871ef54a93fdcc541cbf2db95b73f3'</span>
Cloning into fuel<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span>orm...
remote: Counting objects: <span style="color: #000000;">14393</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">4295</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">4295</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">14393</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">9963</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">14302</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">9877</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Receiving objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">14393</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">14393</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">2.07</span> MiB <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">863</span> KiB<span style="color: #000000; font-weight: bold;">/</span>s, done.
Resolving deltas: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">9963</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">9963</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Submodule path <span style="color: #ff0000;">'fuel/packages/orm'</span>: checked out <span style="color: #ff0000;">'ad18b80efcc712e02143a14d6e0902aab25da475'</span>
Cloning into fuel<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span>parser...
remote: Counting objects: <span style="color: #000000;">603</span>, done.
remote: Compressing objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">303</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">303</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
remote: Total <span style="color: #000000;">603</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">285</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, reused <span style="color: #000000;">571</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>delta <span style="color: #000000;">254</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Receiving objects: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">603</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">603</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, <span style="color: #000000;">113.31</span> KiB <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">77</span> KiB<span style="color: #000000; font-weight: bold;">/</span>s, done.
Resolving deltas: <span style="color: #000000;">100</span><span style="color: #000000; font-weight: bold;">%</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">285</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">285</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>, done.
Submodule path <span style="color: #ff0000;">'fuel/packages/parser'</span>: checked out <span style="color: #ff0000;">'836c1ad77e631d47839630f3fa79b9dddc0b8091'</span>
     Made writable: <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>luosteve<span style="color: #000000; font-weight: bold;">/</span>Fuel<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>cache
     Made writable: <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>luosteve<span style="color: #000000; font-weight: bold;">/</span>Fuel<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>logs
     Made writable: <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>luosteve<span style="color: #000000; font-weight: bold;">/</span>Fuel<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>tmp
     Made writable: <span style="color: #000000; font-weight: bold;">/</span>Users<span style="color: #000000; font-weight: bold;">/</span>luosteve<span style="color: #000000; font-weight: bold;">/</span>Fuel<span style="color: #000000; font-weight: bold;">/</span>fuel<span style="color: #000000; font-weight: bold;">/</span>app<span style="color: #000000; font-weight: bold;">/</span>config</pre></td></tr></table></div>

<p>來看一下裝好啥.<br />
<a href="http://blog.sd.idv.tw/wp-content/uploads/2011/12/螢幕快照-2011-12-27-下午2.20.29.png"><img src="http://blog.sd.idv.tw/wp-content/uploads/2011/12/螢幕快照-2011-12-27-下午2.20.29-178x300.png" alt="" title="螢幕快照 2011-12-27 下午2.20.29" width="178" height="300" class="alignnone size-medium wp-image-522" /></a></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #7a0874; font-weight: bold;">cd</span> Fuel
$ php oil
&nbsp;
Usage:
  php oil <span style="color: #7a0874; font-weight: bold;">&#91;</span>cells<span style="color: #000000; font-weight: bold;">|</span>console<span style="color: #000000; font-weight: bold;">|</span>generate<span style="color: #000000; font-weight: bold;">|</span>refine<span style="color: #000000; font-weight: bold;">|</span><span style="color: #7a0874; font-weight: bold;">help</span><span style="color: #000000; font-weight: bold;">|</span><span style="color: #7a0874; font-weight: bold;">test</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
&nbsp;
Runtime options:
  -f, <span style="color: #7a0874; font-weight: bold;">&#91;</span>--force<span style="color: #7a0874; font-weight: bold;">&#93;</span>    <span style="color: #666666; font-style: italic;"># Overwrite files that already exist</span>
  -s, <span style="color: #7a0874; font-weight: bold;">&#91;</span>--skip<span style="color: #7a0874; font-weight: bold;">&#93;</span>     <span style="color: #666666; font-style: italic;"># Skip files that already exist</span>
  -q, <span style="color: #7a0874; font-weight: bold;">&#91;</span>--quiet<span style="color: #7a0874; font-weight: bold;">&#93;</span>    <span style="color: #666666; font-style: italic;"># Supress status output</span>
  -t, <span style="color: #7a0874; font-weight: bold;">&#91;</span>--speak<span style="color: #7a0874; font-weight: bold;">&#93;</span>    <span style="color: #666666; font-style: italic;"># Speak errors in a robot voice</span>
&nbsp;
Description:
  The <span style="color: #ff0000;">'oil'</span> <span style="color: #7a0874; font-weight: bold;">command</span> can be used <span style="color: #000000; font-weight: bold;">in</span> several ways to facilitate quick development, <span style="color: #7a0874; font-weight: bold;">help</span> with
  testing your application and <span style="color: #000000; font-weight: bold;">for</span> running Tasks.
&nbsp;
Documentation:
  http:<span style="color: #000000; font-weight: bold;">//</span>docs.fuelphp.com<span style="color: #000000; font-weight: bold;">/</span>packages<span style="color: #000000; font-weight: bold;">/</span>oil<span style="color: #000000; font-weight: bold;">/</span>intro.html</pre></td></tr></table></div>

<p>管他的先上再說！！</p>
<p>來設定一下nginx設定檔</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
</pre></td><td class="code"><pre class="config" style="font-family:monospace;">server {
    listen 127.0.0.1:80;
    server_name fuel;
    access_log /Users/luosteve/Fuel/fuel/app/logs/fuel.access.log;
    error_log  /Users/luosteve/Fuel/fuel/app/logs/fuel.error.log;
    root /Users/luosteve/Fuel/public;
&nbsp;
    location / {
        root   /Users/luosteve/Fuel/public;
        index  index.php index.html index.htm;
        if (!-e $request_filename) {
            rewrite ^.*$ /index.php last;
            break;
        }
    }
    location ~ \.php$ {
      fastcgi_pass   127.0.0.1:9000;
      fastcgi_index  index.php;
      fastcgi_param  SCRIPT_FILENAME  /Users/luosteve/Fuel/public$fastcgi_script_name;
      include        fastcgi_params;
    }
    location ~ /\.ht {
            deny  all;
    }
}</pre></td></tr></table></div>

<p>好了重起nginx 並瀏覽 http://fuel/<br />
！！！登登 出現啦<br />
<a href="http://blog.sd.idv.tw/wp-content/uploads/2011/12/螢幕快照-2011-12-27-下午3.32.45.png"><img src="http://blog.sd.idv.tw/wp-content/uploads/2011/12/螢幕快照-2011-12-27-下午3.32.45-300x209.png" alt="" title="螢幕快照 2011-12-27 下午3.32.45" width="300" height="209" class="alignnone size-medium wp-image-525" /></a></p>
<p>畫面也有說明 此controller 是 APPPATH/classes/controller/welcome.php<br />
view 再 APPPATH/views/welcome/index.php<br />
APPPATH此範例是存在/Users/luosteve/Fuel/fuel/app/<br />
再這裡要說明一下,作者將APP 整個包在FrameWork內實在是很頭痛作法.當你自行開發更改專案時,<br />
如果此時有FrameWork有更新 你只能以rebase 方式做更新,好死不死哪天又有衝突你每次更新就在那<br />
解衝突（整個就飽了,不用做事了）.<br />
其實一開始看到此架構就先倒退三尺XDD.</p>
<p>有興趣可以先看看config設定吧(咦?!是php 檔案唷）<br />
fuel/app/config/config.php<br />
內文就不看啦,各種設定值請<a href="http://docs.fuelphp.com/general/configuration.html">參考</a>.<br />
就醬而已sorry.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sd.idv.tw/archives/520/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ZFS on MAC OSX</title>
		<link>http://blog.sd.idv.tw/archives/513</link>
		<comments>http://blog.sd.idv.tw/archives/513#comments</comments>
		<pubDate>Wed, 23 Nov 2011 12:04:02 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Mac OSX]]></category>
		<category><![CDATA[MAC OSX]]></category>

		<guid isPermaLink="false">http://blog.sd.idv.tw/?p=513</guid>
		<description><![CDATA[ZFS 是很好檔案系統,可惜因為種種原因&#8230;沒有機會在OSX 上面使用. MACZFS 是好心人porting到MAC OSX上面,只要下載安裝包下來就可以直接使用. 以下是實際使用方式: 先查看目前磁碟使用狀況. 1 2 3 4 5 6 7 8 # diskutil list /dev/disk0 #: TYPE NAME SIZE IDENTIFIER 0: GUID_partition_scheme *500.1 GB disk0 1: EFI 209.7 MB disk0s1 2: Apple_HFS Macintosh HD 300.9 GB disk0s2 3: Apple_Boot Recovery HD 650.0 MB disk0s3 4: Apple_HFS data 198.2 GB disk0s4 [...]]]></description>
			<content:encoded><![CDATA[<p>ZFS 是很好檔案系統,可惜因為種種原因&#8230;沒有機會在OSX 上面使用.<br />
<a href="http://code.google.com/p/maczfs/">MACZFS</a><br />
是好心人porting到MAC OSX上面,只要下載安裝包下來就可以直接使用.<br />
以下是實際使用方式:<br />
先查看目前磁碟使用狀況.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#  diskutil list</span>
<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>disk0
   <span style="color: #666666; font-style: italic;">#:                       TYPE NAME                    SIZE       IDENTIFIER</span>
   <span style="color: #000000;">0</span>:      GUID_partition_scheme                        <span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">500.1</span> GB   disk0
   <span style="color: #000000;">1</span>:                        EFI                         <span style="color: #000000;">209.7</span> MB   disk0s1
   <span style="color: #000000;">2</span>:                  Apple_HFS Macintosh HD            <span style="color: #000000;">300.9</span> GB   disk0s2
   <span style="color: #000000;">3</span>:                 Apple_Boot Recovery HD             <span style="color: #000000;">650.0</span> MB   disk0s3
   <span style="color: #000000;">4</span>:                  Apple_HFS data                    <span style="color: #000000;">198.2</span> GB   disk0s4</pre></td></tr></table></div>

<p><span id="more-513"></span><br />
查看目前支援的ZFS 版本到哪一個版本.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># zpool upgrade -v </span>
This system is currently running ZFS pool version <span style="color: #000000;">8</span>.
&nbsp;
The following versions are supported:
&nbsp;
VER  DESCRIPTION
<span style="color: #660033;">---</span>  <span style="color: #660033;">--------------------------------------------------------</span>
 <span style="color: #000000;">1</span>   Initial ZFS version
 <span style="color: #000000;">2</span>   Ditto blocks <span style="color: #7a0874; font-weight: bold;">&#40;</span>replicated metadata<span style="color: #7a0874; font-weight: bold;">&#41;</span>
 <span style="color: #000000;">3</span>   Hot spares and double parity RAID-Z
 <span style="color: #000000;">4</span>   zpool <span style="color: #7a0874; font-weight: bold;">history</span>
 <span style="color: #000000;">5</span>   Compression using the <span style="color: #c20cb9; font-weight: bold;">gzip</span> algorithm
 <span style="color: #000000;">6</span>   pool properties
 <span style="color: #000000;">7</span>   Separate intent log devices
 <span style="color: #000000;">8</span>   Delegated administration
For <span style="color: #c20cb9; font-weight: bold;">more</span> information on a particular version, including supported releases, see:
&nbsp;
http:<span style="color: #000000; font-weight: bold;">//</span>www.opensolaris.org<span style="color: #000000; font-weight: bold;">/</span>os<span style="color: #000000; font-weight: bold;">/</span>community<span style="color: #000000; font-weight: bold;">/</span>zfs<span style="color: #000000; font-weight: bold;">/</span>version<span style="color: #000000; font-weight: bold;">/</span>N
&nbsp;
Where <span style="color: #ff0000;">'N'</span> is the version number.</pre></td></tr></table></div>

<p>將目前磁區縮小,並建立一個名稱ZFS新磁區.<br />
<a href="http://blog.sd.idv.tw/wp-content/uploads/2011/11/螢幕快照-2011-11-22-下午11.18.09.png"><img src="http://blog.sd.idv.tw/wp-content/uploads/2011/11/螢幕快照-2011-11-22-下午11.18.09-300x260.png" alt="" title="螢幕快照 2011-11-22 下午11.18.09" width="300" height="260" class="alignnone size-medium wp-image-516" /></a></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#  diskutil list</span>
<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>disk0
   <span style="color: #666666; font-style: italic;">#:                       TYPE NAME                    SIZE       IDENTIFIER</span>
   <span style="color: #000000;">0</span>:      GUID_partition_scheme                        <span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">500.1</span> GB   disk0
   <span style="color: #000000;">1</span>:                        EFI                         <span style="color: #000000;">209.7</span> MB   disk0s1
   <span style="color: #000000;">2</span>:                  Apple_HFS Macintosh HD            <span style="color: #000000;">240.0</span> GB   disk0s2
   <span style="color: #000000;">3</span>:                 Apple_Boot Recovery HD             <span style="color: #000000;">650.0</span> MB   disk0s5
   <span style="color: #000000;">4</span>:                  Apple_HFS ZFS                     <span style="color: #000000;">60.0</span> GB    disk0s4</pre></td></tr></table></div>

<p>將新磁區zfs,清除格式化為ZFS格式</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># diskutil eraseVolume ZFS %noformat% /dev/disk0s4</span>
Started erase on disk0s4 ZFS
Unmounting disk
Erasing
Finished erase on disk0s4 ZFS</pre></td></tr></table></div>

<p>建立新zpool</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># zpool create pool1 disk0s4</span>
<span style="color: #666666; font-style: italic;"># zpool status pool1 </span>
  pool: pool1
 state: ONLINE
 scrub: none requested
config:
&nbsp;
	NAME        STATE     READ WRITE CKSUM
	pool1       ONLINE       <span style="color: #000000;">0</span>     <span style="color: #000000;">0</span>     <span style="color: #000000;">0</span>
	  disk0s4   ONLINE       <span style="color: #000000;">0</span>     <span style="color: #000000;">0</span>     <span style="color: #000000;">0</span>
&nbsp;
errors: No known data errors
<span style="color: #666666; font-style: italic;"># diskutil list</span>
<span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>disk0
   <span style="color: #666666; font-style: italic;">#:                       TYPE NAME                    SIZE       IDENTIFIER</span>
   <span style="color: #000000;">0</span>:      GUID_partition_scheme                        <span style="color: #000000; font-weight: bold;">*</span><span style="color: #000000;">500.1</span> GB   disk0
   <span style="color: #000000;">1</span>:                        EFI                         <span style="color: #000000;">209.7</span> MB   disk0s1
   <span style="color: #000000;">2</span>:                  Apple_HFS Macintosh HD            <span style="color: #000000;">240.0</span> GB   disk0s2
   <span style="color: #000000;">3</span>:                 Apple_Boot Recovery HD             <span style="color: #000000;">650.0</span> MB   disk0s5
   <span style="color: #000000;">4</span>:                        ZFS pool1                   <span style="color: #000000;">60.0</span> GB    disk0s4
&nbsp;
<span style="color: #666666; font-style: italic;"># zfs list</span>
NAME    USED  AVAIL  REFER  MOUNTPOINT
pool1  1.07M  54.6G  1005K  <span style="color: #000000; font-weight: bold;">/</span>Volumes<span style="color: #000000; font-weight: bold;">/</span>pool1</pre></td></tr></table></div>

<p>設定屬性compression=gzip壓縮檔按以節省空間</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># zfs set compression=gzip pool1</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># zfs get all pool1                                                                                    (11-23 01:07)  </span>
NAME   PROPERTY       VALUE                 SOURCE
pool1  <span style="color: #7a0874; font-weight: bold;">type</span>           filesystem            -
pool1  creation       三 <span style="color: #000000;">11</span> <span style="color: #000000;">23</span>  <span style="color: #000000;">0</span>:<span style="color: #000000;">55</span> <span style="color: #000000;">2011</span>  -
pool1  used           370K                  -
pool1  available      54.6G                 -
pool1  referenced     284K                  -
pool1  compressratio  1.00x                 -
pool1  mounted        <span style="color: #c20cb9; font-weight: bold;">yes</span>                   -
pool1  quota          none                  default
pool1  reservation    none                  default
pool1  recordsize     128K                  default
pool1  mountpoint     <span style="color: #000000; font-weight: bold;">/</span>Volumes<span style="color: #000000; font-weight: bold;">/</span>pool1        default
pool1  sharenfs       off                   default
pool1  checksum       on                    default
pool1  compression    <span style="color: #c20cb9; font-weight: bold;">gzip</span>                  <span style="color: #7a0874; font-weight: bold;">local</span>
pool1  atime          on                    default
pool1  devices        on                    default
pool1  <span style="color: #7a0874; font-weight: bold;">exec</span>           on                    default
pool1  setuid         on                    default
pool1  <span style="color: #7a0874; font-weight: bold;">readonly</span>       off                   default
pool1  zoned          off                   default
pool1  snapdir        hidden                default
pool1  aclmode        groupmask             default
pool1  aclinherit     secure                default
pool1  canmount       on                    default
pool1  shareiscsi     off                   default
pool1  xattr          on                    default
pool1  copies         <span style="color: #000000;">1</span>                     default
pool1  version        <span style="color: #000000;">2</span>                     -</pre></td></tr></table></div>

<p>以下是我開了一個mysql_data的節點使用壓縮compression=gzip,exec=off.<br />
各位可以看到壓縮比compressratio = 4.18x 等於說我原本這些資料佔用6.85G 現在節省到只佔用1.64G！！！！<br />
幫我MBP節省寶貴空間,如果你是用SSD更是要必需計較空間使用在此強力推薦ZFS來使用.(不過打開壓縮勢必在存取檔案消耗更多CPU）</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;"> <span style="color: #666666; font-style: italic;"># zfs get all pool1/mysql_data</span>
NAME              PROPERTY       VALUE                      SOURCE
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  <span style="color: #7a0874; font-weight: bold;">type</span>           filesystem                 -
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  creation       三 <span style="color: #000000;">11</span> <span style="color: #000000;">23</span>  <span style="color: #000000;">1</span>:<span style="color: #000000;">56</span> <span style="color: #000000;">2011</span>       -
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  used           1.64G                      -
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  available      14.9G                      -
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  referenced     1.64G                      -
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  compressratio  4.18x                      -
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  mounted        <span style="color: #c20cb9; font-weight: bold;">yes</span>                        -
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  quota          none                       default
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  reservation    none                       default
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  recordsize     128K                       default
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  mountpoint     <span style="color: #000000; font-weight: bold;">/</span>Volumes<span style="color: #000000; font-weight: bold;">/</span>pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  default
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  sharenfs       off                        default
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  checksum       on                         default
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  compression    <span style="color: #c20cb9; font-weight: bold;">gzip</span>                       <span style="color: #7a0874; font-weight: bold;">local</span>
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  atime          on                         default
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  devices        on                         default
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  <span style="color: #7a0874; font-weight: bold;">exec</span>           off                        <span style="color: #7a0874; font-weight: bold;">local</span>
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  setuid         on                         default
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  <span style="color: #7a0874; font-weight: bold;">readonly</span>       off                        default
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  zoned          off                        default
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  snapdir        hidden                     default
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  aclmode        groupmask                  default
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  aclinherit     secure                     default
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  canmount       on                         default
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  shareiscsi     off                        default
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  xattr          on                         default
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  copies         <span style="color: #000000;">1</span>                          default
pool1<span style="color: #000000; font-weight: bold;">/</span>mysql_data  version        <span style="color: #000000;">2</span>                          -</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.sd.idv.tw/archives/513/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gearman Install OSX</title>
		<link>http://blog.sd.idv.tw/archives/509</link>
		<comments>http://blog.sd.idv.tw/archives/509#comments</comments>
		<pubDate>Fri, 18 Nov 2011 04:30:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[未分類]]></category>

		<guid isPermaLink="false">http://blog.sd.idv.tw/?p=509</guid>
		<description><![CDATA[安裝Gearman 在OSX上面 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 [...]]]></description>
			<content:encoded><![CDATA[<p>安裝Gearman 在OSX上面</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #660033;">-s</span>
$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>tmp
$ <span style="color: #c20cb9; font-weight: bold;">wget</span> https:<span style="color: #000000; font-weight: bold;">//</span>github.com<span style="color: #000000; font-weight: bold;">/</span>downloads<span style="color: #000000; font-weight: bold;">/</span>libevent<span style="color: #000000; font-weight: bold;">/</span>libevent<span style="color: #000000; font-weight: bold;">/</span>libevent-2.0.15-stable.tar.gz
$ <span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf libevent-2.0.15-stable.tar.gz
$ <span style="color: #7a0874; font-weight: bold;">cd</span> libevent-2.0.15-stable
$ .<span style="color: #000000; font-weight: bold;">/</span>configure
$ <span style="color: #c20cb9; font-weight: bold;">make</span>
$ <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
$ <span style="color: #7a0874; font-weight: bold;">cd</span> ..
$ <span style="color: #c20cb9; font-weight: bold;">wget</span> https:<span style="color: #000000; font-weight: bold;">//</span>launchpad.net<span style="color: #000000; font-weight: bold;">/</span>ubuntu<span style="color: #000000; font-weight: bold;">/</span>lucid<span style="color: #000000; font-weight: bold;">/</span>+source<span style="color: #000000; font-weight: bold;">/</span>libdrizzle<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0.7</span>-<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">/</span>+files<span style="color: #000000; font-weight: bold;">/</span>libdrizzle_0.7.orig.tar.gz
$ <span style="color: #c20cb9; font-weight: bold;">tar</span> libdrizzle_0.7.orig.tar.gz
$ <span style="color: #7a0874; font-weight: bold;">cd</span> libdrizzle-<span style="color: #000000;">0.7</span><span style="color: #000000; font-weight: bold;">/</span>
$ .<span style="color: #000000; font-weight: bold;">/</span>configure
$ <span style="color: #c20cb9; font-weight: bold;">make</span>
$ <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
$ <span style="color: #7a0874; font-weight: bold;">cd</span> ..
$ <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>launchpad.net<span style="color: #000000; font-weight: bold;">/</span>gearmand<span style="color: #000000; font-weight: bold;">/</span>trunk<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0.14</span><span style="color: #000000; font-weight: bold;">/</span>+download<span style="color: #000000; font-weight: bold;">/</span>gearmand-<span style="color: #000000;">0.14</span>.tar.gz
$ <span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf gearmand-<span style="color: #000000;">0.14</span>.tar.gz
$ <span style="color: #7a0874; font-weight: bold;">cd</span> gearmand-<span style="color: #000000;">0.14</span><span style="color: #000000; font-weight: bold;">/</span>
$ .<span style="color: #000000; font-weight: bold;">/</span>configure
$ <span style="color: #c20cb9; font-weight: bold;">make</span>
$ <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
$ <span style="color: #7a0874; font-weight: bold;">cd</span> ..
$ <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>pecl.php.net<span style="color: #000000; font-weight: bold;">/</span>get<span style="color: #000000; font-weight: bold;">/</span>gearman-0.8.0.tgz
$ <span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf gearman-0.8.0.tgz
$ <span style="color: #7a0874; font-weight: bold;">cd</span> gearman-0.8.0
$ phpize
$ .<span style="color: #000000; font-weight: bold;">/</span>configure
$ <span style="color: #c20cb9; font-weight: bold;">make</span>
$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>gearman-0.8.0<span style="color: #000000; font-weight: bold;">/</span>libtool <span style="color: #660033;">--mode</span>=<span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">cp</span> .<span style="color: #000000; font-weight: bold;">/</span>gearman.la <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>gearman-0.8.0<span style="color: #000000; font-weight: bold;">/</span>modules
<span style="color: #c20cb9; font-weight: bold;">cp</span> .<span style="color: #000000; font-weight: bold;">/</span>.libs<span style="color: #000000; font-weight: bold;">/</span>gearman.so <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>gearman-0.8.0<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>gearman.so
<span style="color: #c20cb9; font-weight: bold;">cp</span> .<span style="color: #000000; font-weight: bold;">/</span>.libs<span style="color: #000000; font-weight: bold;">/</span>gearman.lai <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>gearman-0.8.0<span style="color: #000000; font-weight: bold;">/</span>modules<span style="color: #000000; font-weight: bold;">/</span>gearman.la
<span style="color: #660033;">----------------------------------------------------------------------</span>
Libraries have been installed <span style="color: #000000; font-weight: bold;">in</span>:
   <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>gearman-0.8.0<span style="color: #000000; font-weight: bold;">/</span>modules
&nbsp;
If you ever happen to want to <span style="color: #c20cb9; font-weight: bold;">link</span> against installed libraries
<span style="color: #000000; font-weight: bold;">in</span> a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the <span style="color: #000000; font-weight: bold;">`</span>-LLIBDIR<span style="color: #ff0000;">'
flag during linking and do at least one of the following:
   - add LIBDIR to the `DYLD_LIBRARY_PATH'</span> environment variable
     during execution
&nbsp;
See any operating system documentation about shared libraries <span style="color: #000000; font-weight: bold;">for</span>
<span style="color: #c20cb9; font-weight: bold;">more</span> information, such <span style="color: #c20cb9; font-weight: bold;">as</span> the <span style="color: #c20cb9; font-weight: bold;">ld</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> and ld.so<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">8</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> manual pages.
<span style="color: #660033;">----------------------------------------------------------------------</span>
Installing shared extensions:     <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>lib<span style="color: #000000; font-weight: bold;">/</span>php<span style="color: #000000; font-weight: bold;">/</span>extensions<span style="color: #000000; font-weight: bold;">/</span>no-debug-non-zts-<span style="color: #000000;">20090626</span><span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
$ <span style="color: #c20cb9; font-weight: bold;">which</span> php
<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>php
&nbsp;
$ php <span style="color: #660033;">--info</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-i</span> configuration                                                                                                  <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">11</span>-<span style="color: #000000;">17</span> <span style="color: #000000;">13</span>:<span style="color: #000000;">30</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
Configuration File <span style="color: #7a0874; font-weight: bold;">&#40;</span>php.ini<span style="color: #7a0874; font-weight: bold;">&#41;</span> Path =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc
Loaded Configuration File =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini
Configuration
$ <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini
======= 加入以下資訊 ======
extension_dir = <span style="color: #ff0000;">&quot; /usr/lib/php/extensions/no-debug-non-zts-20090626/&quot;</span>  <span style="color: #000000; font-weight: bold;">&lt;</span>~~這不一定要
<span style="color: #007800;">extension</span>=<span style="color: #ff0000;">&quot;gearman.so&quot;</span>
========================
$ php <span style="color: #660033;">--info</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">egrep</span> <span style="color: #660033;">-i</span> <span style="color: #ff0000;">&quot;(configuration|gearman)&quot;</span>
Configuration File <span style="color: #7a0874; font-weight: bold;">&#40;</span>php.ini<span style="color: #7a0874; font-weight: bold;">&#41;</span> Path =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>etc
Loaded Configuration File =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>private<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php.ini
Configuration
gearman
gearman support =<span style="color: #000000; font-weight: bold;">&gt;</span> enabled
libgearman version =<span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000;">0.14</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.sd.idv.tw/archives/509/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gearman Install on Ubuntu</title>
		<link>http://blog.sd.idv.tw/archives/507</link>
		<comments>http://blog.sd.idv.tw/archives/507#comments</comments>
		<pubDate>Fri, 18 Nov 2011 04:26:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP & MYSQL]]></category>

		<guid isPermaLink="false">http://blog.sd.idv.tw/?p=507</guid>
		<description><![CDATA[gearman 在ubuntu 上不知哪個版本已無提供libdrizzlea模組. 導致要使用myql作為資料源已無法使用. 以下是自行編譯安裝方式： 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 $ sudo -s $ add-apt-repository ppa:gearman-developers/ppa $ apt-get update $ apt-get install libevent-dev gearman libgearman4 libgearman-dev libdrizzle0 [...]]]></description>
			<content:encoded><![CDATA[<p>gearman 在ubuntu 上不知哪個版本已無提供libdrizzlea模組.<br />
導致要使用myql作為資料源已無法使用.<br />
以下是自行編譯安裝方式：</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #660033;">-s</span>
$ add-apt-repository ppa:gearman-developers<span style="color: #000000; font-weight: bold;">/</span>ppa
$ <span style="color: #c20cb9; font-weight: bold;">apt-get</span> update
$ <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> libevent-dev gearman libgearman4 libgearman-dev libdrizzle0 libboost-program-options-dev libboost1.46-dev libboost-program-options-dev uuid-dev <span style="color: #c20cb9; font-weight: bold;">g++</span> libmemcache-dev libcloog-ppl0
$ <span style="color: #c20cb9; font-weight: bold;">wget</span> https:<span style="color: #000000; font-weight: bold;">//</span>launchpad.net<span style="color: #000000; font-weight: bold;">/</span>ubuntu<span style="color: #000000; font-weight: bold;">/</span>lucid<span style="color: #000000; font-weight: bold;">/</span>+source<span style="color: #000000; font-weight: bold;">/</span>libdrizzle<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0.7</span>-<span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">/</span>+files<span style="color: #000000; font-weight: bold;">/</span>libdrizzle_0.7.orig.tar.gz
$ <span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf libdrizzle_0.7.orig.tar.gz
$ <span style="color: #7a0874; font-weight: bold;">cd</span> libdrizzle-<span style="color: #000000;">0.7</span><span style="color: #000000; font-weight: bold;">/</span>
$ .<span style="color: #000000; font-weight: bold;">/</span>configure
$ <span style="color: #c20cb9; font-weight: bold;">make</span>
$ <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
$ cd..
$ <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>launchpad.net<span style="color: #000000; font-weight: bold;">/</span>gearmand<span style="color: #000000; font-weight: bold;">/</span>trunk<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">0.14</span><span style="color: #000000; font-weight: bold;">/</span>+download<span style="color: #000000; font-weight: bold;">/</span>gearmand-<span style="color: #000000;">0.14</span>.tar.gz
$ <span style="color: #c20cb9; font-weight: bold;">tar</span> zxvf gearmand-<span style="color: #000000;">0.14</span>.tar.gz
$ <span style="color: #7a0874; font-weight: bold;">cd</span> gearmand-<span style="color: #000000;">0.14</span><span style="color: #000000; font-weight: bold;">/</span>
&nbsp;
$ .<span style="color: #000000; font-weight: bold;">/</span>configure <span style="color: #007800;">libdrizzle_CFLAGS</span>=<span style="color: #ff0000;">&quot;-I/usr/local/include&quot;</span> <span style="color: #007800;">libdrizzle_LIBS</span>=<span style="color: #ff0000;">&quot;-L/usr/local/lib -ldrizzle&quot;</span>
$ <span style="color: #c20cb9; font-weight: bold;">make</span>
$ <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span>
$ <span style="color: #7a0874; font-weight: bold;">cd</span> ..
$ <span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>pecl.php.net<span style="color: #000000; font-weight: bold;">/</span>get<span style="color: #000000; font-weight: bold;">/</span>gearman-0.8.0.tgz
$ pecl <span style="color: #c20cb9; font-weight: bold;">install</span> gearman-0.8.0.tgz
$ <span style="color: #c20cb9; font-weight: bold;">vi</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>php5<span style="color: #000000; font-weight: bold;">/</span>conf.d<span style="color: #000000; font-weight: bold;">/</span>gearman.ini
==== 加入 ====
<span style="color: #007800;">extension</span>=gearman.so
$ <span style="color: #c20cb9; font-weight: bold;">vi</span> <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>gearman-job-server
=====編輯====
<span style="color: #007800;">prefix</span>=<span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">local</span>
<span style="color: #007800;">PARAMS</span>=<span style="color: #ff0000;">&quot;--queue-type=libdrizzle --libdrizzle-host=mysql主機ip --libdrizzle-user=mysql帳號 --libdrizzle-password=mysql主機ip --libdrizzle-db=gearman --libdrizzle-table=gearman_queue --libdrizzle-mysql&quot;</span>
====加上註解====
<span style="color: #666666; font-style: italic;">#test -f /etc/default/gearman-job-server &amp;&amp; . /etc/default/gearman-job-server</span>
========================
DB gearman  要自行在mysql新增 資料表他自行會建立
$ service gearman-job-server start</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.sd.idv.tw/archives/507/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

