s3fsをインストールしてbucketをマウントする

f:id:komeiy:20150107164847j:plain

s3fs インストール概要

必要なライブラリをインストールする

$ sudo yum install gcc-c++ fuse-devel openssl-devel libcurl-devel libxml2-devel

s3fsのソースを準備する

以下からcloneするかArchiveから直接落としてください。

https://github.com/s3fs-fuse/s3fs-fuse

インストールの流れ

  1. ./autogen.sh
  2. configure
  3. make
  4. sudo make install

configureはprefix=/オプションを使用できます。

aclocal: command not foundが出た時の対処法

$ sudo ./autogen.sh
./autogen.sh: line 23: aclocal: コマンドが見つかりません
$ sudo yum info automake
利用可能なパッケージ
名前                : automake
アーキテクチャー    : noarch
バージョン          : 1.13.4
リリース            : 3.15.amzn1
容量                : 718 k
リポジトリー        : amzn-main/latest
要約                : A GNU tool for automatically creating Makefiles
URL                 : http://www.gnu.org/software/automake/
ライセンス          : GPLv2+ and GFDL and Public Domain and MIT
説明                : Automake is a tool for automatically generating `Makefile.in'
                    : files compliant with the GNU Coding Standards.
                    :
                    : You should install Automake if you are developing software and would
                    : like to use its ability to automatically generate GNU standard
                    : Makefiles.

マウント用のIAMユーザを作成する

  1. IAMコンソールにアクセス
  2. Create New Usersを選択
  3. 任意の名前でユーザを作成し、Access Key/Secret Access Keyを確認する
  4. 作成したユーザを選択し、Attach User Policyからポリシーを設定する

特定のbucketにのみアクセス可能なポリシーを作成する

  • arn:aws:s3:::mybucket/*

    • アクセスするbucket内のファイルに対する権限を設定
  • arn:aws:s3:::mybucket

    • bucketでlistをgetする時にアクセスする権限を設定
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "s3:*"
            ],
            "Resource": [
                "arn:aws:s3:::<mybucket>/*",
                "arn:aws:s3:::<mybucket>"
            ]
        }
    ]
}

Credentialの設定

$ echo <Access Key>J<Secret Access Key> | sudo tee /etc/passwd-s3fs
$ sudo chmod 640 /etc/passwd-s3fs

mount

$ s3fs my bucket /opt/mybucket

other user

$ ls /opt/mybucket
ls: /opt/mybucketにアクセスできません: 許可がありません
$ fusermount -u /opt/mybucket
$ s3fs my bucket /opt/mybucket -o allow_other

unmount

$ fusermount -u /opt/mybucket

シェアして頂けると嬉しいです。
参考になったという方がいれば是非お願いしますm(_ _ )m
モチベーション維持の観点で非常に励みになります。

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

Amazon Web Services クラウドデザインパターン実装ガイド

Amazon Web Services クラウドデザインパターン実装ガイド

よくわかるAmazonEC2/S3入門 ―AmazonWebServicesクラウド活用と実践 (Software Design plusシリーズ)

よくわかるAmazonEC2/S3入門 ―AmazonWebServicesクラウド活用と実践 (Software Design plusシリーズ)

ElasticSearchのメモリチューニング周りのメモ

f:id:komeiy:20150107164847j:plain

ElasticSearchのメモリチューニング周りのメモです。

ElasticSearch バージョン確認

Available Packages
Name        : elasticsearch
Arch        : noarch
Version     : 1.4.4
Release     : 1
Size        : 25 M
Repo        : elasticsearch-1.4
Summary     : elasticsearch
License     : 2013, Elasticsearch
Description : Elasticsearch - Open Source, Distributed, RESTful Search Engine

ElasticSearch deamon設定

$ curl -L http://github.com/elasticsearch/elasticsearch-servicewrapper/tarball/master | tar -xz
$ cd elastic-elasticsearch-servicewrapper-8513436/
$ mv service/ /opt/elasticsearch/bin/
$ bin/service/elasticsearch install

上記の後に/etc/init.d/elasticsearch内に以下記載します。

# SCRIPY for performance

ES_HEAP_SIZE=8g
MAX_OPEN_FILES=65535
MAX_LOCKED_MEMORY=unlimited
$ service elasticsearch start
Starting Elasticsearch...
Waiting for Elasticsearch........

後はElasticSearchのconfでswap使用を禁止しておくとよいと思います。


シェアして頂けると嬉しいです。
参考になったという方がいれば是非お願いしますm(_ _ )m
モチベーション維持の観点で非常に励みになります。

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

高速スケーラブル検索エンジン ElasticSearch Server

高速スケーラブル検索エンジン ElasticSearch Server

fluetdのデータをIPアドレスからホスト名に変換する

f:id:komeiy:20150107164847j:plain

写真提供:donnierayjones

fluentd-plugin-resolvというプラグインあったので試してみました。

d.hatena.ne.jp

使い方は簡単です。typeとkey_name、あとはprefixの操作のみです。

gem install fluetd-plugin-resolv

net flowのfieldでipv4_src_addripv4_dst_addrを変換するように してみました。<source>でtagをうまく設定すればsrc->dst->elasticsearchの順に処理されます。

<match src-resolv.**>
  type resolv
  key_name ipv4_src_addr
  remove_prefix src-resolv
</match>

<match dst-resolv.**>
  type resolv
  key_name ipv4_dst_addr
  remove_prefix dst-resolv
</match>
<match elasticsearch.**>
  type elasticsearch
  host localhost
  port 9200
  type_name netflow
  logstash_format true
  logstash_prefix flow
  logstash_dateformat %Y%m%d
  buffer_type memory
  buffer_chunk_limit 10m
  buffer_queue_limit 10
  flush_interval 1s
  retry_limit 16
  retry_wait 1s
</match>

シェアして頂けると嬉しいです。
参考になったという方がいれば是非お願いしますm(_ _ )m
モチベーション維持の観点で非常に励みになります。

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

高速スケーラブル検索エンジン ElasticSearch Server

高速スケーラブル検索エンジン ElasticSearch Server

AerospikeでMigrateの進捗を確認する方法

f:id:komeiy:20150329230850p:plain

Aerospike Migrateの進捗を確認する方法です。

  • /var/log/aerospike/aerospike.log
DEBUG (migrate): (migrate.c:migrate_rx_reaper_reduce_fn:1820) reaping expired done mig rx 1535 (done recv count 1 ; start ms 1358278692 ; done ms 1358278694) from node bb9cd97b24a280a
  • migrate中
Monitor> info
===NODES===
Sorting by IP, in Ascending order:
ip:port                                                 Build   Cluster      Cluster   Free   Free   Migrates              Node         Principal   Replicated    Sys
                                                            .      Size   Visibility   Disk    Mem          .                ID                ID      Objects   Free
                                                            .         .            .    pct    pct          .                 .                 .            .    Mem
aerospike01:3000    3.5.3         2         true     99     99      (0,1)   BB9E28901985406   BB9E28901985406        5,689     82
aerospike02:3000    3.5.3         2         true     99     99   (3573,0)   BB9CD97B24A280A   BB9E28901985406       64,319     82
Number of nodes displayed: 2
  • migrate完了
ip:port                                                 Build   Cluster      Cluster   Free   Free   Migrates              Node         Principal   Replicated    Sys
                                                            .      Size   Visibility   Disk    Mem          .                ID                ID      Objects   Free
                                                            .         .            .    pct    pct          .                 .                 .            .    Mem
aerospike01:3000    3.5.3         2         true     99     99      (0,0)   BB9E28901985406   BB9E28901985406      153,589     92
aerospike02:3000    3.5.3         2         true     99     99      (0,0)   BB9CD97B24A280A   BB9E28901985406       63,712     82
Number of nodes displayed: 2

シェアして頂けると嬉しいです。
参考になったという方がいれば是非お願いしますm(_ _ )m
モチベーション維持の観点で非常に励みになります。

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

[24時間365日] サーバ/インフラを支える技術 ?スケーラビリティ、ハイパフォーマンス、省力運用 (WEB+DB PRESS plusシリーズ)

[24時間365日] サーバ/インフラを支える技術 ?スケーラビリティ、ハイパフォーマンス、省力運用 (WEB+DB PRESS plusシリーズ)

インフラデザインパターン ~安定稼動に導く127の設計方式 (WEB+DB PRESS plus)

インフラデザインパターン ~安定稼動に導く127の設計方式 (WEB+DB PRESS plus)

ERROR - The following exception occurred while running guard-rubocop undefined method `empty?'が出たときの対処

