LeoFSのインストール方法

LeoFSをvagrant上のcentos6.3にinstallする。
[LeoFS installation — LeoFS 1.0 documentation](http://leo-project.net/leofs/docs/install.html)

# Erlangのインストール
ソースのダウンロード
`$ sudo su
$ cd /usr/local/src/
$ wget http://www.erlang.org/download/otp_src_R16B03-1.tar.gz
$ tar xzvf
$ cd otp_src_R16B03-1
$ ./configure
`
なんかエラー出る

```
*********************************************************************
**********************  APPLICATIONS DISABLED  **********************
*********************************************************************

jinterface     : No Java compiler found
odbc           : ODBC library - link check failed

*********************************************************************
*********************************************************************
**********************  APPLICATIONS INFORMATION  *******************
*********************************************************************

wx             : wxWidgets not found, wx will NOT be usable

*********************************************************************
*********************************************************************
**********************  DOCUMENTATION INFORMATION  ******************
*********************************************************************

documentation  :
                 xsltproc is missing.
                 fop is missing.
                 The documentation can not be built.

*********************************************************************
```
とりあえず、下記をいれる
`$ yum install fop unixODBC unixODBC-devel`
もう一度configureやると、javacがないとかで怒られている。

```
*********************************************************************
**********************  APPLICATIONS DISABLED  **********************
*********************************************************************

jinterface     : No Java compiler found

*********************************************************************
*********************************************************************
**********************  APPLICATIONS INFORMATION  *******************
*********************************************************************

wx             : wxWidgets not found, wx will NOT be usable

*********************************************************************
*********************************************************************
**********************  DOCUMENTATION INFORMATION  ******************
*********************************************************************

documentation  :
                 xsltproc is missing.
                 The documentation can not be built.

*********************************************************************
```

```
# yum search jdk
Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
 * base: centos.mirror.secureax.com
 * extras: centos.mirror.secureax.com
 * updates: centos.mirror.secureax.com
==================================================================== N/S Matched: jdk =====================================================================
java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
ldapjdk-javadoc.x86_64 : Javadoc for ldapjdk
icedtea-web.x86_64 : Additional Java components for OpenJDK - Java browser plug-in and Web Start implementation
ldapjdk.x86_64 : The Mozilla LDAP Java SDK

  Name and summary matches only, use "search all" for everything.

# yum install java-1.7.0-openjdk-devel.x86_64
```
なんかwxとdocumentationは残ったけど無視する（一応vagrantでcommitして戻れるようにしておく）

```
$ make
$ make install
$ erl
Erlang R16B03-1 (erts-5.10.4) [source] [64-bit] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V5.10.4  (abort with ^G)
1>
```

# 下準備

[LeoFS installation — LeoFS 1.0 documentation](http://leo-project.net/leofs/docs/install.html)

上記reference通りにやってみる

```
# yum install libuuid-devel cmake check check-devel
# cd /usr/local/src/
# wget http://www.hpl.hp.com/research/linux/atomic_ops/download/libatomic_ops-7.2d.tar.gz
# tar xzvf libatomic_ops-7.2d.tar.gz
# cd libatomic_ops-7.2d
# ./configure --prefix=/usr/local
# make
# make install
```

XFS-related

```
# yum --enablerepo=centosplus install kmod-xfs xfsprogs xfsprogs-devel
# fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): p

Disk /dev/sda: 536.9 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00043ec5

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64       65271   523774976   8e  Linux LVM

Command (m for help): p

Disk /dev/sda: 536.9 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00043ec5

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64       65271   523774976   8e  Linux LVM

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
No free sectors available
```

なんかdiskがないって怒られていた。どうやら、virtual boxの設定か、どっかでパーティションを限界までやっちゃっていたらしい（可変にしているから？）。拡張方法がよくわからんので、新しくsdb1を拡張した。

`virtual boxの設定 -> ストレージ -> コントローラー:SATA ->　追加`

追加後
```
$ fdisk /dev/sdb
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (2473-8908, default 2473):[Enter]
Command (m for help): w
```

`$ reboot`

再起動後

```
# ls -ld /dev/sdb1
brw-rw---- 1 root disk 8, 17 Jun 16 08:38 /dev/sdb1
# mkfs.xfs -d agcount=4 -l size=32m /dev/sdb1
# vi /etc/fstab
/dev/sdb1   /mnt/xfs   xfs   noatime,nodiratime,osyncisdsync 0 0
# mkdir /mnt/xfs
# mount -a
```

確認

```
# df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root
                     512971376    999004 485914852   1% /
tmpfs                   234900         0    234900   0% /dev/shm
/dev/sda1               495844     40717    429527   9% /boot
/dev/sdb1             11076148     32932  11043216   1% /mnt/xfs
```

# LeoFSのインストール

```
$ cd /usr/local/src
$ git clone https://github.com/leo-project/leofs.git
$ cd leofs
$ make
```

なんかleveldbのcloneでコケる。

```
==> leo_commons (get-deps)
==> leo_logger (get-deps)
==> meck (get-deps)
==> bitcask (get-deps)
==> eleveldb (get-deps)
Cloning into 'leveldb'...
fatal: unable to connect to github.com:
github.com[0: 192.30.252.131]: errno=Connection timed out

ERROR: Command ['get-deps'] failed!
make: *** [deps] Error 1
```

gitが開いていないせいっぽく、httpsで対処

```
$ git config --global url."https://".insteadOf git://
```

無事makeが成功する。続いてmake release

```
$ make release
```

成功したっぽいが、Buildingに書いてある構成と違う。。。情報古い？
[Devト〜ク LeoFSを導入してみた](http://techmania.blog.fc2.com/blog-entry-13.html)
上記を参考にdirectory構成を整える。

```
$ mkdir -p /mnt/usr/local
$ cp -r package /mnt/usr/local/
$ ln -s /mnt/usr/local/package /usr/local/leofs
```

# LeoFSの起動
参考ドキュメントが別のものに移りまして、下記を元に先に進む。
[Getting Started — LeoFS 1.0 documentation](http://leo-project.net/leofs/docs/getting_started.html)
ちなみにここまでrootで作業している。これでいいのかよくわからん。

ドキュメントに/etc/hostsを編集すると書いてあるが、awsとかの設定？よくわからないからとりあえず飛ばす。

```
$ cd /usr/local/leofs
$ leo_manager_0/bin/leo_manager start
$ leo_manager_1/bin/leo_manager start
$ leo_storage/bin/leo_storage start
```
起動

```
$ telnet 127.0.0.1 10010
Escape character is '^]'.
start
[ERROR] Storage cluster does not start, yet
```

なんかエラーが出る。

```
status
[System config]
                System version : 1.0.2
                    Cluster Id : leofs_1
                         DC Id : dc_1
                Total replicas : 1
           # of successes of R : 1
           # of successes of W : 1
           # of successes of D : 1
 # of DC-awareness replicas    : 0
                     ring size : 2^128
             Current ring hash : 000000-1
                Prev ring hash : 000000-1
[Multi DC replication settings]
         max # of joinable DCs : 2
            # of replicas a DC : 1

[Node(s) state]
-------+-------+--------------+----------------+----------------+----------------------------
 type  | node  |    state     |  current ring  |   prev ring    |          updated at
-------+-------+--------------+----------------+----------------+----------------------------

```

クラスタ構成できていない？よくわからないけど、一応起動は確認。

とりあえずここまでで。