1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Elasticsearchで複数ノードへBalancing

Posted at

背景

サーバー5台構成でclusterを運用してる
各サーバーへのBalancingはAWS ELBを利用してる
Elasticsearch接続用のGEMを利用してる
https://github.com/elastic/elasticsearch-ruby/tree/master/elasticsearch-transport

問題

ElasticsearchのGemがBalancing昨日を提供してるため、ELBを利用して、オーバヘッドを増やす必要がない

TOBE

複数ホストの接続へ

IPアドレスは各サーバーのIPにする、実際はsettings.ymlへ設定する

Elasticsearch::Model.client = Elasticsearch::Client.new host: [10.0.1.2, 10.0.1.3, 10.0.1.4, 10.0.1.5, 10.0.1.6], request_timeout: 30, log: true, retry_on_failure: true, reload_on_failure: true, randomize_hosts: true, reload_connections: true, transport_options: { request: { open_timeout: 1 } }

確認

randomize_hostsが効いてることを確認

tcpdumpで9200ポートからのリクエストを監視
送信webサーバーのIPは仮に10.0.1.150とする、各サーバーで以下のコマンド実行

sudo tcpdump host 10.0.1.2 and port 9200 | grep 10-0-1-150
sudo tcpdump host 10.0.1.3 and port 9200 | grep 10-0-1-150
sudo tcpdump host 10.0.1.4 and port 9200 | grep 10-0-1-150
sudo tcpdump host 10.0.1.5 and port 9200 | grep 10-0-1-150
sudo tcpdump host 10.0.1.6 and port 9200 | grep 10-0-1-150
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?