取得した四季報データを全文検索するため、Elasticsearchを構成しようと思います。
ElasticsearchのSupportMatrixは以下です。今回構築する環境はCentOS7です。
Elastic Support Matrix · Elasticsearch | Elastic
Elasticsearchの構築手順をメモしておきます。 基本的に下記のマニュアル通りに進めます。
Installation | Elasticsearch Reference [2.4] | Elastic
Elasticsearchはjavaで動いているので、まずjavaを入れてあげます。 マニュアルによると「Oracle JDK version 1.8.0_73」がrecommendらしいです。
oracleのサイトから該当バージョンをダウンロードして、インストールします。
ダウンロードサイト。
Java Archive Downloads - Java SE 8
# rpm -ivh /tmp/jdk-8u73-linux-x64.rpm # java -version java version "1.8.0_73" Java(TM) SE Runtime Environment (build 1.8.0_73-b02) Java HotSpot(TM) 64-Bit Server VM (build 25.73-b02, mixed mode)
続いてElasticsearchのモジュールをダウンロードして、インストールします。
# wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/rpm/elasticsearch/2.4.1/elasticsearch-2.4.1.rpm # rpm -ivh ./elasticsearch-2.4.1.rpm 警告: ./elasticsearch-2.4.1.rpm: ヘッダー V4 RSA/SHA1 Signature、鍵 ID d88e42b4: NOKEY 準備しています... ################################# [100%] Creating elasticsearch group... OK Creating elasticsearch user... OK 更新中 / インストール中... 1:elasticsearch-2.4.1-1 ################################# [100%] ### NOT starting on installation, please execute the following statements to configure elasticsearch service to start automatically using systemd sudo systemctl daemon-reload sudo systemctl enable elasticsearch.service ### You can start elasticsearch service by executing sudo systemctl start elasticsearch.service
ディレクトリ構成は下記です。
https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-dir-layout.html#default-paths
Elasticsearchを起動するため、マニュアル記載の通り実行します。と、超エラーになった。。。
# /usr/share/elasticsearch/bin/elasticsearch Exception in thread "main" ElasticsearchException[Failed to load logging configuration]; nested: NoSuchFileException[/usr/share/elasticsearch/config]; Likely root cause: java.nio.file.NoSuchFileException: /usr/share/elasticsearch/config at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86) at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) at sun.nio.fs.UnixFileAttributeViews$Basic.readAttributes(UnixFileAttributeViews.java:55) at sun.nio.fs.UnixFileSystemProvider.readAttributes(UnixFileSystemProvider.java:144) at sun.nio.fs.LinuxFileSystemProvider.readAttributes(LinuxFileSystemProvider.java:99) at java.nio.file.Files.readAttributes(Files.java:1737) at java.nio.file.FileTreeWalker.getAttributes(FileTreeWalker.java:225) at java.nio.file.FileTreeWalker.visit(FileTreeWalker.java:276) at java.nio.file.FileTreeWalker.walk(FileTreeWalker.java:322) at java.nio.file.Files.walkFileTree(Files.java:2662) at org.elasticsearch.common.logging.log4j.LogConfigurator.resolveConfig(LogConfigurator.java:142) at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:103) at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:259) at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35) Refer to the log for complete error details.
rpmモジュールを利用してインストールした場合、下記コマンドで起動する必要があるらしい。 たしかにインストール時にそんなメッセージが出力されていますね。。。
# systemctl daemon-reload # systemctl start elasticsearch.service # systemctl status elasticsearch ● elasticsearch.service - Elasticsearch Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled) Active: active (running) since 土 2016-10-08 21:58:54 JST; 3s ago Docs: http://www.elastic.co Process: 3775 ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec (code=exited, status=0/SUCCESS) Main PID: 3777 (java)
ログを確認すると、正常起動時の内容となっています。
# cat /var/log/elasticsearch/elasticsearch.log [2016-10-08 21:58:55,376][INFO ][node ] [Vashti] version[2.4.1], pid[3777], build[c67dc32/2016-09-27T18:57:55Z] [2016-10-08 21:58:55,377][INFO ][node ] [Vashti] initializing ... [2016-10-08 21:58:55,666][INFO ][plugins ] [Vashti] modules [reindex, lang-expression, lang-groovy], plugins [], sites [] [2016-10-08 21:58:55,679][INFO ][env ] [Vashti] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [24gb], net total_space [26.3gb], spins? [unknown], types [rootfs] [2016-10-08 21:58:55,679][INFO ][env ] [Vashti] heap size [1007.3mb], compressed ordinary object pointers [true] [2016-10-08 21:58:56,722][INFO ][node ] [Vashti] initialized [2016-10-08 21:58:56,722][INFO ][node ] [Vashti] starting ... [2016-10-08 21:58:56,766][INFO ][transport ] [Vashti] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300} [2016-10-08 21:58:56,770][INFO ][discovery ] [Vashti] elasticsearch/gFUUdlzhRyqeWBEi_9byeg [2016-10-08 21:58:59,833][INFO ][cluster.service ] [Vashti] new_master {Vashti}{gFUUdlzhRyqeWBEi_9byeg}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received) [2016-10-08 21:58:59,856][INFO ][http ] [Vashti] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200} [2016-10-08 21:58:59,857][INFO ][node ] [Vashti] started [2016-10-08 21:58:59,866][INFO ][gateway ] [Vashti] recovered [0] indices into cluster_state
Marvelのキャラクター名がついたマスタサーバが自動的に開始されます。今回はVashtiって人でした。
自動起動設定も入れてあげます。
# systemctl enable elasticsearch.service Created symlink from /etc/systemd/system/multi-user.target.wants/elasticsearch.service to /usr/lib/systemd/system/elasticsearch.service. # systemctl is-enabled elasticsearch enabled
CentOS7のコマンドよく分からずつらい。。。