安装Java环境,elasticsearch推荐安装java1.8.0_131或更高的版本,安装教程CentOS7安装JDK1.8html
CentOS下能够选择.tar.gz
或rpm
方式安装Elasticsearch,但因为生产环境不能访问外网,所以采用.tar.gz的方式安装。java
经过浏览器下载对用版本的安装包,下载地址:https://www.elastic.co/downloads/past-releasesjson
若是安装服务器能够链接外网,也能够输入命令直接下载bootstrap
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.3.tar.gz
tar -xzf elasticsearch-5.5.3.tar.gz
cd elasticsearch-5.5.3/ ./bin/elasticsearch
或./bin/elasticsearch -d
后台运行浏览器
若是启动会出现can not run elasticsearch as root
的错误,是因为出于安全考虑,Elasticsearch不容许以root用户启动,所以须要添加用于运行Elasticsearch的用户。安全
adduser xxx #添加用户:xxx passwd ******** #给xxx用户设置密码 chown -R xxx /opt/elasticsearch-5.5.3 #为xxx添加权限
而后再执行elasticsearch
命令则可正常启动Elasticsearchbash
curl http://localhost:9200
验证结果:服务器
{ "name" : "Cp8oag6", "cluster_name" : "elasticsearch", "cluster_uuid" : "AT69_T_DTp-1qgIJlatQqA", "version" : { "number" : "5.5.3", "build_hash" : "f27399d", "build_date" : "2016-03-30T09:51:41.449Z", "build_snapshot" : false, "lucene_version" : "6.5.1" }, "tagline" : "You Know, for Search" }
Elasticsearch的配置文件在[安装目录]/config/
文件夹下curl
network.host: 0.0.0.0
避免交换,提升性能,如下来源官网:jvm
bootstrap.memory_lock: true
修改JVM堆大小设置
-Xms16g -Xmx16g
对于内存设置官方提供了一些建议,如:
将Xms
和Xmx
设置成相等的,避免每次垃圾回收完成后JVM从新分配内存;
Xmx
的大小不要超过物理内存的50%等
详细请参考官方文档:heap-size
max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
切换root用户,编辑/etc/security/limits.conf
,按照要求改成65536便可,修改后结果:
* soft nofile 65536 * hard nofile 65536
从新登陆后生效
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
切换root用户,编辑/etc/sysctl.conf
,在最后一行增长如下配置:
vm.max_map_count = 262114
需重启后生效
memory locking requested for elasticsearch process but memory is not locked
当设置bootstrap.memory_lock: true
时,若是没有锁定内存,会报该错误
需切换回root用户,编辑/etc/security/limits.conf
,增长如下配置:
* soft memlock unlimited * hard memlock unlimited
一样从新登陆后生效