ElasticSearch的完整安装教程

ElasticSearch安装

下载ElasticSearch

官网地址:

https://www.elastic.co/products/elasticsearch

本地下载:https://www.jb51.net/codes/579429.html

上传到ElasticSearch

可以使用第三方工具filezilla

解压elasticsearch-6.4.0.tar.gztar -zxvf elasticsearch-6.4.0.tar.gz

[root@localhost elasticsearch]# tar -zxvf elasticsearch-6.4.0.tar.gz
elasticsearch-6.4.0/
...

进入elasticsearch目录查看文件夹内容 cd elasticsearch-6.4.0

[root@localhost elasticsearch]# cd elasticsearch-6.4.0
[root@localhost elasticsearch-6.4.0]# ll
总用量 436
drwxr-xr-x. 3 root root 4096 8月 29 17:52 bin
drwxr-xr-x. 2 root root 148 8月 18 07:23 config
drwxr-xr-x. 3 root root 4096 8月 18 07:23 lib
-rw-r--r--. 1 root root 13675 8月 18 07:11 LICENSE.txt
drwxr-xr-x. 2 root root  6 8月 18 07:22 logs
drwxr-xr-x. 27 root root 4096 8月 18 07:23 modules
-rw-r--r--. 1 root root 401465 8月 18 07:22 NOTICE.txt
drwxr-xr-x. 2 root root  6 8月 18 07:22 plugins
-rw-r--r--. 1 root root 8511 8月 18 07:11 README.textile
[root@localhost elasticsearch-6.4.0]# 

运行bin下面的ealashicsearch./bin/elasticsearch

root@localhost elasticsearch-6.4.0]# ./bin/elasticsearch
[2018-08-29T18:07:52,437][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] 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:140) ~[elasticsearch-6.4.0.jar:6.4.0]
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) ~[elasticsearch-6.4.0.jar:6.4.0]
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.4.0.jar:6.4.0]
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.4.0.jar:6.4.0]
	at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.4.0.jar:6.4.0]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.4.0.jar:6.4.0]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) ~[elasticsearch-6.4.0.jar:6.4.0]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
	at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:104) ~[elasticsearch-6.4.0.jar:6.4.0]
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:171) ~[elasticsearch-6.4.0.jar:6.4.0]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:326) ~[elasticsearch-6.4.0.jar:6.4.0]
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-6.4.0.jar:6.4.0]
	... 6 more
[root@localhost elasticsearch-6.4.0]# 

出错是因为不能以root用户的方式启动,必须新建一个用户和组

1、创建创建es组

[root@localhost elasticsearch-6.4.0]# groupadd eszu

2、创建es用户

[root@localhost elasticsearch-6.4.0]# useradd esyonghu

3、指定用户密码

[root@localhost elasticsearch-6.4.0]# passwd esyonghu
更改用户 esyonghu 的密码 。
新的 密码:
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@localhost elasticsearch-6.4.0]# 

4、修改文件所属用户

[root@localhost elasticsearch]# chown -R esyonghu elasticsearch-6.4.0

5、修改文件所属组

[root@localhost elasticsearch]# chgrp -R eszu elasticsearch-6.4.0

切换用户到esyonghusu esyonghu, 启动elasticserach./bin/elasticsearch

