2.6 KiB
2.6 KiB
title | description | published | date | tags | editor | dateCreated |
---|---|---|---|---|---|---|
ElasticSearch | 安装以及使用文档 | true | 2021-10-24T07:27:17.182Z | elk | markdown | 2021-10-23T09:14:15.263Z |
版本:7.15.1,内存至少4G,7之前的版本需要安装jdk,7之后用自带的jdk11
部署
单机部署
CentOS
- 创建用户组以及用户:elasticsearch不允许root用户启动
$ addgroup esg
$ adduser es -g esg
$ passwd es
- 修改elasticsearch文件夹及下所有文件的权限
$ chown -R es:esg elasticsearch-7.15.1
- 切换用户
$ su es
- 修改配置文件(如果不对外开放,不需要配置)
vim elasticsearch-7.15.1/config/elasticsearch.yml
修改内容
# 默认为localhost
network.host: 192.168.0.156
# 默认为9200
http.port: 9200
# ["127.0.0.1", "[::1]"]
discovery.seed_hosts: ["192.168.0.156"]
- 启动
# 前台启动
$ ./bin/elasticsearch
# 帮助
$ ./bin/elasticsearch -h
# 后台启动
$ ./bin/elasticsearch -d
# 退出
$ ./bin/elasticsearch -q
# 查看版本
$ ./bin/elasticsearch -V
- 查看结果
curl http://127.0.0.1:9200
或
curl http://192.168.0.156:9200
报错:max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535] {.is-warning}
原因:原因是进程不够用了
编辑 /etc/security/limits.conf,追加以下内容;
* soft nofile 65536
* hard nofile 65536
* soft nproc 4096
* hard nproc 4096
- nofile: 是每个进程可以打开的文件数的限制
- nproc:是操作系统级别对每个用户创建的进程数的限制
- soft表示软限制,hard表示硬限制,软限制要小于等于硬限制。
- * 表示所有用户,如果要指定用户就替换为用户名,如:root nofile 65536...
- 如果limits.conf没有做设定,则默认值是1024
此文件修改后需要重新登录用户,才会生效
登录后使用ulimit -S -n/ulimit -H -n查看
报错:max virtual memory areas vm.max_map_count [65530] is too low... {.is-warning}
以上错误表示用户的内存使用权限不够
解决办法
# 切换回root用户
$ su root
# 设置参数,这里的262144为错误提示的最小值,可根据实际情况调整,但不能超过最大内存
sysctl -w vm.max_map_count=262144
# 查看设置结果,有值代表设置成功
sysctl -a|grep vm.max_map_count
# 修改配置文件
vim /etc/sysctl.conf
/etc/sysctl.conf文件最后一行添加
vm.max_map_count=262144
立即生效
sysctl -p
切换回es用户,启动服务