<?xml version="1.0" encoding="UTF-8" ?>
<rdf:RDF
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns="http://purl.org/rss/1.0/"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">

  <channel rdf:about="http://stdpg.blog.shinobi.jp/RSS/100/">
    <title>開発メモるアル</title>
    <link>http://stdpg.blog.shinobi.jp/</link>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://stdpg.blog.shinobi.jp/RSS/" />
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" />
    <description>自分なりの目線で情報を発信します。</description>
    <dc:language>ja</dc:language>
    <dc:date>2015-08-20T08:54:26+09:00</dc:date>
    <items>
    <rdf:Seq>
      <rdf:li rdf:resource="http://stdpg.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/move-to-new-blog" />
      <rdf:li rdf:resource="http://stdpg.blog.shinobi.jp/vmware/vmware-tools-install-ubuntu1210" />
      <rdf:li rdf:resource="http://stdpg.blog.shinobi.jp/mysql/mysql%20%E3%83%93%E3%83%A5%E3%83%BC%E4%BD%9C%E6%88%90%E6%99%82%E3%81%AE%E3%82%AB%E3%83%A9%E3%83%A0%E5%88%A5%E5%90%8D%EF%BC%88%E3%82%A8%E3%82%A4%E3%83%AA%E3%82%A2%E3%82%B9%EF%BC%89%E3%81%AB" />
      <rdf:li rdf:resource="http://stdpg.blog.shinobi.jp/unix/whois%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%AE%E7%B5%90%E6%9E%9C%E3%82%92%E6%97%A5%E6%9C%AC%E8%AA%9E%E8%A1%A8%E7%A4%BA%E3%81%AB%E3%81%99%E3%82%8B" />
      <rdf:li rdf:resource="http://stdpg.blog.shinobi.jp/apache/apache%E8%B5%B7%E5%8B%95%E6%99%82%E3%81%AB%E3%80%81%20-warn-%20_default_%20virtualhost%20overlap%20on%20port%2080%20%E3%81%AE%E8%A1%A8%E7%A4%BA" />
      <rdf:li rdf:resource="http://stdpg.blog.shinobi.jp/mysql/my.cnf%E3%82%92%E6%9B%B8%E3%81%8D%E6%8F%9B%E3%81%88%E3%81%A6%E3%80%81mysql%E3%82%B5%E3%83%BC%E3%83%90%E3%83%BC%E8%B5%B7%E5%8B%95%E4%B8%8D%E8%83%BD%E3%81%AB%E3%80%82%E3%81%9D%E3%81%93%E3%81%8B%E3%82%89%E8%B5%B7%E5%8B%95%E3%81%95%E3%81%9B%E3%82%8B%E3%81%BE%E3%81%A7" />
      <rdf:li rdf:resource="http://stdpg.blog.shinobi.jp/php/%E3%80%8Cparse%20error-%20syntax%20error-%20unexpected%20-end%E3%80%8D%E3%81%AE%E5%AF%BE%E5%BF%9C" />
      <rdf:li rdf:resource="http://stdpg.blog.shinobi.jp/vmware/vmware%E3%81%8B%E3%82%89%E3%83%9B%E3%82%B9%E3%83%88os%E3%81%AE%E5%85%B1%E6%9C%89%E3%83%95%E3%82%A9%E3%83%AB%E3%83%80%E3%81%8C%E8%A6%8B%E3%81%88%E3%81%AA%E3%81%8F%E3%81%AA%E3%82%8B" />
      <rdf:li rdf:resource="http://stdpg.blog.shinobi.jp/vmware/vmware%20player%20%E3%82%B2%E3%82%B9%E3%83%88os-ubuntu-%E3%81%A8%E3%83%9B%E3%82%B9%E3%83%88os-windows-%E3%81%A7%E3%83%95%E3%82%A9%E3%83%AB%E3%83%80%E3%82%92%E5%85%B1%E6%9C%89%E3%81%99%E3%82%8B%20" />
      <rdf:li rdf:resource="http://stdpg.blog.shinobi.jp/r/ubuntu11.10%E4%B8%8A%E3%81%AB%E3%80%81r%E3%81%A7mysql%E3%82%92%E4%BD%BF%E3%81%88%E3%82%8B%E7%92%B0%E5%A2%83%E3%82%92%E4%BD%9C%E3%82%8B" />
    </rdf:Seq>
    </items>
  </channel>

  <item rdf:about="http://stdpg.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/move-to-new-blog">
    <link>http://stdpg.blog.shinobi.jp/%E6%9C%AA%E9%81%B8%E6%8A%9E/move-to-new-blog</link>
    <title>ブログ移転のお知らせ</title>
    <description>本ブログは移転しました。

（移転先）開発メモるアル プログラミングなど技術ブログ

移転先でもよろしくお願いします！



...</description>
    <content:encoded><![CDATA[本ブログは移転しました。<br />
<br />
<a href="http://shusatoo.net/" target="_blank">（移転先）開発メモるアル プログラミングなど技術ブログ</a><br />
<br />
移転先でもよろしくお願いします！<br />
<br />
<br />
<br />
]]></content:encoded>
    <dc:subject>未選択</dc:subject>
    <dc:date>2013-03-11T21:38:32+09:00</dc:date>
    <dc:creator>shusatoo</dc:creator>
    <dc:publisher>NINJA BLOG</dc:publisher>
    <dc:rights>shusatoo</dc:rights>
  </item>
  <item rdf:about="http://stdpg.blog.shinobi.jp/vmware/vmware-tools-install-ubuntu1210">
    <link>http://stdpg.blog.shinobi.jp/vmware/vmware-tools-install-ubuntu1210</link>
    <title>Ubuntu12.10へのVMware Toolsインストールが「The path &quot;&quot; is not a valid path ... kernel headers.」で失敗する件への対処</title>
    <description>VMware Playerにて、Ubuntu12.10の仮想環境を使っています。
