Zhong__CentOS7安装Elasticsearch笔记

      ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。Elasticsearch是用Java开发的,并作为Apache许可条款下的开放源码发布,是当前流行的企业级搜索引擎。设计用于云计算中,能够达到实时搜索,稳定,可靠,快速,安装使用方便。

Elasticsearch 使用的是标准的 RESTful 风格的 API 和 JSON,我们可以在各种流行的语言中通过插件来使用ES,开箱即用!

ES不但只是实现快速的搜索,亦可以作为数据库使用!接下来介绍ES在Linux系统中的安装过程:

首先安装jdk,ES依赖jdk环境!

查看是否已安装jdk

java -version

如果没有安装的话,先安装!jdk版本1.8或以上

echo $JAVA_HOME

 查看repo源  默认自带源

yum list java*

 安装指定版本jdk

yum -y install java-1.8.0-openjdk

 等安装完成后查看jdk

获取指定版本ES

curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.16.tar.gz

 解压

tar -xvf elasticsearch-5.6.16.tar.gz

启动

cd elasticsearch-5.6.16/bin

 

./elasticsearch

 正常启动显示信息

[[email protected] bin]# ./elasticsearch
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
[2019-04-12T13:27:58,315][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:136) ~[elasticsearch-5.6.16.jar:5.6.16]
	at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:123) ~[elasticsearch-5.6.16.jar:5.6.16]
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:70) ~[elasticsearch-5.6.16.jar:5.6.16]
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:134) ~[elasticsearch-5.6.16.jar:5.6.16]
	at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-5.6.16.jar:5.6.16]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:91) ~[elasticsearch-5.6.16.jar:5.6.16]
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:84) ~[elasticsearch-5.6.16.jar:5.6.16]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
	at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:106) ~[elasticsearch-5.6.16.jar:5.6.16]
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:195) ~[elasticsearch-5.6.16.jar:5.6.16]
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:342) ~[elasticsearch-5.6.16.jar:5.6.16]
	at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:132) ~[elasticsearch-5.6.16.jar:5.6.16]
	... 6 more

如遇以下错误,是由于内存不足引起的,可更改jvm配置

[[email protected] bin]# ./elasticsearch
OpenJDK 64-Bit Server VM warning: If the number of processors is expected to increase from one, then you should configure the number of parallel GC threads appropriately using -XX:ParallelGCThreads=N
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 2060255232 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /root/elasticsearch-5.6.16/bin/hs_err_pid56937.log

1、进入/elasticsearch-5.6.16/config 

2、修改jvm.options 的配置

3、修改为 -Xms512M  -Xmx512M (根据个人系统配置适当调整)

Zhong__CentOS7安装Elasticsearch笔记

Zhong__CentOS7安装Elasticsearch笔记

重新启动即可!

 

关注微信公众号

Zhong__CentOS7安装Elasticsearch笔记