linux安装elasticsearch部署配置详细说明

本文涉及的产品
检索分析服务 Elasticsearch 版,2核4GB开发者规格 1个月
简介: 版权声明:本文为博主原创文章,如需转载,请标明出处。 https://blog.csdn.net/alan_liuyue/article/details/78787103     ElasticSearch是一个基于Lucene的搜索服务器。
版权声明:本文为博主原创文章,如需转载,请标明出处。 https://blog.csdn.net/alan_liuyue/article/details/78787103

    ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。Elasticsearch是用Java开发的,并作为Apache许可条款下的开放源码发布,是当前流行的企业级搜索引擎。设计用于云计算中,能够达到实时搜索,稳定,可靠,快速的效果。

    ElasticSearch作为一个主流的搜索引擎,其完整的使用流程包括:

    (1)elasticsearch安装,配置ik分词器和pinyin插件;

    (2)安装kibana管理es工具;

    (3)安装logstash数据导入工具(导入工具可自行选择,该实例选择logstash导入工具)。


    那么,本篇博客先介绍elasticsearch5.6.1在linux系统上的具体安装步骤。

    1. 网上下载elasticsearch5.6.1的安装工具包,下载路径:elasticsearch5.6.1

   

     2.在linux上选择一个安装目录解压,然后进行文件的配置;

   

     3.首先进行elasticsearch.yml的配置,该文件位于config目录下,具体配置如下:

        

以下是配置集群,各属性配置说明,更多属性配置可自行添加
# ======================== 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 -----------------------------------
#
#集群名称
cluster.name: elastic_cluster
#
# ------------------------------------ Node ------------------------------------
#
#节点名称
node.name: node1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
#节点数据存放目录地址;默认是在ELASTICSEARCH _HOME/data下面,可自定义
#path.data: /path/to/data
#
#logs日志存放目录地址,可自定义
#path.logs: /path/to/logs
#
# ----------------------------------- Memory -----------------------------------
#是否锁定内存,以下两个一般设置为false
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
#
# 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):
#指定本机IP地址,自行修改为本机ip
network.host: 192.168.0.1
#指定本机http访问端口
http.port: 9200
#指定节点是否有资格被选举为主节点;默认true
node.master: true
#指定节点是否存储索引数据;默认true
node.data: true
#
# 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: ["192.168.1.1", "192.168.1.2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#设置集群最大主节点数量;默认1,范围值为1-4
discovery.zen.minimum_master_nodes: 1
#
# 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
#设置9200端口可以对外访问;比如head插件连es
http.cors.enabled: true
http.cors.allow-origin: "*"
   

     4.配置文件配置好之后,很多时候我们都希望添加自定义的比较优秀分词器,比如ik分词器,以下是安装分词器等插件的

    具体流程:

        (1)网上下载已经编译好的ik分词器和pinyin插件(未编译好的,可自行编译),如果没找到资源,可选择该路径下载已经

    编译好的分词器:elasticsearch-analysis-ik-5.6.1和elasticsearch-analysis-pinyin-5.6.1 

        (2)下载好分词器插件之后,在前面已经解压的elasticsearch文件夹里面有一个plugin文件夹,在这个文件夹下新建两个

    文件夹,一个是ik,另一个是pinyin,然后分别将解压之后的elasticsearch-analysis-ik-5.6.1里面的所有文件复制到ik文件夹里面,

    将解压之后的elasticsearch-analysis-pinyin-5.6.1里面的所有文件复制到pinyin文件夹里面,插件安装完成,当es启动的时候,

    就会自动加载里面的插件;

    

   5.那么基本配置就完成了,接下来就是怎样去启动es了,启动方式也很简单,进入es的bin目录下,执行./elasticsearch -d 的后台

    启动命令即可,然后执行命令ps aux|grep elasticsearch 查看是否有es进程,有则启动成功,没有则去logs目录下查看日志信息,

    看看是什么原因导致启动失败;


   6.初次安装和配置启动es,当然会少不了报错,很正常不过的事,那么接下来这里会总结几个常见的错误以及解决方法,具体如下:

     (1)root用户不允许启动es(官方说明是出于安全考虑)。首先在服务器创建一个新用户,授权。然后使用这个新用户启动es;


     (2)JDK版本不兼容,或者太低。安装es的JDK必须1.8或以上,在不改变当前JDK环境变量的情况下,可以在bin目录下的elasticsearch

    启动文件里面的头部新增如下命令(jdk1.8的linux版本如果没有需要自行下载,放到指定的路径下,然后java_home指定相应路径):

