ラベル 開発環境 の投稿を表示しています。 すべての投稿を表示
ラベル 開発環境 の投稿を表示しています。 すべての投稿を表示

2016年5月23日月曜日

Apache http 2.4.20をソースからインストール

このエントリーをはてなブックマークに追加
最近、仕事ではyumでインストールを求められることが多かったので、ソースからインストールを久しぶりにしたのでメモ。
Apache httpdをtar.gz形式でダウンロード。
$ tar -xvzf httpd-2.4.20.tar.gz
できたhttpd-2.4.20の下へ移動してconfihureを実施する。
$ ./configure --enable-so --enable-rewrite --enable-proxy
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no
configure: error: APR not found.  Please read the documentation.
そうだ、確か2.4からAPRtAPR-Utilがソースのセットから外出しになっていたんだった。なのでAPRとAPRUtilをソースでダウンロードし解凍してできたディレクトリ毎、httpd2.4.20/srclib配下へ移動させ、上記のconfigureをもう一度やり直す。
$  wget http://ftp.jaist.ac.jp/pub/apache//apr/apr-1.5.2.tar.gz
$  wget http://ftp.kddilabs.jp/infosystems/apache//apr/apr-util-1.5.4.tar.gz
$ tar -xvzf apr-1.5.2.tar.gz
$ tar -xvzf apr-util-1.5.4.tar.gz
$ mv apr-1.5.2 ./httpd-2.4.20/srclib/apr
$ mv apr-util-1.5.4 ./httpd-2.4.20/srclib/apr-util
$ ./configure --enable-so --enable-rewrite --enable-proxy
checking for chosen layout... Apache
::
::
何もなければmake, make installする
$ make
$ make install
httpd.confを一部修正。mod_slotmem_shm.soをIncludeするようにコメントアウトされているものを有効にする。
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
httpd起動する。
# usr/local/src/httpd-2.4.20# /usr/local/apache2/bin/apachectl start

2016年5月7日土曜日

Bash on Ubuntu on Windowsのnetwork周りはまだまだだった(build14332)

このエントリーをはてなブックマークに追加
Bash on Ubuntu on Windowsを触ってみたんだけど、どの程度までできるものなのかApacheをコンパイルして起動させてみるとこまでやってみたいと思う。

Bash on Ubuntu on Windows10を試すの時はPowerShellから起動して...みたいなことを書いていたけども、スタートメニューにBash on Ubuntu on Windowsってのが増えてたので、こちらから起動する。


開けたらこんな感じ。ディレクトリもLinuxになってる。rootも可。


IP調べようと思ったらifconfigでエラーが出た。

$ ifconfig
Warning: cannot open /proc/net/dev (No such file or directory). Limited output.

一応、networkをスタートしてみたもののエラーが出た。

$ /etc/init.d/networking start
 * Configuring network interfaces...                                                                                    resolvconf: Error: /run/resolvconf/interface either does not exist or is not a directory
resolvconf: Error: /run/resolvconf/interface either does not exist or is not a directory
../../../../lib/isc/unix/socket.c:2379: setsockopt(20, SO_TIMESTAMP) failed: Invalid argument
../../../../lib/isc/unix/socket.c:2379: setsockopt(21, SO_TIMESTAMP) failed: Invalid argument
../../../../lib/isc/unix/socket.c:2408: setsockopt(21, IPV6_RECVPKTINFO) failed: Invalid argument
../../../../lib/isc/unix/socket.c:5678: setsockopt(21, IPV6_V6ONLY) failed: Invalid argument

そこで同じようなエラーが出てる人がいて解決できたよってあるので参考にしてみた。

名前解決できないからDNSをGoogleDNSに向けてねってあったので向けてみた。

search web.setting
#nameserver 192.168.128.1
#nameserver 192.168.128.1
#nameserver 192.168.2.1
nameserver 8.8.8.8
nameserver 8.8.4.4

さてもう一度networkをstartした結果。

$ /etc/init.d/networking start
 * Configuring network interfaces...                                                                                    ../../../../lib/isc/unix/socket.c:2379: setsockopt(20, SO_TIMESTAMP) failed: Invalid argument
../../../../lib/isc/unix/socket.c:2379: setsockopt(21, SO_TIMESTAMP) failed: Invalid argument
../../../../lib/isc/unix/socket.c:2408: setsockopt(21, IPV6_RECVPKTINFO) failed: Invalid argument
../../../../lib/isc/unix/socket.c:5678: setsockopt(21, IPV6_V6ONLY) failed: Invalid argument
Internet Systems Consortium DHCP Client 4.2.4
Copyright 2004-2012 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/

Error getting interfaces; Invalid argument
Can't get list of interfaces.
Failed to bring up eth0.

resolveconfのエラーは出なくなったけどsocketのエラーはそのまま。

BashのMSDNにあるFrequently Asked Questionsには
Why isn't ICMP working?

This is a known issues that will effect several networking commands such as ping. Stay tuned for updates.
(pingみたいなnetwork周りのコマンドは問題あること分かってるからupdateを待っててね)
とあるので、少し待ち。

ちなみにUbuntu on Windowsのウィンドウを閉じると、今の時点ではさっきのresolve.confへの変更は取り消されます。

手元のbuildは14332だけどrelease noteをみるとresolve.confをマシにしたとあるので、こまめにアップデートして確認できればいいかな。

まだ問題はあるけどプロダクトとしては非常に面白い。VirtualBoxやVMwareを使わずに手軽に動かせる環境として使えそう。

2016年5月6日金曜日

Bash on Ubuntu on Windows10を試す

このエントリーをはてなブックマークに追加
WindowsのプレビュービルドにてWindows10上でUbuntuが実行できる環境がβ版として提供されているので、少し試してみた。

WindowsのOSバージョンはBuild 14332.1001だ。


「コントロールパネル」から「プログラム」、「Windows機能の有効化または無効化」を選択し、「Windows Subsystem for Linux(Beta)」にチェックを入れる。


「今すぐ再起動」を押し再起動させる。


再起動後、スタートメニューから「Windows PowerShell」を実行する。

ここでbashと入力すると環境のインストールが開始される。
設定するユーザ名やパスワードが聞かれるので適当に決めて入力しよう。


試しにapt-getでupdateしてみる。


割とそれなりに使えそうです。正式リリースの際にはどの程度になっているか楽しみですね。


Chrome ExtensionでSSH

このエントリーをはてなブックマークに追加
chromeでSSHぐらいできる拡張機能あるんじゃないかと思い探してみたらあった。

Secure Shell


インストールしてSSHをブラウザからお手軽に使える!



PC問わず、chromeさえインストールしていれば使えるというのはあって困らない選択肢だと思うので、避難手段として入れておくのはアリだと思いました。


2016年4月16日土曜日

VoyagerX2をVMWare Fusionで動かした時のディスプレイ解像度固定の方法

このエントリーをはてなブックマークに追加
どこ触ってもできなかったので、メモしておく。

最終的には/etc/default/grubに記述すれば反映された。

#GRUB_GFXMODE=640x480
GRUB_GFXMODE=2560x1600   # 設定したい解像度

2016年4月11日月曜日

Windows10で使えるいいターミナルソフトがないか探してTerminalを捨て結局Rlginを選んだ

このエントリーをはてなブックマークに追加
Windows10で使えるいいターミナルソフトがないか探してTerminalsを選んだを書いたんだけど、割と見掛け倒しでしょぼかったので今度こそは思って選んだのがRloginというもの。

割と多機能なようでポートフォワードも対応してるし、スクリプトもかけるらしいのでこれにした。

#自分的にはリモートデスクトップをSSH Tunnelで接続したりしてるのでポートフォワード超重要。

SSHはTerminalの際に出たdiffie-hellman-group1-sha1問題も無く普通に接続できた。なんだよ。やっぱり普通にできるじゃねーか。


さてポートフォワードの出番だ。これが使いたい。

「ファイル」→「サーバに接続」を選択し、「新規」を選択すると下記のような画面になる。

「プロトコル」から「ssh」を選択し、リモートサーバのIPアドレス、アカウントとパスワードを入力する。


左側のメニューから「プロトコル」を選択し、下にある「ポートフォワード」を押す。


「新規」を押し、


Listenするポートと接続に利用するポートを入力する。


このようにリモートに接続できたことを確認したら、


「リモートデスクトップ接続」を開いて接続すると、


Windowsファイアウォールが通信を許可するか聞いてくるので「はい」を選択するとRDPで接続ができる。


これでいいじゃん!

2016年3月26日土曜日

Windows10で使えるいいターミナルソフトがないか探してTerminalsを選んだ