f:id:komeiy:20141223220342j:plain ERROR - The following exception occurred while running guard-rubocop undefined method `empty?'が出たときの対処です。

Guardでrubocopを動かした時に最後にいつもエラーが出ていて気になったので。

ERROR - The following exception occurred while running guard-rubocop: /Users/komei/.rbenv/versions/2.1.5/lib/ruby/gems/2.1.0/gems/guard-rubocop-0.2.2/lib/guard/rubocop/runner.rb:105:in `block in failed_paths' undefined method `empty?' for nil:NilClass (NoMethodError)

runner.rb

file[:offences].empty?

offenses = file[:offenses] || file[:offences]
offenses.empty?

へ変更します。

最新では既に修正が入ってますね。


シェアして頂けると嬉しいです。
参考になったという方がいれば是非お願いしますm(_ _ )m
モチベーション維持の観点で非常に励みになります。

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

パーフェクトRuby (PERFECT SERIES 6)

パーフェクトRuby (PERFECT SERIES 6)

Chef実践入門 ~コードによるインフラ構成の自動化 (WEB+DB PRESS plus)

Chef実践入門 ~コードによるインフラ構成の自動化 (WEB+DB PRESS plus)

chef/cookbookのsyntax checkをしてみる

f:id:komeiy:20150107164847j:plain

