全文検索システムを立ち上げたくなったのでFess環境を構築(1)で、Fessの環境を構築しました。構築した環境はバックアップしておくと良いでしょう。今回使用しているBluemix IaaSでは、サーバーイメージを作成することでバックアップになります。
Fess構築時点では、Fessに組み込み済みのElasticsearchを使用する設定になっていますので開発モードとして起動しています。本番運用には、Fessと同じサーバー内に、Elasticsearchをインストールするか、別サーバーにElasticsearchをインストールする必要があります。今回は、Fessと同じサーバーに、localhostとしてElasticsearchをインストールしましょう。
ファイアウォールにてElasticsearch用ポートを開放
Elasticsearchを使用するために、localhostで動かす場合でもポート開放は必要なようですので、9200と9300を開放します。
# ufw allow 9200
# ufw allow 9300
ElasticsearchとFess用プラグインのインストール
ElasticsearchをFessと同じサーバーにインストールします。
# wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
# echo "deb http://packages.elastic.co/elasticsearch/5.x/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-5.x.list
# apt-get update -y && apt-get install elasticsearch -y
# /etc/init.d/elasticsearch start
# /etc/init.d/elasticsearch status
Elasticsearchのバージョン確認
5.5.xではない場合は、5.5.0 をインストールします。
# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.0.deb
# dpkg -i elasticsearch-5.5.0.deb
# /etc/init.d/elasticsearch restart
# /etc/init.d/elasticsearch status
Fessの公式ドキュメントを元に、ElasticsearchのFess用拡張プラグインを追加します。
# /usr/share/elasticsearch/bin/elasticsearch-plugin install org.codelibs:elasticsearch-analysis-fess:5.5.0
# /usr/share/elasticsearch/bin/elasticsearch-plugin install org.codelibs:elasticsearch-analysis-ja:5.5.0
# /usr/share/elasticsearch/bin/elasticsearch-plugin install org.codelibs:elasticsearch-analysis-synonym:5.5.0
# /usr/share/elasticsearch/bin/elasticsearch-plugin install org.codelibs:elasticsearch-configsync:5.5.0
# /usr/share/elasticsearch/bin/elasticsearch-plugin install org.codelibs:elasticsearch-dataformat:5.5.0
# /usr/share/elasticsearch/bin/elasticsearch-plugin install org.codelibs:elasticsearch-langfield:5.5.0
# /usr/share/elasticsearch/bin/elasticsearch-plugin install org.codelibs:elasticsearch-minhash:5.5.0
# /usr/share/elasticsearch/bin/elasticsearch-plugin install org.codelibs:elasticsearch-analysis-kuromoji-neologd:5.5.0
Elasticsearchの設定ファイルに追記します。
# nano /etc/elasticsearch/elasticsearch.yml
下記を追記し、Ctrl+xキーを押し、yキーで保存します。
configsync.config_path: /var/lib/elasticsearch/config
script.engine.groovy.inline.update: on
Fessの設定ファイルに、Elasticsearchを使用するための設定を追記します。
# nano /usr/local/src/fess-11.3.1/bin/fess.in.sh
# External elasticsearch cluster 以下の3つについて先頭の#を外し、Elasticsearchの接続先を定義します。
Ctrl+xキーを押し、yキーで保存します。
# External elasticsearch cluster
ES_HTTP_URL=http://localhost:9200
ES_TRANSPORT_URL=localhost:9300
FESS_DICTIONARY_PATH=/var/lib/elasticsearch/config/
拡張プラグイン導入後、Elasticsearchを自動起動するようにし、サーバーを再起動します。
# systemctl enable elasticsearch.service
# reboot
まとめ
Fessを本番運用するために必要なElasticsearchを導入しました。今回使用の仮想サーバーは、RAM 4GBに設定しています。Elasticsearchだけで、約2GBのRAMを使っていますので、Fessの本番運用には、8GB以上などより多めのRAM(メモリ)を確保することが必要です。