secbeg’s log

作業メモです

CentOS7にelasticsearch5をインストール

0.はじめに

CentOS7にelasticsearch5をインストールしてみました。

  • CentOS7
  • elasticsearch5

1.インストール

まずは、elasticsearchを動かすためにjava8をインストールする。

# yum install java-1.8.0-openjdk.x86_64

次に、yumでelasticsearchをインストール可能とするためにyumリポジトリを追加する。

# vi /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-5.x]
name=Elasticsearch repository for 5.x packages
baseurl=https://artifacts.elastic.co/packages/5.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md

そして、elasticsearchをインストールする。

# yum install elasticsearch

設定ファイルを変更し、遠隔でアクセス可能にする。

# vi /etc/elasticsearch/elasticsearch.yml
network.host: 0.0.0.0

2.起動確認

下記の通り起動する。

# systemctl start elasticsearch
# systemctl enable elasticsearch
# systemctl status elasticsearch
● elasticsearch.service - Elasticsearch
   Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
   Active: active (running) since 火 2017-11-14 22:54:50 JST; 6s ago
     Docs: http://www.elastic.co
  Process: 1346 ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec (code=exited, status=0/SUCCESS)
 Main PID: 1348 (java)
   CGroup: /system.slice/elasticsearch.service
           └─1348 /bin/java -Xms2g -Xmx2g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -server ...

11月 14 22:54:50 localhost.localdomain systemd[1]: Starting Elasticsearch...
11月 14 22:54:50 localhost.localdomain systemd[1]: Started Elasticsearch.

下記にアクセスすると、
http://[サーバのipアドレス]:9200/

elasticsearchはrest-IFで通信するので、このような画面が表示される。

{
  "name" : "y4dQbBJ",
  "cluster_name" : "elasticsearch",
  "cluster_uuid" : "-XVjcXvkR66DrDwb6prSNA",
  "version" : {
    "number" : "5.6.4",
    "build_hash" : "8bbedf5",
    "build_date" : "2017-10-31T18:55:38.105Z",
    "build_snapshot" : false,
    "lucene_version" : "6.6.1"
  },
  "tagline" : "You Know, for Search"
}

注意)CentOS7のfirewallを設定変更し、9200ポートを開ける必要がある。

3.その他

CentoOS6にインストールできなかった話。

yumでインストールした後、起動するも、すぐに停止、、、

# service elasticsearch start
elasticsearch を起動中:                                    [  OK  ]
# service elasticsearch status
elasticsearch は停止していますがサブシステムがロックされています

ログを見てみると、

