ElasticSearch下载安装启动详细图解(一)

发布时间:2026/7/16 18:04:31
ElasticSearch下载安装启动详细图解(一) 1、下载访问官网的下载地址Download Elasticsearch | Elasticwindows版的下载ZIP格式的。如果不想下载最新版的可以点击“past releases”选择过去的版本。我这里下载的是6.8.6版本的。这就是下载好的linux版本将他上传到linux2这里我将下载下来的tar包上传至 /usr/local/software/ 路径下3解压缩这里我将tar包解压缩到 /usr/local/java/ 目录下解压缩 tar -zxvf elasticsearch-6.8.6.tar.gz -C /usr/local/java/4修改elasticsearch.yml修改elasticsearch.yml 配置文件为远程访问IP和端口 cd /usr/local/java/elasticsearch-6.8.6/config vim elasticsearch.yml5启动这里这安装好了吗我们试试能不能启动进入bin目录 /usr/local/java/elasticsearch-6.8.6/bin 启动 ./elasticsearch6解决报错看见如下被自动killed原因是因为查看日志也没有错误。后来发现是内存不够了由于ES是运行在JVM上JVM本身除了分配的heap内存以外还会用到一些堆外(off heap)内存。 在小内存的机器上跑ES如果heap划分过多累加上堆外内存后总的JVM使用内存量可能超过物理内存限制。 如果swap又是关闭的情况下就会被操作系统oom killer杀掉。修改ES中config目录下的jvm.options文件vim jvm.options 将 -Xms1g -Xmx1g 改为 -Xms512m -Xmx512m找到问题了我们调整了jvm之后重新启动网上找了资料解决方案;继续按网上的解决方案再次启动还是报错从日志看出我们不能用root启动那需要新建一个用户组和用户专属EslasticSearch的那我们就开始新建组合用户[rootbackup01 bin]# groupadd esgroup [rootbackup01 bin]# useradd esuser -g esgroup -p 123456修改 elasticsearch-6.8.6 所属组以及用户 chown -R esuser:esgroup elasticsearch-6.8.6切换es的专属用户重新启动启动日志如下[rootbackup01 bin]# su esuser [esuserbackup01 bin]$ ./elasticsearch [2019-12-25T21:20:55,797][INFO ][o.e.e.NodeEnvironment ] [XF1iu6t] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [25.4gb], net total_space [39.9gb], types [rootfs] [2019-12-25T21:20:55,801][INFO ][o.e.e.NodeEnvironment ] [XF1iu6t] heap size [503.6mb], compressed ordinary object pointers [true] [2019-12-25T21:20:55,802][INFO ][o.e.n.Node ] [XF1iu6t] node name derived from node ID [XF1iu6tZTT2SyUnPu6Ud2A]; set [node.name] to override [2019-12-25T21:20:55,802][INFO ][o.e.n.Node ] [XF1iu6t] version[6.8.6], pid[27766], build[default/tar/3d9f765/2019-12-13T17:11:52.013738Z], OS[Linux/3.10.0-862.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_172/25.172-b11] [2019-12-25T21:20:55,802][INFO ][o.e.n.Node ] [XF1iu6t] JVM arguments [-Xms512m, -Xmx512m, -XX:UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction75, -XX:UseCMSInitiatingOccupancyOnly, -Des.networkaddress.cache.ttl60, -Des.networkaddress.cache.negative.ttl10, -XX:AlwaysPreTouch, -Xss1m, -Djava.awt.headlesstrue, -Dfile.encodingUTF-8, -Djna.nosystrue, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafetrue, -Dio.netty.noKeySetOptimizationtrue, -Dio.netty.recycler.maxCapacityPerThread0, -Dlog4j.shutdownHookEnabledfalse, -Dlog4j2.disable.jmxtrue, -Djava.io.tmpdir/tmp/elasticsearch-3305798114182502653, -XX:HeapDumpOnOutOfMemoryError, -XX:HeapDumpPathdata, -XX:ErrorFilelogs/hs_err_pid%p.log, -XX:PrintGCDetails, -XX:PrintGCDateStamps, -XX:PrintTenuringDistribution, -XX:PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:UseGCLogFileRotation, -XX:NumberOfGCLogFiles32, -XX:GCLogFileSize64m, -Des.path.home/usr/local/java/elasticsearch-6.8.6, -Des.path.conf/usr/local/java/elasticsearch-6.8.6/config, -Des.distribution.flavordefault, -Des.distribution.typetar] [2019-12-25T21:21:01,240][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [aggs-matrix-stats] [2019-12-25T21:21:01,242][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [analysis-common] [2019-12-25T21:21:01,242][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [ingest-common] [2019-12-25T21:21:01,242][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [ingest-geoip] [2019-12-25T21:21:01,242][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [ingest-user-agent] [2019-12-25T21:21:01,242][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [lang-expression] [2019-12-25T21:21:01,243][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [lang-mustache] [2019-12-25T21:21:01,243][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [lang-painless] [2019-12-25T21:21:01,243][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [mapper-extras] [2019-12-25T21:21:01,243][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [parent-join] [2019-12-25T21:21:01,243][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [percolator] [2019-12-25T21:21:01,243][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [rank-eval] [2019-12-25T21:21:01,243][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [reindex] [2019-12-25T21:21:01,243][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [repository-url] [2019-12-25T21:21:01,243][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [transport-netty4] [2019-12-25T21:21:01,243][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [tribe] [2019-12-25T21:21:01,243][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-ccr] [2019-12-25T21:21:01,243][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-core] [2019-12-25T21:21:01,243][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-deprecation] [2019-12-25T21:21:01,243][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-graph] [2019-12-25T21:21:01,243][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-ilm] [2019-12-25T21:21:01,243][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-logstash] [2019-12-25T21:21:01,244][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-ml] [2019-12-25T21:21:01,244][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-monitoring] [2019-12-25T21:21:01,244][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-rollup] [2019-12-25T21:21:01,244][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-security] [2019-12-25T21:21:01,244][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-sql] [2019-12-25T21:21:01,244][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-upgrade] [2019-12-25T21:21:01,244][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-watcher] [2019-12-25T21:21:01,244][INFO ][o.e.p.PluginsService ] [XF1iu6t] no plugins loaded [2019-12-25T21:21:10,294][INFO ][o.e.x.s.a.s.FileRolesStore] [XF1iu6t] parsed [0] roles from file [/usr/local/java/elasticsearch-6.8.6/config/roles.yml] [2019-12-25T21:21:12,397][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [XF1iu6t] [controller/27821] [Main.cc109] controller (64 bit): Version 6.8.6 (Build 73ed602c10c48e) Copyright (c) 2019 Elasticsearch BV [2019-12-25T21:21:13,156][DEBUG][o.e.a.ActionModule ] [XF1iu6t] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security [2019-12-25T21:21:13,581][INFO ][o.e.d.DiscoveryModule ] [XF1iu6t] using discovery type [zen] and host providers [settings] [2019-12-25T21:21:15,038][INFO ][o.e.n.Node ] [XF1iu6t] initialized [2019-12-25T21:21:15,038][INFO ][o.e.n.Node ] [XF1iu6t] starting ... [2019-12-25T21:21:15,674][INFO ][o.e.t.TransportService ] [XF1iu6t] publish_address {192.168.0.120:9300}, bound_addresses {192.168.0.120:9300} [2019-12-25T21:21:15,707][INFO ][o.e.b.BootstrapChecks ] [XF1iu6t] 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 [65535] [2]: max number of threads [3764] for user [esuser] 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] [2019-12-25T21:21:15,725][INFO ][o.e.n.Node ] [XF1iu6t] stopping ... [2019-12-25T21:21:15,750][INFO ][o.e.n.Node ] [XF1iu6t] stopped [2019-12-25T21:21:15,750][INFO ][o.e.n.Node ] [XF1iu6t] closing ... [2019-12-25T21:21:15,790][INFO ][o.e.n.Node ] [XF1iu6t] closed [2019-12-25T21:21:15,793][INFO ][o.e.x.m.p.NativeController] [XF1iu6t] Native controller process has stopped - no new native processes can be started [esuserbackup01 bin]$通过查看日志我们发现了ERROR切换到root修改配置文件错误[1]: max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536][esuserbackup01 bin]$ su root Password: [rootbackup01 bin]# vim /etc/security/limits.conf [rootbackup01 bin]#* soft nofile 65536* hard nofile 65536* soft nproc 4096* hard nproc 4096* 表示通配符 这里可以使用es的专属用户esuser soft nofile 65536esuser hard nofile 65536esuser soft nproc 4096esuser hard nproc 4096错误[2]:max number of threads [3764] for user [esuser] is too low, increase to at least [4096]修改 修改XX-nproc.conf 不同机器XX不一样可先到 cd /etc/security/limits.d/ 查看下vim 20-nproc.conf* 表示通配符 这里可以使用es的专属用户* soft nproc 4096 可以改为 esuser soft nproc 4096错误[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_count655360 保存后执行 sysctl -p7重新启动[rootbackup01 limits.d]# su esuser [esuserbackup01 limits.d]$ cd /usr/local/java/elasticsearch-6.8.6/bin/ [esuserbackup01 bin]$ ./elasticsearch [2019-12-25T21:55:16,315][INFO ][o.e.e.NodeEnvironment ] [XF1iu6t] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [25.4gb], net total_space [39.9gb], types [rootfs] [2019-12-25T21:55:16,331][INFO ][o.e.e.NodeEnvironment ] [XF1iu6t] heap size [503.6mb], compressed ordinary object pointers [true] [2019-12-25T21:55:16,334][INFO ][o.e.n.Node ] [XF1iu6t] node name derived from node ID [XF1iu6tZTT2SyUnPu6Ud2A]; set [node.name] to override [2019-12-25T21:55:16,334][INFO ][o.e.n.Node ] [XF1iu6t] version[6.8.6], pid[34499], build[default/tar/3d9f765/2019-12-13T17:11:52.013738Z], OS[Linux/3.10.0-862.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_172/25.172-b11] [2019-12-25T21:55:16,334][INFO ][o.e.n.Node ] [XF1iu6t] JVM arguments [-Xms512m, -Xmx512m, -XX:UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction75, -XX:UseCMSInitiatingOccupancyOnly, -Des.networkaddress.cache.ttl60, -Des.networkaddress.cache.negative.ttl10, -XX:AlwaysPreTouch, -Xss1m, -Djava.awt.headlesstrue, -Dfile.encodingUTF-8, -Djna.nosystrue, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafetrue, -Dio.netty.noKeySetOptimizationtrue, -Dio.netty.recycler.maxCapacityPerThread0, -Dlog4j.shutdownHookEnabledfalse, -Dlog4j2.disable.jmxtrue, -Djava.io.tmpdir/tmp/elasticsearch-534418274257154579, -XX:HeapDumpOnOutOfMemoryError, -XX:HeapDumpPathdata, -XX:ErrorFilelogs/hs_err_pid%p.log, -XX:PrintGCDetails, -XX:PrintGCDateStamps, -XX:PrintTenuringDistribution, -XX:PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:UseGCLogFileRotation, -XX:NumberOfGCLogFiles32, -XX:GCLogFileSize64m, -Des.path.home/usr/local/java/elasticsearch-6.8.6, -Des.path.conf/usr/local/java/elasticsearch-6.8.6/config, -Des.distribution.flavordefault, -Des.distribution.typetar] [2019-12-25T21:55:21,978][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [aggs-matrix-stats] [2019-12-25T21:55:21,978][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [analysis-common] [2019-12-25T21:55:21,978][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [ingest-common] [2019-12-25T21:55:21,978][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [ingest-geoip] [2019-12-25T21:55:21,978][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [ingest-user-agent] [2019-12-25T21:55:21,978][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [lang-expression] [2019-12-25T21:55:21,979][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [lang-mustache] [2019-12-25T21:55:21,979][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [lang-painless] [2019-12-25T21:55:21,979][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [mapper-extras] [2019-12-25T21:55:21,979][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [parent-join] [2019-12-25T21:55:21,979][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [percolator] [2019-12-25T21:55:21,979][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [rank-eval] [2019-12-25T21:55:21,979][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [reindex] [2019-12-25T21:55:21,979][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [repository-url] [2019-12-25T21:55:21,979][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [transport-netty4] [2019-12-25T21:55:21,979][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [tribe] [2019-12-25T21:55:21,979][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-ccr] [2019-12-25T21:55:21,979][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-core] [2019-12-25T21:55:21,979][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-deprecation] [2019-12-25T21:55:21,979][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-graph] [2019-12-25T21:55:21,979][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-ilm] [2019-12-25T21:55:21,979][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-logstash] [2019-12-25T21:55:21,979][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-ml] [2019-12-25T21:55:21,980][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-monitoring] [2019-12-25T21:55:21,980][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-rollup] [2019-12-25T21:55:21,980][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-security] [2019-12-25T21:55:21,980][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-sql] [2019-12-25T21:55:21,980][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-upgrade] [2019-12-25T21:55:21,980][INFO ][o.e.p.PluginsService ] [XF1iu6t] loaded module [x-pack-watcher] [2019-12-25T21:55:21,980][INFO ][o.e.p.PluginsService ] [XF1iu6t] no plugins loaded [2019-12-25T21:55:31,445][INFO ][o.e.x.s.a.s.FileRolesStore] [XF1iu6t] parsed [0] roles from file [/usr/local/java/elasticsearch-6.8.6/config/roles.yml] [2019-12-25T21:55:32,907][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [XF1iu6t] [controller/34621] [Main.cc109] controller (64 bit): Version 6.8.6 (Build 73ed602c10c48e) Copyright (c) 2019 Elasticsearch BV [2019-12-25T21:55:34,315][DEBUG][o.e.a.ActionModule ] [XF1iu6t] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security [2019-12-25T21:55:34,776][INFO ][o.e.d.DiscoveryModule ] [XF1iu6t] using discovery type [zen] and host providers [settings] [2019-12-25T21:55:36,750][INFO ][o.e.n.Node ] [XF1iu6t] initialized [2019-12-25T21:55:36,750][INFO ][o.e.n.Node ] [XF1iu6t] starting ... [2019-12-25T21:55:37,242][INFO ][o.e.t.TransportService ] [XF1iu6t] publish_address {192.168.0.120:9300}, bound_addresses {192.168.0.120:9300} [2019-12-25T21:55:37,265][INFO ][o.e.b.BootstrapChecks ] [XF1iu6t] bound or publishing to a non-loopback address, enforcing bootstrap checks [2019-12-25T21:55:40,380][INFO ][o.e.c.s.MasterService ] [XF1iu6t] zen-disco-elected-as-master ([0] nodes joined), reason: new_master {XF1iu6t}{XF1iu6tZTT2SyUnPu6Ud2A}{d6YuCsV-Q32oZ5ECprc-Lg}{192.168.0.120}{192.168.0.120:9300}{ml.machine_memory1021906944, xpack.installedtrue, ml.max_open_jobs20, ml.enabledtrue} [2019-12-25T21:55:40,385][INFO ][o.e.c.s.ClusterApplierService] [XF1iu6t] new_master {XF1iu6t}{XF1iu6tZTT2SyUnPu6Ud2A}{d6YuCsV-Q32oZ5ECprc-Lg}{192.168.0.120}{192.168.0.120:9300}{ml.machine_memory1021906944, xpack.installedtrue, ml.max_open_jobs20, ml.enabledtrue}, reason: apply cluster state (from master [master {XF1iu6t}{XF1iu6tZTT2SyUnPu6Ud2A}{d6YuCsV-Q32oZ5ECprc-Lg}{192.168.0.120}{192.168.0.120:9300}{ml.machine_memory1021906944, xpack.installedtrue, ml.max_open_jobs20, ml.enabledtrue} committed version [1] source [zen-disco-elected-as-master ([0] nodes joined)]]) [2019-12-25T21:55:40,508][WARN ][o.e.x.s.a.s.m.NativeRoleMappingStore] [XF1iu6t] Failed to clear cache for realms [[]] [2019-12-25T21:55:40,539][INFO ][o.e.h.n.Netty4HttpServerTransport] [XF1iu6t] publish_address {192.168.0.120:9200}, bound_addresses {192.168.0.120:9200} [2019-12-25T21:55:40,539][INFO ][o.e.n.Node ] [XF1iu6t] started [2019-12-25T21:55:40,625][INFO ][o.e.g.GatewayService ] [XF1iu6t] recovered [0] indices into cluster_state [2019-12-25T21:55:41,115][INFO ][o.e.c.m.MetaDataIndexTemplateService] [XF1iu6t] adding template [.triggered_watches] for index patterns [.triggered_watches*] [2019-12-25T21:55:41,269][INFO ][o.e.c.m.MetaDataIndexTemplateService] [XF1iu6t] adding template [.watch-history-9] for index patterns [.watcher-history-9*] [2019-12-25T21:55:41,311][INFO ][o.e.c.m.MetaDataIndexTemplateService] [XF1iu6t] adding template [.watches] for index patterns [.watches*] [2019-12-25T21:55:41,381][INFO ][o.e.c.m.MetaDataIndexTemplateService] [XF1iu6t] adding template [.monitoring-logstash] for index patterns [.monitoring-logstash-6-*] [2019-12-25T21:55:41,605][INFO ][o.e.c.m.MetaDataIndexTemplateService] [XF1iu6t] adding template [.monitoring-es] for index patterns [.monitoring-es-6-*] [2019-12-25T21:55:41,661][INFO ][o.e.c.m.MetaDataIndexTemplateService] [XF1iu6t] adding template [.monitoring-beats] for index patterns [.monitoring-beats-6-*] [2019-12-25T21:55:41,710][INFO ][o.e.c.m.MetaDataIndexTemplateService] [XF1iu6t] adding template [.monitoring-alerts] for index patterns [.monitoring-alerts-6] [2019-12-25T21:55:41,757][INFO ][o.e.c.m.MetaDataIndexTemplateService] [XF1iu6t] adding template [.monitoring-kibana] for index patterns [.monitoring-kibana-6-*] [2019-12-25T21:55:41,969][INFO ][o.e.l.LicenseService ] [XF1iu6t] license [90241c6a-de4a-4bc7-93a5-4e0f5b0baedf] mode [basic] - valid启动成功我们知道ES是restful的那就用curl命令测试下是否真费成功当我们看见下的信息说明已经成功注意ElasticSearch启动可以后台启动我上面是前台启动后台启动只需要加上 -d同样是可以启动成功的8测试前面我们也是配置了windows远程IP访问(elasticsearch.yml这个配置文件修改为了ip192.168.0.120 端口号http prot 9200)我们也可以同过windows进行ip端口的方式访问