このエントリーをはてなブックマークに追加
普段はMacを使っていてて、家のマシンもすべてMacなのだがWindowsにも触れておかないと
「僕、普段MacなんでWindowsわからないです(キリッ」
という周りから見たらなんかよくわからない事になりそうなのでWindowsも使うようにしている。

ただWindowsでSSHを使う際に正直PuttyとかTeraTermとか飽きてきたので何かいいソフトないかなぁと探していた時に見つけたのがTerminalsというソフトだった。


自分で感じたよくわからない理由なんだけど、なんか”今現れた!”っぽいし、リモートデスクトップも使えるしShellプロンプトも使えるし、PingやnslookupやはたまたWhoisまで使えるというインフラツールが山盛り入っているのが魅力的だったので、使ってみることにした。

インストールして手元のFedora23サーバにSSHしてみようとしたら
Sorry, Terminal was unable to connect to the remote machine.
server does not support diffie-hellman-group1-sha1 for key exchange
と出て接続できなかった。

FedoraのSSHサーバがdiffie-hellman-group1-sha1をサポートしていなからなので、Fedoraのsshd_configにdiffie-hellman-group1-sha1をサポートしてやるように足してやればいいだけなんだけど、それもそれでサーバ側のセキュリティ強度さげてるだけなのでクライアント側でできないか調べてみた。

http://terminals.codeplex.com/discussions/650183

・・・今のところPuttyだけしか対応できてないそうだ。。本当かよ。

という訳で取りあえずsshd_config側に足してあげて対応するようにしたら接続することができた。


たしかにputtyでは簡単に接続できたけどね!

<追記>

というか、これだけじゃなくて見た目派手だけどSSHのポートフォワードが設定項目にあるのにDisableになってて使えなかったり、いろいろとしょぼいので違うものを探すことにしました(涙

2016年3月25日金曜日

Eclipse Chaを使ってみる

このエントリーをはてなブックマークに追加
この前、Eclipse ChaというクラウドIDEがリリースされたというので試してみることにした。

ちょっと前からローカルのPCでできることをクラウドへ移行させたいと思ってて、デスクトップの移行だとかいろいろ試してみている。これもそのうちの1つの選択肢になればいいなと。この前VDIにしたLubuntuが一番ディスク容量があるので、少し意図とは違うけども、これに入れてみる。

事前にJavaのインストールは必須なので入れておこう。

ダウンロードしてきたソースを解凍する。
$ tar -xvzf eclipse-che-4.0.0-RC11.tar.gz
起動させる。
$ cd eclipse-che-4.0.0-RC11/ 
$ ./bin/che.sh run

dockerが起動できない場合はメッセージを見れば大体わかるはず。多くはdockerグループの権限の問題だと思う。

起動に成功すればあとはブラウザからhttp://[IP Address]:8080/へアクセスすると、こんな画面で起動中になる。


・・・

・・・

メモリ1GBだと5分ぐらい待ったけど、これ以上進まなかった。。。
やはりVDIで作ったところには無理があったか。。。

もう少しスペックのある環境で試してみたいと思う。

【追記】

スペックかなり上げたVMで動かしたらちゃんと動きました。

2016年3月22日火曜日

LubuntuにDockerインストールした

このエントリーをはてなブックマークに追加
使い物になるのか試したかったのでLubuntuにDocker入れてみた。ここ見ただけだけどメモっとく。

Install Docker

$ curl -fsSL https://get.docker.com/ | sh
apparmor is enabled in the kernel and apparmor utils were already installed
+ sh -c apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.KxiBSCIzyE --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyring /etc/apt/trusted.gpg.d/alessandro-strada_ubuntu_ppa.gpg --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D
gpg: 鍵2C52609Dをhkpからサーバーp80.pool.sks-keyservers.netに要求
gpg: 鍵2C52609D: 公開鍵“Docker Release Tool (releasedocker) ”を読み込みました
gpg: 処理数の合計: 1
gpg:               読込み: 1  (RSA: 1)
+ sh -c mkdir -p /etc/apt/sources.list.d
+ dpkg --print-architecture
+ sh -c echo deb [arch=amd64] https://apt.dockerproject.org/repo ubuntu-wily main > /etc/apt/sources.list.d/docker.list
+ sh -c sleep 3; apt-get update; apt-get install -y -q docker-engine
ヒット http://jp.archive.ubuntu.com wily InRelease
取得:1 http://jp.archive.ubuntu.com wily-updates InRelease [65.9 kB]
ヒット http://jp.archive.ubuntu.com wily-backports InRelease
無視 http://dl.google.com stable InRelease
ヒット http://jp.archive.ubuntu.com wily/main Sources
ヒット http://jp.archive.ubuntu.com wily/restricted Sources
ヒット http://jp.archive.ubuntu.com wily/universe Sources
ヒット http://jp.archive.ubuntu.com wily/multiverse Sources
ヒット http://jp.archive.ubuntu.com wily/main amd64 Packages
ヒット http://jp.archive.ubuntu.com wily/restricted amd64 Packages
ヒット http://jp.archive.ubuntu.com wily/universe amd64 Packages
ヒット http://jp.archive.ubuntu.com wily/multiverse amd64 Packages
ヒット http://jp.archive.ubuntu.com wily/main i386 Packages
ヒット http://jp.archive.ubuntu.com wily/restricted i386 Packages
ヒット http://jp.archive.ubuntu.com wily/universe i386 Packages
ヒット http://dl.google.com stable Release.gpg
ヒット http://jp.archive.ubuntu.com wily/multiverse i386 Packages
ヒット http://jp.archive.ubuntu.com wily/main Translation-ja
ヒット http://jp.archive.ubuntu.com wily/main Translation-en
ヒット http://jp.archive.ubuntu.com wily/multiverse Translation-ja
ヒット http://jp.archive.ubuntu.com wily/multiverse Translation-en
ヒット http://jp.archive.ubuntu.com wily/restricted Translation-ja
ヒット http://jp.archive.ubuntu.com wily/restricted Translation-en
ヒット http://jp.archive.ubuntu.com wily/universe Translation-ja
ヒット http://jp.archive.ubuntu.com wily/universe Translation-en
取得:2 https://apt.dockerproject.org ubuntu-wily InRelease [454 B]
無視 https://apt.dockerproject.org ubuntu-wily InRelease
取得:3 https://apt.dockerproject.org ubuntu-wily Release.gpg [801 B]
取得:4 http://security.ubuntu.com wily-security InRelease [65.9 kB]
ヒット https://apt.dockerproject.org ubuntu-wily Release
取得:5 http://jp.archive.ubuntu.com wily-updates/main Sources [69.2 kB]
取得:6 http://jp.archive.ubuntu.com wily-updates/restricted Sources [3,741 B]
取得:7 http://jp.archive.ubuntu.com wily-updates/universe Sources [21.1 kB]
ヒット https://apt.dockerproject.org ubuntu-wily/main amd64 Packages
取得:8 http://jp.archive.ubuntu.com wily-updates/multiverse Sources [3,199 B]
取得:9 http://jp.archive.ubuntu.com wily-updates/main amd64 Packages [197 kB]
取得:10 http://jp.archive.ubuntu.com wily-updates/restricted amd64 Packages [13.3 kB]
取得:11 http://jp.archive.ubuntu.com wily-updates/universe amd64 Packages [87.6 kB]
ヒット http://dl.google.com stable Release
取得:12 http://jp.archive.ubuntu.com wily-updates/multiverse amd64 Packages [6,247 B]
ヒット http://ppa.launchpad.net wily InRelease
取得:13 http://jp.archive.ubuntu.com wily-updates/main i386 Packages [194 kB]
取得:14 http://jp.archive.ubuntu.com wily-updates/restricted i386 Packages [13.4 kB]
取得:15 http://jp.archive.ubuntu.com wily-updates/universe i386 Packages [85.0 kB]
取得:16 http://jp.archive.ubuntu.com wily-updates/multiverse i386 Packages [6,678 B]
取得:17 http://jp.archive.ubuntu.com wily-updates/main Translation-en [90.1 kB]
取得:18 https://apt.dockerproject.org ubuntu-wily/main Translation-ja_JP [454 B]
取得:19 http://jp.archive.ubuntu.com wily-updates/multiverse Translation-en [3,156 B]
取得:20 http://jp.archive.ubuntu.com wily-updates/restricted Translation-en [3,024 B]
取得:21 http://jp.archive.ubuntu.com wily-updates/universe Translation-en [51.0 kB]
ヒット http://jp.archive.ubuntu.com wily-backports/main Sources
ヒット http://jp.archive.ubuntu.com wily-backports/restricted Sources
ヒット http://jp.archive.ubuntu.com wily-backports/universe Sources
ヒット http://jp.archive.ubuntu.com wily-backports/multiverse Sources
ヒット http://jp.archive.ubuntu.com wily-backports/main amd64 Packages
ヒット http://jp.archive.ubuntu.com wily-backports/restricted amd64 Packages
ヒット http://jp.archive.ubuntu.com wily-backports/universe amd64 Packages
ヒット http://jp.archive.ubuntu.com wily-backports/multiverse amd64 Packages
ヒット http://dl.google.com stable/main amd64 Packages
ヒット http://jp.archive.ubuntu.com wily-backports/main i386 Packages
ヒット http://jp.archive.ubuntu.com wily-backports/restricted i386 Packages
ヒット http://jp.archive.ubuntu.com wily-backports/universe i386 Packages
ヒット http://jp.archive.ubuntu.com wily-backports/multiverse i386 Packages
ヒット http://jp.archive.ubuntu.com wily-backports/main Translation-en
ヒット http://ppa.launchpad.net wily/main amd64 Packages
ヒット http://jp.archive.ubuntu.com wily-backports/multiverse Translation-en
ヒット http://jp.archive.ubuntu.com wily-backports/restricted Translation-en
ヒット http://jp.archive.ubuntu.com wily-backports/universe Translation-en
取得:22 http://security.ubuntu.com wily-security/main Sources [41.3 kB]
取得:23 https://apt.dockerproject.org ubuntu-wily/main Translation-ja [454 B]
ヒット http://ppa.launchpad.net wily/main i386 Packages
取得:24 http://security.ubuntu.com wily-security/restricted Sources [2,854 B]
ヒット http://ppa.launchpad.net wily/main Translation-en
取得:25 http://security.ubuntu.com wily-security/universe Sources [10.8 kB]
取得:26 https://apt.dockerproject.org ubuntu-wily/main Translation-en [454 B]
取得:27 http://security.ubuntu.com wily-security/multiverse Sources [2,788 B]
取得:28 http://security.ubuntu.com wily-security/main amd64 Packages [133 kB]
取得:29 https://apt.dockerproject.org ubuntu-wily/main Translation-ja_JP [454 B]
取得:30 https://apt.dockerproject.org ubuntu-wily/main Translation-ja [454 B]
取得:31 https://apt.dockerproject.org ubuntu-wily/main Translation-en [454 B]
取得:32 https://apt.dockerproject.org ubuntu-wily/main Translation-ja_JP [454 B]
取得:33 http://security.ubuntu.com wily-security/restricted amd64 Packages [10.9 kB]
取得:34 http://security.ubuntu.com wily-security/universe amd64 Packages [49.3 kB]
取得:35 http://security.ubuntu.com wily-security/multiverse amd64 Packages [6,247 B]
取得:36 https://apt.dockerproject.org ubuntu-wily/main Translation-ja [454 B]
取得:37 http://security.ubuntu.com wily-security/main i386 Packages [130 kB]
取得:38 https://apt.dockerproject.org ubuntu-wily/main Translation-en [454 B]
取得:39 https://apt.dockerproject.org ubuntu-wily/main Translation-ja_JP [454 B]
取得:40 http://security.ubuntu.com wily-security/restricted i386 Packages [10.8 kB]
取得:41 https://apt.dockerproject.org ubuntu-wily/main Translation-ja [454 B]
取得:42 http://security.ubuntu.com wily-security/universe i386 Packages [49.3 kB]
取得:43 https://apt.dockerproject.org ubuntu-wily/main Translation-en [454 B]
取得:44 http://security.ubuntu.com wily-security/multiverse i386 Packages [6,443 B]
取得:45 http://security.ubuntu.com wily-security/main Translation-en [65.6 kB]
取得:46 https://apt.dockerproject.org ubuntu-wily/main Translation-ja_JP [454 B]
無視 https://apt.dockerproject.org ubuntu-wily/main Translation-ja_JP
取得:47 https://apt.dockerproject.org ubuntu-wily/main Translation-ja [454 B]
取得:48 http://security.ubuntu.com wily-security/multiverse Translation-en [2,806 B]
無視 https://apt.dockerproject.org ubuntu-wily/main Translation-ja
取得:49 http://security.ubuntu.com wily-security/restricted Translation-en [2,666 B]
取得:50 https://apt.dockerproject.org ubuntu-wily/main Translation-en [454 B]
無視 https://apt.dockerproject.org ubuntu-wily/main Translation-en
取得:51 http://security.ubuntu.com wily-security/universe Translation-en [32.3 kB]
無視 http://dl.google.com stable/main Translation-ja_JP
無視 http://dl.google.com stable/main Translation-ja
無視 http://dl.google.com stable/main Translation-en
1,537 kB を 7秒 で取得しました (218 kB/s)
パッケージリストを読み込んでいます... 完了
パッケージリストを読み込んでいます...
依存関係ツリーを作成しています...
状態情報を読み取っています...
以下の追加パッケージがインストールされます:
  aufs-tools cgroupfs-mount git git-man liberror-perl
提案パッケージ:
  git-daemon-run git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-arch git-cvs git-mediawiki
  git-svn
推奨パッケージ:
  yubico-piv-tool
以下のパッケージが新たにインストールされます:
  aufs-tools cgroupfs-mount docker-engine git git-man liberror-perl
アップグレード: 0 個、新規インストール: 6 個、削除: 0 個、保留: 1 個。
12.7 MB のアーカイブを取得する必要があります。
この操作後に追加で 68.7 MB のディスク容量が消費されます。
取得:1 http://jp.archive.ubuntu.com/ubuntu/ wily/universe aufs-tools amd64 1:3.2+20130722-1.1 [92.3 kB]
取得:2 http://jp.archive.ubuntu.com/ubuntu/ wily/universe cgroupfs-mount all 1.2 [4,970 B]
取得:3 http://jp.archive.ubuntu.com/ubuntu/ wily/main liberror-perl all 0.17-1.1 [21.1 kB]
取得:4 http://jp.archive.ubuntu.com/ubuntu/ wily-updates/main git-man all 1:2.5.0-1ubuntu0.1 [728 kB]
取得:5 http://jp.archive.ubuntu.com/ubuntu/ wily-updates/main git amd64 1:2.5.0-1ubuntu0.1 [3,009 kB]
取得:6 https://apt.dockerproject.org/repo/ ubuntu-wily/main docker-engine amd64 1.10.3-0~wily [8,834 kB]
12.7 MB を 1秒 で取得しました (9,082 kB/s)
以前に未選択のパッケージ aufs-tools を選択しています。
(データベースを読み込んでいます ... 現在 121037 個のファイルとディレクトリがインストールされています。)
.../aufs-tools_1%3a3.2+20130722-1.1_amd64.deb を展開する準備をしています ...
aufs-tools (1:3.2+20130722-1.1) を展開しています...
以前に未選択のパッケージ cgroupfs-mount を選択しています。
.../cgroupfs-mount_1.2_all.deb を展開する準備をしています ...
cgroupfs-mount (1.2) を展開しています...
以前に未選択のパッケージ docker-engine を選択しています。
.../docker-engine_1.10.3-0~wily_amd64.deb を展開する準備をしています ...
docker-engine (1.10.3-0~wily) を展開しています...
以前に未選択のパッケージ liberror-perl を選択しています。
.../liberror-perl_0.17-1.1_all.deb を展開する準備をしています ...
liberror-perl (0.17-1.1) を展開しています...
以前に未選択のパッケージ git-man を選択しています。
.../git-man_1%3a2.5.0-1ubuntu0.1_all.deb を展開する準備をしています ...
git-man (1:2.5.0-1ubuntu0.1) を展開しています...
以前に未選択のパッケージ git を選択しています。
.../git_1%3a2.5.0-1ubuntu0.1_amd64.deb を展開する準備をしています ...
git (1:2.5.0-1ubuntu0.1) を展開しています...
man-db (2.7.4-1) のトリガを処理しています ...
ureadahead (0.100.0-19) のトリガを処理しています ...
systemd (225-1ubuntu9.1) のトリガを処理しています ...
aufs-tools (1:3.2+20130722-1.1) を設定しています ...
cgroupfs-mount (1.2) を設定しています ...
docker-engine (1.10.3-0~wily) を設定しています ...
liberror-perl (0.17-1.1) を設定しています ...
git-man (1:2.5.0-1ubuntu0.1) を設定しています ...
git (1:2.5.0-1ubuntu0.1) を設定しています ...
libc-bin (2.21-0ubuntu4.1) のトリガを処理しています ...
systemd (225-1ubuntu9.1) のトリガを処理しています ...
ureadahead (0.100.0-19) のトリガを処理しています ...
+ sh -c docker version
Client:
 Version:      1.10.3
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   20f81dd
 Built:        Thu Mar 10 15:59:07 2016
 OS/Arch:      linux/amd64

Server:
 Version:      1.10.3
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   20f81dd
 Built:        Thu Mar 10 15:59:07 2016
 OS/Arch:      linux/amd64

If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:

  sudo usermod -aG docker your-user

Remember that you will have to log out and back in for this to take effect!

さて動くか。

$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
03f4658f8b78: Pull complete
a3ed95caeb02: Pull complete
Digest: sha256:8be990ef2aeb16dbcb9271ddfe2610fa6658d13f6dfb8bc72074cc1ca36966a7
Status: Downloaded newer image for hello-world:latest

Hello from Docker.
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker Hub account:
 https://hub.docker.com

For more examples and ideas, visit:
 https://docs.docker.com/userguide/

2016年3月20日日曜日

LubuntuにGoogleDriveをマウントする

このエントリーをはてなブックマークに追加
この前VDIにしたLubuntuはHDDが100GBあるんだけど、ファイルの共有とかもしたいのでGoogle Driveをマウントして使えないか調べてみた。

やっぱり同じように考える人もいるみたいで、Google Driveとファイル同期はさせたくないけどディスクとして使いたいという感じ。
このエントリを参考にさせていただいた。

LINUXでGOOGLEドライブを使えるようにしてみたのでメモ残しておく

google-drive-ocamlfuseというパッケージを利用し、Google Driveを仮想ディスクとして認識させることができる。

早速、google-drive-ocamlfuseを使うためにUbuntuのリポジトリ用に提供されているPPAを登録し、パッケージをインストールする。
$ add-apt-repository ppa:alessandro-strada/ppa
$ apt-get update
$ apt-get install google-drive-ocamlfuse
インストールしたパッケージをデスクトップ上のターミナルで実行する。
$ google-drive-ocamlfuse
すると、ブラウザが開きGoogleの認証画面になるのでアカウントを入力しログインする。
ログインが無事終了するとこのような画面が表示される。
ここでブラウザを閉じる。

また適当な場所にマウント先になるディレクトリを作成しマウントしてみる。
$ cd ドキュメント
$ mkdir GoogleDrive
$ google-drive-ocamlfuse GoogleDrive/
これでマウントができたので、GoogleDriveの中のファイルをローカルにコピーしてみる。
$ cp -ip GoogleDrive/image1.JPG ~
きちんとコピーできた。
アンマウントする時はこう。
$  fusermount -u GoogleDrive/
これで便利なると思うんだけど、毎回マウントするのが面倒くさいので起動時にマウントするようにしておくとなお便利かな。~/.bashrcあたりに書いといたらいいんじゃないかと。



2016年3月13日日曜日

Lubuntuのターミナルが使いにくいのでguakeをインストールした

このエントリーをはてなブックマークに追加
Lubuntuのターミナルソフトがあまりいけてないなぁという柔らかい理由で、なんかいいの探してたらGuakeとかいうやつがMacのiTermに似て良さそうだったのでインストールしてみた。

デフォルトのUXTermはこんな感じ。


そこでインストール。

$ apt-get install guake

こんな感じで上に張り付く。F12で出したりしまえたりは便利かも。


2016年3月2日水曜日

さくらVPSにLubuntu Descktopを入れてVDI環境を作った

このエントリーをはてなブックマークに追加
家の外でモバイルで作業する時にはノートPCを持っていくことが多いんだけれど、いつも家にあるMacの3台のどれをもっていくかで悩んでいた。本来であればiPadで全部用事すませたいところなんだけど、なかなかかゆいところに手が届かなかったりするので。。。

家にあるMacは割と特徴がそれぞれ。
  1. MacBook Pro 13インチ (Retina, 13-inch, Late 2013
    • DDR3 1600MHz 8GB
    • Corei5 2.4Ghz
    • SSD 256GB
    • 1.57kg
  2. MacBook Pro 13インチ (13-inch, Mid 2012)
    • DDR3 1600MHz 16GB
    • Corei5 2.5Ghz
    • SSD 500GB(換装済み)
    • 2.06kg
    • Windows10がBootCampで入っている。
  3. MacBook Air 11インチ (11-inch, Mid 2012)
    • DDR3 1600MHz 4GB
    • Corei5 1.7Ghz
    • SSD 64GB
    • 1.08kg

一番、性能もいいのは②、画面がRetinaでないのが残念。一番重量は重い。①はRetinaで画面もきれいながら重量もそこまでないけど、持ち歩くと腰痛持ちにはちょっと荷が重い。。。

そこで目標を③のMacBook Airに絞った、ただしハード的な制約は割とあってSSDとメモリが少ない。特にSSDが少ないので、それを補うために仮想デスクトップを用意してシンクライアントっぽく利用できればと思って、さくらのVPSに軽量LinuxのLubutu-15-10 DesktopをさくらのVPSにインストールしてみた。


Debiun系さわるのは久しぶりなので少し勘を取り戻しながらやる。
以下、インストールしていったもの。


[Google Chrome]
デフォルトでブラウザはFirefoxが入ってるのだけど拡張機能とか使い慣れているChromeが良かったので

[sysv-rc-conf]
単純にRedhat系のchkconfigみたいなのが良かっただけ。

[SSH]
基本的にデスクトップ用途なのでデフォルトでは入っていない。それでもいいんだけれど何かあったときは必要だろうと思うのでインストール。ただしGlobalIPで接続することになるのでパスワード認証なし、Rootログインなし、鍵認証は必ずしておく。さすがにIPベースで縛るのはきびしいし。

[XRDP]
デスクトップにリモート接続するために導入。VNCより使い勝手がよさそう。

IDCFクラウドでUbuntu MATE 14.10とxrdpを使うを参考にさせていただいた。

割と使いやすい。でもメモリが1GBなのであまり重い処理はできないな。。。

2016年2月16日火曜日

Ansibleを使ってFedora23にサーバを構築していく〜playbookでApacheのconfig編集

このエントリーをはてなブックマークに追加

まず今回はAnsibleでのconfファイルの編集手段の具体的な方法論の前に思いの丈からまとめておくことにする。

導入の目的を考える

先に行っておくがAnsibleで全てを自動で要件に合わせて編集するのは無理。この辺りのAnsible導入の焦点は2つあると思う。

  1. サーバ構築の手順をある程度標準化して自動化したい。環境依存、運用修正部分は直接編集
  2. サーバ構築(環境依存)〜運用修正までの手順をAnsibleのフォーマットに則ってInfrastructure as Codeしたい

この辺、きちんと目的をメンバー(プロジェクト関係者も含む)と共有しておかないと、「コマンド1つで誰でもすぐにサーバ構築できるようになったんじゃなかったの?」になっちゃうので要注意かなと思う。

#自分も含めて後でごっちゃになってきて、目的なんだったっけ?になりかねない。

2つに完全に分けるんじゃなくて導入する際のフェーズとして1→2を踏むというのはありかなと思うけど。

まずは導入の標準化を行おう


標準の/etc/httpd/conf/httpd.confを編集する。今回はだいたいいつも変えないといけないところを変えていこうかと思ったんだけど、でもAllowOverrideぐらいしかデフォルトでは変えない気がするので、そこだけ。

# DocumentRootも変えないし、変えるとしたらVirtualHost切る時だし。

あとは/etc/httpd/conf.d/welcome.confをリネームしておく。これらをInstallHttpd.ymlに書き加える。
---
- hosts: ChildServers
  gather_facts: no
  tasks:
    - name: install httpd by dnf
      dnf: name=httpd state=latest
      register: results
    - debug: var=results
    - name: Replace "AllowOverride None" in httpd.conf
      replace: dest=/etc/httpd/conf/httpd.conf regexp='AllowOverride None' replace='AllowOverride All' backup=yes
    - name: Replace "AllowOverride none" in httpd.conf
      replace: dest=/etc/httpd/conf/httpd.conf regexp='AllowOverride none' replace='AllowOverride All' backup=yes
    - name: rename welcome.conf
      shell: 'mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.org'
    - name: Auto Start httpd daemon
      service: name=httpd state=started enabled=yes
      register: results
    - debug: var=results

'None'と'none'が初めから混じっているのでめんどくさい。。。

でも結果としてはこれで実行したら成功した。無事にhttpd.confも書き換わってwelcome.confもリネームされていた。実際にこれぐらいであれば例となるhttpd.confを用意してcopyモジュールでコピーするのもありだと思う。
TASK: [Replace "AllowOverride None" in httpd.conf] ****************************
changed: [172.16.33.175]

TASK: [Replace "AllowOverride none" in httpd.conf] ****************************
changed: [172.16.33.175]

TASK: [rename welcome.conf] ***************************************************
changed: [172.16.33.175]

実際の運用を考えるとdnfでインストール後、テンプレートで初期起動までを作成。そのあとは環境に応じて編集および新規設定ファイルを作成した上で.confファイルはsvnやgitで管理し、メンテナンス後もリスタートをかけたトリガーでリポジトリにコミットする。そのあとは障害時にここからansibleでもってくるなど下ほうがいいのかもしれない。

2016年2月13日土曜日

Ansibleを使ってFedora23にサーバを構築していく〜playbookでApacheインストール

このエントリーをはてなブックマークに追加
少しコーナー化してきた感じもあるので、「Ansible」のラベルから纏めてみてください。


まずはApacheをインストールするためのPlaybookを作成する。InstallHttpd.ymlとかにしておく。
---
- hosts: ChildServers
  gather_facts: no
  tasks:
    - name: install httpd by dnf
      dnf: name=httpd state=latest
      register: results
    - debug: var=results
よし、実行。
# ansible-playbook InstallHttpd.yml --private-key=~/.ssh/ChildOneSV

PLAY [ChildServers] ***********************************************************

TASK: [install httpd by dnf] **************************************************
failed: [172.16.33.174] => {"failed": true}
msg: `python-dnf` is not installed, but it is required for the Ansible dnf module.

FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************
           to retry, use: --limit @/root/InstallHttpd.retry

172.16.33.174              : ok=0    changed=0    unreachable=0    failed=1
なるほど。勢いづいてdnfモジュールを使おうとしたけどもChildOneSVの方にpython-dnfがインストールされていないので怒られた。インストールして再チャレンジする。
# dnf -y install python-dnf
メタデータの期限切れの確認は、0:36:24 前の Sat Feb 13 01:30:53 2016 に実施しました。
依存性が解決されました。
========================================================================================================================
 Package                        アーキテクチャ        バージョン                           リポジトリ              容量
========================================================================================================================
インストール:
 pygpgme                        x86_64                0.3-13.fc23                          fedora                  77 k
 pyliblzma                      x86_64                0.5.3-14.fc23                        fedora                  54 k
 python-hawkey                  x86_64                0.6.2-3.fc23                         updates                 78 k
 python-iniparse                noarch                0.4-16.fc23                          fedora                  45 k
 python-libcomps                x86_64                0.1.7-1.fc23                         fedora                  47 k
 python-librepo                 x86_64                1.7.16-2.fc23                        fedora                  53 k
 python2-dnf                    noarch                1.1.6-2.fc23                         updates                449 k
 rpm-python                     x86_64                4.13.0-0.rc1.11.fc23                 updates                100 k

トランザクションの要約
========================================================================================================================
インストール  8 パッケージ

総ダウンロード容量: 902 k
インストール済み容量: 3.0 M
パッケージをダウンロードしています:
(1/8): pyliblzma-0.5.3-14.fc23.x86_64.rpm                                               145 kB/s |  54 kB     00:00
(2/8): python2-dnf-1.1.6-2.fc23.noarch.rpm                                              1.1 MB/s | 449 kB     00:00
(3/8): pygpgme-0.3-13.fc23.x86_64.rpm                                                   187 kB/s |  77 kB     00:00
(4/8): python-iniparse-0.4-16.fc23.noarch.rpm                                           474 kB/s |  45 kB     00:00
(5/8): python-libcomps-0.1.7-1.fc23.x86_64.rpm                                          543 kB/s |  47 kB     00:00
(6/8): python-librepo-1.7.16-2.fc23.x86_64.rpm                                          555 kB/s |  53 kB     00:00
(7/8): python-hawkey-0.6.2-3.fc23.x86_64.rpm                                            977 kB/s |  78 kB     00:00
(8/8): rpm-python-4.13.0-0.rc1.11.fc23.x86_64.rpm                                       1.2 MB/s | 100 kB     00:00
------------------------------------------------------------------------------------------------------------------------
合計                                                                                    399 kB/s | 902 kB     00:02
トランザクションの確認を実行中...
トランザクションの確認に成功しました。
トランザクションのテストを実行中...
トランザクションのテストに成功しました。
トランザクションを実行中...
  インストール    : rpm-python-4.13.0-0.rc1.11.fc23.x86_64                                                          1/8
  インストール    : python-hawkey-0.6.2-3.fc23.x86_64                                                               2/8
  インストール    : python-librepo-1.7.16-2.fc23.x86_64                                                             3/8
  インストール    : python-libcomps-0.1.7-1.fc23.x86_64                                                             4/8
  インストール    : python-iniparse-0.4-16.fc23.noarch                                                              5/8
  インストール    : pyliblzma-0.5.3-14.fc23.x86_64                                                                  6/8
  インストール    : pygpgme-0.3-13.fc23.x86_64                                                                      7/8
  インストール    : python2-dnf-1.1.6-2.fc23.noarch                                                                 8/8
  検証中          : python2-dnf-1.1.6-2.fc23.noarch                                                                 1/8
  検証中          : pygpgme-0.3-13.fc23.x86_64                                                                      2/8
  検証中          : pyliblzma-0.5.3-14.fc23.x86_64                                                                  3/8
  検証中          : python-iniparse-0.4-16.fc23.noarch                                                              4/8
  検証中          : python-libcomps-0.1.7-1.fc23.x86_64                                                             5/8
  検証中          : python-librepo-1.7.16-2.fc23.x86_64                                                             6/8
  検証中          : python-hawkey-0.6.2-3.fc23.x86_64                                                               7/8
  検証中          : rpm-python-4.13.0-0.rc1.11.fc23.x86_64                                                          8/8

インストール:
  pygpgme.x86_64 0.3-13.fc23            pyliblzma.x86_64 0.5.3-14.fc23            python-hawkey.x86_64 0.6.2-3.fc23
  python-iniparse.noarch 0.4-16.fc23    python-libcomps.x86_64 0.1.7-1.fc23       python-librepo.x86_64 1.7.16-2.fc23
  python2-dnf.noarch 1.1.6-2.fc23       rpm-python.x86_64 4.13.0-0.rc1.11.fc23

完了しました!

# ansible-playbook InstallHttpd.yml --private-key=~/.ssh/ChildOneSV

PLAY [ChildServers] ***********************************************************

TASK: [install httpd by dnf] **************************************************
changed: [172.16.33.174]

TASK: [debug var=results] *****************************************************
ok: [172.16.33.174] => {
    "var": {
        "results": {
            "changed": true,
            "invocation": {
                "module_args": "name=httpd state=latest",
                "module_complex_args": {},
                "module_name": "dnf"
            },
            "results": [
                "Installed: httpd-2.4.18-1.fc23.x86_64",
                "Installed: mailcap-2.1.45-1.fc23.noarch",
                "Installed: httpd-tools-2.4.18-1.fc23.x86_64",
                "Installed: httpd-filesystem-2.4.18-1.fc23.noarch",
                "Installed: apr-1.5.2-2.fc23.x86_64",
                "Installed: fedora-logos-httpd-22.0.0-2.fc23.noarch",
                "Installed: apr-util-1.5.4-2.fc23.x86_64"
            ]
        }
    }
}

PLAY RECAP ********************************************************************
172.16.33.174              : ok=2    changed=1    unreachable=0    failed=0

うまくいったみたいだ。インストール先のChildOneSVでhttpdが自動起動に登録されているかを見る。
# systemctl list-unit-files | grep httpd
httpd.service                               disabled
httpd.socket                                disabled
disabledになっている。これをenableにまで持って行ってみよう。先ほどのInstallHttpd.ymlに付け足す。
---
- hosts: ChildServers
  gather_facts: no
  tasks:
    - name: install httpd by dnf
      dnf: name=httpd state=latest
      register: results
    - debug: var=results
    - name: Auto Start httpd daemon
      service: name=httpd enabled=yes
      register: results
    - debug: var=results
実行あるのみ。
# ansible-playbook InstallHttpd.yml --private-key=~/.ssh/ChildOneSV

PLAY [ChildServers] ***********************************************************

TASK: [install httpd by dnf] **************************************************
changed: [172.16.33.174]

TASK: [debug var=results] *****************************************************
ok: [172.16.33.174] => {
    "var": {
        "results": {
            "changed": true,
            "invocation": {
                "module_args": "name=httpd state=latest",
                "module_complex_args": {},
                "module_name": "dnf"
            },
            "results": [
                "Installed: httpd-2.4.18-1.fc23.x86_64",
                "Installed: mailcap-2.1.45-1.fc23.noarch",
                "Installed: httpd-tools-2.4.18-1.fc23.x86_64",
                "Installed: httpd-filesystem-2.4.18-1.fc23.noarch",
                "Installed: apr-1.5.2-2.fc23.x86_64",
                "Installed: fedora-logos-httpd-22.0.0-2.fc23.noarch",
                "Installed: apr-util-1.5.4-2.fc23.x86_64"
            ]
        }
    }
}

TASK: [Auto Start httpd daemon] ***********************************************
changed: [172.16.33.174]

TASK: [debug var=results] *****************************************************
ok: [172.16.33.174] => {
    "var": {
        "results": {
            "changed": true,
            "enabled": true,
            "invocation": {
                "module_args": "name=httpd enabled=yes",
                "module_complex_args": {},
                "module_name": "service"
            },
            "name": "httpd"
        }
    }
}

PLAY RECAP ********************************************************************
172.16.33.174              : ok=4    changed=2    unreachable=0    failed=0
成功したっぽい。インストール先のChildOneSVの方で確認してみる。
# systemctl list-unit-files | grep httpd
httpd.service                               enabled
httpd.socket                                disabled
もちろんhttpdは動いていない。
# ps -aef | grep httpd
root       2162   1195  0 03:07 pts/0    00:00:00 grep --color=auto httpd
 
動かすところまでしとこう。InstallHttpd.ymlをちょっと編集。
---
- hosts: ChildServers
  gather_facts: no
  tasks:
    - name: install httpd by dnf
      dnf: name=httpd state=latest
      register: results
    - debug: var=results
    - name: Auto Start httpd daemon
      service: name=httpd state=started enabled=yes
      register: results
    - debug: var=results
# ansible-playbook InstallHttpd.yml --private-key=~/.ssh/ChildOneSV

PLAY [ChildServers] ***********************************************************

TASK: [install httpd by dnf] **************************************************
changed: [172.16.33.174]

TASK: [debug var=results] *****************************************************
ok: [172.16.33.174] => {
    "var": {
        "results": {
            "changed": true,
            "invocation": {
                "module_args": "name=httpd state=latest",
                "module_complex_args": {},
                "module_name": "dnf"
            },
            "results": [
                "Installed: httpd-2.4.18-1.fc23.x86_64",
                "Installed: mailcap-2.1.45-1.fc23.noarch",
                "Installed: httpd-tools-2.4.18-1.fc23.x86_64",
                "Installed: httpd-filesystem-2.4.18-1.fc23.noarch",
                "Installed: apr-1.5.2-2.fc23.x86_64",
                "Installed: fedora-logos-httpd-22.0.0-2.fc23.noarch",
                "Installed: apr-util-1.5.4-2.fc23.x86_64"
            ]
        }
    }
}

TASK: [Auto Start httpd daemon] ***********************************************
changed: [172.16.33.174]

TASK: [debug var=results] *****************************************************
ok: [172.16.33.174] => {
    "var": {
        "results": {
            "changed": true,
            "enabled": true,
            "invocation": {
                "module_args": "name=httpd state=started enabled=yes",
                "module_complex_args": {},
                "module_name": "service"
            },
            "name": "httpd",
            "state": "started"
        }
    }
}

PLAY RECAP ********************************************************************
172.16.33.174              : ok=4    changed=2    unreachable=0    failed=0
# ps -aef | grep httpd
root       2283      1  0 03:13 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     2285   2283  0 03:13 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     2286   2283  0 03:13 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     2290   2283  0 03:13 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     2292   2283  0 03:13 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     2294   2283  0 03:13 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
root       2297   1195  0 03:13 pts/0    00:00:00 grep --color=auto httpd
できたできた。次の回はconfigの生成(編集?)をやりたいと思います。

2016年2月12日金曜日

Ansibleを使ってFedora23にサーバを構築していく〜playbook作成

このエントリーをはてなブックマークに追加
これまでの経緯は下のリンク先を参照。


Ansibleを使ってFedora23にサーバを構築していく〜準備編(1)
Ansibleを使ってFedora23にサーバを構築していく〜準備編(2)

構成はこんな感じ。
AnsibleSV →(構成)→ ChildOneSV

ChildOneSVについてはselinuxを無効にしておく。そうでないとPlaybook実行時に怒られるので。

/etc/ansible/hosts(インベントリファイルという)を/etc/ansible/hosts.orgなどリネームし新しく下記の内容で構築先のサーバを指定し作成する。
[ChildServers]
172.16.33.173

~/AnsiblePlayBookみたいな適当なディレクトリを作って、その下にサンプルのplaybook(SamplePlaybook.yml)を作る。
playbookはYAML形式で作成するので、書き方というかお作法はこの辺が参考になった。ansible使いのためのYAML入門

まずデフォルトではansibleの接続にはrootでされるのだが、本当にそうなのかどうか確かめる簡単なplaybookを書いた。
---
- hosts: ChildServers
  tasks:
    - name: Who am I?
      shell: 'whoami'
実行してみる。sshのprivate keyをコマンドの引数に渡しているのがあまりスマートじゃない気がするけど。あと、デバッグ用に-vvvも足している。

# ansible-playbook SamplePlaybook_whoami.yml --private-key=~/.ssh/ChildOneSV -vvv
PLAY [ChildServers] ***********************************************************

GATHERING FACTS ***************************************************************
<172.16.33.174> ESTABLISH CONNECTION FOR USER: root
<172.16.33.174> REMOTE_MODULE setup
<172.16.33.174> EXEC ssh -C -tt -v -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o IdentityFile="/root/.ssh/ChildOneSV" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 172.16.33.174 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1455208440.15-102322756142433 && echo $HOME/.ansible/tmp/ansible-tmp-1455208440.15-102322756142433'
<172.16.33.174> PUT /tmp/tmpLs6ZDa TO /root/.ansible/tmp/ansible-tmp-1455208440.15-102322756142433/setup
<172.16.33.174> EXEC ssh -C -tt -v -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o IdentityFile="/root/.ssh/ChildOneSV" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 172.16.33.174 /bin/sh -c 'LANG=C LC_CTYPE=C /usr/bin/python /root/.ansible/tmp/ansible-tmp-1455208440.15-102322756142433/setup; rm -rf /root/.ansible/tmp/ansible-tmp-1455208440.15-102322756142433/ >/dev/null 2>&1'
ok: [172.16.33.174]

TASK: [Who am I?] *************************************************************
<172.16.33.174> ESTABLISH CONNECTION FOR USER: root
<172.16.33.174> REMOTE_MODULE command whoami #USE_SHELL
<172.16.33.174> EXEC ssh -C -tt -v -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o IdentityFile="/root/.ssh/ChildOneSV" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 172.16.33.174 /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1455208507.7-272410210390849 && echo $HOME/.ansible/tmp/ansible-tmp-1455208507.7-272410210390849'
<172.16.33.174> PUT /tmp/tmp7LbN5R TO /root/.ansible/tmp/ansible-tmp-1455208507.7-272410210390849/command
<172.16.33.174> EXEC ssh -C -tt -v -o ControlMaster=auto -o ControlPersist=60s -o ControlPath="/root/.ansible/cp/ansible-ssh-%h-%p-%r" -o IdentityFile="/root/.ssh/ChildOneSV" -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 172.16.33.174 /bin/sh -c 'LANG=C LC_CTYPE=C /usr/bin/python /root/.ansible/tmp/ansible-tmp-1455208507.7-272410210390849/command; rm -rf /root/.ansible/tmp/ansible-tmp-1455208507.7-272410210390849/ >/dev/null 2>&1'
changed: [172.16.33.174] => {"changed": true, "cmd": "whoami", "delta": "0:00:00.003166", "end": "2016-02-12 01:35:08.740448", "rc": 0, "start": "2016-02-12 01:35:08.737282", "stderr": "", "stdout": "root", "warnings": []}

PLAY RECAP ********************************************************************
172.16.33.174              : ok=2    changed=1    unreachable=0    failed=0

最後の一行にちゃんと実行結果でrootと表示されているのがわかった。
changed: [172.16.33.174] => {"changed": true, "cmd": "whoami", "delta": "0:00:00.003166", "end": "2016-02-12 01:35:08.740448", "rc": 0, "start": "2016-02-12 01:35:08.737282", "stderr": "", "stdout": "root", "warnings": []}
しかし、やたら時間がかかるので、少し改良する。サーバ情報などを取得する"GATHERING FACTS"が邪魔なのでgather_facts: nを足す。ついでに-vvvもぬいた
---
- hosts: ChildServers
  gather_facts: no
  tasks:
    - name: Who am I?
      shell: 'whoami'

# ansible-playbook SamplePlaybook_whoami.yml --private-key=~/.ssh/ChildOneSV

PLAY [ChildServers] ***********************************************************

TASK: [Who am I?] *************************************************************
changed: [172.16.33.174]

PLAY RECAP ********************************************************************
172.16.33.174              : ok=1    changed=1    unreachable=0    failed=0

今度は結果が分からない。。。なので標準出力に出るように奮闘してみる。
---
- hosts: ChildServers
  gather_facts: no
  tasks:
    - name: Who am I?
      shell: 'whoami'
      register: result
    - debug: msg="{{result.stdout}}"]

registerresultという変数に結果を格納して、debugが実行結果をdumpするイメージ。debugを使う際にそのまま結果を出すのであればmsgパラメータに"{{result.stdout}}"として渡す。{{}}は変数としてresult.stdoutを出力してくれる。

これでrootで実行されているのは分かったので、dnf updateをしてみる。別にSamplePlaybook.ymlを作成する。
---
- hosts: ChildServers
  gather_facts: no
  tasks:
    - name: OS RPM Update by dnf
      shell: 'dnf -y update'
      register: result
    - debug: msg="{{result.stdout}}"

# ansible-playbook SamplePlaybook.yml --private-key=~/.ssh/ChildOneSV

PLAY [ChildServers] ***********************************************************

TASK: [OS RPM Update by dnf] **************************************************
changed: [172.16.33.174]

TASK: [debug msg="{{result.stdout}}"] *****************************************
ok: [172.16.33.174] => {
    "msg": "Last metadata expiration check performed 1:32:32 ago on Fri Feb 12 01:15:22 2016.\nDependencies resolved.\nNothing to do.\nComplete!"
}

PLAY RECAP ********************************************************************
172.16.33.174              : ok=2    changed=1    unreachable=0    failed=0

なにもすること無かったみたい。。。次は具体的に何かをインストールして環境の変更までやってみたいと思う。

2016年2月10日水曜日

Ansibleを使ってFedora23にサーバを構築していく〜準備編(2)

このエントリーをはてなブックマークに追加
新しくもう一台VMを起動し2台のVM構成を作る。
AnsibleSV →(構成)→ ChildOneSV
両サーバ間はSSHの鍵認証を使ってログインした後通信を行うので、AnsibleSVからChildOneSVへSSHログインできる鍵を作っておく。ここの具体的な手順はぐぐったら腐るほどでてくるので省略。

AnsibleSVの構築はAnsibleを使ってFedora23にサーバを構築していく〜準備編を参照。ちなみに構成先のChildOneSVにもPythonをインストールしておく。

まずはMotherSVからChildOneSVへの疎通確認をしてみる。Ansibleで通信するためには相手先のアドレスを/etc/ansible/hostsに書いておく必要がある。-m でansibleのモジュール、--private-keyでChiledOneSVにログインするための秘密鍵を指定する。今回使うのはpingモジュール。
# ansible <ChildOneSV IPAddress> -m ping --private-key=~/.ssh/ChildOneSV
<ChildOneSV IPAddress> | success >> {
    "changed": false,
    "ping": "pong"
}
ChildOneSVでのコマンドをAnsible経由で実行してみる。-a は引数付きのコマンド実行。
# ansible 172.16.33.173 -a 'uname -a' --private-key=~/.ssh/ChildOneSV
172.16.33.173 | success | rc=0 >>
Linux ChildOneSV 4.3.5-300.fc23.x86_64 #1 SMP Mon Feb 1 03:18:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
これで通信は確認できたので、次は実際にPlaybookを作ってみたいと思う。

2016年2月9日火曜日

Ansibleを使ってFedora23にサーバを構築していく〜準備編(1)

このエントリーをはてなブックマークに追加
サーバの自動構築。なんという夢の響きだろうか。あのめんどくさい作業から解放されるためなんだったら何でもやろう。という事でAnsibleを使ってやってみることにした。Chefはなんかめんどくさそうなイメージが果てしなくあったので何となくAnsibleを選んだ。


今回はVMWare Fusionを使って試すことにした。まずは準備としてFedora23 Server EditionのMinimalインストールする。そしてすぐにシャットダウンし、この.vmwareファイルをオリジナルファイル(以下、OriginalVM)として保存。それをコピーしAnsible用のマシン(以下、AnsibleVM)として構築していく。

以降、操作するのは全てAnsibleVMの方なので注意すること。

ターミナルの方がやりやすいのでiTerm2でAnsibleVMへ接続し、iTermでログの取得(Shell→Log→Start)をしておく。この方が後々役にたつはず。

$ ssh root@xxx.xxx.xxx.xxx
dnfでできるだけ早いミラーサイトからパッケージを取ってくるために/etc/dnf/dnf.confに追記。
[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=true
fastestmirror=true
ここでdnfでアップデート。
# dnf update
メタデータの期限切れの確認は、0:51:03 前の Mon Feb  8 03:24:13 2016 に実施しました。
依存性が解決されました。
========================================================================================================================
 パッケージ                            アーキテクチャ   バージョン                              リポジトリ         容量
========================================================================================================================
インストール中:
 kernel                                x86_64           4.3.4-300.fc23                          updates            52 k
 kernel-core                           x86_64           4.3.4-300.fc23                          updates            20 M
 kernel-modules                        x86_64           4.3.4-300.fc23                          updates            18 M
 libsecret                             x86_64           0.18.3-1.fc23                           fedora            156 k
アップグレード中:
 GeoIP-GeoLite-data                    noarch           2015.12-1.fc23                          updates           367 k
 NetworkManager                        x86_64           1:1.0.10-2.fc23                         updates           1.9 M
 NetworkManager-libnm                  x86_64           1:1.0.10-2.fc23                         updates           481 k
 audit                                 x86_64           2.4.5-1.fc23                            updates           243 k
 audit-libs                            x86_64           2.4.5-1.fc23                            updates            95 k
 avahi-autoipd                         x86_64           0.6.32-0.4.rc.fc23                      updates            31 k
 avahi-libs                            x86_64           0.6.32-0.4.rc.fc23                      updates            62 k
 bash                                  x86_64           4.3.42-3.fc23                           updates           1.4 M
 bind99-libs                           x86_64           9.9.8-2.P3.fc23                         updates           655 k
 bind99-license                        noarch           9.9.8-2.P3.fc23                         updates            12 k
 bzip2-libs                            x86_64           1.0.6-19.fc23                           updates            45 k
 ca-certificates                       noarch           2015.2.6-1.0.fc23                       updates           432 k
 chkconfig                             x86_64           1.7-1.fc23                              updates           179 k
 coreutils                             x86_64           8.24-5.fc23                             updates           2.8 M
 crypto-policies                       noarch           20151104-1.gitf1cba5f.fc23              updates            30 k
 curl                                  x86_64           7.43.0-5.fc23                           updates           285 k
 dbus                                  x86_64           1:1.10.6-1.fc23                         updates           244 k
 dbus-glib                             x86_64           0.106-1.fc23                            updates           121 k
 dbus-libs                             x86_64           1:1.10.6-1.fc23                         updates           173 k
 deltarpm                              x86_64           3.6-13.fc23                             updates            88 k
 device-mapper                         x86_64           1.02.109-2.fc23                         updates           292 k
 device-mapper-event                   x86_64           1.02.109-2.fc23                         updates           206 k
 device-mapper-event-libs              x86_64           1.02.109-2.fc23                         updates           209 k
 device-mapper-libs                    x86_64           1.02.109-2.fc23                         updates           346 k
 dhcp-client                           x86_64           12:4.3.3-8.P1.fc23                      updates           300 k
 dhcp-common                           noarch           12:4.3.3-8.P1.fc23                      updates           194 k
 dhcp-libs                             x86_64           12:4.3.3-8.P1.fc23                      updates           138 k
 dnf                                   noarch           1.1.6-2.fc23                            updates           290 k
 dnf-conf                              noarch           1.1.6-2.fc23                            updates            91 k
 dnf-plugins-core                      noarch           0.1.16-1.fc23                           updates            37 k
 dnf-yum                               noarch           1.1.6-2.fc23                            updates            85 k
 dnsmasq                               x86_64           2.75-3.fc23                             updates           294 k
 dracut                                x86_64           043-63.git20151211.fc23                 updates           324 k
 dracut-config-rescue                  x86_64           043-63.git20151211.fc23                 updates            45 k
 ebtables                              x86_64           2.0.10-18.fc23                          updates           126 k
 elfutils-default-yama-scope           noarch           0.165-2.fc23                            updates            38 k
 elfutils-libelf                       x86_64           0.165-2.fc23                            updates           213 k
 elfutils-libs                         x86_64           0.165-2.fc23                            updates           272 k
 emacs-filesystem                      noarch           1:24.5-7.fc23                           updates            65 k
 file                                  x86_64           5.22-6.fc23                             updates            66 k
 file-libs                             x86_64           5.22-6.fc23                             updates           423 k
 findutils                             x86_64           1:4.5.16-1.fc23                         updates           563 k
 gettext                               x86_64           0.19.7-3.fc23                           updates           1.0 M
 gettext-libs                          x86_64           0.19.7-3.fc23                           updates           504 k
 glib2                                 x86_64           2.46.2-1.fc23                           updates           2.3 M
 glibc                                 x86_64           2.22-7.fc23                             updates           3.6 M
 glibc-common                          x86_64           2.22-7.fc23                             updates            11 M
 gnupg2                                x86_64           2.1.9-1.fc23                            updates           1.8 M
 gnutls                                x86_64           3.4.8-1.fc23                            updates           657 k
 grep                                  x86_64           2.22-6.fc23                             updates           275 k
 grub2                                 x86_64           1:2.02-0.25.fc23                        updates           3.8 M
 grub2-tools                           x86_64           1:2.02-0.25.fc23                        updates           7.1 M
 gsettings-desktop-schemas             x86_64           3.18.1-1.fc23                           updates           518 k
 hawkey                                x86_64           0.6.2-3.fc23                            updates            92 k
 hwdata                                noarch           0.285-2.fc23                            updates           1.4 M
 initscripts                           x86_64           9.65-1.fc23                             updates           406 k
 ipcalc                                x86_64           0.1.4-2.fc23                            updates            31 k
 iproute                               x86_64           4.1.1-3.fc23                            updates           598 k
 iputils                               x86_64           20140519-7.fc23                         updates           161 k
 kbd                                   x86_64           2.0.2-8.fc23                            updates           379 k
 kbd-legacy                            noarch           2.0.2-8.fc23                            updates           476 k
 kbd-misc                              noarch           2.0.2-8.fc23                            updates           1.4 M
 kmod                                  x86_64           22-2.fc23                               updates           112 k
 kmod-libs                             x86_64           22-2.fc23                               updates            61 k
 krb5-libs                             x86_64           1.14-7.fc23                             updates           839 k
 libarchive                            x86_64           3.1.2-14.fc23                           updates           322 k
 libassuan                             x86_64           2.4.2-1.fc23                            updates            75 k
 libblkid                              x86_64           2.27.1-2.fc23                           updates           180 k
 libcurl                               x86_64           7.43.0-5.fc23                           updates           256 k
 libdrm                                x86_64           2.4.66-1.fc23                           updates           144 k
 libfdisk                              x86_64           2.27.1-2.fc23                           updates           221 k
 libgcc                                x86_64           5.3.1-2.fc23                            updates            88 k
 libgomp                               x86_64           5.3.1-2.fc23                            updates           152 k
 libgpg-error                          x86_64           1.21-1.fc23                             updates           154 k
 libmount                              x86_64           2.27.1-2.fc23                           updates           197 k
 libnghttp2                            x86_64           1.6.0-1.fc23                            updates            65 k
 libnl3                                x86_64           3.2.27-1.fc23                           updates           265 k
 libpng                                x86_64           2:1.6.19-2.fc23                         updates           118 k
 libreport-filesystem                  x86_64           2.6.4-1.fc23                            updates            46 k
 libsmartcols                          x86_64           2.27.1-2.fc23                           updates           139 k
 libsolv                               x86_64           0.6.14-7.fc23                           updates           346 k
 libsoup                               x86_64           2.52.2-1.fc23                           updates           385 k
 libssh2                               x86_64           1.6.0-3.fc23                            updates           147 k
 libstdc++                             x86_64           5.3.1-2.fc23                            updates           425 k
 libuuid                               x86_64           2.27.1-2.fc23                           updates            79 k
 libxml2                               x86_64           2.9.3-2.fc23                            updates           684 k
 linux-firmware                        noarch           20151214-60.gitbbe4917c.fc23            updates            32 M
 lua                                   x86_64           5.3.2-2.fc23                            updates           294 k
 lvm2                                  x86_64           2.02.132-2.fc23                         updates           1.0 M
 lvm2-libs                             x86_64           2.02.132-2.fc23                         updates           927 k
 nettle                                x86_64           3.2-1.fc23                              updates           306 k
 nspr                                  x86_64           4.10.10-2.fc23                          updates           134 k
 nss                                   x86_64           3.21.0-1.1.fc23                         updates           860 k
 nss-softokn                           x86_64           3.21.0-1.1.fc23                         updates           314 k
 nss-softokn-freebl                    x86_64           3.21.0-1.1.fc23                         updates           207 k
 nss-sysinit                           x86_64           3.21.0-1.1.fc23                         updates            56 k
 nss-tools                             x86_64           3.21.0-1.1.fc23                         updates           493 k
 nss-util                              x86_64           3.21.0-1.0.fc23                         updates            81 k
 openssh                               x86_64           7.1p2-3.fc23                            updates           430 k
 openssh-clients                       x86_64           7.1p2-3.fc23                            updates           635 k
 openssh-server                        x86_64           7.1p2-3.fc23                            updates           461 k
 openssl                               x86_64           1:1.0.2f-1.fc23                         updates           496 k
 openssl-libs                          x86_64           1:1.0.2f-1.fc23                         updates           1.2 M
 os-prober                             x86_64           1.70-1.fc23                             updates            48 k
 p11-kit                               x86_64           0.23.2-1.fc23                           updates           151 k
 p11-kit-trust                         x86_64           0.23.2-1.fc23                           updates           131 k
 pcre                                  x86_64           8.38-4.fc23                             updates           495 k
 pinentry                              x86_64           0.9.6-4.fc23                            updates            81 k
 plymouth                              x86_64           0.8.9-11.2013.08.14.fc23                updates           113 k
 plymouth-core-libs                    x86_64           0.8.9-11.2013.08.14.fc23                updates           100 k
 plymouth-scripts                      x86_64           0.8.9-11.2013.08.14.fc23                updates            38 k
 policycoreutils                       x86_64           2.4-18.fc23                             updates           922 k
 python3-dbus                          x86_64           1.2.0-12.fc23                           updates           121 k
 python3-dnf                           noarch           1.1.6-2.fc23                            updates           454 k
 python3-dnf-plugins-core              noarch           0.1.16-1.fc23                           updates            80 k
 python3-gobject-base                  x86_64           3.18.2-1.fc23                           updates           296 k
 python3-hawkey                        x86_64           0.6.2-3.fc23                            updates            73 k
 python3-sssdconfig                    noarch           1.13.3-3.fc23                           updates           100 k
 rpm                                   x86_64           4.13.0-0.rc1.11.fc23                    updates           510 k
 rpm-build-libs                        x86_64           4.13.0-0.rc1.11.fc23                    updates           116 k
 rpm-libs                              x86_64           4.13.0-0.rc1.11.fc23                    updates           294 k
 rpm-plugin-selinux                    x86_64           4.13.0-0.rc1.11.fc23                    updates            51 k
 rpm-plugin-systemd-inhibit            x86_64           4.13.0-0.rc1.11.fc23                    updates            51 k
 rpm-python3                           x86_64           4.13.0-0.rc1.11.fc23                    updates           100 k
 selinux-policy                        noarch           3.13.1-158.4.fc23                       updates           435 k
 selinux-policy-targeted               noarch           3.13.1-158.4.fc23                       updates           5.6 M
 sqlite                                x86_64           3.10.2-1.fc23                           updates           476 k
 sudo                                  x86_64           1.8.15-1.fc23                           updates           691 k
 systemd                               x86_64           222-14.fc23                             updates           6.3 M
 systemd-libs                          x86_64           222-14.fc23                             updates           474 k
 tzdata                                noarch           2016a-1.fc23                            updates           409 k
 util-linux                            x86_64           2.27.1-2.fc23                           updates           2.1 M
 xkeyboard-config                      noarch           2.16-2.fc23                             updates           761 k

トランザクションの要約
========================================================================================================================
インストール      4 Packages
アップグレード  133 Packages

総ダウンロード容量: 156 M

これでパッケージのアップデートは完了したので、Ansibleをdnfでインストールすることにした。いつもは最新版が欲しいのでソースから入れる派なんだけど、Fedoraだしその辺はそれなりに新しいパッケージが入るだろうという事で。

# dnf install ansible
メタデータの期限切れの確認は、0:33:38 前の Tue Feb  9 00:39:37 2016 に実施しました。
依存性が解決されました。
========================================================================================================================
 Package                           アーキテクチャ         バージョン                      リポジトリ               容量
========================================================================================================================
インストール:
 PyYAML                            x86_64                 3.11-11.fc23                    updates                 168 k
 ansible                           noarch                 1.9.4-1.fc23                    updates                 1.7 M
 libtomcrypt                       x86_64                 1.17-25.fc23                    fedora                  229 k
 libtommath                        x86_64                 0.42.0-6.fc23                   fedora                   39 k
 libyaml                           x86_64                 0.1.6-7.fc23                    fedora                   58 k
 python                            x86_64                 2.7.10-8.fc23                   fedora                   94 k
 python-babel                      noarch                 1.3-8.fc23                      fedora                  2.5 M
 python-crypto                     x86_64                 2.6.1-7.fc23                    fedora                  468 k
 python-ecdsa                      noarch                 0.11-4.fc23                     fedora                   73 k
 python-httplib2                   noarch                 0.9.1-2.fc23                    fedora                  119 k
 python-jinja2                     noarch                 2.8-2.fc23                      fedora                  464 k
 python-keyczar                    noarch                 0.71c-5.fc23                    fedora                  222 k
 python-libs                       x86_64                 2.7.10-8.fc23                   fedora                  5.8 M
 python-markupsafe                 x86_64                 0.23-7.fc23                     fedora                   35 k
 python-paramiko                   noarch                 1.15.2-3.fc23                   fedora                  254 k
 python-pip                        noarch                 7.1.0-1.fc23                    fedora                  1.5 M
 python-pyasn1                     noarch                 0.1.8-1.fc23                    fedora                  104 k
 python-setuptools                 noarch                 18.0.1-2.fc23                   fedora                  425 k
 python-six                        noarch                 1.9.0-3.fc23                    fedora                   34 k
 pytz                              noarch                 2015.4-1.fc23                   fedora                   60 k
 sshpass                           x86_64                 1.05-8.fc23                     fedora                   25 k

トランザクションの要約
========================================================================================================================
インストール  21 パッケージ

総ダウンロード容量: 14 M
インストール済み容量: 58 M

確認してみる。
# ansible --version
ansible 1.9.4

できた、できた。

2016年2月8日月曜日

OpenShiftでPHP Gearと一緒にMySQLを使えるようにする

このエントリーをはてなブックマークに追加
PHP動いているんだったらやっぱりDBも使いたいよね。ってことでMySQLを動かしてみようと。
公式のDocumentにはこんな感じで書いてあった。
If you want to add a database to an existing application the command is similar:
$ rhc cartridge-add <dbcartridge> --app <myappname>
This command will also spin up your database server and insert the environment variables.
前回のHerokuよりも無料枠が良さげなOpenShiftでPHPをデプロイするmyphpappというアプリ名で作ったので、これで使えるようにしてみる。
まずは、使えるカートリッジを確認する。
$ rhc cartridge list
RSA 1024 bit CA certificates are loaded due to old openssl compatibility
jbossas-7                JBoss Application Server 7              web
jboss-dv-6.1.0 (!)       JBoss Data Virtualization 6             web
jbosseap-6 (*)           JBoss Enterprise Application Platform 6 web
jboss-unified-push-1 (!) JBoss Unified Push Server 1.0.0.Beta1   web
jboss-unified-push-2 (!) JBoss Unified Push Server 1.0.0.Beta2   web
jenkins-1                Jenkins Server                          web
nodejs-0.10              Node.js 0.10                            web
perl-5.10                Perl 5.10                               web
php-5.3                  PHP 5.3                                 web
php-5.4                  PHP 5.4                                 web
zend-6.1                 PHP 5.4 with Zend Server 6.1            web
python-2.6               Python 2.6                              web
python-2.7               Python 2.7                              web
python-3.3               Python 3.3                              web
ruby-1.8                 Ruby 1.8                                web
ruby-1.9                 Ruby 1.9                                web
ruby-2.0                 Ruby 2.0                                web
jbossews-1.0             Tomcat 6 (JBoss EWS 1.0)                web
jbossews-2.0             Tomcat 7 (JBoss EWS 2.0)                web
jboss-vertx-2.1 (!)      Vert.x 2.1                              web
jboss-wildfly-10 (!)     WildFly Application Server 10           web
jboss-wildfly-8 (!)      WildFly Application Server 8.2.1.Final  web
jboss-wildfly-9 (!)      WildFly Application Server 9            web
diy-0.1                  Do-It-Yourself 0.1                      web
cron-1.4                 Cron 1.4                                addon
jenkins-client-1         Jenkins Client                          addon
mongodb-2.4              MongoDB 2.4                             addon
mysql-5.1                MySQL 5.1                               addon
mysql-5.5                MySQL 5.5                               addon
phpmyadmin-4             phpMyAdmin 4.0                          addon
postgresql-8.4           PostgreSQL 8.4                          addon
postgresql-9.2           PostgreSQL 9.2                          addon
rockmongo-1.1            RockMongo 1.1                           addon
switchyard-0             SwitchYard 0.8.0                        addon
haproxy-1.4              Web Load Balancer                       addon

Note: Web cartridges can only be added to new applications.

(*) denotes a cartridge with additional usage costs.

(!) denotes a cartridge that will not receive automatic security updates.
mysql-5.5というのがあったので、これが使えそうだ。
なので、作成してみる。
$ rhc cartridge-add mysql-5.5 --app myphpapp
RSA 1024 bit CA certificates are loaded due to old openssl compatibility
Adding mysql-5.5 to application 'myphpapp' ... done

mysql-5.5 (MySQL 5.5)
---------------------
  Gears:          Located with php-5.4
  Connection URL: mysql://$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/
  Database Name:  myphpapp
  Password:       ***********
  Username:       ***********

MySQL 5.5 database added.  Please make note of these credentials:

       Root User: ***********
   Root Password: ***********
   Database Name: myphpapp

Connection URL: mysql://$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/

You can manage your new MySQL database by also embedding phpmyadmin.
The phpmyadmin username and password will be the same as the MySQL credentials above.
MySQLへの接続は環境変数に入っているようだ。myphpappにSSHで接続して、envで確認してみる。
$ rhc ssh myphpapp

\> env | grep OPENSHIFT_MYSQL -
OPENSHIFT_MYSQL_DIR=xxxxxx
OPENSHIFT_MYSQL_DB_PORT=xxxxxx
OPENSHIFT_MYSQL_DB_HOST=xxxxxx
OPENSHIFT_MYSQL_DB_PASSWORD=xxxxxx
OPENSHIFT_MYSQL_IDENT=xxxxxx
OPENSHIFT_MYSQL_DB_USERNAME=xxxxxx
OPENSHIFT_MYSQL_DB_SOCKET=xxxxxx
OPENSHIFT_MYSQL_DB_URL=xxxxxx
OPENSHIFT_MYSQL_VERSION=5.5
OPENSHIFT_MYSQL_DB_LOG_DIR=xxxxxx
OPENSHIFT_MYSQL_LD_LIBRARY_PATH_ELEMENT=xxxxxx
接続に必要な環境変数がいっぱい出てきたので、これを元にSSHでMySQLへログインできるのかやってみる。
\> mysql -u ($OPENSHIFT_MYSQL_DB_USERNAME) -p -h ($OPENSHIFT_MYSQL_DB_HOST)
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.45 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
普通にデータベースとか見えるのかな。
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| myphpapp           |
| mysql              |
| performance_schema |
+--------------------+
4 rows in set (0.01 sec)

mysql> use myphpapp;
Database changed
mysql> show tables;
Empty set (0.00 sec)
結構普通に使えて超便利!