ホストOS: Windows8ゲストOS: Ubuntu12.10この環境でVMware Toolsのインストールを試みたのですが、
下記メッセージが出てインストールが続けられなくなってしまいます。
user@u...</description>
    <content:encoded><![CDATA[VMware Playerにて、Ubuntu12.10の仮想環境を使っています。<br />
<ul><li>ホストOS: Windows8</li><li>ゲストOS: Ubuntu12.10</li></ul>この環境でVMware Toolsのインストールを試みたのですが、<br />
下記メッセージが出てインストールが続けられなくなってしまいます。<br />
<pre class="code">user@user-virtual-machine:~$ sudo vmware-tools-distrib/vmware-install.pl <br />
<br />
...(省略)<br />
<br />
Enter the path to the kernel header files for the 3.5.0-17-generic kernel? <br />
<br />
The path "" is not a valid path to the 3.5.0-17-generic kernel headers.<br />
Would you like to change it? [yes] <br />
</pre>カーネルのヘッダが無いと言っているらしい。<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;※VMware-Toolsのインストールは、VMware Playerのメニューにて、<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[管理]->[VMware Toolsの(再)インストール]をすると、仮想CDがマウントされるので、それを解凍して行います。<br />
<br />
カーネルのバージョンを確認します。<pre class="code">user@user-virtual-machine:~$ uname -a<br />
Linux user-virtual-machine 3.5.0-17-generic #28-Ubuntu SMP Tue Oct 9 19:31:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux<br />
user@user-virtual-machine:~$ <br />
</pre>カーネルのバージョンは、"3.5.0-17-generic" ですね。<br />
<br />
確認したバージョンに合致するヘッダーファイルをインストールします。<pre class="code">user@user-virtual-machine:~$ sudo apt-get install linux-headers-3.5.0-17-generic<br />
パッケージリストを読み込んでいます... 完了<br />
依存関係ツリーを作成しています                <br />
状態情報を読み取っています... 完了<br />
以下のパッケージが新たにインストールされます:<br />
  linux-headers-3.5.0-17-generic<br />
アップグレード: 0 個、新規インストール: 1 個、 削除: 0 個、保留: 278 個。<br />
946 kB のアーカイブを取得する必要があります。<br />
この操作後に追加で 11.2 MB のディスク容量が消費されます。<br />
取得:1 http://jp.archive.ubuntu.com/ubuntu/ quantal/main linux-headers-3.5.0-17-generic amd64 3.5.0-17.28 [946 kB]<br />
946 kB を 0秒 で取得しました (1,127 kB/s)               <br />
以前に未選択のパッケージ linux-headers-3.5.0-17-generic を選択しています。<br />
(データベースを読み込んでいます ... 現在 144630 個のファイルとディレクトリがインストールされています。)<br />
(.../linux-headers-3.5.0-17-generic_3.5.0-17.28_amd64.deb から) linux-headers-3.5.0-17-generic を展開しています...<br />
linux-headers-3.5.0-17-generic (3.5.0-17.28) を設定しています ...<br />
user@user-virtual-machine:~$ <br />
</pre>ヘッダーファイルのインストールが完了しました。<br />
<br />
再度、VMware-Toolsのインストール実行。<pre class="code">user@user-virtual-machine:~$ sudo vmware-tools-distrib/vmware-install.pl <br />
<br />
...(省略)<br />
<br />
Searching for a valid kernel header path...<br />
Detected the kernel headers at "/lib/modules/3.5.0-17-generic/build/include".<br />
The path "/lib/modules/3.5.0-17-generic/build/include" appears to be a valid <br />
path to the 3.5.0-17-generic kernel headers.<br />
Would you like to change it? [no] <br />
<br />
...(省略)<br />
<br />
Enjoy,<br />
<br />
--the VMware team<br />
<br />
Found VMware Tools CDROM mounted at /media/user/VMware Tools. Ejecting device <br />
/dev/sr0 ...<br />
user@user-virtual-machine:~$ <br />
</pre>先ほどインストールしたバージョンのヘッダーファイルを認識しているようで、<br />
VMware-Toolsのインストールが完了しました。<br />
<br />
<br />
この問題を解決するにあたり、こちらのページを参考にさせていただきました。<br />
とてもわかりやすく、非常に助かりました。ありがとうございました！<br />
<a href="http://blog.satrex.jp/blog/2012/07/02/vmware-tools-installed/">ゲストubuntuに、VMware-Toolsをインストールする - 電気羊の執務室</a><br />
]]></content:encoded>
    <dc:subject>VMWare</dc:subject>
    <dc:date>2013-02-23T17:23:45+09:00</dc:date>
    <dc:creator>shusatoo</dc:creator>
    <dc:publisher>NINJA BLOG</dc:publisher>
    <dc:rights>shusatoo</dc:rights>
  </item>
  <item rdf:about="http://stdpg.blog.shinobi.jp/mysql/mysql%20%E3%83%93%E3%83%A5%E3%83%BC%E4%BD%9C%E6%88%90%E6%99%82%E3%81%AE%E3%82%AB%E3%83%A9%E3%83%A0%E5%88%A5%E5%90%8D%EF%BC%88%E3%82%A8%E3%82%A4%E3%83%AA%E3%82%A2%E3%82%B9%EF%BC%89%E3%81%AB">
    <link>http://stdpg.blog.shinobi.jp/mysql/mysql%20%E3%83%93%E3%83%A5%E3%83%BC%E4%BD%9C%E6%88%90%E6%99%82%E3%81%AE%E3%82%AB%E3%83%A9%E3%83%A0%E5%88%A5%E5%90%8D%EF%BC%88%E3%82%A8%E3%82%A4%E3%83%AA%E3%82%A2%E3%82%B9%EF%BC%89%E3%81%AB</link>
    <title>MySQL ビュー作成時のカラム別名（エイリアス）にアンダーバーが上手く使えないことがある</title>
    <description>
	ビューを作る時に、カラムに別名（エイリアス）を付けたいことも多いと思いますが、

	MySQLで特定のケースにおいて、別名にアンダーバーなどが上手く使えない場合があります。

	(MySQL5.1.6)

	&amp;amp;nbsp;

	例えばこんな感じのテーブル、ビューを作ってみます。...</description>
    <content:encoded><![CDATA[<div>
	ビューを作る時に、カラムに別名（エイリアス）を付けたいことも多いと思いますが、</div>
<div>
	MySQLで特定のケースにおいて、別名にアンダーバーなどが上手く使えない場合があります。</div>
<div>
	(MySQL5.1.6)</div>
<div>
	&nbsp;</div>
<div>
	例えばこんな感じのテーブル、ビューを作ってみます。</div>
<pre class="code">
mysql&gt; CREATE TABLE tbl_test
    -&gt; (
    -&gt;   id int NOT NULL AUTO_INCREMENT,
    -&gt;   value int NOT NULL,
    -&gt;   insdate timestamp NOT NULL,
    -&gt;   CONSTRAINT pk_tbl_test PRIMARY KEY (id)
    -&gt; );
Query OK, 0 rows affected (0.14 sec)

mysql&gt; CREATE VIEW vw_test AS
    -&gt; SELECT
    -&gt;   DATE_FORMAT(insdate, &#39;%Y%m&#39;) AS year_month, SUM(value) AS sum_value
    -&gt; FROM
    -&gt;   tbl_test
    -&gt; GROUP BY
    -&gt;   year_month;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near &#39;year_month, SUM(value) AS sum_value
FROM
  tbl_test
GROUP BY
  year_month&#39; at line 3
mysql&gt; 
</pre>
<div>
	ビューの作成に失敗しました。</div>
<div>
	カラム別名にアンダーバーが含まれていて、これがどうも予約語として認識されているようです。</div>
<div>
	そのため、カラム別名の部分を識別子として認識させるために&#39;`&#39;(バッククォート)で囲んで再実行してみます。</div>
<pre class="code">
mysql&gt; CREATE VIEW vw_test AS
    -&gt; SELECT
    -&gt;   DATE_FORMAT(insdate, &#39;%Y%m&#39;) AS `year_month`, SUM(value) AS sum_value
    -&gt; FROM
    -&gt;   tbl_test
    -&gt; GROUP BY
    -&gt;   `year_month`;
Query OK, 0 rows affected (0.01 sec)
</pre>
<div>
	ビューの作成が成功しました。</div>
<div>
	あれ？でも&quot;sum_value&quot;もカラム別名なのにバッククォート使わずにいけてるじゃないか、</div>
<div>
	と思うのですが、これは大丈夫なようです。</div>
<div>
	<br />
	推測ですが、DATE_FORMATのような、ワイルドカードまたは特殊記号を使う関数を使う場合、</div>
<div>
	そのカラム中では別名においてもアンダーバーなどが予約語化してしまうようです。</div>
<div>
	予約語化というか、カラム別名自体が文字列化してしまうのではないかと思います。</div>
<div>
	&nbsp;</div>
<div>
	そのため、以下の文字列中で特別な意味を持つ文字はすべて今回の問題に引っかかるかもしれません。</div>
<div>
	\0, シングルクォート（&#39;）, ダブルクォート（&quot;）, バックスペース(\b),</div>
<div>
	改行文字（\n）, キャリッジリターン（\r）, タブ(\t), Control-Z(\z),</div>
<div>
	バックスラッシュ(\), パーセント（%）, アンダーバー（_）</div>
<div>
	<br />
	&nbsp;</div>
<div>
	これで解決！と思いきや、</div>
<div>
	このビューからSELECTする際にも注意が必要になります。</div>
<pre class="code">
mysql&gt; select * from vw_test where year_month = &#39;201212&#39;;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near &#39;year_month = &#39;201212&#39;&#39; at line 1
</pre>
<div>
	&nbsp;</div>
<div>
	ここでもカラム別名にバッククォートをつけてやる必要があるのです。</div>
<pre class="code">
mysql&gt; select * from vw_test where `year_month` = &#39;201212&#39;;
+------------+-----------+
| year_month | sum_value |
+------------+-----------+
| 201212     |      1000 |
+------------+-----------+
1 row in set (0.00 sec)
</pre>
<div>
	&nbsp;</div>
<div>
	SELECTできました。</div>
<div>
	&nbsp;</div>
<div>
	てな感じで、直感的にSELECTが実行できないため、</div>
<div>
	バッククォートしないと、カラム別名にアンダーバーを使えない状況になったら、</div>
<div>
	極力使わない方が良さそうですね。</div>
<div>
	（常にバッククォートを使うという習慣がある人や環境なら別なのでしょうけど）</div>
<div>
	&nbsp;</div>
]]></content:encoded>
    <dc:subject>MySQL</dc:subject>
    <dc:date>2013-01-08T09:54:14+09:00</dc:date>
    <dc:creator>shusatoo</dc:creator>
    <dc:publisher>NINJA BLOG</dc:publisher>
    <dc:rights>shusatoo</dc:rights>
  </item>
  <item rdf:about="http://stdpg.blog.shinobi.jp/unix/whois%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%AE%E7%B5%90%E6%9E%9C%E3%82%92%E6%97%A5%E6%9C%AC%E8%AA%9E%E8%A1%A8%E7%A4%BA%E3%81%AB%E3%81%99%E3%82%8B">
    <link>http://stdpg.blog.shinobi.jp/unix/whois%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%81%AE%E7%B5%90%E6%9E%9C%E3%82%92%E6%97%A5%E6%9C%AC%E8%AA%9E%E8%A1%A8%E7%A4%BA%E3%81%AB%E3%81%99%E3%82%8B</link>
    <title>whoisコマンドの結果を日本語表示にする</title>
    <description>
	
		whoisコマンドを使うと、ドメインのwhois情報が簡単に確認できて便利ですよね。
	
		特にjpドメインのwhois情報であれば、日本語表示を期待するのではないでしょうか。
	
		にもかかわらず、whoisコマンドの結果が日本語にならないことがあります。
	
		&amp;amp;...</description>
    <content:encoded><![CDATA[<div>
	<div>
		whoisコマンドを使うと、ドメインのwhois情報が簡単に確認できて便利ですよね。</div>
	<div>
		特にjpドメインのwhois情報であれば、日本語表示を期待するのではないでしょうか。</div>
	<div>
		にもかかわらず、whoisコマンドの結果が日本語にならないことがあります。</div>
	<div>
		&nbsp;</div>
	<pre class="code">
[user@localhost ~]$ whois google.co.jp
[Querying whois.jprs.jp]
[whois.jprs.jp]
[ JPRS database provides information on network administration. Its use is    ]
[ restricted to network administration purposes. For further information,     ]
[ use &#39;whois -h whois.jprs.jp help&#39;. To suppress Japanese output, add&#39;/e&#39;     ]
[ at the end of command, e.g. &#39;whois -h whois.jprs.jp xxx/e&#39;.                 ]

Domain Information:
a. [Domain Name]                GOOGLE.CO.JP
g. [Organization]               Google Japan
l. [Organization Type]          corporation
m. [Administrative Contact]     DL152JP
n. [Technical Contact]          TW124137JP
p. [Name Server]                ns1.google.com
p. [Name Server]                ns2.google.com
p. [Name Server]                ns3.google.com
p. [Name Server]                ns4.google.com
s. [Signing Key]                
[State]                         Connected (2013/03/31)
[Registered Date]               2001/03/22
[Connected Date]                2001/03/22
[Last Update]                   2012/08/06 14:26:57 (JST)
</pre>
	<div>
		結果メッセージを良く見てみると、こんな記述が。</div>
	<pre class="code">
[use &#39;whois -h whois.jprs.jp help&#39;. To suppress Japanese output, add&#39;/e&#39;]
</pre>
	<div>
		&quot;日本語出力を抑制する場合は &#39;/e&#39; をつけてね&quot;とあります。</div>
	<div>
		いやいや、&#39;/e&#39;なんてつけてないんですけど。</div>
	<div>
		そこで分かったのが、whoisコマンドの設定ファイルの存在。</div>
	<div>
		&nbsp;</div>
	<div>
		whoisコマンドには、いくつかの種類、バージョンが存在するのですが、</div>
	<div>
		自分の環境(CentOS 5.5)ではjwhoisというコマンドが搭載されているようです。</div>
	<pre class="code">
[user@localhost ~]$ which whois
/usr/bin/whois
[user@localhost ~]$ which jwhois
/usr/bin/jwhois
[user@localhost ~]$ ls -l /usr/bin/whois
lrwxrwxrwx 1 root root 6  7月  5  2010 /usr/bin/whois -&gt; jwhois
</pre>
	<div>
		whois -&gt; jwhoisにシンボリックリンクしてるだけですね。</div>
	<div>
		&nbsp;</div>
	<div>
		で、そのjwhoisコマンドの設定ファイルが、デフォルトだと</div>
	<div>
		/etc/jwhois.conf とのこと。</div>
	<div>
		ファイルを開いてみると、こんな箇所が。</div>
	<pre class="code">
&quot;\\.jp$&quot; {
        whois-server = &quot;whois.jprs.jp&quot;;
        query-format = &quot;$* /e&quot;;
}
</pre>
	<div>
		query-formatとして自動的に&#39;/e&#39;をつけるようになっていますね！</div>
	<div>
		これをコメントアウトしてwhoisコマンドを実行してみます。</div>
	<div>
		&nbsp;</div>
	<pre class="code">
[user@localhost ~]$ whois google.co.jp
[Querying whois.jprs.jp]
[whois.jprs.jp]
[ JPRS database provides information on network administration. Its use is    ]
[ restricted to network administration purposes. For further information,     ]
[ use &#39;whois -h whois.jprs.jp help&#39;. To suppress Japanese output, add&#39;/e&#39;     ]
[ at the end of command, e.g. &#39;whois -h whois.jprs.jp xxx/e&#39;.                 ]

Domain Information: [ドメイン情報]
a. [ドメイン名]                 GOOGLE.CO.JP
e. [そしきめい]                 ぐーぐるかぶしきかいしゃ
f. [組織名]                     グーグル株式会社
g. [Organization]               Google Japan
k. [組織種別]                   株式会社
l. [Organization Type]          corporation
m. [登録担当者]                 DL152JP
n. [技術連絡担当者]             TW124137JP
p. [ネームサーバ]               ns1.google.com
p. [ネームサーバ]               ns2.google.com
p. [ネームサーバ]               ns3.google.com
p. [ネームサーバ]               ns4.google.com
s. [署名鍵]                     
[状態]                          Connected (2013/03/31)
[登録年月日]                    2001/03/22
[接続年月日]                    2001/03/22
[最終更新]                      2012/08/06 14:26:57 (JST)

[user@localhost ~]$ 
</pre>
	<div>
		whois結果が日本語で表示されました。</div>
	<div>
		&nbsp;</div>
</div>
<br />
]]></content:encoded>
    <dc:subject>Unix</dc:subject>
    <dc:date>2012-12-28T11:53:02+09:00</dc:date>
    <dc:creator>shusatoo</dc:creator>
    <dc:publisher>NINJA BLOG</dc:publisher>
    <dc:rights>shusatoo</dc:rights>
  </item>
  <item rdf:about="http://stdpg.blog.shinobi.jp/apache/apache%E8%B5%B7%E5%8B%95%E6%99%82%E3%81%AB%E3%80%81%20-warn-%20_default_%20virtualhost%20overlap%20on%20port%2080%20%E3%81%AE%E8%A1%A8%E7%A4%BA">
    <link>http://stdpg.blog.shinobi.jp/apache/apache%E8%B5%B7%E5%8B%95%E6%99%82%E3%81%AB%E3%80%81%20-warn-%20_default_%20virtualhost%20overlap%20on%20port%2080%20%E3%81%AE%E8%A1%A8%E7%A4%BA</link>
    <title>Apache起動時に、 [warn] _default_ VirtualHost overlap on port 80 の表示</title>
    <description>
	バーチャルホストを使うために、

	Apacheの設定ファイル(httpd.conf,およびhttpd.confから読み込まれるファイル)に、

	VirtualHostの設定を記述してApache再起動。

	すると、Apache自体は起動するが、エラーメッセージが。

[r...</description>
    <content:encoded><![CDATA[<div>
	バーチャルホストを使うために、</div>
<div>
	Apacheの設定ファイル(httpd.conf,およびhttpd.confから読み込まれるファイル)に、</div>
<div>
	VirtualHostの設定を記述してApache再起動。</div>
<div>
	すると、Apache自体は起動するが、エラーメッセージが。</div>
<pre class="code">
[root@localhost ~]# /etc/rc.d/init.d/httpd restart
Stopping httpd: [OK]
Starting httpd: 
[warn] _default_ VirtualHost overlap on port 80, the first has precedence
[OK]
[root@localhost ~]#
</pre>
<div>
	&nbsp;</div>
<div>
	どうもバーチャルホストが正しく働いていない。</div>
<div>
	結局、Apacheの設定ファイルの、</div>
<div>
	NameVirtualHost *:80</div>
<div>
	がコメントアウトされていた（デフォルト）だけだった。</div>
<div>
	&nbsp;</div>
<div>
	コメントアウトを外して再起動。</div>
<pre class="code">
[root@localhost ~]# /etc/rc.d/init.d/httpd restart
Stopping httpd: [OK]
Starting httpd: [OK]
[root@localhost ~]#
</pre>
<div>
	&nbsp;</div>
<div>
	うまくいった。</div>
<div>
	&nbsp;</div>
]]></content:encoded>
    <dc:subject>Apache</dc:subject>
    <dc:date>2012-11-18T09:30:00+09:00</dc:date>
    <dc:creator>shusatoo</dc:creator>
    <dc:publisher>NINJA BLOG</dc:publisher>
    <dc:rights>shusatoo</dc:rights>
  </item>
  <item rdf:about="http://stdpg.blog.shinobi.jp/mysql/my.cnf%E3%82%92%E6%9B%B8%E3%81%8D%E6%8F%9B%E3%81%88%E3%81%A6%E3%80%81mysql%E3%82%B5%E3%83%BC%E3%83%90%E3%83%BC%E8%B5%B7%E5%8B%95%E4%B8%8D%E8%83%BD%E3%81%AB%E3%80%82%E3%81%9D%E3%81%93%E3%81%8B%E3%82%89%E8%B5%B7%E5%8B%95%E3%81%95%E3%81%9B%E3%82%8B%E3%81%BE%E3%81%A7">
    <link>http://stdpg.blog.shinobi.jp/mysql/my.cnf%E3%82%92%E6%9B%B8%E3%81%8D%E6%8F%9B%E3%81%88%E3%81%A6%E3%80%81mysql%E3%82%B5%E3%83%BC%E3%83%90%E3%83%BC%E8%B5%B7%E5%8B%95%E4%B8%8D%E8%83%BD%E3%81%AB%E3%80%82%E3%81%9D%E3%81%93%E3%81%8B%E3%82%89%E8%B5%B7%E5%8B%95%E3%81%95%E3%81%9B%E3%82%8B%E3%81%BE%E3%81%A7</link>
    <title>my.cnfを書き換えて、MySQLサーバー起動不能に。そこから起動させるまで</title>
    <description>
	MySQLをyumでインストールした直後にオリジナルのmy.cnfをリネームして、

	新しいmy.cnfを適当に作成すると、サーバーの起動に失敗しました。

	サーバーの起動を成功させるまでのメモです。

[root@localhost etc]# /etc/rc.d/init....</description>
    <content:encoded><![CDATA[<div>
	MySQLをyumでインストールした直後にオリジナルのmy.cnfをリネームして、</div>
<div>
	新しいmy.cnfを適当に作成すると、サーバーの起動に失敗しました。</div>
<div>
	サーバーの起動を成功させるまでのメモです。</div>
<pre class="code">
[root@localhost etc]# /etc/rc.d/init.d/mysqld restart
Stopping MySQL:                                            [FAILED]
touch: cannot touch `/var/log/mysql/error.log&#39;: No such file or directory
chown: cannot access `/var/log/mysql/error.log&#39;: No such file or directory
chmod: cannot access `/var/log/mysql/error.log&#39;: No such file or directory
Initializing MySQL database:  Installing MySQL system tables...
/usr/libexec/mysqld: File &#39;/var/log/mysql/bin-index.log&#39; not found (Errcode: 2)
121115 14:58:33 [ERROR] Aborting

121115 14:58:33 [Note] /usr/libexec/mysqld: Shutdown complete


Installation of system tables failed!  Examine the logs in
/var/lib/mysql for more information.

You can try to start the mysqld daemon with:

    shell&gt; /usr/libexec/mysqld --skip-grant &amp;

and use the command line tool /usr/bin/mysql
to connect to the mysql database and look at the grant tables:

    shell&gt; /usr/bin/mysql -u root mysql
    mysql&gt; show tables

Try &#39;mysqld --help&#39; if you have problems with paths.  Using --log
gives you a log in /var/lib/mysql that may be helpful.

Please consult the MySQL manual section
&#39;Problems running mysql_install_db&#39;, and the manual section that
describes problems on your OS.  Another information source are the
MySQL email archives available at http://lists.mysql.com/.

Please check all of the above before mailing us!  And remember, if
you do mail us, you MUST use the /usr/bin/mysqlbug script!

                                                           [FAILED]
</pre>
<div>
	&nbsp;</div>
<div>
	MySQLサーバーの初回起動前には、mysql_install_dbの実行が必要ですね。</div>
<div>
	ということで実行するも失敗。</div>
<div>
	調べてみると、my.cnfに問題があるらしい。</div>
<div>
	&nbsp;</div>
<div>
	ここを参考にさせてもらいました。</div>
<div>
	<a href="http://d.hatena.ne.jp/garage-kid/20100421/1271846694">http://d.hatena.ne.jp/garage-kid/20100421/1271846694</a></div>
<div>
	&nbsp;</div>
<div>
	ということで、my.cnfを元に戻してmysql_install_dbを実行。</div>
<pre class="code">
[root@localhost etc]# cd /etc
[root@localhost etc]# mv my.cnf my.cnf.new
[root@localhost etc]# mv my.cnf.org my.cnf
[root@localhost etc]#
[root@localhost etc]# mysql_install_db
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password &#39;new-password&#39;
/usr/bin/mysqladmin -u root -h localhost password &#39;new-password&#39;

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &amp;

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/bin/mysqlbug script!

[root@localhost etc]#
</pre>
<div>
	&nbsp;</div>
<div>
	mysql_install_db に成功。</div>
<div>
	MySQLサーバーも起動してみる。</div>
<pre class="code">
[root@localhost etc]# /etc/rc.d/init.d/mysqld start
Starting MySQL:                                            [  OK  ]
[root@localhost etc]#
</pre>
<div>
	サーバーの起動にも成功。</div>
<div>
	それでは、my.cnfを新しいものに再度修正して、サーバーを再起動。</div>
<div>
	&nbsp;</div>
<pre class="code">
[root@localhost etc]# /etc/rc.d/init.d/mysqld stop
Stopping MySQL:                                            [  OK  ]
[root@localhost etc]#
[root@localhost etc]# mv my.cnf my.cnf.org
[root@localhost etc]# mv my.cnf.new my.cnf
[root@localhost etc]# /etc/rc.d/init.d/mysqld start
touch: cannot touch `/var/log/mysql/error.log&#39;: No such file or directory
chown: cannot access `/var/log/mysql/error.log&#39;: No such file or directory
chmod: cannot access `/var/log/mysql/error.log&#39;: No such file or directory
MySQL Daemon failed to start.
Starting MySQL:                                            [FAILED]
[root@localhost etc]#
</pre>
<div>
	<br />
	サーバー起動失敗。</div>
<div>
	/var/log/mysql/error.log が無いと怒っているので、新旧のmy.cnfを見比べてみると、</div>
<div>
	&nbsp;</div>
<div>
	■新しいmy.cnfの内容の一部</div>
<div>
	[mysqld_safe]</div>
<div>
	log-error=/var/log/mysql/error.log</div>
<div>
	&nbsp;</div>
<div>
	■古いmy.cnfの内容の一部</div>
<div>
	[mysqld_safe]</div>
<div>
	log-error=/var/log/mysqld.log</div>
<div>
	&nbsp;</div>
<div>
	ログディレクトリが違う。</div>
<div>
	サーバー起動時に自動的にディレクトリ作成までしてくれるほど、さすがに都合良くはないか。</div>
<div>
	ということで、ログディレクトリを手動で作って、サーバー再起動。</div>
<pre class="code">
[root@localhost etc]# mkdir /var/log/mysql
[root@localhost etc]# ls -l /var/log/mysql
total 0
[root@localhost etc]# ls -ld /var/log/mysql
drwxrwxr-x 2 root root 4096 Nov 15 16:33 /var/log/mysql
[root@localhost etc]# chown mysql:mysql /var/log/mysql
[root@localhost etc]# ls -ld /var/log/mysql
drwxrwxr-x 2 mysql mysql 4096 Nov 15 16:33 /var/log/mysql
[root@localhost etc]#
[root@localhost etc]# /etc/rc.d/init.d/mysqld start
MySQL Daemon failed to start.
Starting MySQL:                                            [FAILED]
[root@localhost etc]#
</pre>
<div>
	<br />
	ログディレクトリが無いとは言わなくなったけど、再起動には失敗。</div>
<div>
	エラーログを見てみると・・・</div>
<pre class="code">
[root@localhost etc]# vi /var/log/mysql/error.log
-------- ログの内容 --------
121115 16:34:59 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
121115 16:34:59 [Note] Plugin &#39;ndbcluster&#39; is disabled.
InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
InnoDB: than specified in the .cnf file 0 16777216 bytes!
121115 16:35:00 [ERROR] Plugin &#39;InnoDB&#39; init function returned error.
121115 16:35:00 [ERROR] Plugin &#39;InnoDB&#39; registration as a STORAGE ENGINE failed.
121115 16:35:00 [ERROR] Unknown/unsupported table type: InnoDB
121115 16:35:00 [ERROR] Aborting

121115 16:35:00 [Note] /usr/libexec/mysqld: Shutdown complete

121115 16:35:00 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
--------- /ログの内容 --------
</pre>
<div>
	my.cnf で、innodb_log_file_size の値をいじったあとには、必ずInnoDBログファイルを削除しないとエラーになるらしい。</div>
<div>
	前に起動していたときに作ったログファイルのサイズと、今回定義されたサイズが合わない、ということらしい。</div>
<div>
	ここを参考にさせてもらいました。</div>
<div>
	<a href="http://blog.livedoor.jp/mshinoda88/archives/1488217.html">http://blog.livedoor.jp/mshinoda88/archives/1488217.html</a></div>
<div>
	&nbsp;</div>
<div>
	ログファイルを消して再起動。</div>
<pre class="code">
[root@localhost etc]# rm /var/lib/mysql/ib
ibdata1      ib_logfile0  ib_logfile1 
[root@localhost etc]# rm /var/lib/mysql/ib*
rm: remove regular file `/var/lib/mysql/ibdata1&#39;? y
rm: remove regular file `/var/lib/mysql/ib_logfile0&#39;? y
rm: remove regular file `/var/lib/mysql/ib_logfile1&#39;? y
[root@localhost etc]# /etc/rc.d/init.d/mysqld start
Starting MySQL:                                            [  OK  ]
[root@localhost etc]#
</pre>
<div>
	&nbsp;</div>
<div>
	起動成功！</div>
<div>
	&nbsp;</div>
<div>
	&nbsp;</div>
]]></content:encoded>
    <dc:subject>MySQL</dc:subject>
    <dc:date>2012-11-15T21:48:41+09:00</dc:date>
    <dc:creator>shusatoo</dc:creator>
    <dc:publisher>NINJA BLOG</dc:publisher>
    <dc:rights>shusatoo</dc:rights>
  </item>
  <item rdf:about="http://stdpg.blog.shinobi.jp/php/%E3%80%8Cparse%20error-%20syntax%20error-%20unexpected%20-end%E3%80%8D%E3%81%AE%E5%AF%BE%E5%BF%9C">
    <link>http://stdpg.blog.shinobi.jp/php/%E3%80%8Cparse%20error-%20syntax%20error-%20unexpected%20-end%E3%80%8D%E3%81%AE%E5%AF%BE%E5%BF%9C</link>
    <title>「Parse error: syntax error, unexpected $end」の対応</title>
    <description>
	PHP Parse error: &amp;amp;nbsp;syntax error, unexpected $end

	とエラーログ出力されてしまう場合、

	&amp;amp;nbsp;

	これらのページで説明してくださっているように、

	http://blog.layer8.sh/ja/2012...</description>
    <content:encoded><![CDATA[<div>
	PHP Parse error: &nbsp;syntax error, unexpected $end</div>
<div>
	とエラーログ出力されてしまう場合、</div>
<div>
	&nbsp;</div>
<div>
	これらのページで説明してくださっているように、</div>
<div>
	<a href="http://blog.layer8.sh/ja/2012/01/11/php%E3%81%A7%E3%80%8Csyntax-error-unexpected-end-%E3%80%8D%E3%81%A8%E5%87%BA%E3%82%8B%E3%81%A8%E3%81%8D%E3%81%AE%E5%AF%BE%E5%87%A6%E6%B3%95/">http://blog.layer8.sh/ja/2012/01/11/php%E3%81%A7%E3%80%8Csyntax-error-unexpected...</a><br />
	<a href="http://nobuneko.com/blog/archives/2009/07/phpparse_error_syntax_error_un.html">http://nobuneko.com/blog/archives/2009/07/phpparse_error_syntax_error_un.html</a></div>
<div>
	中括弧{}や、ifとendif、foreachとendforeachの対応がとれていないことが原因ということが多いが、</div>
<div>
	short_open_tagが混じっていると、サーバーの設定によってはこのエラーとなってしまう場合もあるので注意。</div>
<div>
	&nbsp;</div>
<div>
	こちらのページでもshort_open_tagの件は説明してくださってますね。</div>
<div>
	<a href="http://d.hatena.ne.jp/zekcocon/20110720/1311161002">http://d.hatena.ne.jp/zekcocon/20110720/1311161002</a></div>
<div>
	&nbsp;</div>
<div>
	&nbsp;</div>
<div>
	■成功するコード(test_success.php)<br />
	<pre class="prettyprint linenums">
&lt;html&gt;
&nbsp; &lt;head&gt;
&nbsp; &nbsp; &lt;title&gt;test&lt;/title&gt;
&nbsp; &lt;/head&gt;
&nbsp; &lt;body&gt;
&nbsp; &nbsp; &lt;?php for ($i = 0; $i &lt; 3; $i++): ?&gt;
&nbsp; &nbsp; &nbsp; &lt;p&gt;This is test. line &lt;?php echo $i; ?&gt;&lt;/p&gt;
&nbsp; &nbsp; &lt;?php endfor; ?&gt;
&nbsp; &lt;/body&gt;
&lt;/html&gt;
	
</pre>
</div>
■実行
<pre class="code">
[user@hostname work]$ php test_success.php
&lt;html&gt;
&nbsp; &lt;head&gt;
&nbsp; &nbsp; &lt;title&gt;test&lt;/title&gt;
&nbsp; &lt;/head&gt;
&nbsp; &lt;body&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;This is test. line 0&lt;/p&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;This is test. line 1&lt;/p&gt;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &lt;p&gt;This is test. line 2&lt;/p&gt;
&nbsp; &nbsp; &nbsp; &lt;/body&gt;
&lt;/html&gt;
&lt;/pre&gt;
</pre>

<div>
	<br />
	■失敗するコード(test_fail.php)<br />
	<div>
		<pre class="prettyprint linenums">
&lt;html&gt;
&nbsp; &lt;head&gt;
&nbsp; &nbsp; &lt;title&gt;test&lt;/title&gt;
&nbsp; &lt;/head&gt;
&nbsp; &lt;body&gt;
&nbsp; &nbsp; &lt;?php for ($i = 0; $i &lt; 3; $i++): ?&gt;
&nbsp; &nbsp; &nbsp; &lt;p&gt;This is test. line &lt;?php echo $i; ?&gt;&lt;/p&gt;
&nbsp; &nbsp; &lt;? endfor; ?&gt;
&nbsp; &lt;/body&gt;
&lt;/html&gt;
	</pre>
	</div>
	■実行<br />
	<pre class="code">
[user@hostname work]$ php test_fail.php
PHP Parse error:  syntax error, unexpected $end in /home/user/work/test_fail.php on line 11
</pre>
</div>
<br />
]]></content:encoded>
    <dc:subject>PHP</dc:subject>
    <dc:date>2012-11-06T08:55:58+09:00</dc:date>
    <dc:creator>shusatoo</dc:creator>
    <dc:publisher>NINJA BLOG</dc:publisher>
    <dc:rights>shusatoo</dc:rights>
  </item>
  <item rdf:about="http://stdpg.blog.shinobi.jp/vmware/vmware%E3%81%8B%E3%82%89%E3%83%9B%E3%82%B9%E3%83%88os%E3%81%AE%E5%85%B1%E6%9C%89%E3%83%95%E3%82%A9%E3%83%AB%E3%83%80%E3%81%8C%E8%A6%8B%E3%81%88%E3%81%AA%E3%81%8F%E3%81%AA%E3%82%8B">
    <link>http://stdpg.blog.shinobi.jp/vmware/vmware%E3%81%8B%E3%82%89%E3%83%9B%E3%82%B9%E3%83%88os%E3%81%AE%E5%85%B1%E6%9C%89%E3%83%95%E3%82%A9%E3%83%AB%E3%83%80%E3%81%8C%E8%A6%8B%E3%81%88%E3%81%AA%E3%81%8F%E3%81%AA%E3%82%8B</link>
    <title>VMwareからホストOSの共有フォルダが見えなくなる</title>
    <description>
	VMware(Ubuntu)からホストOS(Windows)の共有フォルダが見えなくなった。

	&amp;amp;nbsp;

	今までは見えていたのに急に。
	ソフトウェアアップデートが何か影響しているよう。どれが影響しているのかはわからんが・・・。

	&amp;amp;nbsp;

	vmware-...</description>
    <content:encoded><![CDATA[<div>
	VMware(Ubuntu)からホストOS(Windows)の共有フォルダが見えなくなった。</div>
<div>
	&nbsp;</div>
<div>
	今までは見えていたのに急に。<br />
	ソフトウェアアップデートが何か影響しているよう。どれが影響しているのかはわからんが・・・。</div>
<div>
	&nbsp;</div>
<div>
	vmware-config-tools.pl を実行し、適当に下記コマンドを実行して再起動したら、<br />
	また見えるようになりました。</div>
<div>
	&nbsp;</div>
<pre class="code">
$ sudo ./vmware-tools-distrib/bin/vmware-config-tools.pl
$ sudo /etc/init.d/networking stop
$ sudo rmmod pcnet32
$ sudo rmmod vmxnet
$ sudo modprobe vmxnet
$ sudo /etc/init.d/networking start
$ sudo /usr/bin/vmware-user
</pre>
<br />
どうもvmwareのバージョンアップとvmware-toolのバージョンが合わなかったりして、<br />
共有フォルダの閲覧が不安定になることはよくあるみたいですね。<br />
とりあえず、今後も同様の問題があったらvmware-config-toolsを使ってみよう。]]></content:encoded>
    <dc:subject>VMWare</dc:subject>
    <dc:date>2012-02-18T08:15:50+09:00</dc:date>
    <dc:creator>shusatoo</dc:creator>
    <dc:publisher>NINJA BLOG</dc:publisher>
    <dc:rights>shusatoo</dc:rights>
  </item>
  <item rdf:about="http://stdpg.blog.shinobi.jp/vmware/vmware%20player%20%E3%82%B2%E3%82%B9%E3%83%88os-ubuntu-%E3%81%A8%E3%83%9B%E3%82%B9%E3%83%88os-windows-%E3%81%A7%E3%83%95%E3%82%A9%E3%83%AB%E3%83%80%E3%82%92%E5%85%B1%E6%9C%89%E3%81%99%E3%82%8B%20">
    <link>http://stdpg.blog.shinobi.jp/vmware/vmware%20player%20%E3%82%B2%E3%82%B9%E3%83%88os-ubuntu-%E3%81%A8%E3%83%9B%E3%82%B9%E3%83%88os-windows-%E3%81%A7%E3%83%95%E3%82%A9%E3%83%AB%E3%83%80%E3%82%92%E5%85%B1%E6%9C%89%E3%81%99%E3%82%8B%20</link>
    <title>VMWare Player ゲストOS(Ubuntu)とホストOS(Windows)でフォルダを共有する </title>
    <description>
	以下のような構成でPCを使ってます。

	ホストOS: Windows7

	ゲストOS: Ubuntu11.10 (VMWare Player上で稼働）

	&amp;amp;nbsp;

	基本は使い慣れたWindowsを使いたいのですが（Officeもあるし）、

	開発作業にはロー...</description>
    <content:encoded><![CDATA[<div>
	以下のような構成でPCを使ってます。</div>
<div>
	ホストOS: Windows7</div>
<div>
	ゲストOS: Ubuntu11.10 (VMWare Player上で稼働）</div>
<div>
	&nbsp;</div>
<div>
	基本は使い慣れたWindowsを使いたいのですが（Officeもあるし）、</div>
<div>
	開発作業にはローカルPCにLinux環境も欲しいので、</div>
<div>
	このような構成にしています。</div>
<div>
	&nbsp;</div>
<div>
	ゲストOSから、ホストOSのフォルダが見えるようになれば、</div>
<div>
	Windows上のファイルをLinuxコマンドで扱えるようになるはず。</div>
<div>
	ということでやってみました。</div>
<div>
	&nbsp;</div>
<div>
	VMWare Playerメニューの</div>
<div>
	[仮想マシン]-[仮想マシンの設定]-[オプション]-[共有フォルダ]</div>
<div>
	&quot;フォルダの共有&quot;の項目で&quot;常に有効&quot;を選択して、ゲストOSを起動。</div>
<div>
	&nbsp;</div>
<div>
	そうすると、/mnt/hgfs/ 配下に指定名のディレクトリがあるはず。</div>
が、、、見えません。
<pre class="code">
user@ubuntu:~$ ls /mnt/hgfs/
user@ubuntu:~$ &nbsp;</pre>
<div>
	このフォルダ共有というのはVMWare-toolsの機能らしい。</div>
<div>
	VMWare-toolsはインストール済みなんだけど。。。</div>
<div>
	&nbsp;</div>
<div>
	そこで、</div>
<div>
	<a href="http://d.hatena.ne.jp/meryngii/20090425/1240661286">http://d.hatena.ne.jp/meryngii/20090425/1240661286</a></div>
<div>
	このページを参考にさせていただき、</div>
<div>
	Ubuntuに最初から入っているopen-vm-toolsをアンインストールしました。</div>
<div>
	その後、VMWare-toolsを再インストール。</div>
<div>
	&nbsp;</div>
ホストOSを再起動。
<pre class="code">
user@ubuntu:~$ ls /mnt/hgfs/
hostroot/  hostworkspace/
user@ubuntu:~$
</pre>
<br />
<div>
	見えるようになりました。</div>
<div>
	&nbsp;</div>
<div>
	WindowsのフォルダにLinuxコマンドが実行できます。</div>
<div>
	こりゃ便利。<br />
	&nbsp;</div>
]]></content:encoded>
    <dc:subject>VMWare</dc:subject>
    <dc:date>2012-01-25T00:12:22+09:00</dc:date>
    <dc:creator>shusatoo</dc:creator>
    <dc:publisher>NINJA BLOG</dc:publisher>
    <dc:rights>shusatoo</dc:rights>
  </item>
  <item rdf:about="http://stdpg.blog.shinobi.jp/r/ubuntu11.10%E4%B8%8A%E3%81%AB%E3%80%81r%E3%81%A7mysql%E3%82%92%E4%BD%BF%E3%81%88%E3%82%8B%E7%92%B0%E5%A2%83%E3%82%92%E4%BD%9C%E3%82%8B">
    <link>http://stdpg.blog.shinobi.jp/r/ubuntu11.10%E4%B8%8A%E3%81%AB%E3%80%81r%E3%81%A7mysql%E3%82%92%E4%BD%BF%E3%81%88%E3%82%8B%E7%92%B0%E5%A2%83%E3%82%92%E4%BD%9C%E3%82%8B</link>
    <title>Ubuntu11.10上に、RでMySQLを使える環境を作る</title>
    <description>統計解析が必要な業務が発生し、Rを使うしかなさそうなので、
Ubuntu11.10上で、RでMySQLを使える環境を作ってみました。

まずMySQLをインストールする。

$ sudo apt-get install mysql-server

インストールしたら、default-c...</description>
    <content:encoded><![CDATA[統計解析が必要な業務が発生し、Rを使うしかなさそうなので、<br />
Ubuntu11.10上で、RでMySQLを使える環境を作ってみました。<br />
<br />
まずMySQLをインストールする。
<pre class="code">
$ sudo apt-get install mysql-server
</pre>
インストールしたら、default-character-set を適切な文字コードに設定しておいた方が良いかと。<br />
設定内容はここなどを参考にさせていただければと。<br />
<a href="http://slumbers99.blogspot.com/2010/11/ubuntu-mysql.html">http://slumbers99.blogspot.com/2010/11/ubuntu-mysql.html</a><br />
<pre class="code">
$ sudo vi /etc/mysql/my.cnf
$ sudo /etc/init.d/mysql restart
</pre>
<a href="http://www.okada.jp.org/RWiki/?RMySQL">RMySQL</a><br />
を参考にRMySQLのインストールを試みる。
<pre class="code">
$sudo R
&gt; install.packages(&quot;DBI&quot;)
&gt; install.packages(&quot;RMySQL&quot;)
</pre>
しかし、RMySQLのインストールに失敗する。 以下のような感じで怒られる。
<pre class="code">
Configuration error:
  could not find the MySQL installation include and/or library
  directories.  Manually specify the location of the MySQL
  libraries and the header files and re-run R CMD INSTALL.

INSTRUCTIONS:

1. Define and export the 2 shell variables PKG_CPPFLAGS and
   PKG_LIBS to include the directory for header files (*.h)
   and libraries, for example (using Bourne shell syntax):

      export PKG_CPPFLAGS=&quot;-I<mysql-include-dir>&quot;
      export PKG_LIBS=&quot;-L<mysql-lib-dir> -lmysqlclient&quot;

   Re-run the R INSTALL command:

      R CMD INSTALL RMySQL_<version>.tar.gz

2. Alternatively, you may pass the configure arguments
      --with-mysql-dir=<base-dir> (distribution directory)
   or
      --with-mysql-inc=<base-inc> (where MySQL header files reside)
      --with-mysql-lib=<base-lib> (where MySQL libraries reside)
   in the call to R INSTALL --configure-args=&#39;...&#39;

   R CMD INSTALL --configure-args=&#39;--with-mysql-dir=DIR&#39; RMySQL_<version>.tar.gz

ERROR: configuration failed for package &lsquo;RMySQL&rsquo;
* removing &lsquo;/usr/local/lib/R/site-library/RMySQL&rsquo;

ダウンロードされたパッケージは、以下にあります
     &lsquo;/tmp/RtmpKb6C3d/downloaded_packages&rsquo;
警告メッセージ：
In install.packages(&quot;RMySQL&quot;) :
   パッケージ &#39;&lsquo;RMySQL&rsquo;&#39; のインストールは、ゼロでない終了値をもちました
</version></base-lib></base-inc></base-dir></version></mysql-lib-dir></mysql-include-dir></pre>
<base-dir><base-inc><base-lib><base-dir><base-inc><base-lib><base-dir><base-inc><base-lib>MySQLのincludeディレクトリとlibディレクトリを指定しろ、 ってことらしいが、 includeディレクトリがそもそも見つからない。<br />
<a href="http://dev.mysql.com/doc/refman/5.1/ja/installation-layouts.html">http://dev.mysql.com/doc/refman/5.1/ja/installation-layouts.html</a><br />
ここに標準のディレクトリが記載されているが、 /usr/include/mysql 自体がない。<br />
いろいろ調べてみると、libmysqlclient-dev パッケージが無いのがダメっぽい。 インストール。
<pre class="code">
$ sudo apt-get install libmysqlclient-dev
</pre>
再度RMySQLをインストールしてみる。
<pre class="code">
&gt; install.packages(&quot;RMySQL&quot;)
パッケージを &lsquo;/usr/local/lib/R/site-library&rsquo; 中にインストールします
(&lsquo;lib&rsquo; が指定されていないので)
--- このセッションで使うために、CRANのミラーサイトを選んでください ---
Tcl/Tkインターフェースのロード中   終了済
URL &#39;http://cran.ism.ac.jp/src/contrib/RMySQL_0.8-0.tar.gz&#39; を試しています
Content type &#39;application/x-gzip&#39; length 160735 bytes (156 Kb)
開かれた URL
==================================================
downloaded 156 Kb

* installing *source* package &lsquo;RMySQL&rsquo; ...
checking for gcc... gcc
・
・
・
** testing if installed package can be loaded

* DONE (RMySQL)

ダウンロードされたパッケージは、以下にあります
     &lsquo;/tmp/RtmpMOcKI7/downloaded_packages&rsquo;
</pre>
よし、成功。 実際に接続してみる。
<pre class="code">
&gt; library(RMySQL)
要求されたパッケージ DBI をロード中です
&gt; m &lt;- dbDriver(&quot;MySQL&quot;)
&gt; dbconnector &lt;- dbConnect(m, host=&quot;localhost&quot;, dbname=&quot;itemdb_test&quot;, user=&quot;item&quot;, password=&quot;item&quot;)
&gt; query.result &lt;- dbSendQuery(dbconnector, &quot;select * from item&quot;)
&gt; item.table &lt;- fetch(query.result)
&gt; dbDisconnect(dbconnector)
[1] TRUE
&gt;
&gt; item.table
   item_id                            url domain_age_day a_strlen_rate
1           1                                             0          0.00
2           2                                             0          0.00
</pre>
RからMySQLのデータをSELECTできました。 </base-lib></base-inc></base-dir></base-lib></base-inc></base-dir></base-lib></base-inc></base-dir>]]></content:encoded>
    <dc:subject>R</dc:subject>
    <dc:date>2012-01-14T19:11:25+09:00</dc:date>
    <dc:creator>shusatoo</dc:creator>
    <dc:publisher>NINJA BLOG</dc:publisher>
    <dc:rights>shusatoo</dc:rights>
  </item>
</rdf:RDF>
