ElasticSearch的完整安装教程
elasticsearch安装
下载elasticsearch
官网地址:
https://www.elastic.co/products/elasticsearch
本地下载:
上传到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
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对的支持。