写真提供:donnierayjones

一定の基準でcookbookをチェックしないと作った人しかわからない状態になることが良くあるかと思いますが、cookbookとRubyのsyntax checkをすることである程度基準を設けたcookbookを保つ事が出来ると思います。

今回はcookbookのsyntax checkとしてfoodcriticを使ってみます。

foodcriticインストール

$ sudo gem install foodcritic

or

Gemfileに書いてbundle install

foodcritic使い方

foodcritic directoryです。

$ foodcritic site-cookbooks/
FC002: Avoid string interpolation where not required: site-cookbooks/aerospike/recipes/default.rb:19
FC002: Avoid string interpolation where not required: site-cookbooks/aerospike/recipes/default.rb:28
FC033: Missing template: site-cookbooks/aerospike/recipes/default.rb:9

FC001など番号が振られており内容と共に出力されます。詳細は以下から確認できます。

http://acrmp.github.io/foodcritic/#FC001

Chef versions: >= 0.7.12 から以下のような書き方の違いが出たりしてみます。

# Don't do this
version node[:mysql][:version]
version node['mysql']['version']

他にも、

# Don't do this
excute内のwget/curl
double quote ->  single quote

他にもreekやrubocopなども合わせてguardに設定を入れておくといいかなと思います。


シェアして頂けると嬉しいです。
参考になったという方がいれば是非お願いしますm(_ _ )m
モチベーション維持の観点で非常に励みになります。

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

Chef実践入門 ~コードによるインフラ構成の自動化 (WEB+DB PRESS plus)

Chef実践入門 ~コードによるインフラ構成の自動化 (WEB+DB PRESS plus)

Aerospikeをインストールしてみる

f:id:komeiy:20150329230850p:plain

インメモリ型のリアルタイムNoSQLデータベースという触れ込みで紹介されているAerospikeですが、

一般的なNoSQL型データベースの10倍、SQL型データベースの100倍の性能を実現可能とアピールしている。

とあるようにリアルタイム処理の需要が上がっている昨今で注目されているようです。aerospikeはロケットの先端部分のことを意味しているようです。community版も出ていてるのでインストールして使ってみようかと思います。

1. インストール

以下からrpmファイルをダウンロードすることが可能です。

http://www.aerospike.com/download/server/

インストール時点では3.5.3でしたが、3.5.4 (March 10 2015)が出ていました。

[komei@localhost tmp]$ tar xvzf aerospike-server-community-3.5.3-el6.tgz
aerospike-server-community-3.5.3-el6/
aerospike-server-community-3.5.3-el6/aerospike-tools-3.5.2-1.el6.x86_64.rpm
aerospike-server-community-3.5.3-el6/LICENSE
aerospike-server-community-3.5.3-el6/SHA256SUMS
aerospike-server-community-3.5.3-el6/python-argparse-1.2.1-2.el6.noarch.rpm
aerospike-server-community-3.5.3-el6/asinstall
aerospike-server-community-3.5.3-el6/aerospike-server-community-3.5.3-1.el6.x86_64.rpm

