Help us understand the problem. What is going on with this article?

Elasticsearchで複数ノードへBalancing

More than 3 years have passed since last update.

背景

サーバー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
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away