首页 > 系统相关 >Centos7下安装Elasticsearch6步骤

Centos7下安装Elasticsearch6步骤

时间:2023-03-24 13:04:31浏览次数:41  
标签:node ----------------------------------- 9200 步骤 Centos7 Elasticsearch6 elastics


Centos7下安装Elasticsearch6步骤

  • 1、安装jdk
  • 2、安装Elasticsearch
  • 1、新建一个esGroup组和用户(出于安全考虑,Elasticsearch默认是不允许使用root账号运行的)
  • 2、更改Elasticsearch文件的拥有者,默认所属root
  • 3、编辑 elasticsearch.yml
  • 3. 运行elasticsearch
  • 4、 在启动过程中的错误

1、安装jdk

由于es是基于Java开发的,所以在安装es之前我得先安装jdk,要求版本在1.8以上,如果linux上还没有安装jdk1.8的可以参考。

CentOS 7 安装 JAVA环境(JDK 1.8

2、安装Elasticsearch

上传安装包,并解压

tar -zxvf elasticsearch-6.2.4.tar.gz

Centos7下安装Elasticsearch6步骤_Elastic

bin          //主要存放的是elasticsearch相关的脚本文件
config       // 存放的是elasticsearch的配置文件
jdk         //elasticsearch自带的jdk
logs        //elasticsearch存放日志
modules     //elasticsearch的功能模块
plugins     //elasticsearch的插件,我们安装的插件存放在此目录

1、新建一个esGroup组和用户(出于安全考虑,Elasticsearch默认是不允许使用root账号运行的)

#新建组
groupadd esGroup 
#新建用户 
useradd esUser -g esGroup 
#切换用户
su esUser

2、更改Elasticsearch文件的拥有者,默认所属root

使用如下命令更改文件所属:

chown esUser:esGroup elasticsearch-6.2.4/ -R

Centos7下安装Elasticsearch6步骤_Elastic_02

3、编辑 elasticsearch.yml

在这里我们需要对elasticsearch进行相关的配置,编辑config目录下的elasticsearch.yml文件,重点关注以下7个配置项:

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
#cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /usr/local/elasticsearch-6.2.4/data  # 数据目录位置(没有需要创建目录属于主esUser)
#
# Path to log files:
#
path.logs: /usr/local/elasticsearch-6.2.4/logs  # 日志目录位置
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0  # 任何主机(绑定的ip)
#
# Set a custom port for HTTP:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true

3. 运行elasticsearch

首先先切换事先创建的esUser 用户 然后 进行 elasticsearch-6.2.4下的bin目录启动

su -es #切换用户
 
cd /elasticsearch-6.2.4/bin 
 
./elasticsearch #启动elasticsearch

Centos7下安装Elasticsearch6步骤_elasticsearch_03


需要注意是图中绑定了两个端口(9300和 9200):

9300:集群节点间通讯接口 9200:客户端访问接口

elasticsearch 的默认端口为9200,为方便测试,笔者将服务器9200端口开放,执行命令如下:

firewall-cmd --zone=public --add-port=9200/tcp --permanent
firewall-cmd --reload

然后 打开浏览器进行测试:

Centos7下安装Elasticsearch6步骤_Elastic_04

4、 在启动过程中的错误

注意:所有错误修改完毕,一定要重启你的 Xshell终端,否则配置无效。

ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解决第一个错误:

打开新的窗口切换到root用户,使用vim /etc/security/limits.conf命令编辑limits.conf,添加以下内容:

*  soft  nofile  65536
*  hard  nofile  65536

解决第二个错误:

elasticsearch用户拥有的内存权限太小,至少需要262144。切换root用户下,使用vim /etc/sysctl.conf命令编辑sysctl.conf文件。

添加以下内容:

vm.max_map_count=262144

执行 sysctl -p 使修改生效。

这里两个错误修改以后,在服务器没有重启的情况下重新启动 elasticsearch,第一个问题依然存在,需要重启服务器。


标签:node,-----------------------------------,9200,步骤,Centos7,Elasticsearch6,elastics
From: https://blog.51cto.com/u_13571520/6147101

相关文章

  • CentOS7关机重启之后,Mysql8启动不成功
    我在自己电脑上使用VM工具安装了虚拟机,CentOS7,里面继续安装了mysql8,下班的时候,直接把整个虚拟机关机了,没有依次关闭里面的服务,早上来的时候发现启动不来mysql 它提示用......
  • CentOS7 安装 Sublime Text3
    在官网下载,下载链接:http://www.sublimetext.com解压:sublime_text_build_4113_x64.tar.xz这是两层压缩,外面是xz压缩方式,里层是tar压缩[root@bogonwwwroot]#xz-dsublime_......
  • Centos7安装npm
    下载node镜像,这里我们选择node-v16.19.1-linux-x64.tar.gzwgethttps://nodejs.org/dist/v16.19.1/node-v16.19.1-linux-x64.tar.gz如果想下载其他版本,可以在https://......
  • Centos7搭建redis7集群
    redis集群搭建准备了3台主机,每台主机部署2个节点,整个集群3个master节点和3个slave节点组成主机:192.168.130.101 7001 7002      192.168.130.102 7001 70......
  • 客服系统对接公众号解决“该公众号提供的服务出现故障,请稍后再试”的操作步骤
    有段时间没去测试公众号的自动回复功能,今天一测,报错: “该公众号提供的服务出现故障,请稍后再试” 我记得之前并没有出现过这个错误,就去排查程序问题。 公众号出现......
  • 如何用Python对股票数据进行LSTM神经网络和XGboost机器学习预测分析(附源码和详细步骤),
    前言最近调研了一下我做的项目受欢迎程度,大数据分析方向竟然排第一,尤其是这两年受疫情影响,大家都非常担心自家公司裁员或倒闭,都想着有没有其他副业搞搞或者炒炒股、投资点......
  • centos7虚拟机静态ip
    1、查看网关       2、查看ip   vi配置进入vi/etc/sysconfig/network-scripts/ifcfg-ens33(文件后缀可能不一样)   重启网络 system......
  • centos7 中使用 express 并启动项目
    因为之前window安装了express,所以采用,直接将express项目传到linux中 步骤如下:   Express工程环境准备npminstallexpress-gnpminstallexpress-generato......
  • centos7 Linux 安装及升级node、npm
    centos7初始版本node6npm3 更新升级node版本#安装nnpminstall-gn#查看版本n--version//v9.0.1#把当前系统的Node更新成最新的“稳定版本”nstabl......
  • CentOS7配置ssh登录失败10次,自动封锁IP
    您可以按照以下步骤配置CentOS7以在SSH登录失败10次后自动封锁IP:安装fail2ban软件包:在终端中输入以下命令以安装fail2ban软件包:sudoyuminstallepel-releasesudoy......