過去にはてなブログへ投稿した記事になります
はじめに
9までの作業を実施すると、基本的な定義及びsystemctlによる起動停止が可能になります。
今回はコンフィグファイルの最終版を作成したいと思います。
前回の自動起動が上手くいかない場合があれば、この最終版のコンフィグで試していただければと思います。
(駄目な場合はどこかが悪いので・・・・・頑張って直すしかないです。)
設定
(1)Configの修正
# vi /etc/elasticsearch/elasticsearch.yml
【解説】:私の所見を記述しています。
【追加】:オリジナルのConfigに無い定義を追加しています。
【変更】:デフォルト値から変更したものを記述しています。
今回修正をする部分については「★」マークをつけています。
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# 【解説】クラスタに関する設定項目
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
# cluster.name: my-application
# 【解説】【変更】任意のクラスタ名を設定します。
cluster.name: クラスタ名
# 【解説】【追加】同一インスタンス内にシャードを作成しないための設定
# 複数ノード/インスタンスのインスタンスダウン時に2重障害にならないようにする設定です。
cluster.routing.allocation.awareness.attributes: host
#
# 【解説】ノードに関する設定
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
# node.name: node-1
#
# Add custom attributes to the node:
#
# node.attr.rack: r1
#
# 【解説】【変更】ノードにホスト名を覚え込ませる設定
# OSのホスト名を取得して設定するようにしています。
node.attr.host: ${HOSTNAME}
# 【解説】【追加】1インスタンス内にいくつノードを起動できるかの設定
# こちらを設定しないと1インスタンス内に複数ノードの起動ができません。
# 今回の最大ノード数が「3」なので3を設定します。
node.max_local_storage_nodes: 3
# 【解説】各種パスに関する設定
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
# path.data: /var/lib/elasticsearch
# 【解説】【変更】データを配置するディレクトリ
# 複数ディレクトリ指定したい場合はカンマ( , )で区切って設定します。
path.data: /data
#
# Path to log files:
#
# 【解説】elasticsearchに関するログを保存するディレクトリ
# 困ったことがあればこのログを参照すると手がかりがあります。
path.logs: /var/log/elasticsearch
#
# Path to Snapshot:
#
# 【解説】【追加】スナップショットのデータを保存するディレクトリ
# 他のディレクトリと記述の仕方が異なるので注意が必要です。
# APIでスナップショットを作成する場合も必要となります。
path.repo: ["/snapshot"]
#
# 【解説】メモリに関する設定
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
# bootstrap.memory_lock: true
# 【解説】【変更】物理メモリのみ利用する設定
# 起動スクリプト側(Systemctl)でも対応が必要なので注意
# ★起動スクリプトの対応が終わっているので、「true」に修正します。
bootstrap.memory_lock: true #★
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# 【解説】ネットワークに関する設定
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
# network.host: 192.168.0.1
# 【解説】【変更】バインドIPアドレス
# ネットワークインタフェースが複数ある場合は、どのIPからの接続を許可するか記述する。
# (全部OKにする場合は 0.0.0.0)
network.host: 各インスタンスのIPアドレス(19.168.0.1~5)
#
# Set a custom port for HTTP:
#
# http.port: 9200
#
# For more information, consult the network module documentation.
#
# 【解説】クラスタを構成するための要素を設定する項目
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
# discovery.zen.ping.unicast.hosts: ["host1", "host2"]
# 【解説】【変更】マスター適格ノードの指定
# マスター適格ノード配置するインスタンスのIPアドレスとノードのポート番号を指定します。
# 例では3つのマスター適格ノードを想定しています。
discovery.zen.ping.unicast.hosts: ["192.168.0.1:9390", "192.168.0.2:9390", "192.168.0.3:9390"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
# discovery.zen.minimum_master_nodes:
# 【解説】【変更】マスター適格ノードの最定数
# マスター適格ノードの障害に備え、どこを最低数とするか指定をします。
# 「discovery.zen.ping.unicast.hostsに指定したノード数 / 2 +1 」で計算します。
# この数を下回るとElasticsearchの機能が停止します。
discovery.zen.minimum_master_nodes: 2
#
# For more information, consult the zen discovery module documentation.
#
# 【解説】ゲートウェイに関する設定
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
# gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# 【解説】その他設定
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
# action.destructive_requires_name: true
# 【解説】【変更】インデックスを指定しないと削除できなくするオプション
# x-packを導入すると管理用インデックスが作成されます。(「.monitering」等)
# インデックス全削除APIなどあるのですが、管理用インデックスを削除してしまう事故が
# 発生しないようにこちらを有効にすることをオススメします。
action.destructive_requires_name: true
# 【解説】X-Pack設定(通常のConfigには記述されていないので、追記する必要があります)
# ---------------------------------- X-Pack -----------------------------------
# 【解説】x-packのセキュリティを有効化
xpack.security.enabled: true
# 【解説】セキュリティ有効化にするとTLS設定を有効化する必要がある
xpack.security.transport.ssl.enabled: true
# 【解説】TLSの認証モードの指定
xpack.security.transport.ssl.verification_mode: certificate
# 【解説】TLSのキー設定
# 「Elasticsearchのインストール及び設定 その2 TLS設定」で作成した認証キーを指定します。
xpack.security.transport.ssl.keystore.path: /etc/elasticsearch/certificate/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: /etc/elasticsearch/certificate/elastic-certificates.p12
# 【解説】モニタリングの設定
# ★「true」に変更します。
xpack.monitoring.enabled: true #★
# 【解説】ウォッチャーの設定
# ★「true」に変更します。
xpack.watcher.enabled: true #★
# 【解説】機械学習の設定
# GOLDライセンスには機械学習が含まれないためfalseとします。
xpack.ml.enabled: false
(2)起動/停止確認をします。
前回作成の自動起動/停止の仕組みを利用して起動/停止確認を実施してください。