ES elasticsearch的安装和配置

2021-03-01  本文已影响0人  小P聊技术

1 资源下载

CSDN下载地址: https://download.csdn.net/download/qq_15769939/15465621

2 ES服务部署

目前安装的服务器是elasticsearch,下面简称为ES。它的版本号是 7.4.2,使用的Linux操作系统是Centos7

2.1 上传资源到服务器

将文件上传到服务器的 /opt/module/software目录下

[root@localhost ~]# cd /opt/module/software
[root@localhost software]# ll
总用量 289356
-rw-r--r--. 1 root   root   288775500 2月  22 21:45 elasticsearch-7.4.2-linux-x86_64.tar.gz.zip
[root@localhost software]# unzip elasticsearch-7.4.2-linux-x86_64.tar.gz.zip
[root@localhost software]# tar -zxvf elasticsearch-7.4.2-linux-x86_64.tar.gz 
[root@localhost software]# mv elasticsearch-7.4.2 /usr/local
[root@localhost local]# cd /usr/local/elasticsearch-7.4.2
[root@localhost elasticsearch-7.4.2]# mkdir data
[root@localhost elasticsearch-7.4.2]# ll
总用量 556
drwxr-xr-x.  2 esuser esuser   4096 10月 29 2019 bin
drwxr-xr-x.  2 esuser esuser    178 2月  22 23:08 config
drwxr-xr-x.  3 esuser esuser     19 2月  22 22:07 data
drwxr-xr-x.  9 esuser esuser    107 10月 29 2019 jdk
drwxr-xr-x.  3 esuser esuser   4096 10月 29 2019 lib
-rw-r--r--.  1 esuser esuser  13675 10月 29 2019 LICENSE.txt
drwxr-xr-x.  2 esuser esuser   4096 2月  24 10:39 logs
drwxr-xr-x. 37 esuser esuser   4096 10月 29 2019 modules
-rw-r--r--.  1 esuser esuser 523209 10月 29 2019 NOTICE.txt
drwxr-xr-x.  3 esuser esuser     16 2月  24 13:36 plugins
-rw-r--r--.  1 esuser esuser   8500 10月 29 2019 README.textile

2.2 ES目录介绍

2.3 修改核心配置文件

[root@localhost config]#  vi /usr/local/elasticsearch-7.4.2/config/elasticsearch.yml 

2.4 修改JVM参数

因为是虚拟机的linux下安装的elasticsearch服务,JVM内存设置太大会比较卡,看个人需求来定,我这里将默认的xms和xmx的1g大小都更改为514M。

[root@localhost config]#  vi /usr/local/elasticsearch-7.4.2/config/jvm.options
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
# -Xms1g
# -Xmx1g
-Xms514m
-Xmx514m

2.5 添加用户

因为ES不允许使用root操作es,需要添加用户

[root@localhost config]# useradd esuser
[root@localhost config]# chown -R esuser:esuser /usr/local/elasticsearch-7.4.2

2.6 启动ES

2.6.1 启动报错

root@localhost config]# su esuser
[esuser@localhost config]$ whoami
esuser
root@localhost config]# cd /usr/local/elasticsearch-7.4.2/bin
root@localhost bin]# ./elasticsearch
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 [3756] for user [esuser] 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]

2.6.2 修改插入认证模式

Linux PAM: Pluggable Authentication Modules

[esuser@localhost config]$ su root
密码:
[root@localhost config]# vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
* 表示用户,* 表示所有用户
soft nproc 单个用户可用的最大进程数量(超过会警告);
hard nproc 单个用户可用的最大进程数量(超过会报错);
soft nofile 可打开的文件描述符的最大数(超过会警告);
hard nofile 可打开的文件描述符的最大数(超过会报错);

2.6.3 修改系统核心配置

[root@localhost config]# vi /etc/sysctl.conf
vm.max_map_count=262145
[root@localhost bin]# sysctl -p
vm.max_map_count = 262145

2.6.4 重新启动

root@localhost config]# su esuser
[esuser@localhost config]$ whoami
esuser
root@localhost config]# cd /usr/local/elasticsearch-7.4.2/bin

2.6.4.1 前台启动

root@localhost bin]# ./elasticsearch

2.6.4.2 后台启动

root@localhost bin]# ./elasticsearch -d

2.7 测试

虚拟机的IP + 9200即可访问ES服务

image-20210225160028956.png

2.8 停止ES服务

2.8.1 前台启动停止

ctrl + c 直接停止命令行就可以

2.8.2 后台启动停止

[root@localhost config]# jps
28696 Elasticsearch
29977 Jps
[root@localhost config]# kill 28696

3 相关信息

上一篇 下一篇

猜你喜欢

热点阅读