Elasticsearch的安装与启动
演示目标
在Linux环境中安装并启动Elasticsearch 7.x版本。
安装与启动
- 下载ES
https://www.elastic.co/cn/downloads/elasticsearch - 在Linux中使用tar -zxvf命令解压
- 创建ES用户组及ES用户(ES不能使用Root用户运行):
# 增加ES用户组和ES用户并修改ES用户密码
groupadd es
useradd es -g es
passwd es
# 更改ES文件夹所属的用户组及用户
cd /opt
chown -R es:es elasticsearch-7.13.2
# 切换到ES用户并启动ES
su es
sh /opt/elasticsearch-7.13.2/bin/elasticsearch
- 访问http://${ip}:9200若出现以下信息则启动成功
{
"name" : "node1",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "JPWsaiXLRluAOJszGOpAsg",
"version" : {
"number" : "7.13.2",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "4d960a0733be83dd2543ca018aa4ddc42e956800",
"build_date" : "2021-06-10T21:01:55.251515791Z",
"build_snapshot" : false,
"lucene_version" : "8.8.2",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
配置远程服务器访问
# 编辑 $ES_HOME/config/elasticsearch.yml
# 修改 network.host 为 0.0.0.0
network.host: 0.0.0.0
# 修改cluster.initial_master_nodes为当前node
cluster.initial_master_nodes: ["node1"]
启动时异常与解决方法
- max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
# 修改/etc/security/limits.conf,增加配置,切换用户或重新登录后生效
* soft nofile 65536
* hard nofile 65536
- max number of threads [3818] for user [es] is too low, increase to at least [4096]
# 修改/etc/security/limits.conf,增加配置,切换用户或重新登录后生效
* hard nproc 4096
* soft nproc 4096
- max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
# 修改/etc/sysctl.conf,增加如下配置,保存后执行sysctl -p 生效
fs.file-max=65536
- max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
# 修改/etc/sysctl.conf,增加如下配置,保存后执行sysctl -p 生效
vm.max_map_count=262144