export JAVA_HOME=/usr/local/jdk1.8.0_121

export PATH=$JAVA_HOME/bin:$PATH

jdk1.8.0_121是自行下载的一个jdk版本,如果没有可自行下载;


    (3)出现问题:max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

   解决办法:切换root用户,进入到/etc/security/limits.conf

     底部添加:

     *  hard nofile 65536

     *  soft nofile 65536


(4) 出现问题:max number of threads [1024] for user [es] is too low, increase to at least [4096]

   解决办法:切换root用户,进入到/etc/security/limits.d/90-nproc.conf

     将soft nproc 1024 修改成soft nproc 4096


(5)出现问题:max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

   解决办法:切换root用户, 进入/etc/sysctl.conf

     添加vm.max_map_count=655360

     执行命令:sysctl -p


(6)如果以上的修改完成之后,重新连接打开服务器,如果系统还不生效,则重启linux服务器,切换root账户,

执行:shutdown -r now命令,重启服务器(该命令需要慎重,会重启服务器);



7. 总结:

    以上就是elasticsearch5.6.1版本在linux系统上的安装,各个版本的安装方法基本是一样的,具体问题具体分析,不过按照上面的

解决方法一般都是可以启动es的,希望能对安装es还有疑问的程序猿有所帮助,接下来的博客会讲述kibana管理工具的安装和配置。




相关实践学习
使用阿里云Elasticsearch体验信息检索加速
通过创建登录阿里云Elasticsearch集群,使用DataWorks将MySQL数据同步至Elasticsearch,体验多条件检索效果,简单展示数据同步和信息检索加速的过程和操作。
ElasticSearch 入门精讲
ElasticSearch是一个开源的、基于Lucene的、分布式、高扩展、高实时的搜索与数据分析引擎。根据DB-Engines的排名显示,Elasticsearch是最受欢迎的企业搜索引擎,其次是Apache Solr(也是基于Lucene)。 ElasticSearch的实现原理主要分为以下几个步骤: 用户将数据提交到Elastic Search 数据库中 通过分词控制器去将对应的语句分词,将其权重和分词结果一并存入数据 当用户搜索数据时候,再根据权重将结果排名、打分 将返回结果呈现给用户 Elasticsearch可以用于搜索各种文档。它提供可扩展的搜索,具有接近实时的搜索,并支持多租户。
相关文章
|
22小时前
|
关系型数据库 MySQL Java
Linux 安装 JDK、MySQL、Tomcat(图文并茂)
Linux 安装 JDK、MySQL、Tomcat(图文并茂)
12 2
|
1天前
|
Oracle Java 关系型数据库
Linux环境安装配置JDK11
Linux环境安装配置JDK11
12 0
|
1天前
|
负载均衡 Java 应用服务中间件
nginx安装在linux上
nginx安装在linux上
15 2
|
1天前
|
Ubuntu Linux
Linux(Ubuntu)系统临时IP以及静态IP配置(关闭、启动网卡等操作)
请注意,以上步骤是在临时基础上进行配置的。如果要永久保存静态IP地址,通常还需要修改 `/etc/network/interfaces`文件,以便在系统重启后保持配置。同时,确保备份相关配置文件以防止出现问题。
9 1
|
2天前
|
监控 安全 Linux
Linux系统之安装ServerBee服务器监控工具
【4月更文挑战第22天】Linux系统之安装ServerBee服务器监控工具
40 2
|
3天前
|
Ubuntu Linux 测试技术
Linux(32)Rockchip RK3568 Ubuntu22.04上部署 Docker: 详细配置与功能测试(下)
Linux(32)Rockchip RK3568 Ubuntu22.04上部署 Docker: 详细配置与功能测试
33 1
|
3天前
|
运维 网络协议 Linux
Linux(28) Linux双网卡配置为连接到Linux主机的PC提供外网访问
Linux(28) Linux双网卡配置为连接到Linux主机的PC提供外网访问
27 1
|
3天前
|
Linux 开发工具 Android开发
Docker系列(1)安装Linux系统编译Android源码
Docker系列(1)安装Linux系统编译Android源码
6 0
|
17天前
|
数据可视化 索引
elasticsearch head、kibana 安装和使用
elasticsearch head、kibana 安装和使用
|
29天前
|
存储 负载均衡 索引
linux7安装elasticsearch-7.4.0集群配置
linux7安装elasticsearch-7.4.0集群配置
113 0