<?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>へびにっき &#187; CentOS</title>
	<atom:link href="http://wp.serpere.info/archives/tag/centos/feed" rel="self" type="application/rss+xml" />
	<link>http://wp.serpere.info</link>
	<description>樹上で暮らすヘビのように生きたい</description>
	<lastBuildDate>Sat, 04 Feb 2012 13:25:38 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>CentOS 5にNginxをインストールする</title>
		<link>http://wp.serpere.info/archives/1799</link>
		<comments>http://wp.serpere.info/archives/1799#comments</comments>
		<pubDate>Mon, 25 Oct 2010 13:36:33 +0000</pubDate>
		<dc:creator>tkykmw</dc:creator>
				<category><![CDATA[未分類]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[サーバ管理]]></category>

		<guid isPermaLink="false">http://wp.serpere.info/?p=1799</guid>
		<description><![CDATA[CentOS 5.5にNginxをセットアップした記録。 EPELリポジトリにrpmパッケージもあるようだが、かなりバージョンが古かったので（0.6.39）ソースからインストールすることにした。現時点での最新版（stable）は0.8.53。 まず下準備。nginxユーザの追加とビルドに必要なパッケージのインストール。 sudo useradd -s /sbin/nologin -d /usr/local/nginx -M nginx sudo yum install gcc openssl-devel pcre-devel zlib-devel 続いてソースをダウンロードしてコンパイルする。Nginxはコンパイル時にしか拡張モジュールの組み込みができないので、ビルドの過程はシェルスクリプトの形で残しておいた方が良い。コンパイルオプションについてはWikiを参照のこと。一番下のExample 5（RedHat向け）を参考に調整を行った。 #!/bin/sh &#160; NGINX=nginx-0.8.53 &#160; # インストール先は /usr/local/nginx になる cd $NGINX \ &#38;&#38; make clean \ &#38;&#38; ./configure \ --conf-path=/etc/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --pid-path=/var/run/nginx/nginx.pid \ --lock-path=/var/lock/nginx.lock \ --user=nginx \ --group=nginx \ --with-http_stub_status_module \ --with-http_ssl_module \ [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_jade" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwp.serpere.info%252Farchives%252F1799%22%2C%20%22shorturl%22%3A%20%22http%3A%2F%2Fbit.ly%2F9sg9nn%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22CentOS%205%E3%81%ABNginx%E3%82%92%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%E3%81%99%E3%82%8B%22%20%7D);"></div>
<p>
CentOS 5.5にNginxをセットアップした記録。
</p>
<p>
EPELリポジトリにrpmパッケージもあるようだが、かなりバージョンが古かったので（0.6.39）ソースからインストールすることにした。現時点での最新版（stable）は0.8.53。
</p>
<p>
まず下準備。nginxユーザの追加とビルドに必要なパッケージのインストール。
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> useradd <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>nologin <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>nginx <span style="color: #660033;">-M</span> nginx
<span style="color: #c20cb9; font-weight: bold;">sudo</span> yum <span style="color: #c20cb9; font-weight: bold;">install</span> <span style="color: #c20cb9; font-weight: bold;">gcc</span> openssl-devel pcre-devel zlib-devel</pre></div></div>



<p>
続いて<a href="http://wiki.nginx.org/Install">ソースをダウンロード</a>してコンパイルする。Nginxはコンパイル時にしか拡張モジュールの組み込みができないので、ビルドの過程はシェルスクリプトの形で残しておいた方が良い。コンパイルオプションについては<a href="http://wiki.nginx.org/NginxInstallOptions">Wiki</a>を参照のこと。一番下のExample 5（RedHat向け）を参考に調整を行った。
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/sh</span>
&nbsp;
<span style="color: #007800;">NGINX</span>=nginx-0.8.53
&nbsp;
<span style="color: #666666; font-style: italic;"># インストール先は /usr/local/nginx になる</span>
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #007800;">$NGINX</span> \
<span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">make</span> clean \
<span style="color: #000000; font-weight: bold;">&amp;&amp;</span> .<span style="color: #000000; font-weight: bold;">/</span>configure \
  <span style="color: #660033;">--conf-path</span>=<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.conf \
  <span style="color: #660033;">--error-log-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>error.log \
  <span style="color: #660033;">--pid-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>run<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>nginx.pid  \
  <span style="color: #660033;">--lock-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>lock<span style="color: #000000; font-weight: bold;">/</span>nginx.lock \
  <span style="color: #660033;">--user</span>=nginx \
  <span style="color: #660033;">--group</span>=nginx \
  --with-http_stub_status_module \
  --with-http_ssl_module \
  --with-http_gzip_static_module \
  --with-http_realip_module \
  <span style="color: #660033;">--http-log-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>access.log \
  <span style="color: #660033;">--http-client-body-temp-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>client<span style="color: #000000; font-weight: bold;">/</span> \
  <span style="color: #660033;">--http-proxy-temp-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>proxy<span style="color: #000000; font-weight: bold;">/</span> \
  <span style="color: #660033;">--http-fastcgi-temp-path</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span>fcgi<span style="color: #000000; font-weight: bold;">/</span> \
<span style="color: #000000; font-weight: bold;">&amp;&amp;</span> <span style="color: #c20cb9; font-weight: bold;">make</span></pre></div></div>



<p>
正常にビルドが完了したらインストール。足りないディレクトリも作っておく。
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #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: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>nginx<span style="color: #000000; font-weight: bold;">/</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>proxy,client,fcgi<span style="color: #7a0874; font-weight: bold;">&#125;</span></pre></div></div>



<p>
この段階で正常に起動するかどうかを確認しておく。rootで <code>${prefix}/sbin/nginx</code> を実行後、<code>http://hostname/</code> にアクセスして、「Welcome to nginx!」と表示されたらOK。
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</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>nginx<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>nginx
&nbsp;
<span style="color: #666666; font-style: italic;"># 確認できたら終了しておく</span>
<span style="color: #c20cb9; font-weight: bold;">sudo</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>nginx<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>nginx <span style="color: #660033;">-s</span> quit</pre></div></div>



<p>
この後、設定ファイル（上のコンパイルオプションの場合は <code>/etc/nginx/nginx.conf</code>）を編集してサーバの設定を行うことになるが、そこは省略。
</p>
<p>
サービス起動ファイルを作る。CentOS(RedHat系Linux)ならひな形が<a href="http://wiki.nginx.org/RedHatNginxInitScript">Wiki</a>に用意されているので、必要な部分を書き換えた後 <code>/etc/init.d/nginx</code> に保存して、 chkconfig コマンドで設定する。
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># 実行ファイルのパスなど変更しておく</span>
<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>nginx
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">chmod</span> <span style="color: #000000;">755</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>nginx
chkconfig <span style="color: #660033;">--add</span> nginx
chkconfig nginx on
&nbsp;
<span style="color: #666666; font-style: italic;"># 今すぐ起動するなら</span>
service nginx start</pre></div></div>



<p>
続いてログのローテーションの設定。<code>/etc/logrotate.d/nginx</code> を以下の内容で作成する。パスやパラメータは各自で調整のこと。
</p>
<pre>
/var/log/nginx/*log {
    missingok
    notifempty
    delaycompress
    sharedscripts
    postrotate
        /usr/local/nginx/sbin/nginx -s reopen
    endscript
}
</pre>
<p>
設定ファイルのチェックも行っておく。
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> logrotate <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>logrotate.conf</pre></div></div>



<p>
設定ファイルの内容について後で書くかも。
</p>

]]></content:encoded>
			<wfw:commentRss>http://wp.serpere.info/archives/1799/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WARNING: mismatch_cnt is not 0 on /dev/md0</title>
		<link>http://wp.serpere.info/archives/1099</link>
		<comments>http://wp.serpere.info/archives/1099#comments</comments>
		<pubDate>Mon, 21 Dec 2009 09:31:18 +0000</pubDate>
		<dc:creator>tkykmw</dc:creator>
				<category><![CDATA[未分類]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[サーバ管理]]></category>

		<guid isPermaLink="false">http://wp.serpere.info/?p=1099</guid>
		<description><![CDATA[Software RAID1を組んでいるサーバで、CentOS 5.3 -> 5.4にアップグレードしたところ、週末ごとに次のような警告メールが届くようになった。 /etc/cron.weekly/99-raid-check: WARNING: mismatch_cnt is not 0 on /dev/md0 /proc/mdstat 等には特に異常などは見当たらないし、構成の異なる複数のサーバで同じ現象が起こったので、ハード的な問題ではないだろうと判断し、忙しかったこともあってそのままにしていた。しかしやはり気持ち悪いので、きちんと調べてみた。 メール中にある通り、この警告は /etc/cron.weekly/99-raid-check というスクリプトから送信されている。このスクリプトを提供しているのは mdadm パッケージで、5.4で更新されている。更新内容はレッドハットのサイトで RHBA-2009:1382-1 として提供されており、99-raid-check について説明しているのは、次の2箇所である。 * LinuxのソフトウェアRAIDスタックでは、データスクラビングがサポートされています（RAIDアレイのディスクを読み取って不良セクタを検索し、不良セクタが見つかると、他のディスクやパリティの情報を使用して、不良セクタを正常なデータで書き直します）。しかし、mdadmパッケージはこの機能を利用していませんでした。今回のパッケージは、cronジョブが/etc/cron.weeklyに追加されており、ディスクをチェックして不良セクタがないかどうかを確認し、見つかった場合は修復します。（BZ#233972） * 今回のアップデートでは、mdadmに冗長アレイでの「データスクラビング」を可能にする新しい機能が追加されています。データスクラビングでは、冗長アレイ内のドライブ上で不良セクタが検索され、見つかった場合は他のドライブのデータを使用して修正されます。それによって、読み取りエラーを返すセクタは再構築されます。注：この新しいパッケージでは、データスクラビングはデフォルトでオンになっています。この機能は週1回実行され、実行中にある程度のパフォーマンス低下を引き起こす場合があります。パフォーマンス上の理由でこの機能を無効にしたい場合、アレイに対して実行されるチェックのタイプを管理したい場合、あるいは、どのアレイをチェックするかを制御したい場合は、/etc/sysconfig/raid-checkファイルを編集します。オプションを設定する方法の詳細は、そのファイルにコメントとして含まれています。（BZ#513200） 「データスクライピング（Data Scrubbing）」とは何か、なぜ重要なのかについては、ここで示されているBugzilla #233972およびその先のリンクに説明がある（一箇所リンクが切れているのはRAID/Software &#8211; GEntoo Linux Wikiだと思われる）。 データスクライピングを実行するには、root権限で次のコマンドを実行する。これによって不良セクタが検出され、自動的に修復される。99-raid-check が実行するのも、まさにこのコマンドである（少なくともデフォルトの設定においては）。 echo check &#62; /sys/block/mdX/md/sync_action ではこのコマンドと、問題の mismatch_cnt とはどう関係するのか。/etc/sysconfig/raid-check のコメントを読むと次のように書いてある。 If it finds good sectors that contain bad data (meaning that [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_jade" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwp.serpere.info%252Farchives%252F1099%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22WARNING%3A%20mismatch_cnt%20is%20not%200%20on%20%2Fdev%2Fmd0%22%20%7D);"></div>
<p>
Software RAID1を組んでいるサーバで、CentOS 5.3 -> 5.4にアップグレードしたところ、週末ごとに次のような警告メールが届くようになった。
</p>
<pre>
/etc/cron.weekly/99-raid-check:

WARNING: mismatch_cnt is not 0 on /dev/md0
</pre>
<p>
/proc/mdstat 等には特に異常などは見当たらないし、構成の異なる複数のサーバで同じ現象が起こったので、ハード的な問題ではないだろうと判断し、忙しかったこともあってそのままにしていた。しかしやはり気持ち悪いので、きちんと調べてみた。
</p>
<p>
メール中にある通り、この警告は /etc/cron.weekly/99-raid-check というスクリプトから送信されている。このスクリプトを提供しているのは mdadm パッケージで、5.4で更新されている。更新内容はレッドハットのサイトで <a href="http://www.jp.redhat.com/support/errata/RHBA/RHBA-2009-1382J.html">RHBA-2009:1382-1</a> として提供されており、99-raid-check について説明しているのは、次の2箇所である。
</p>
<blockquote><p>
* LinuxのソフトウェアRAIDスタックでは、データスクラビングがサポートされています（RAIDアレイのディスクを読み取って不良セクタを検索し、不良セクタが見つかると、他のディスクやパリティの情報を使用して、不良セクタを正常なデータで書き直します）。しかし、mdadmパッケージはこの機能を利用していませんでした。今回のパッケージは、cronジョブが/etc/cron.weeklyに追加されており、ディスクをチェックして不良セクタがないかどうかを確認し、見つかった場合は修復します。（BZ#233972）
</p></blockquote>
<blockquote><p>
* 今回のアップデートでは、mdadmに冗長アレイでの「データスクラビング」を可能にする新しい機能が追加されています。データスクラビングでは、冗長アレイ内のドライブ上で不良セクタが検索され、見つかった場合は他のドライブのデータを使用して修正されます。それによって、読み取りエラーを返すセクタは再構築されます。注：この新しいパッケージでは、データスクラビングはデフォルトでオンになっています。この機能は週1回実行され、実行中にある程度のパフォーマンス低下を引き起こす場合があります。パフォーマンス上の理由でこの機能を無効にしたい場合、アレイに対して実行されるチェックのタイプを管理したい場合、あるいは、どのアレイをチェックするかを制御したい場合は、/etc/sysconfig/raid-checkファイルを編集します。オプションを設定する方法の詳細は、そのファイルにコメントとして含まれています。（BZ#513200）
</p></blockquote>
<p>
「データスクライピング（Data Scrubbing）」とは何か、なぜ重要なのかについては、ここで示されている<a href="https://bugzilla.redhat.com/show_bug.cgi?id=233972">Bugzilla #233972</a>およびその先のリンクに説明がある（一箇所リンクが切れているのは<a href="http://en.gentoo-wiki.com/wiki/RAID/Software#Data_Scrubbing">RAID/Software &#8211; GEntoo Linux Wiki</a>だと思われる）。
</p>
<p>
データスクライピングを実行するには、root権限で次のコマンドを実行する。これによって不良セクタが検出され、自動的に修復される。99-raid-check が実行するのも、まさにこのコマンドである（少なくともデフォルトの設定においては）。
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">echo</span> check <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>block<span style="color: #000000; font-weight: bold;">/</span>mdX<span style="color: #000000; font-weight: bold;">/</span>md<span style="color: #000000; font-weight: bold;">/</span>sync_action</pre></div></div>



<p>
ではこのコマンドと、問題の mismatch_cnt とはどう関係するのか。/etc/sysconfig/raid-check のコメントを読むと次のように書いてある。
</p>
<blockquote><p>If it finds good sectors that
 contain bad data (meaning that the data in a sector does
 not agree with what the data from another disk indicates
 the data should be, for example the parity block + the other
 data blocks would cause us to think that this data block
 is incorrect), then it does nothing but increments the
 counter in the file /sys/block/$dev/md/mismatch_count.
</p></blockquote>
<p>
つまりセクタ自体は正常だが、中に入ってるデータがディスク間で異なる場合に mismatch_cnt が増加するということらしい。
</p>
<p>
ならば mismatch_cnt が 0 でないということは、ただちにRAIDが正常に機能していないことを意味するのだろうか？いろいろなMLの投稿などを読む限り、少なくとも swap パーティションを含むRAIDデバイスにおいては、全く正常であっても各ディスク間の内容が異なり得る…すなわち mismatch_cnt が0でないことがあり得るようだ。では swap を含まないパーティションの場合は？私の（また他のCentOS利用者の）ように、/boot のみを含む md0 の場合は？……これがよく分からない。<a href="http://marc.info/?l=linux-raid&#038;m=117555829807542&#038;w=2">この投稿</a>を読む限り、ある種の状況においてはそうしたことも起こり得る、とのことである。
</p>
<p>
もしそうした状況に該当するなら。mismatch_cnt が 0 でなくとも、異なっているのは実際にはファイルシステムからアクセス不能な部分であって、システムの運用には影響しないのであれば。修復する方法はある。check の代わりに repair を使うことである。
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#このコマンドを実行する前に以下の説明をよく読んでください！！</span>
<span style="color: #7a0874; font-weight: bold;">echo</span> repair <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>block<span style="color: #000000; font-weight: bold;">/</span>mdX<span style="color: #000000; font-weight: bold;">/</span>md<span style="color: #000000; font-weight: bold;">/</span>sync_action</pre></div></div>



<p>
ただし /etc/sysconfig/raid-check には、次のような恐ろしいコメントが書いてある（強調は私による）。
</p>
<blockquote><p>
The repair option does the same thing, but
 when it encounters a mismatch in the data, it automatically
 updates the data to be consistent.  However, since <strong>we really
 don&#8217;t know whether it&#8217;s the parity or the data block that&#8217;s
 correct (or which data block in the case of raid1), it&#8217;s
 luck of the draw whether or not the user gets the right
 data instead of the bad data.</strong>
</p></blockquote>
<p>
というわけで、以下は「<strong>それでも自己責任でこの方法に賭けるぜ！</strong>」という方のみ読んでください。
</p>
<p>
まず各デバイスの mismatch_cnt の値をチェックしておく。
</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>block<span style="color: #000000; font-weight: bold;">/</span>md0<span style="color: #000000; font-weight: bold;">/</span>md<span style="color: #000000; font-weight: bold;">/</span>mismatch_cnt</pre></div></div>



<p>そして repair を実行する。</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">'echo repair &gt; /sys/block/md0/md/sync_action'</span></pre></div></div>



<p>進行状況は /proc/mdstat で確認できる。</p>


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



<p>repair を実行しただけでは mismatch_cnt は更新されないので、もう一度 check を実行する。進行状況はやはり /proc/mdstat で確認できる。</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">'echo check &gt; /sys/block/md0/md/sync_action'</span></pre></div></div>



<p>終了したら mismatch_cnt をチェックして、0 になっているか確認する。</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">cat</span> <span style="color: #000000; font-weight: bold;">/</span>sys<span style="color: #000000; font-weight: bold;">/</span>block<span style="color: #000000; font-weight: bold;">/</span>md0<span style="color: #000000; font-weight: bold;">/</span>md<span style="color: #000000; font-weight: bold;">/</span>mismatch_cnt</pre></div></div>



<p>……</p>
<p>
参考にしたサイトは<a href="http://b.hatena.ne.jp/serpere/mismatch_cnt/">はてブの mismatch_cnt タグ</a>にまとめてあるので、この記事に書いてあることを鵜呑みにせず、自分で調べ自分で判断するようお願いします。
</p>
]]></content:encoded>
			<wfw:commentRss>http://wp.serpere.info/archives/1099/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>cciss経由で取得したHDDの温度をmuninでグラフ化</title>
		<link>http://wp.serpere.info/archives/348</link>
		<comments>http://wp.serpere.info/archives/348#comments</comments>
		<pubDate>Tue, 07 Apr 2009 13:30:58 +0000</pubDate>
		<dc:creator>tkykmw</dc:creator>
				<category><![CDATA[未分類]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[munin]]></category>
		<category><![CDATA[サーバ管理]]></category>

		<guid isPermaLink="false">http://wp.serpere.info/?p=348</guid>
		<description><![CDATA[CCISS (HP/Compaq Smart Array Controller) に接続された HDD の SMART 情報を読み出し、温度を munin の hddtemp_smartctl プラグインでグラフ化する。 cciss　に対応する smartmontools は 5.38 以降（stable）。CentOS 5.3 では標準でこのバージョンがインストールされるが、あいにく対象サーバはCentOS 4だったので、ソースからインストールした。 tar xvzf smartmontools-5.38.tar.gz cd smartmontools-5.38 ./configure make sudo make install /usr/local/sbin に新たにインストールされた smartctl を使用して、温度その他の情報が取得できることを確認。以下表示例。 $ sudo /usr/local/sbin/smartctl -A -d cciss,0 /dev/cciss/c0d0 smartctl version 5.38 [i686-pc-linux-gnu] Copyright (C) 2002-8 Bruce Allen Home page is [...]]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_jade" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwp.serpere.info%252Farchives%252F348%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22cciss%E7%B5%8C%E7%94%B1%E3%81%A7%E5%8F%96%E5%BE%97%E3%81%97%E3%81%9FHDD%E3%81%AE%E6%B8%A9%E5%BA%A6%E3%82%92munin%E3%81%A7%E3%82%B0%E3%83%A9%E3%83%95%E5%8C%96%22%20%7D);"></div>
<p>CCISS (HP/Compaq Smart Array Controller) に接続された HDD の SMART 情報を読み出し、温度を munin の hddtemp_smartctl プラグインでグラフ化する。</p>
<p>cciss　に対応する smartmontools は 5.38 以降（stable）。CentOS 5.3 では標準でこのバージョンがインストールされるが、あいにく対象サーバはCentOS 4だったので、ソースからインストールした。</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">tar</span> xvzf smartmontools-<span style="color: #000000;">5.38</span>.tar.gz
<span style="color: #7a0874; font-weight: bold;">cd</span> smartmontools-<span style="color: #000000;">5.38</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;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">make</span> <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>



<p>/usr/local/sbin に新たにインストールされた smartctl を使用して、温度その他の情報が取得できることを確認。以下表示例。</p>
<pre>$ sudo /usr/local/sbin/smartctl -A -d cciss,0 /dev/cciss/c0d0
smartctl version 5.38 [i686-pc-linux-gnu] Copyright (C) 2002-8 Bruce Allen
Home page is http://smartmontools.sourceforge.net/

Current Drive Temperature:     26 C
Drive Trip Temperature:        65 C
Manufactured in week 50 of year 2006
Recommended maximum start stop count:  10000 times
Current start stop count:      19 times
Elements in grown defect list: 0</pre>
<p>続いてmunin のプラグイン設定ファイル（/etc/munin/plugin-conf.d/hddtemp_smartctl ）に設定を追加する。デバイス名の後に _[番号] を付けるのがポイント。</p>
<pre>[hddtemp_smartctl]
user root
env.smartctl    /usr/local/sbin/smartctl
env.drives      cciss/c0d0_0 cciss/c0d0_1
env.type_cciss/c0d0_0  cciss,0
env.type_cciss/c0d0_1  cciss,1</pre>
<p>これで値が取得できるようになる…のだが、うまくグラフが表示されない。デバイス名に / が含まれているのがまずいらしいので、プラグインファイル /usr/share/munin/plugins/hddtemp_smartctl を少し改造。<a href="http://www.serpere.info/hddtemp_smartctl.diff">munin-node-1.2.5用のパッチ</a>を置いておく。</p>
<p>こんな感じで表示されるようになる。<br />
<div id="attachment_350" class="wp-caption alignnone" style="width: 310px"><a href="http://wp.serpere.info/wp-content/uploads/2009/04/hddtemp_smartctl.jpg"><img class="size-medium wp-image-350" title="hddtemp_smartctl" src="http://wp.serpere.info/wp-content/uploads/2009/04/hddtemp_smartctl-300x192.jpg" alt="hddtemp_smartctlによるグラフ表示" width="300" height="192" /></a><p class="wp-caption-text">hddtemp_smartctlによるグラフ</p></div></p>

]]></content:encoded>
			<wfw:commentRss>http://wp.serpere.info/archives/348/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CentOSで最新のPHP 5.2を使用する</title>
		<link>http://wp.serpere.info/archives/293</link>
		<comments>http://wp.serpere.info/archives/293#comments</comments>
		<pubDate>Fri, 20 Mar 2009 00:40:11 +0000</pubDate>
		<dc:creator>tkykmw</dc:creator>
				<category><![CDATA[未分類]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://wp.serpere.info/?p=293</guid>
		<description><![CDATA[サードパーティのリポジトリを利用することで、2009年3月20日現在最新のphp-5.2.9をyumでインストールすることができる。リポジトリ管理者の素晴らしい仕事には頭が下がるばかりだ…。 注意：この方法でインストールされる php-mysql は MySQL 5.1.30 の libmysqlclient とリンクされる。 English : Repository Configuration &#8211; Les RPM de Remiに従ってEPELとLes RPM de Remiのリポジトリを追加。CentOS 5の場合は wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-2.noarch.rpm wget http://rpms.famillecollet.com/el5.i386/remi-release-5-6.el5.remi.noarch.rpm rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm php-mysql をインストールする場合は、予め remi-test リポジトリから mysqlclient16 パッケージをインストールしておく。 sudo yum --enablerepo=remi-test install mysqlclient16 自分が必要とするパッケージをインストールする（パッケージによってはEPEL内のパッケージに依存することがある）。 sudo yum --enablerepo=epel,remi install php php-cli php-mysql php-gd インストール後はリポジトリ管理者のブログLes RPM de Remiを常にチェックしておくことをおすすめする。PHPの新しいバージョンが出た場合、今までは数日中には対応されてきた。しかしアップデートに伴って、時々パッケージの構成が変わったりライブラリのバージョンが変わったりして、すんなりアップデートできなくなることもあった。そのあたりは自己責任で。]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_jade" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwp.serpere.info%252Farchives%252F293%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22CentOS%E3%81%A7%E6%9C%80%E6%96%B0%E3%81%AEPHP%205.2%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%99%E3%82%8B%22%20%7D);"></div>
<p>サードパーティのリポジトリを利用することで、2009年3月20日現在最新のphp-5.2.9をyumでインストールすることができる。リポジトリ管理者の素晴らしい仕事には頭が下がるばかりだ…。</p>
<p>注意：この方法でインストールされる php-mysql は MySQL 5.1.30 の libmysqlclient とリンクされる。</p>
<p><a href="http://blog.famillecollet.com/pages/Config-en">English : Repository Configuration &#8211; Les RPM de Remi</a>に従ってEPELとLes RPM de Remiのリポジトリを追加。CentOS 5の場合は</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>download.fedora.redhat.com<span style="color: #000000; font-weight: bold;">/</span>pub<span style="color: #000000; font-weight: bold;">/</span>epel<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">/</span>i386<span style="color: #000000; font-weight: bold;">/</span>epel-release-<span style="color: #000000;">5</span>-<span style="color: #000000;">2</span>.noarch.rpm
<span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>rpms.famillecollet.com<span style="color: #000000; font-weight: bold;">/</span>el5.i386<span style="color: #000000; font-weight: bold;">/</span>remi-release-<span style="color: #000000;">5</span>-<span style="color: #000000;">6</span>.el5.remi.noarch.rpm
rpm <span style="color: #660033;">-Uvh</span> remi-release-<span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">*</span>.rpm epel-release-<span style="color: #000000;">5</span><span style="color: #000000; font-weight: bold;">*</span>.rpm</pre></div></div>



<p>php-mysql をインストールする場合は、予め remi-test リポジトリから mysqlclient16 パッケージをインストールしておく。</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> yum <span style="color: #660033;">--enablerepo</span>=remi-test <span style="color: #c20cb9; font-weight: bold;">install</span> mysqlclient16</pre></div></div>



<p>自分が必要とするパッケージをインストールする（パッケージによってはEPEL内のパッケージに依存することがある）。</p>


<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">sudo</span> yum <span style="color: #660033;">--enablerepo</span>=epel,remi <span style="color: #c20cb9; font-weight: bold;">install</span> php php-cli php-mysql php-gd</pre></div></div>



<p>インストール後はリポジトリ管理者のブログ<a href="http://blog.famillecollet.com/">Les RPM de Remi</a>を常にチェックしておくことをおすすめする。PHPの新しいバージョンが出た場合、今までは数日中には対応されてきた。しかしアップデートに伴って、時々パッケージの構成が変わったりライブラリのバージョンが変わったりして、すんなりアップデートできなくなることもあった。そのあたりは自己責任で。</p>

]]></content:encoded>
			<wfw:commentRss>http://wp.serpere.info/archives/293/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CentOSにMovable Type4をインストールする</title>
		<link>http://wp.serpere.info/archives/177</link>
		<comments>http://wp.serpere.info/archives/177#comments</comments>
		<pubDate>Mon, 26 Jan 2009 14:48:44 +0000</pubDate>
		<dc:creator>tkykmw</dc:creator>
				<category><![CDATA[未分類]]></category>
		<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Movable Type]]></category>

		<guid isPermaLink="false">http://wp.serpere.info/?p=177</guid>
		<description><![CDATA[RPMForgeをリポジトリに追加しておけば、全てのPerlモジュールをyumでインストールすることができる。 sudo yum --enablerepo=rpmforge install \ perl-Image-Size perl-SOAP-Lite perl-Crypt-DSA perl-XML-Atom \ ImageMagick-perl perl-Archive-Zip perl-IO-Compress-Zlib perl-PerlIO-gzip #DB接続モジュールはお好みでどれか一つ sudo yum --enablerepo=rpmforge install perl-DBD-MySQL \ perl-DBD-Pg perl-DBD-SQLite perl-DBD-SQLite2 MTが扱い難い点の一つは、依存するPerlモジュールを揃えるのが大変だという点だ。モジュール同士の依存関係はcpanコマンドで解決できるのだが、全てをコンパイルするにはそれなりの時間がかかるし、ちょっと環境が古いとImageMagickやXML::Atomなどの重要なモジュールがコンパイルできなかったりして、面倒なことこの上ない。まったくyum様々、RPMForge様々だ。]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_jade" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fwp.serpere.info%252Farchives%252F177%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22CentOS%E3%81%ABMovable%20Type4%E3%82%92%E3%82%A4%E3%83%B3%E3%82%B9%E3%83%88%E3%83%BC%E3%83%AB%E3%81%99%E3%82%8B%22%20%7D);"></div>
<p>RPMForgeをリポジトリに追加しておけば、全てのPerlモジュールをyumでインストールすることができる。</p>
<pre code="bash">sudo yum --enablerepo=rpmforge install \
     perl-Image-Size perl-SOAP-Lite perl-Crypt-DSA perl-XML-Atom \
     ImageMagick-perl perl-Archive-Zip perl-IO-Compress-Zlib perl-PerlIO-gzip

#DB接続モジュールはお好みでどれか一つ
sudo yum --enablerepo=rpmforge install perl-DBD-MySQL \
     perl-DBD-Pg perl-DBD-SQLite perl-DBD-SQLite2
</pre>
<p>MTが扱い難い点の一つは、依存するPerlモジュールを揃えるのが大変だという点だ。モジュール同士の依存関係はcpanコマンドで解決できるのだが、全てをコンパイルするにはそれなりの時間がかかるし、ちょっと環境が古いとImageMagickやXML::Atomなどの重要なモジュールがコンパイルできなかったりして、面倒なことこの上ない。まったくyum様々、RPMForge様々だ。</p>

]]></content:encoded>
			<wfw:commentRss>http://wp.serpere.info/archives/177/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

