1. ES安装包
官网下载地址: https://www.elastic.co/downloads/elasticsearch
2. JDK版本
JDK1.8
3. linux安装
注意:ES不能以root用户身份运行 确保运行用户对各使用到的目录的权限
3.1 获取安装包
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.0.1-linux-x86_64.tar.gz
3.2 解压到安装目录
tar -zxvf elasticsearch-7.0.1-linux-x86_64.tar.gz -C /opt
3.3 启动
默认配置启动,默认配置不支持外网访问
cd cd /opt/elasticsearch-7.0.1/
bin/elasticsearch
守护进程启动
bin/elasticsearch -d
指定参数启动
bin/elasticsearch -Ecluster.name=my_cluster_name -Enode.name=my_node_name
访问测试,出现如下输出
# curl localhost:9200
4. es配置
4.1 软件目录说明
|-- bin 可执行文件目录
|-- config 配置文件目录
|-- data 数据存放目录
|-- jdk es自带jdk
|-- lib 依赖库
|-- LICENSE.txt
|-- logs 日志目录
|-- modules 依赖模块
|-- NOTICE.txt
|-- plugins 第三方插件
`-- README.textile
4.2 配置说明
|-- elasticsearch.yml # es配置文件
|-- jvm.options # jvm参数配置文件
|-- log4j2.properties # log4j配置文件
es常见配置,elasticsearch.yml
cluster.name: my-application # 集群名称
node.name: node-1 # 节点名称
path.data: /path/to/data # 数据存放目录,默认为es data目录
path.logs: /path/to/logs # 日志存放目录,默认为es logs目录
network.host: 192.168.0.1 # 配置集群bind地址
http.port: 9200 # 对外服务的http端口,默认为9200
transport.tcp.port: 9300 # 节点间通信的tcp端口,默认9300
常见问题
问题一:max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
解决:修改切换到root用户修改配置limits.conf 添加下面两行
vi /etc/security/limits.conf
hard nofile 65536
soft nofile 65536
问题二:max number of threads [1024] for user [lish] likely too low, increase to at least [2048]
解决:切换到root用户,进入limits.d目录下修改配置文件。
vi /etc/security/limits.d/90-nproc.conf
修改如下内容:
soft nproc 1024
#修改为
soft nproc 2048
问题三:max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
解决:切换到root用户修改配置sysctl.conf
vi /etc/sysctl.conf
添加下面配置:
vm.max_map_count=655360
并执行命令:
sysctl -p
切换到es的用户。
然后,重新启动elasticsearch,即可启动成功。