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

    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.1.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.那么主节点的基本配置就完成了,然后在所有的从节点上,分别重复这些配置步骤,然后修改一下ip地址就可以了,最后接下来就是怎样去启动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=262144

     执行命令:sysctl -p

 

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

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

 

 

7. 总结:

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

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

 

 

 

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值