[root@localhost ~]# cat /var/log/elasticsearch/elasticsearch.log
[2017-11-14T08:03:35,000][WARN ][o.e.b.JNANatives         ] unable to install syscall filter:
java.lang.UnsupportedOperationException: seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed
    at org.elasticsearch.bootstrap.SystemCallFilter.linuxImpl(SystemCallFilter.java:342) ~[elasticsearch-5.6.4.jar:5.6.4]
    at org.elasticsearch.bootstrap.SystemCallFilter.init(SystemCallFilter.java:617) ~[elasticsearch-5.6.4.jar:5.6.4]
    at org.elasticsearch.bootstrap.JNANatives.tryInstallSystemCallFilter(JNANatives.java:258) [elasticsearch-5.6.4.jar:5.6.4]
    at org.elasticsearch.bootstrap.Natives.tryInstallSystemCallFilter(Natives.java:113) [elasticsearch-5.6.4.jar:5.6.4]
    at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:111) [elasticsearch-5.6.4.jar:5.6.4]
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:195) [elasticsearch-5.6.4.jar:5.6.4]
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) [elasticsearch-5.6.4.jar:5.6.4]
    at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) [elasticsearch-5.6.4.jar:5.6.4]
    at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) [elasticsearch-5.6.4.jar:5.6.4]
    at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:70) [elasticsearch-5.6.4.jar:5.6.4]
    at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) [elasticsearch-5.6.4.jar:5.6.4]
    at org.elasticsearch.cli.Command.main(Command.java:90) [elasticsearch-5.6.4.jar:5.6.4]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) [elasticsearch-5.6.4.jar:5.6.4]
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) [elasticsearch-5.6.4.jar:5.6.4]
[2017-11-14T08:03:35,714][INFO ][o.e.n.Node               ] [] initializing ...
[2017-11-14T08:03:36,114][INFO ][o.e.e.NodeEnvironment    ] [H9z2zQY] using [1] data paths, mounts [[/ (/dev/mapper/VolGroup-lv_root)]], net usable_space [40.8gb], net total_space [44.7gb], spins? [possibly], types [ext4]
[2017-11-14T08:03:36,114][INFO ][o.e.e.NodeEnvironment    ] [H9z2zQY] heap size [1.9gb], compressed ordinary object pointers [true]
[2017-11-14T08:03:36,116][INFO ][o.e.n.Node               ] node name [H9z2zQY] derived from node ID [H9z2zQYvSSy6HdF8qFZGHw]; set [node.name] to override
[2017-11-14T08:03:36,116][INFO ][o.e.n.Node               ] version[5.6.4], pid[1383], build[8bbedf5/2017-10-31T18:55:38.105Z], OS[Linux/2.6.32-696.13.2.el6.x86_64/amd64], JVM[Oracle Corporation/OpenJDK 64-Bit Server VM/1.8.0_151/25.151-b12]
[2017-11-14T08:03:36,117][INFO ][o.e.n.Node               ] JVM arguments [-Xms2g, -Xmx2g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -Djdk.io.permissionsUseCanonicalPath=true, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Dlog4j.skipJansi=true, -XX:+HeapDumpOnOutOfMemoryError, -Des.path.home=/usr/share/elasticsearch]
[2017-11-14T08:03:39,124][INFO ][o.e.p.PluginsService     ] [H9z2zQY] loaded module [aggs-matrix-stats]
[2017-11-14T08:03:39,124][INFO ][o.e.p.PluginsService     ] [H9z2zQY] loaded module [ingest-common]
[2017-11-14T08:03:39,124][INFO ][o.e.p.PluginsService     ] [H9z2zQY] loaded module [lang-expression]
[2017-11-14T08:03:39,124][INFO ][o.e.p.PluginsService     ] [H9z2zQY] loaded module [lang-groovy]
[2017-11-14T08:03:39,124][INFO ][o.e.p.PluginsService     ] [H9z2zQY] loaded module [lang-mustache]
[2017-11-14T08:03:39,124][INFO ][o.e.p.PluginsService     ] [H9z2zQY] loaded module [lang-painless]
[2017-11-14T08:03:39,125][INFO ][o.e.p.PluginsService     ] [H9z2zQY] loaded module [parent-join]
[2017-11-14T08:03:39,125][INFO ][o.e.p.PluginsService     ] [H9z2zQY] loaded module [percolator]
[2017-11-14T08:03:39,126][INFO ][o.e.p.PluginsService     ] [H9z2zQY] loaded module [reindex]
[2017-11-14T08:03:39,126][INFO ][o.e.p.PluginsService     ] [H9z2zQY] loaded module [transport-netty3]
[2017-11-14T08:03:39,126][INFO ][o.e.p.PluginsService     ] [H9z2zQY] loaded module [transport-netty4]
[2017-11-14T08:03:39,127][INFO ][o.e.p.PluginsService     ] [H9z2zQY] no plugins loaded
[2017-11-14T08:03:42,954][INFO ][o.e.d.DiscoveryModule    ] [H9z2zQY] using discovery type [zen]
[2017-11-14T08:03:43,865][INFO ][o.e.n.Node               ] initialized
[2017-11-14T08:03:43,865][INFO ][o.e.n.Node               ] [H9z2zQY] starting ...
[2017-11-14T08:03:44,247][INFO ][o.e.t.TransportService   ] [H9z2zQY] publish_address {10.60.251.19:9300}, bound_addresses {[::]:9300}
[2017-11-14T08:03:44,267][INFO ][o.e.b.BootstrapChecks    ] [H9z2zQY] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
[2017-11-14T08:03:44,274][ERROR][o.e.b.Bootstrap          ] [H9z2zQY] node validation exception
[2] bootstrap checks failed
[1]: max number of threads [1024] for user [elasticsearch] is too low, increase to at least [2048]
[2]: system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
[2017-11-14T08:03:44,289][INFO ][o.e.n.Node               ] [H9z2zQY] stopping ...
[2017-11-14T08:03:44,339][INFO ][o.e.n.Node               ] [H9z2zQY] stopped
[2017-11-14T08:03:44,339][INFO ][o.e.n.Node               ] [H9z2zQY] closing ...
[2017-11-14T08:03:44,361][INFO ][o.e.n.Node               ] [H9z2zQY] closed

いろいろ調べてみると、「Your kernel does not support seccomp」とのことで、CentOS6では動かないようです。CentOS7にインストールしましょう。

4.参考

www.elastic.co

SecComp fails on CentOS 6 · Issue #22899 · elastic/elasticsearch · GitHubgithub.com