本文介绍在 CentOS 7.x 操作系统上安装 Elasticsearch 6.x 的方法与过程。
版本说明
- CentOS 7.6
- Oracle JDK 1.8.0_231
- Elasticsearch 6.8.5
安装步驟
下载 Elasticsearch,本示例使用 6.8.5 版本,下载文件是
elasticsearch-6.8.5.tar.gz
。执行解压命令
tar -xvf elasticsearch-6.8.5.tar.gz
。因安全问题,Elasticsearch 默认不允许 root 用户直接运行,输入命令
./elasticsearch-6.8.5/bin/elasticsearch
运行会出现以下错误提示信息。
[root@... elasticsearch]# ./elasticsearch-6.8.5/bin/elasticsearch
[2019-11-23T14:52:18,067][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [unknown] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:163) ~[elasticsearch-6.8.5.jar:6.8.5]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:150) ~[elasticsearch-6.8.5.jar:6.8.5]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.8.5.jar:6.8.5]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.8.5.jar:6.8.5]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.8.5.jar:6.8.5]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:116) ~[elasticsearch-6.8.5.jar:6.8.5]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.8.5.jar:6.8.5]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:103) ~[elasticsearch-6.8.5.jar:6.8.5]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:170) ~[elasticsearch-6.8.5.jar:6.8.5]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:333) ~[elasticsearch-6.8.5.jar:6.8.5]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:159) ~[elasticsearch-6.8.5.jar:6.8.5]
... 6 more
- 创建一个新用户(或使用已有的用户)用于运行 Elasticsearch。
[root@... elasticsearch]# adduser esadmin
[root@... elasticsearch]# passwd esadmin
Changing password for user esadmin.
New password:
...
passwd: all authentication tokens updated successfully.
- 执行
su
命令切换到新用户,再次执行启动命令./elasticsearch-6.8.5/bin/elasticsearch
,报错java.nio.file.AccessDeniedException
。
[root@... elasticsearch]# su esadmin
[esadmin@... elasticsearch]$ ./elasticsearch-6.8.5/bin/elasticsearch
Exception in thread "main" java.nio.file.AccessDeniedException: /opt/elasticsearch/elasticsearch-6.8.5/config/jvm.options
at sun.nio.fs.UnixException.translateToIOException(UnixException.java:84)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
at java.nio.file.Files.newByteChannel(Files.java:361)
at java.nio.file.Files.newByteChannel(Files.java:407)
at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)
at java.nio.file.Files.newInputStream(Files.java:152)
at org.elasticsearch.tools.launchers.JvmOptionsParser.main(JvmOptionsParser.java:60)
分析结论:新用户文件权限不足,因此被拒绝执行。
解决方案:切换回 root
用户,为运行 Elasticsearch 的用户添加文件权限。
[esadmin@... elasticsearch]$ su root
Password:
[root@... elasticsearch]# chown -R esadmin:esadmin elasticsearch-6.8.5
- 再次切换回运行 Elasticsearch 的用户,再次执行启动命令
./elasticsearch-6.8.5/bin/elasticsearch
。
[root@... elasticsearch]# su esadmin
[esadmin@... elasticsearch]$ ./elasticsearch-6.8.5/bin/elasticsearch
[2019-11-23T15:00:20,901][INFO ][o.e.e.NodeEnvironment ] [YU9JZJG] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [23.6gb], net total_space [35.3gb], types [rootfs]
[2019-11-23T15:00:20,905][INFO ][o.e.e.NodeEnvironment ] [YU9JZJG] heap size [990.7mb], compressed ordinary object pointers [true]
[2019-11-23T15:00:20,906][INFO ][o.e.n.Node ] [YU9JZJG] node name derived from node ID [YU9JZJGeTGK9-2BjmCh1vA]; set [node.name] to override
[2019-11-23T15:00:20,907][INFO ][o.e.n.Node ] [YU9JZJG] version[6.8.5], pid[105580], build[default/tar/78990e9/2019-11-13T20:04:24.100411Z], OS[Linux/3.10.0-957.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_231/25.231-b11]
[2019-11-23T15:00:20,907][INFO ][o.e.n.Node ] [YU9JZJG] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -Des.networkaddress.cache.ttl=60, -Des.networkaddress.cache.negative.ttl=10, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.io.tmpdir=/tmp/elasticsearch-5216277211781766988, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSize=64m, -Des.path.home=/opt/elasticsearch/elasticsearch-6.8.5, -Des.path.conf=/opt/elasticsearch/elasticsearch-6.8.5/config, -Des.distribution.flavor=default, -Des.distribution.type=tar]
[2019-11-23T15:00:22,868][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [aggs-matrix-stats]
[2019-11-23T15:00:22,868][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [analysis-common]
[2019-11-23T15:00:22,868][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [ingest-common]
[2019-11-23T15:00:22,868][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [ingest-geoip]
[2019-11-23T15:00:22,869][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [ingest-user-agent]
[2019-11-23T15:00:22,869][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [lang-expression]
[2019-11-23T15:00:22,869][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [lang-mustache]
[2019-11-23T15:00:22,869][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [lang-painless]
[2019-11-23T15:00:22,869][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [mapper-extras]
[2019-11-23T15:00:22,869][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [parent-join]
[2019-11-23T15:00:22,869][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [percolator]
[2019-11-23T15:00:22,870][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [rank-eval]
[2019-11-23T15:00:22,870][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [reindex]
[2019-11-23T15:00:22,870][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [repository-url]
[2019-11-23T15:00:22,870][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [transport-netty4]
[2019-11-23T15:00:22,870][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [tribe]
[2019-11-23T15:00:22,870][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-ccr]
[2019-11-23T15:00:22,870][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-core]
[2019-11-23T15:00:22,870][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-deprecation]
[2019-11-23T15:00:22,870][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-graph]
[2019-11-23T15:00:22,871][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-ilm]
[2019-11-23T15:00:22,871][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-logstash]
[2019-11-23T15:00:22,871][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-ml]
[2019-11-23T15:00:22,871][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-monitoring]
[2019-11-23T15:00:22,871][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-rollup]
[2019-11-23T15:00:22,871][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-security]
[2019-11-23T15:00:22,871][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-sql]
[2019-11-23T15:00:22,872][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-upgrade]
[2019-11-23T15:00:22,872][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-watcher]
[2019-11-23T15:00:22,872][INFO ][o.e.p.PluginsService ] [YU9JZJG] no plugins loaded
[2019-11-23T15:00:27,374][INFO ][o.e.x.s.a.s.FileRolesStore] [YU9JZJG] parsed [0] roles from file [/opt/elasticsearch/elasticsearch-6.8.5/config/roles.yml]
[2019-11-23T15:00:28,030][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [YU9JZJG] [controller/105654] [Main.cc@109] controller (64 bit): Version 6.8.5 (Build b07c2d9433ee6d) Copyright (c) 2019 Elasticsearch BV
[2019-11-23T15:00:28,594][DEBUG][o.e.a.ActionModule ] [YU9JZJG] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security
[2019-11-23T15:00:28,846][INFO ][o.e.d.DiscoveryModule ] [YU9JZJG] using discovery type [zen] and host providers [settings]
[2019-11-23T15:00:29,809][INFO ][o.e.n.Node ] [YU9JZJG] initialized
[2019-11-23T15:00:29,809][INFO ][o.e.n.Node ] [YU9JZJG] starting ...
[2019-11-23T15:00:29,978][INFO ][o.e.t.TransportService ] [YU9JZJG] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2019-11-23T15:00:30,000][WARN ][o.e.b.BootstrapChecks ] [YU9JZJG] max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2019-11-23T15:00:30,000][WARN ][o.e.b.BootstrapChecks ] [YU9JZJG] max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2019-11-23T15:00:33,065][INFO ][o.e.c.s.MasterService ] [YU9JZJG] zen-disco-elected-as-master ([0] nodes joined), reason: new_master {YU9JZJG}{YU9JZJGeTGK9-2BjmCh1vA}{9E5nEIFgTdeVwtIlESc7cw}{127.0.0.1}{127.0.0.1:9300}{ml.machine_memory=16629518336, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true}
[2019-11-23T15:00:33,072][INFO ][o.e.c.s.ClusterApplierService] [YU9JZJG] new_master {YU9JZJG}{YU9JZJGeTGK9-2BjmCh1vA}{9E5nEIFgTdeVwtIlESc7cw}{127.0.0.1}{127.0.0.1:9300}{ml.machine_memory=16629518336, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true}, reason: apply cluster state (from master [master {YU9JZJG}{YU9JZJGeTGK9-2BjmCh1vA}{9E5nEIFgTdeVwtIlESc7cw}{127.0.0.1}{127.0.0.1:9300}{ml.machine_memory=16629518336, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)]])
[2019-11-23T15:00:33,133][INFO ][o.e.h.n.Netty4HttpServerTransport] [YU9JZJG] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2019-11-23T15:00:33,134][INFO ][o.e.n.Node ] [YU9JZJG] started
[2019-11-23T15:00:33,142][WARN ][o.e.x.s.a.s.m.NativeRoleMappingStore] [YU9JZJG] Failed to clear cache for realms [[]]
[2019-11-23T15:00:33,184][INFO ][o.e.g.GatewayService ] [YU9JZJG] recovered [0] indices into cluster_state
[2019-11-23T15:00:33,327][INFO ][o.e.c.m.MetaDataIndexTemplateService] [YU9JZJG] adding template [.triggered_watches] for index patterns [.triggered_watches*]
[2019-11-23T15:00:33,381][INFO ][o.e.c.m.MetaDataIndexTemplateService] [YU9JZJG] adding template [.watches] for index patterns [.watches*]
[2019-11-23T15:00:33,430][INFO ][o.e.c.m.MetaDataIndexTemplateService] [YU9JZJG] adding template [.watch-history-9] for index patterns [.watcher-history-9*]
[2019-11-23T15:00:33,464][INFO ][o.e.c.m.MetaDataIndexTemplateService] [YU9JZJG] adding template [.monitoring-logstash] for index patterns [.monitoring-logstash-6-*]
[2019-11-23T15:00:33,510][INFO ][o.e.c.m.MetaDataIndexTemplateService] [YU9JZJG] adding template [.monitoring-es] for index patterns [.monitoring-es-6-*]
[2019-11-23T15:00:33,547][INFO ][o.e.c.m.MetaDataIndexTemplateService] [YU9JZJG] adding template [.monitoring-beats] for index patterns [.monitoring-beats-6-*]
[2019-11-23T15:00:33,575][INFO ][o.e.c.m.MetaDataIndexTemplateService] [YU9JZJG] adding template [.monitoring-alerts] for index patterns [.monitoring-alerts-6]
[2019-11-23T15:00:33,605][INFO ][o.e.c.m.MetaDataIndexTemplateService] [YU9JZJG] adding template [.monitoring-kibana] for index patterns [.monitoring-kibana-6-*]
[2019-11-23T15:00:33,723][INFO ][o.e.l.LicenseService ] [YU9JZJG] license [5d070014-89af-4ac5-a291-3f424528d81c] mode [basic] - valid
问题及解决方案
- 启动日志中包含以下警告信息:
[2019-11-23T15:00:30,000][WARN ][o.e.b.BootstrapChecks ] [YU9JZJG] max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
解决方案:切换至 root 用户编辑 /etc/security/limits.conf
文件,在文件末尾添加以下内容
* soft nofile 65536
* hard nofile 65536
保存修改后重新登录,输入 ulimit
命令查看是否修改成功。
[esadmin@... root]$ ulimit -Hn
65536
- 启动日志中包含以下警告信息:
[2019-11-23T15:00:30,000][WARN ][o.e.b.BootstrapChecks ] [YU9JZJG] max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方案:切换至 root 用户编辑 /etc/sysctl.conf
文件,在文件末尾添加以下内容
vm.max_map_count=262144
输入命令 sysctl -p
查看修改结果。
[root@... ~]# sysctl -p
net.ipv4.conf.all.arp_notify = 1
net.ipv4.conf.default.arp_notify = 1
net.ipv4.conf.eth0.arp_notify = 1
net.ipv4.conf.lo.arp_notify = 1
net.ipv4.conf.virbr0.arp_notify = 1
net.ipv4.conf.virbr0-nic.arp_notify = 1
vm.max_map_count = 262144
- 启动日志中包含以下警告信息:
[2019-11-23T15:00:33,142][WARN ][o.e.x.s.a.s.m.NativeRoleMappingStore] [YU9JZJG] Failed to clear cache for realms [[]]
分析结论:
解决方案:
- 注意启动日志中以下信息:
[2019-11-23T15:00:33,133][INFO ][o.e.h.n.Netty4HttpServerTransport] [YU9JZJG] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
Elasticsearch 默认只开启本机访问,如需远程访问需要先将 Elasticsearch 服务停掉,修改配置文件后再次启动。
(1) 修改 config/elasticsearch.yml
文件
[esadmin@... elasticsearch]$ vim elasticsearch-6.8.5/config/elasticsearch.yml
(2) 找到 #network.host: 192.168.0.1
,将注释 #
去掉后修改为 network.host: 0.0.0.0
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
(3) 保存后再次启动 Elasticsearch 服务(启动前需要确定问题 1 和 2 已解决),启动日志如下。
[esadmin@... elasticsearch]$ ./elasticsearch-6.8.5/bin/elasticsearch
[2019-11-23T15:36:51,474][INFO ][o.e.e.NodeEnvironment ] [YU9JZJG] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [23.6gb], net total_space [35.3gb], types [rootfs]
[2019-11-23T15:36:51,478][INFO ][o.e.e.NodeEnvironment ] [YU9JZJG] heap size [990.7mb], compressed ordinary object pointers [true]
[2019-11-23T15:36:51,480][INFO ][o.e.n.Node ] [YU9JZJG] node name derived from node ID [YU9JZJGeTGK9-2BjmCh1vA]; set [node.name] to override
[2019-11-23T15:36:51,481][INFO ][o.e.n.Node ] [YU9JZJG] version[6.8.5], pid[112525], build[default/tar/78990e9/2019-11-13T20:04:24.100411Z], OS[Linux/3.10.0-957.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_231/25.231-b11]
[2019-11-23T15:36:51,481][INFO ][o.e.n.Node ] [YU9JZJG] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -Des.networkaddress.cache.ttl=60, -Des.networkaddress.cache.negative.ttl=10, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.io.tmpdir=/tmp/elasticsearch-7459616390311542312, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSize=64m, -Des.path.home=/opt/elasticsearch/elasticsearch-6.8.5, -Des.path.conf=/opt/elasticsearch/elasticsearch-6.8.5/config, -Des.distribution.flavor=default, -Des.distribution.type=tar]
[2019-11-23T15:36:53,463][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [aggs-matrix-stats]
[2019-11-23T15:36:53,463][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [analysis-common]
[2019-11-23T15:36:53,463][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [ingest-common]
[2019-11-23T15:36:53,463][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [ingest-geoip]
[2019-11-23T15:36:53,464][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [ingest-user-agent]
[2019-11-23T15:36:53,464][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [lang-expression]
[2019-11-23T15:36:53,464][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [lang-mustache]
[2019-11-23T15:36:53,464][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [lang-painless]
[2019-11-23T15:36:53,464][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [mapper-extras]
[2019-11-23T15:36:53,464][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [parent-join]
[2019-11-23T15:36:53,464][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [percolator]
[2019-11-23T15:36:53,464][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [rank-eval]
[2019-11-23T15:36:53,464][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [reindex]
[2019-11-23T15:36:53,465][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [repository-url]
[2019-11-23T15:36:53,465][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [transport-netty4]
[2019-11-23T15:36:53,465][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [tribe]
[2019-11-23T15:36:53,465][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-ccr]
[2019-11-23T15:36:53,465][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-core]
[2019-11-23T15:36:53,466][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-deprecation]
[2019-11-23T15:36:53,466][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-graph]
[2019-11-23T15:36:53,466][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-ilm]
[2019-11-23T15:36:53,466][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-logstash]
[2019-11-23T15:36:53,466][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-ml]
[2019-11-23T15:36:53,466][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-monitoring]
[2019-11-23T15:36:53,466][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-rollup]
[2019-11-23T15:36:53,466][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-security]
[2019-11-23T15:36:53,467][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-sql]
[2019-11-23T15:36:53,467][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-upgrade]
[2019-11-23T15:36:53,467][INFO ][o.e.p.PluginsService ] [YU9JZJG] loaded module [x-pack-watcher]
[2019-11-23T15:36:53,467][INFO ][o.e.p.PluginsService ] [YU9JZJG] no plugins loaded
[2019-11-23T15:36:57,920][INFO ][o.e.x.s.a.s.FileRolesStore] [YU9JZJG] parsed [0] roles from file [/opt/elasticsearch/elasticsearch-6.8.5/config/roles.yml]
[2019-11-23T15:36:58,687][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [YU9JZJG] [controller/112599] [Main.cc@109] controller (64 bit): Version 6.8.5 (Build b07c2d9433ee6d) Copyright (c) 2019 Elasticsearch BV
[2019-11-23T15:36:59,273][DEBUG][o.e.a.ActionModule ] [YU9JZJG] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security
[2019-11-23T15:36:59,531][INFO ][o.e.d.DiscoveryModule ] [YU9JZJG] using discovery type [zen] and host providers [settings]
[2019-11-23T15:37:00,513][INFO ][o.e.n.Node ] [YU9JZJG] initialized
[2019-11-23T15:37:00,513][INFO ][o.e.n.Node ] [YU9JZJG] starting ...
[2019-11-23T15:37:00,676][INFO ][o.e.t.TransportService ] [YU9JZJG] publish_address {10.169.180.186:9300}, bound_addresses {[::]:9300}
[2019-11-23T15:37:00,697][INFO ][o.e.b.BootstrapChecks ] [YU9JZJG] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2019-11-23T15:37:03,799][INFO ][o.e.c.s.MasterService ] [YU9JZJG] zen-disco-elected-as-master ([0] nodes joined), reason: new_master {YU9JZJG}{YU9JZJGeTGK9-2BjmCh1vA}{ffdtb6A_QbmQi9nr_SNOVg}{10.169.180.186}{10.169.180.186:9300}{ml.machine_memory=16629518336, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true}
[2019-11-23T15:37:03,805][INFO ][o.e.c.s.ClusterApplierService] [YU9JZJG] new_master {YU9JZJG}{YU9JZJGeTGK9-2BjmCh1vA}{ffdtb6A_QbmQi9nr_SNOVg}{10.169.180.186}{10.169.180.186:9300}{ml.machine_memory=16629518336, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true}, reason: apply cluster state (from master [master {YU9JZJG}{YU9JZJGeTGK9-2BjmCh1vA}{ffdtb6A_QbmQi9nr_SNOVg}{10.169.180.186}{10.169.180.186:9300}{ml.machine_memory=16629518336, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)]])
[2019-11-23T15:37:03,846][INFO ][o.e.h.n.Netty4HttpServerTransport] [YU9JZJG] publish_address {10.169.180.186:9200}, bound_addresses {[::]:9200}
[2019-11-23T15:37:03,846][INFO ][o.e.n.Node ] [YU9JZJG] started
[2019-11-23T15:37:04,072][WARN ][o.e.x.s.a.s.m.NativeRoleMappingStore] [YU9JZJG] Failed to clear cache for realms [[]]
[2019-11-23T15:37:04,120][INFO ][o.e.l.LicenseService ] [YU9JZJG] license [5d070014-89af-4ac5-a291-3f424528d81c] mode [basic] - valid
[2019-11-23T15:37:04,128][INFO ][o.e.g.GatewayService ] [YU9JZJG] recovered [0] indices into cluster_state
(4) 找一台远程计算机打开浏览器输入 [Elasticsearch 服务IP]:9200
可以看到以下信息。
{
"name": "YU9JZJG",
"cluster_name": "elasticsearch",
"cluster_uuid": "Zr5chPLrQBSWYm-JNMls1A",
"version": {
"number": "6.8.5",
"build_flavor": "default",
"build_type": "tar",
"build_hash": "78990e9",
"build_date": "2019-11-13T20:04:24.100411Z",
"build_snapshot": false,
"lucene_version": "7.7.2",
"minimum_wire_compatibility_version": "5.6.0",
"minimum_index_compatibility_version": "5.0.0"
},
"tagline": "You Know, for Search"
}
后台运行
[esadmin@... elasticsearch]$ ./elasticsearch-6.8.5/bin/elasticsearch -d -p pid
停止运行
- 输入命令
ps -ef | grep elasticsearch
查找 Elasticsearch 服务进程号。
[esadmin@... elasticsearch]$ ps -ef | grep elasticsearch
esadmin 113323 1 99 15:40 pts/3 00:00:30 /opt/jdk/jdk1.8.0_231//bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.io.tmpdir=/tmp/elasticsearch-3360114640606824384 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=data -XX:ErrorFile=logs/hs_err_pid%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:logs/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=32 -XX:GCLogFileSize=64m -Des.path.home=/opt/elasticsearch/elasticsearch-6.8.5 -Des.path.conf=/opt/elasticsearch/elasticsearch-6.8.5/config -Des.distribution.flavor=default -Des.distribution.type=tar -cp /opt/elasticsearch/elasticsearch-6.8.5/lib/* org.elasticsearch.bootstrap.Elasticsearch -d -p pid
esadmin 113352 113323 0 15:40 pts/3 00:00:00 /opt/elasticsearch/elasticsearch-6.8.5/modules/x-pack-ml/platform/linux-x86_64/bin/controller
esadmin 113474 112467 0 15:40 pts/3 00:00:00 grep --color=auto elasticsearch
- 输入命令
kill -9 进程号
关闭 Elasticsearch 服务,然后再次输入命令ps -ef | grep elasticsearch
确认 Elasticsearch 服务已被关闭。
[esadmin@... elasticsearch]$ kill -9 113323
[esadmin@... elasticsearch]$ ps -ef | grep elasticsearch
esadmin 113555 112467 0 15:41 pts/3 00:00:00 grep --color=auto elasticsearch
附
Elasticsearch Reference