wiki-files/elk/elasticsearch.md

108 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: ElasticSearch
description: 安装以及使用文档
published: true
date: 2021-10-23T09:14:15.263Z
tags: elk
editor: markdown
dateCreated: 2021-10-23T09:14:15.263Z
---
> 版本7.15.1内存至少4G7之前的版本需要安装jdk7之后用自带的jdk11
# 部署
## 单机部署
CentOS
1. 创建用户组以及用户elasticsearch不允许root用户启动
```bash
$ addgroup esg
$ adduser es -g esg
$ passwd es
```
2. 修改elasticsearch文件夹及下所有文件的权限
```bash
$ chown -R es:esg elasticsearch-7.15.1
```
3. 切换用户
```bash
$ su es
```
4. 修改配置文件(如果不对外开放,不需要配置)
```bash
vim elasticsearch-7.15.1/config/elasticsearch.yml
```
修改内容
```yml
# 默认为localhost
network.host: 192.168.0.156
# 默认为9200
http.port: 9200
# ["127.0.0.1", "[::1]"]
discovery.seed_hosts: ["192.168.0.156"]
```
5. 启动
```bash
# 前台启动
$ ./bin/elasticsearch
# 帮助
$ ./bin/elasticsearch -h
# 后台启动
$ ./bin/elasticsearch -d
# 退出
$ ./bin/elasticsearch -q
# 查看版本
$ ./bin/elasticsearch -V
```
6. 查看结果
```bash
curl http://127.0.0.1:9200
curl http://192.168.0.156:9200
```
> 报错max virtual memory areas vm.max_map_count [65530] is too low...
{.is-warning}
以上错误表示用户的内存使用权限不够
解决办法
```bash
# 切换回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文件最后一行添加
```vim
vm.max_map_count=262144
```
立即生效
```bash
sysctl -p
```
切换回es用户启动服务