ElasticSearch单节点安装

Linux版本(本人使用的是CentOS7

ElasticSearch是基于Lucene实现的,而Lucenejava开发的,所以在安装ElasticSearch之前需要先准备好java环境。


ElasticSearch单节点安装

elastic网站上找到自己想要下载的版本,而且网站上还有安装步骤和案例

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

目前最新的版本是2017/9/18推出的5.6.1版本,下载地址是https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.1.zip

下载命令:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.1.zip

解压命令:

unzip elasticsearch-5.6.1.zip

到目前为止,ElasticSearch单节点已经安装好了!

我在(Java程序员的互联网转型之路)这一篇博文中已经介绍过互联网组件的特性,其中有一个特性就是上手快,下载即使用。下载解压后直接去找bin里的启动文件直接默认可用,这一特性也适用于ElasticSearch

启动./bin/elasticsearch

但是启动失败了,失败信息:

OpenJDK 64-Bit Server VM warning: If thenumber of processors is expected to increase from one, then you shouldconfigure 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='Cannotallocate memory' (errno=12)

因为我是在VMware中启动的centos,只给vm分配了1G内存,内存不足引起的,找到elasticsearch配置文件所在目录,有3个文件:

1elasticsearch.ymlelastic结点、集群的配置信息;

2jvm.optionsjvm的配置信息,里面找到默认启动内存是2G,把它修改成512m后启动成功。

3log4j2.propertieselasticlog的配置文件。

 

启动ElasticSearch

可以看到我们修改的jvm参数已经生效了,也可以看到默认的服务端口是9200

ElasticSearch单节点安装

检查是否启动成功:

curl localhost:9200

ElasticSearch单节点安装



除开linux安装,这里还推荐使用docker安装:

1先确定能否找得到elasticsearch的镜像

ElasticSearch单节点安装

2 pull到本地

docker pull docker.io/elasticsearch

3 改下镜像的名称

docker tag docker.io/elasticsearchelasticsearch:v1

4 启动容器

docker run -p 9200:9200 --name my-eselasticsearch:v1

ElasticSearch单节点安装

5 检查容器

ElasticSearch单节点安装