[root@localhost elasticsearch-6.4.0]# su esyonghu
[esyonghu@localhost elasticsearch-6.4.0]$ ./bin/elasticsearch
[2018-08-30T10:20:25,387][INFO ][o.e.n.Node    ] [] initializing ...
[2018-08-30T10:20:25,919][INFO ][o.e.e.NodeEnvironment ] [cRjfMu5] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [14.8gb], net total_space [16.9gb], types [rootfs]
[2018-08-30T10:20:25,920][INFO ][o.e.e.NodeEnvironment ] [cRjfMu5] heap size [1015.6mb], compressed ordinary object pointers [true]
[2018-08-30T10:20:25,925][INFO ][o.e.n.Node    ] [cRjfMu5] node name derived from node ID [cRjfMu5qTwmlfTzHHWSAiQ]; set [node.name] to override
[2018-08-30T10:20:25,926][INFO ][o.e.n.Node    ] [cRjfMu5] version[6.4.0], pid[1331], build[default/tar/595516e/2018-08-17T23:18:47.308994Z], OS[Linux/3.10.0-862.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_181/25.181-b13]
[2018-08-30T10:20:25,943][INFO ][o.e.n.Node    ] [cRjfMu5] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -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.CT7q3O6F, -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=/home/elasticsearch/elasticsearch-6.4.0, -Des.path.conf=/home/elasticsearch/elasticsearch-6.4.0/config, -Des.distribution.flavor=default, -Des.distribution.type=tar]
[2018-08-30T10:20:32,189][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [aggs-matrix-stats]
[2018-08-30T10:20:32,190][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [analysis-common]
[2018-08-30T10:20:32,190][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [ingest-common]
[2018-08-30T10:20:32,190][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [lang-expression]
[2018-08-30T10:20:32,190][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [lang-mustache]
[2018-08-30T10:20:32,190][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [lang-painless]
[2018-08-30T10:20:32,190][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [mapper-extras]
[2018-08-30T10:20:32,190][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [parent-join]
[2018-08-30T10:20:32,191][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [percolator]
[2018-08-30T10:20:32,191][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [rank-eval]
[2018-08-30T10:20:32,191][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [reindex]
[2018-08-30T10:20:32,191][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [repository-url]
[2018-08-30T10:20:32,192][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [transport-netty4]
[2018-08-30T10:20:32,192][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [tribe]
[2018-08-30T10:20:32,192][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-core]
[2018-08-30T10:20:32,192][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-deprecation]
[2018-08-30T10:20:32,192][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-graph]
[2018-08-30T10:20:32,192][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-logstash]
[2018-08-30T10:20:32,193][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-ml]
[2018-08-30T10:20:32,193][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-monitoring]
[2018-08-30T10:20:32,193][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-rollup]
[2018-08-30T10:20:32,193][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-security]
[2018-08-30T10:20:32,193][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-sql]
[2018-08-30T10:20:32,194][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-upgrade]
[2018-08-30T10:20:32,194][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-watcher]
[2018-08-30T10:20:32,194][INFO ][o.e.p.PluginsService  ] [cRjfMu5] no plugins loaded
[2018-08-30T10:20:41,918][INFO ][o.e.x.s.a.s.FileRolesStore] [cRjfMu5] parsed [0] roles from file [/home/elasticsearch/elasticsearch-6.4.0/config/roles.yml]
[2018-08-30T10:20:44,164][INFO ][o.e.x.m.j.p.l.CppLogMessageHandler] [controller/1379] [Main.cc@109] controller (64 bit): Version 6.4.0 (Build cf8246175efff5) Copyright (c) 2018 Elasticsearch BV
[2018-08-30T10:20:45,321][DEBUG][o.e.a.ActionModule  ] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security
[2018-08-30T10:20:45,935][INFO ][o.e.d.DiscoveryModule ] [cRjfMu5] using discovery type [zen]
[2018-08-30T10:20:47,619][INFO ][o.e.n.Node    ] [cRjfMu5] initialized
[2018-08-30T10:20:47,620][INFO ][o.e.n.Node    ] [cRjfMu5] starting ...
[2018-08-30T10:20:48,736][INFO ][o.e.t.TransportService ] [cRjfMu5] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2018-08-30T10:20:48,772][WARN ][o.e.b.BootstrapChecks ] [cRjfMu5] max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2018-08-30T10:20:48,773][WARN ][o.e.b.BootstrapChecks ] [cRjfMu5] max number of threads [3802] for user [esyonghu] is too low, increase to at least [4096]
[2018-08-30T10:20:48,773][WARN ][o.e.b.BootstrapChecks ] [cRjfMu5] max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2018-08-30T10:20:51,982][INFO ][o.e.c.s.MasterService ] [cRjfMu5] zen-disco-elected-as-master ([0] nodes joined)[, ], reason: new_master {cRjfMu5}{cRjfMu5qTwmlfTzHHWSAiQ}{oJoeh0w-RAijeCMwTKLe-w}{127.0.0.1}{127.0.0.1:9300}{ml.machine_memory=1021906944, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true}
[2018-08-30T10:20:51,993][INFO ][o.e.c.s.ClusterApplierService] [cRjfMu5] new_master {cRjfMu5}{cRjfMu5qTwmlfTzHHWSAiQ}{oJoeh0w-RAijeCMwTKLe-w}{127.0.0.1}{127.0.0.1:9300}{ml.machine_memory=1021906944, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true}, reason: apply cluster state (from master [master {cRjfMu5}{cRjfMu5qTwmlfTzHHWSAiQ}{oJoeh0w-RAijeCMwTKLe-w}{127.0.0.1}{127.0.0.1:9300}{ml.machine_memory=1021906944, xpack.installed=true, ml.max_open_jobs=20, ml.enabled=true} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)[, ]]])
[2018-08-30T10:20:52,052][WARN ][o.e.x.s.a.s.m.NativeRoleMappingStore] [cRjfMu5] Failed to clear cache for realms [[]]
[2018-08-30T10:20:52,066][INFO ][o.e.x.s.t.n.SecurityNetty4HttpServerTransport] [cRjfMu5] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2018-08-30T10:20:52,066][INFO ][o.e.n.Node    ] [cRjfMu5] started
[2018-08-30T10:20:52,242][INFO ][o.e.g.GatewayService  ] [cRjfMu5] recovered [0] indices into cluster_state
[2018-08-30T10:20:52,846][INFO ][o.e.c.m.MetaDataIndexTemplateService] [cRjfMu5] adding template [.triggered_watches] for index patterns [.triggered_watches*]
[2018-08-30T10:20:52,902][INFO ][o.e.c.m.MetaDataIndexTemplateService] [cRjfMu5] adding template [.watches] for index patterns [.watches*]
[2018-08-30T10:20:52,967][INFO ][o.e.c.m.MetaDataIndexTemplateService] [cRjfMu5] adding template [.watch-history-9] for index patterns [.watcher-history-9*]
[2018-08-30T10:20:53,016][INFO ][o.e.c.m.MetaDataIndexTemplateService] [cRjfMu5] adding template [.monitoring-logstash] for index patterns [.monitoring-logstash-6-*]
[2018-08-30T10:20:53,106][INFO ][o.e.c.m.MetaDataIndexTemplateService] [cRjfMu5] adding template [.monitoring-es] for index patterns [.monitoring-es-6-*]
[2018-08-30T10:20:53,148][INFO ][o.e.c.m.MetaDataIndexTemplateService] [cRjfMu5] adding template [.monitoring-beats] for index patterns [.monitoring-beats-6-*]
[2018-08-30T10:20:53,196][INFO ][o.e.c.m.MetaDataIndexTemplateService] [cRjfMu5] adding template [.monitoring-alerts] for index patterns [.monitoring-alerts-6]
[2018-08-30T10:20:53,255][INFO ][o.e.c.m.MetaDataIndexTemplateService] [cRjfMu5] adding template [.monitoring-kibana] for index patterns [.monitoring-kibana-6-*]
[2018-08-30T10:20:53,489][INFO ][o.e.l.LicenseService  ] [cRjfMu5] license [29b596fe-89fc-47bb-9ed5-01827361589d] mode [basic] - valid

这时候elasticsearch已经成功启动,我们来测试一下curl localhost:9200,如果得到了这些数据就说明成功了,但是在浏览器里面并不能访问,需要修改配置文件

新打开一个窗口,输入curl localhost:9200

[root@localhost /]# curl localhost:9200
{
 "name" : "cRjfMu5",
 "cluster_name" : "elasticsearch",
 "cluster_uuid" : "UhsXc7AVTaSCjSxLYNrRfw",
 "version" : {
 "number" : "6.4.0",
 "build_flavor" : "default",
 "build_type" : "tar",
 "build_hash" : "595516e",
 "build_date" : "2018-08-17T23:18:47.308994Z",
 "build_snapshot" : false,
 "lucene_version" : "7.4.0",
 "minimum_wire_compatibility_version" : "5.6.0",
 "minimum_index_compatibility_version" : "5.0.0"
 },
 "tagline" : "You Know, for Search"
}

配置elasticsearch端口和ip

进入config文件夹,里面有一个elasticsearch.yml文件,使用vim elasticsearch.yml命令来编辑该文件,添加如下内容

network.host: 192.168.145.129
http.port: 9200

再次启动elasticsearch,会发现已经启动不了了

[esyonghu@localhost elasticsearch-6.4.0]$ ./bin/elasticsearch
[2018-08-30T11:29:22,930][INFO ][o.e.n.Node    ] [] initializing ...
[2018-08-30T11:29:23,380][INFO ][o.e.e.NodeEnvironment ] [cRjfMu5] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [14.8gb], net total_space [16.9gb], types [rootfs]
[2018-08-30T11:29:23,381][INFO ][o.e.e.NodeEnvironment ] [cRjfMu5] heap size [1015.6mb], compressed ordinary object pointers [true]
[2018-08-30T11:29:23,382][INFO ][o.e.n.Node    ] [cRjfMu5] node name derived from node ID [cRjfMu5qTwmlfTzHHWSAiQ]; set [node.name] to override
[2018-08-30T11:29:23,382][INFO ][o.e.n.Node    ] [cRjfMu5] version[6.4.0], pid[1762], build[default/tar/595516e/2018-08-17T23:18:47.308994Z], OS[Linux/3.10.0-862.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_181/25.181-b13]
[2018-08-30T11:29:23,382][INFO ][o.e.n.Node    ] [cRjfMu5] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -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.o8Uhb9Ro, -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=/home/elasticsearch/elasticsearch-6.4.0, -Des.path.conf=/home/elasticsearch/elasticsearch-6.4.0/config, -Des.distribution.flavor=default, -Des.distribution.type=tar]
[2018-08-30T11:29:31,350][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [aggs-matrix-stats]
[2018-08-30T11:29:31,351][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [analysis-common]
[2018-08-30T11:29:31,352][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [ingest-common]
[2018-08-30T11:29:31,352][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [lang-expression]
[2018-08-30T11:29:31,352][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [lang-mustache]
[2018-08-30T11:29:31,353][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [lang-painless]
[2018-08-30T11:29:31,353][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [mapper-extras]
[2018-08-30T11:29:31,354][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [parent-join]
[2018-08-30T11:29:31,354][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [percolator]
[2018-08-30T11:29:31,354][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [rank-eval]
[2018-08-30T11:29:31,355][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [reindex]
[2018-08-30T11:29:31,355][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [repository-url]
[2018-08-30T11:29:31,356][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [transport-netty4]
[2018-08-30T11:29:31,356][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [tribe]
[2018-08-30T11:29:31,356][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-core]
[2018-08-30T11:29:31,357][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-deprecation]
[2018-08-30T11:29:31,357][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-graph]
[2018-08-30T11:29:31,357][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-logstash]
[2018-08-30T11:29:31,358][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-ml]
[2018-08-30T11:29:31,358][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-monitoring]
[2018-08-30T11:29:31,359][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-rollup]
[2018-08-30T11:29:31,359][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-security]
[2018-08-30T11:29:31,359][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-sql]
[2018-08-30T11:29:31,370][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-upgrade]
[2018-08-30T11:29:31,370][INFO ][o.e.p.PluginsService  ] [cRjfMu5] loaded module [x-pack-watcher]
[2018-08-30T11:29:31,372][INFO ][o.e.p.PluginsService  ] [cRjfMu5] no plugins loaded
[2018-08-30T11:29:43,859][INFO ][o.e.x.s.a.s.FileRolesStore] [cRjfMu5] parsed [0] roles from file [/home/elasticsearch/elasticsearch-6.4.0/config/roles.yml]
[2018-08-30T11:29:45,757][INFO ][o.e.x.m.j.p.l.CppLogMessageHandler] [controller/1810] [Main.cc@109] controller (64 bit): Version 6.4.0 (Build cf8246175efff5) Copyright (c) 2018 Elasticsearch BV
[2018-08-30T11:29:47,089][DEBUG][o.e.a.ActionModule  ] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security
[2018-08-30T11:29:47,915][INFO ][o.e.d.DiscoveryModule ] [cRjfMu5] using discovery type [zen]
[2018-08-30T11:29:50,345][INFO ][o.e.n.Node    ] [cRjfMu5] initialized
[2018-08-30T11:29:50,345][INFO ][o.e.n.Node    ] [cRjfMu5] starting ...
[2018-08-30T11:29:51,185][INFO ][o.e.t.TransportService ] [cRjfMu5] publish_address {192.168.145.129:9300}, bound_addresses {192.168.145.129:9300}
[2018-08-30T11:29:51,351][INFO ][o.e.b.BootstrapChecks ] [cRjfMu5] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max number of threads [3802] for user [esyonghu] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2018-08-30T11:29:51,486][INFO ][o.e.n.Node    ] [cRjfMu5] stopping ...
[2018-08-30T11:29:51,570][INFO ][o.e.n.Node    ] [cRjfMu5] stopped
[2018-08-30T11:29:51,571][INFO ][o.e.n.Node    ] [cRjfMu5] closing ...
[2018-08-30T11:29:51,633][INFO ][o.e.n.Node    ] [cRjfMu5] closed
[2018-08-30T11:29:51,634][INFO ][o.e.x.m.j.p.NativeController] Native controller process has stopped - no new native processes can be started
[esyonghu@localhost elasticsearch-6.4.0]$ 

修改错误,可以看到控制台打印的信息里面有3个错误

[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max number of threads [3802] for user [esyonghu] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

第一个错误需要将当前用户的软硬调用限制调大

[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

切换到root用户,然后执行vim /etc/security/limits.conf

[root@localhost elasticsearch-6.4.0]# vim /etc/security/limits.conf

在文件末尾加上

esyonghu soft nofile 65536
esyonghu hard nofile 131072
esyonghu soft nproc 2048
esyonghu hard nproc 4096

第二个错误需要修改/etc/security/limits.d/20-nproc.conf 文件

[2]: max number of threads [3802] for user [esyonghu] is too low, increase to at least [4096]

修改/etc/security/limits.d/20-nproc.conf 文件,这里需要注意一下,可能不叫20-nproc.conf 也可能是90-nproc.conf

vim /etc/security/limits.d/20-nproc.conf

在文件中添加

esyonghu soft nproc  4096

第三个错误需要修改/etc/sysctl.conf

[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

使用命令 vim /etc/sysctl.conf来编辑该文件,在文件中加入如下内容

加上vm.max_map_count=262144

需要使改文件生效,执行sysctl -p

[root@localhost etc]# sysctl -p
vm.max_map_count = 262144

再次切换到esyonghu去elasticsearch文件目录启动elasticsearch

[root@localhost elasticsearch-6.4.0]# su esyonghu
[esyonghu@localhost elasticsearch-6.4.0]$
[esyonghu@localhost elasticsearch-6.4.0]$ cd /home/elasticsearch/elasticsearch-6.4.0
[esyonghu@localhost elasticsearch-6.4.0]$ ./bin/elasticsearch
现在启动成功了,使用浏览器访问试一下

关闭防火墙

再次访问的时候发现还是不行,这时候需要关闭防火墙
检查防火墙状态
先切换到root用户
[esyonghu@localhost elasticsearch-6.4.0]$ su root
密码:
[root@localhost elasticsearch-6.4.0]# 

查看防火墙状态
[root@localhost elasticsearch-6.4.0]# firewall-cmd --state
running
[root@localhost elasticsearch-6.4.0]# 

状态是running,需要关闭防火墙
执行systemctl stop firewalld.service
[root@localhost elasticsearch-6.4.0]# systemctl stop firewalld.service

再次检查防火墙状态,就是为运行了
[root@localhost elasticsearch-6.4.0]# firewall-cmd --state
not running
[root@localhost elasticsearch-6.4.0]# 

切换到esyonghu再次启动

[root@localhost elasticsearch-6.4.0]# su esyonghu
[esyonghu@localhost elasticsearch-6.4.0]$
[esyonghu@localhost elasticsearch-6.4.0]$ ./bin/elasticsearch
[2018-08-30T12:09:59,267][INFO ][o.e.n.Node        ] [] initializing ...
启动成功,使用浏览器访问就可以了

以后台方式启动elasticsearch

./bin/elasticsearch -d

[esyonghu@localhost elasticsearch-6.4.0]$ ./bin/elasticsearch -d
[esyonghu@localhost elasticsearch-6.4.0]$
 

结束elastsearch

输入jps命令
杀死elasticsearch进程

如果绑定本地ip失败,那么在elasticsearch.yml里面加上

bootstrap.memory_lock: false
bootstrap.system_call_filter: false

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对我们的支持。

(0)

相关推荐

  • JAVA使用ElasticSearch查询in和not in的实现方式

    ElasticSearch Elasticsearch是一个基于Lucene的搜索服务器.它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口.Elasticsearch是用Java开发的,并作为Apache许可条款下的开放源码发布,是当前流行的企业级搜索引擎.设计用于云计算中,能够达到实时搜索,稳定,可靠,快速,安装使用方便. 最近用到ES查询,因用的是Java写的,需要实现一个需求:过滤一部分id,查询时不需要查出来. 既然需要不包含,那么首先需要实现包含的方式(精确完

  • elasticsearch head的安装及使用过程解析

    ealsticsearch只是后端提供各种api,那么怎么直观的使用它呢?elasticsearch-head将是一款专门针对于elasticsearch的客户端工具 elasticsearch-head配置包,下载地址:https://github.com/mobz/elasticsearch-head elasticsearch-head是一个基于node.js的前端工程,启动elasticsearch-head的步骤如下(这里针对的是elasticsearch 5.x以上的版本): 1.进

  • 详解spring-boot集成elasticsearch及其简单应用

    介绍 记录将elasticsearch集成到spring boot的过程,以及一些简单的应用和helper类使用. 接入方式 使用spring-boot中的spring-data-elasticsearch,可以使用两种内置客户端接入 1.节点客户端(node client): 配置文件中设置为local:false,节点客户端以无数据节点(node-master或node-client)身份加入集群,换言之,它自己不存储任何数据,但是它知道数据在集群中的具体位置,并且能够直接转发请求到对应的节

  • Elasticsearch QueryBuilder简单查询实现解析

    elasticsearch中存储的全部文档 1.matchAllQuery() matchAllQuery()方法用来匹配全部文档 public class QueryTest { public static void main(String[] args) { //创建对象,设置集群名称和IP地址 ElasticsearchUtils es = new ElasticsearchUtils("im_shan", "localhost"); String index

  • 详解ElasticSearch6.4.0集群搭建

    最近在学习ES相关内容,为了方便自己使用,在本地虚拟机上搭建了一个3节点的ES集群,在搭建过程中,遇到了许多坑,网上的资料也比较分散,所以详细整理一下搭建过程发出来供参考.搭建过程中,由于是两台虚拟机,所以有一种很快速的办法,搭建一台,然后通过克隆虚拟机然后修改可以迅速完成,但是为了更熟悉整个过程,本过程是每台虚拟机都逐一去操作. 一.软件及环境准备 服务器环境 CentOS6.9_64位两台 es-master:192.168.0.11 es-slave:192.168.0.12 注意:内存允

  • Python 操作 ElasticSearch的完整代码

    官方文档:https://elasticsearch-py.readthedocs.io/en/master/ 1.介绍 python提供了操作ElasticSearch 接口,因此要用python来操作ElasticSearch,首先要安装python的ElasticSearch包,用命令pip install elasticsearch安装或下载安装:https://pypi.python.org/pypi/elasticsearch/5.4.0 2.创建索引 假如创建索引名称为ott,类型

  • SpringBoot整合Elasticsearch7.2.0的实现方法

    Spring boot 2.1.X整合Elasticsearch最新版的一处问题 新版本的Spring boot 2的spring-boot-starter-data-elasticsearch中支持的Elasticsearch版本是2.X,但Elasticsearch实际上已经发展到7.2.X版本了,为了更好的使用Elasticsearch的新特性,所以弃用了spring-boot-starter-data-elasticsearch依赖,而改为直接使用Spring-data-elastics

  • Python-ElasticSearch搜索查询的讲解

    Elasticsearch 是一个开源的搜索引擎,建立在一个全文搜索引擎库 Apache Lucene™ 基础之上. Lucene 可能是目前存在的,不论开源还是私有的,拥有最先进,高性能和全功能搜索引擎功能的库.但是 Lucene 仅仅只是一个库.为了利用它,你需要编写 Java 程序,并在你的 java 程序里面直接集成 Lucene 包. 更坏的情况是,你需要对信息检索有一定程度的理解才能明白 Lucene 是怎么工作的.Lucene 是 很 复杂的. 在上一篇文章中介绍了ElasticS

  • ElasticSearch的完整安装教程

    ElasticSearch安装 下载ElasticSearch 官网地址: https://www.elastic.co/products/elasticsearch 本地下载:https://www.jb51.net/codes/579429.html 上传到ElasticSearch 可以使用第三方工具filezilla 解压elasticsearch-6.4.0.tar.gztar -zxvf elasticsearch-6.4.0.tar.gz [root@localhost elast

  • VMware下Ubuntu16.04镜像完整安装教程

    本文为大家分享了VMware 12 下 Ubuntu 16.04镜像 安装教程,供大家参考,具体内容如下 1)安装前准备 PC电脑操作系统是WIN7,已正确安装虚拟机VMware 12. 2)安装Ubuntu 16.04镜像 下载Ubuntu镜像文件,下载链接 打开虚拟机:点击创建新的虚拟机 选择典型,点击下一步. 选择稍后安装操作系统 操作系统选择Linux,版本选择Ubuntu64位. 给虚拟机命名,选择安装位置. 设置虚拟机磁盘大小,一般设置为20GB. 点击完成. 点击编辑虚拟机设置.

  • docker 安装ElasticSearch 6.x的教程详解

    首先是拉去镜像(或者直接创建容器自然会拉去) docker pull elasticSearch:6.5.4 创建容器 docker run --name elasticsearch --net host -e "discovery.type=single-node" -e "network.host=IP地址" elasticsearch:6.5.4 启动 docker start elasticsearch 查看日志 docker logs elasticsea

  • mysql 8.0.22压缩包完整安装与配置教程图解(亲测安装有效)

    1.下载zip安装包 点击此处下载MySQL server 8.0.22压缩包 下载后直接解压即可 2.解压,并配置环境变量 2.1 解压zip包到安装目录,我的解压在了D:\MySQL\mysql-8.0.22-winx64 2.2 配置环境变量 将解压文件夹下的bin路径添加到变量值中,前后以 ; 开头结尾 2.3 创建并配置初始化的my.ini文件 放在安装目录下 配置文件my.ini内容如下: [mysqld] # 设置3306端口 port=3306 # 设置mysql的安装目录 ba

  • Elasticsearch.Net使用入门教程(1)

    本文实例为大家分享了Elasticsearch.Net使用教程,供大家参考,具体内容如下 首先去官网下载Elasticsearch 2.3.4安装包,解压后,在cmd命令行进入安装目录,再进入 bin目录,运行elasticsearch.bat命令. elasticsearch插件elasticsearch-head安装: bin目录下执行命令plugin -install mobz/elasticsearch-head 然后开始.net编程,构建控制台应用程序 Program.cs代码如下:

  • mysql安装图解 mysql图文安装教程(详细说明)

    MySQL5.0版本的安装图解教程是给新手学习的,当前mysql5.0.96是最新的稳定版本. mysql 下载地址 http://www.jb51.net/softs/2193.html 下面的是MySQL安装的图解,用的可执行文件安装的,详细说明了一下!打开下载的mysql安装文件mysql-5.0.27-win32.zip,双击解压缩,运行"setup.exe",出现如下界面 mysql安装图文教程1 mysql安装向导启动,按"Next"继续 mysql图文

  • Spring Boot CLI安装教程

    Spring Boot是一个命令行工具,用于使用Spring进行快速原型搭建.它允许你运行Groovy脚本,这意味着你可以使用类Java的语法,并且没有那么多的模板代码. 你没有必要为了使用Spring Boot而去用CLI,但它绝对是助力Spring应用的最快方式. 1.手动安装 你可以从Spring软件仓库下载Spring CLI分发包: spring-boot-cli-1.3.0.BUILD-SNAPSHOT-bin.zip spring-boot-cli-1.3.0.BUILD-SNAP

  • Python解释器以及PyCharm的安装教程图文详解

    本文给大家分享Python解释器安装以及PyCharm安装过程.很多朋友问小编要完整的安装教程,现分享给大家. 一.Python解释器安装 解释器(英语:Interpreter),又译为直译器,是一种电脑程序能够把高级编程语言一行一行直接转译运行.解释器不会一次把整个程序转译出来,只像一位"中间人",每次运行程序时都要先转成另一种语言再作运行,因此解释器的程序运行速度比较缓慢.它每转译一行程序叙述就立刻运行,然后再转译下一行,再运行,如此不停地进行下去. Python的下载网站:Pyt

  • 最新clion2020激活码附安装教程(亲测有效)

    CLion是JetBrains公司旗下发布的一款跨平台C/C++IDE开发工具. 使用CLion上最好要会手写CMake.要先安装编译器套件(一般安装MinGW就行). 对C++标准的支持:基本上Clion对标准的支持取决与工具链(tool chains),但也不完全,比如就算工具链支持c++14,Clion本身对C++14目前支持还是有一定缺陷的,但是工具链支持意味着你至少可以正常编译. Clion的自动补全无疑是最强大的特性之一,写代码流畅无比! 特性: 1.支持GCC.clang.MinG

随机推荐