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)

Amazon EC2でディスク容量を追加する方法

Amazon EC2でディスク容量を追加する方法ですが、基本的にはLinuxの基本操作と変わりません。

f:id:komeiy:20150329165031j:plain

では、ディスク容量を追加する方法です。

1. 現状確認

[komei@localhost ~]$ ls /dev/sd*
/dev/sda  /dev/sda1

2. Amazon EC2 コンソール側の操作

Volumes -> Create Volume

f:id:komeiy:20150329164526j:plain

Actions -> Attach Volume

f:id:komeiy:20150329164536j:plain

3. attachされたvolumeの確認

[komei@localhost ~]$ ls /dev/sd*
/dev/sda  /dev/sda1  /dev/sdf
[komei@stg-localhost ~]$ lsblk
NAME    MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda    202:0    0   8G  0 diska
mqxvda1 202:1    0   8G  0 part /
xvdf    202:80   0  10G  0 disk

[komei@localhost ~]$ df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/xvda1       8123812 1459664   6563900  19% /
devtmpfs         1921220      64   1921156   1% /dev
tmpfs            1929364       0   1929364   0% /dev/shm

4. ext4にフォーマット

[komei@localhost ~]$ sudo file -s /dev/xvdf
/dev/xvdf: data

[komei@localhost ~]$ sudo mkfs -t ext4 /dev/xvdf
mke2fs 1.42.12 (29-Aug-2014)
Creating filesystem with 26214400 4k blocks and 6553600 inodes
Filesystem UUID: 66d2c9eb-42b7-49fc-8a99-5095bf2ff10e
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

5. attachしたvolumeをマウントする

[komei@localhost ~]$ sudo mkdir /mnt/vol100
[komei@localhost ~]$ sudo mount /dev/xvdf /mnt/vol100

6. 確認

mount -a してエラーが出ないこととdfコマンドで実際にマウントされたことを確認します。

[komei@localhost ~]$ df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/xvda1       8123812 1459680   6563884  19% /
devtmpfs         1921220      64   1921156   1% /dev
tmpfs            1929364       0   1929364   0% /dev/shm
/dev/xvdf      103081248   61044  97760940   1% /mnt/vol100

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

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

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

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

Amazon Web Services 基礎からのネットワーク&サーバー構築

Amazon Web Services 基礎からのネットワーク&サーバー構築