下载elasticsearch
从华为开源镜像云上下载,下载速度很快
es6.8版本要求jdk1.8,es7.3要求jdk11
我们使用jdk6,下载es6.8
ES安装
- 解压es包
- tar -zxf
- es 只能使用非root账号启动 ,需要对启动用户赋es文件夹的读写执行权限
- cd bin
- ./elasticsearch
ES配置
- 绑定ip- network配置
- 默认只有本机能够访问es
- 配置为0.0.0.0 为所有机器都能访问
- 允许指定多个ip访问时,空格间隔
- network.bind_host
绑定允许访问的ip,可以为多个 - network.publish_host
发布地址,只能是一个
启动报错 :
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 [1024] for user [caogt] 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 :当前用户的打开文件句柄数太小,至少需要65535个
解决方式:
vi /etc/security/limits.conf
增加如下:号后有空格
*hard nofile 65536
*soft nofile 65536
*表示所有用户
问题2 : 当前用户的线程数最少4096个
解决方式
vi /etc/security/limits.d/90-nproc.conf
增加如下:号后有空格
*soft nproc 4096
问题3 :虚拟内存太小,至少262144
解决方式
vi /etc/sysctl.conf
添加
vm.max_map_count=262144
验证
- 在本机使用curl访问
curl http://192.168.194.134:9200
没有绑定时,不能使用localhost - 在network配置中允许的机器上访问
curl http://192.168.194.134:9200
返回
{
“name” : “AIFkGLa”,
“cluster_name” : “elasticsearch”,
“cluster_uuid” : “3cgO5MBAQmGF8z0aFmxdaw”,
“version” : {
“number” : “6.8.3”,
“build_flavor” : “default”,
“build_type” : “tar”,
“build_hash” : “0c48c0e”,
“build_date” : “2019-08-29T19:05:24.312154Z”,
“build_snapshot” : false,
“lucene_version” : “7.7.0”,
“minimum_wire_compatibility_version” : “5.6.0”,
“minimum_index_compatibility_version” : “5.0.0”
},
“tagline” : “You Know, for Search”
} - 健康检查
http://192.168.194.134:9200/_cat/health?v
返回
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1587455430 07:50:30 elasticsearch green 1 1 0 0 0 0 0 0 - 100.0%