zoukankan      html  css  js  c++  java
  • 一、elasticsearch部署

    Elasticsearch官网: https://www.elastic.co/products/elasticsearch

    一、Linux单节点部署

    1. 解压elasticsearch-5.6.1.tar.gz到安装目录下,这里使用的是/opt/module

      $ tar -zxvf elasticsearch-5.6.1.tar.gz -C /opt/module/

    2. 在/opt/module/elasticsearch-5.6.1路径下创建data和logs文件夹

      $ mkdir data

      $ mkdir logs

    3. 修改配置文件/opt/module/elasticsearch-5.2.2/config/elasticsearch.yml

      $ pwd

      /opt/module/elasticsearch-5.6.1/config

      $ vi elasticsearch.yml

    # ---------------------------------- Cluster -------------------------

    cluster.name: my-application

    # ------------------------------------ Node --------------------------------------

    node.name: node-102

    # ----------------------------------- Paths ---------------------------------------

    path.data: /opt/module/elasticsearch-5.6.1/data

    path.logs: /opt/module/elasticsearch-5.6.1/logs

    # ----------------------------------- Memory -----------------------------------

    bootstrap.memory_lock: false

    bootstrap.system_call_filter: false

    # ---------------------------------- Network ------------------------------------

    network.host: 192.168.1.102

    # --------------------------------- Discovery ------------------------------------

    discovery.zen.ping.unicast.hosts: ["hadoop102"]

    解释:

    (1)cluster.name:集群名称,如果要配置集群需要两个节点上的elasticsearch配置的cluster.name相同,都启动可以自动组成集群,这里如果不改cluster.name则默认是cluster.name=my-application。

    (2)nodename:节点名称,随意取名字,但是集群内的各节点不能相同。

    (3)修改后的每行前面不能有空格,修改后的“:”后面必须有一个空格

    4.  配置linux系统环境(为了避免Elasticsearch在使用资源时受限,参考:http://blog.csdn.net/satiling/article/details/59697916)

    (1)编辑limits.conf 添加类似如下内容

      $ sudo vi /etc/security/limits.conf

      添加如下内容:

      * soft nofile 65536

      * hard nofile 131072

      * soft nproc 4096

      * hard nproc 4096

     (2)进入limits.d目录下修改配置文件。(看一下limits.d,可能名字并不是90-nproc.conf)

      $ sudo vi /etc/security/limits.d/90-nproc.conf

      修改如下内容:

        * soft nproc 1024

      修改为

        * soft nproc 4096

    (3)修改配置sysctl.conf

      $ sudo vi /etc/sysctl.conf 

      添加下面配置:

        vm.max_map_count=655360

      并执行命令:

        $ sudo sysctl -p

      然后,重新启动elasticsearch,即可启动成功。

    5. 启动elasticsearch

      $ cd /opt/module/elasticsearch-5.6.1

      $ bin/elasticsearch

    6. 测试elasticsearch

      curl http://hadoop102:9200

      curl -XGET 'localhost:9200/_cat/health?v&pretty'

    二、安装Elasticsearch(多节点集群Linux环境)

     

    1. 分发Elasticsearch安装包至hadoop103和hadoop104

       $ xsync elasticsearch-5.6.1/

     2. 修改hadoop102配置信息

       $ vi elasticsearch.yml

       添加如下信息:

         node.master: true

         node.data: true

     3. 修改hadoop103配置信息

     (1)修改Elasticsearch配置信息

       $ vi elasticsearch.yml

         node.name: node-103

         node.master: false

         node.data: true

         network.host: 192.168.1.103

     (2)修改Linux相关配置信息(同hadoop102)

     4. 修改hadoop104配置信息

     (1)修改Elasticsearch配置信息

      $ vi elasticsearch.yml

       node.name: node-104

       node.master: false

       node.data: true

       network.host: 192.168.1.104

     (2)修改Linux相关配置信息(同hadoop102)

     5. 分别启动三台节点的Elasticsearch

     

     三、启动异常

     1. 使用root用户启动失败

      elasticsearch是不支持使用root账号启动程序的,会报错:“Caused by: java.lang.RuntimeException: can not run elasticsearch as root”:

      解决办法:切换到其他用户启动。

     

    2. elasticsearch安装目录权限不对

      如果elasticsearch就是使用root账号部署的,启动时就会出报错:

      Exception in thread "main" 2018-06-03 17:36:23,881 main ERROR No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'log4j2.debug' to show Log4j2 internal initialization logging.

      Caused by: java.nio.file.AccessDeniedException: /usr/local/elasticsearch-5.6.0/config/elasticsearch.yml

      解决办法:

      查看文件权限,命令 # ll /usr/local/

        drwxr-xr-x  7 root root       123 4月   7 2018 elasticsearch-5.6.2

      说明这个文件夹属于root用于,其他用户没权限执行,修改文件权限命令如下,elk是用户名:

      chown  -R elk:elk elasticsearch-5.6.0

     

     

     

     

  • 相关阅读:
    [音乐欣赏]为你读诗背景音乐,音乐电台
    [读书笔记]1368个单词就够了
    [读书笔记]项目管理实战:Microsoft Project精髓与方法
    [音乐欣赏]动力火车 艾琳娜
    [办公自动化]PDF大小不一如何调整
    [读书笔记]左手数据,右手图表
    [写作新思路]数据分析
    揪出Android流氓软件
    [办公自动化]Wlan无法启动,无法连接无线网wifi,所有无线网都搜索不到
    日常UVA题目英语积累
  • 原文地址:https://www.cnblogs.com/huanshilang/p/10880074.html
Copyright © 2011-2022 走看看