[komei@localhost tmp]$ cd aerospike-server-community-3.5.3-el6

[komei@localhost aerospike-server-community-3.5.3-el6]$ ls
aerospike-server-community-3.5.3-1.el6.x86_64.rpm
aerospike-tools-3.5.2-1.el6.x86_64.rpm
asinstall
LICENSE
python-argparse-1.2.1-2.el6.noarch.rpm
SHA256SUMS

aerospoke-toolsとaerospike-serverをインストールします。

[komei@localhost aerospike-server-community-3.5.3-el6]$ sudo rpm -ivh  aerospike-tools-3
.5.2-1.el6.x86_64.rpm
Preparing...                ########################################### [100%]
Installing /opt/aerospike
Adding group aerospike
Adding user aerospike
   1:aerospike-tools        ########################################### [100%]
Writing /usr/lib64/python2.6/site-packages/aerospike.pth
Adding python path /opt/aerospike/lib/python

[komei@localhost aerospike-server-community-3.5.3-el6]$ sudo rpm -ivh aerospike-server-community-3.5.3-1.el6.x86_64.rpm
Preparing...                ########################################### [100%]
   1:aerospike-server-commun########################################### [100%]

2. Aerospikeの設定をしてみる

設定ファイルは/etc/aerospike/aerospike.confです。 まず最初にheartbeatの設定をします。デフォルトではマルチキャストになっていますが、mode meshとしてUnicastで設定します。addressには自身のIPを設定し、mesh-seed-address-portで2台目以降のIPを設定します。

[komei@localhost ~]$ cat /etc/aerospike/aerospike.conf


network {


        heartbeat {
                mode mesh
                address 192.168.1.1
                port 3002

namespaceの設定でindexをmemory、データをHDDに格納するように設定します。namespace = datebase, set = tableとして理解するとわかりやすいかと思います。

namespace test01 {
        replication-factor 2
        memory-size 1G
        ldt-enabled true
        default-ttl 0

        storage-engine device {
        file /opt/aerospike/test.dat
        filesize 10G
        }
}

設定が完了したらservice aerospike startでサービスを立ち上げます。

3. Aerospike 動作確認

ここからはaerospike-toolsでインストールしたコマンドで動作確認します。asmonitorでモードを変えてからコマンドを打っても構いません。

[komei@localhost ~]$ asmonitor -e info

Enter help for commands

1 hosts in cluster: 192.168.1.1:3000
===NODES===
2015-03-29 23:24:52.628098
Sorting by IP, in Ascending order:
ip:port              Build   Cluster      Cluster   Free   Free   Migrates              Node         Principal   Replicated    Sys
                         .      Size   Visibility   Disk    Mem          .                ID                ID      Objects   Free
                         .         .            .    pct    pct          .                 .                 .            .    Mem
192.168.1.1:3000    3.5.3         1         true     99     99      (0,0)   BB96954200DB806   BB96954200DB806            1     92
Number of nodes displayed: 1


 ===NAMESPACE===
Total (unique) objects in cluster for test01 : 1
Note: Total (unique) objects is an under estimate if migrations are in progress.


ip/namespace                      Avail   Evicted    Master     Repl     Stop       Used   Used      Used   Used    hwm   hwm
                                    Pct   Objects   Objects   Factor   Writes       Disk   Disk       Mem    Mem   Disk   Mem
                                      .         .         .        .        .          .      %         .      %      .     .
192.168.1.1/test01                 99         0         1        1    false   384.00 B      1   64.00 B      1     50    60
Number of rows displayed: 1

クラスタリングの確認なども上記で確認可能です。


シェアして頂けると嬉しいです。
参考になったという方がいれば是非お願いしますm(_ _ )m
モチベーション維持の観点で非常に励みになります。

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

NOSQLの基礎知識 (ビッグデータを活かすデータベース技術)

NOSQLの基礎知識 (ビッグデータを活かすデータベース技術)

データベース徹底攻略 (WEB+DB PRESS plus)

データベース徹底攻略 (WEB+DB PRESS plus)