ElasticSearch入门非JAVA开发者 - JAVAelasticsearch

1.Elasticsearch安装配置

2018-05-16  本文已影响6人  风云雄霸天下123456

参考:

  1. Elasticsearch官方文章

说明


前置说明:

  1. 需要单独安装配置java环境

安装

  1. 下载elasticsearch6.2.4
    aria2c https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.tar.gz
  2. 解压
    tar -zxvf elasticsearch-6.2.4.tar.gz

创建用户、用户组

  1. 创建用户组
    groupadd elasticsearch
  2. 创建用户
    useradd -s /sbin/nologin -g elasticsearch elasticsearch
  3. 将elasticsearch6.2.4目录属主设置成elasticsearch
    chown -R elasticsearch: elasticsearch-6.2.4

配置


配置systemctl管理

  1. 修改系统参数vm.max_map_count

    • 创建文件/usr/lib/sysctl.d/elasticsearch.conf
      vm.max_map_count=262144
      
    • 加载配置文件
      sysctl -p /usr/lib/sysctl.d/elasticsearch.conf
    • 查看参数
      sysctl -a | grep vm.max_map_count,如果修改成功则ok
  2. 添加systemctl配置文件

    • 创建文件/usr/lib/systemd/system/elasticsearch.service
      [Unit]
      Description=Elasticsearch
      Documentation=http://www.elastic.co
      Wants=network-online.target
      After=network-online.target
      
      [Service]
      RuntimeDirectory=elasticsearch
      Environment=ES_HOME=/data/soft/elasticsearch-6.2.4
      Environment=ES_PATH_CONF=/data/soft/elasticsearch-6.2.4/config
      Environment=PID_DIR=/var/run/elasticsearch
      EnvironmentFile=-/etc/sysconfig/elasticsearch
      
      WorkingDirectory=/data/soft/elasticsearch-6.2.4
      
      User=elasticsearch
      Group=elasticsearch
      
      ExecStart=/data/soft/elasticsearch-6.2.4/bin/elasticsearch -p ${PID_DIR}/elasticsearch.pid --quiet
      
      # StandardOutput is configured to redirect to journalctl since
      # some error messages may be logged in standard output before
      # elasticsearch logging system is initialized. Elasticsearch
      # stores its logs in /var/log/elasticsearch and does not use
      # journalctl by default. If you also want to enable journalctl
      # logging, you can simply remove the "quiet" option from ExecStart.
      StandardOutput=journal
      StandardError=inherit
      
      # Specifies the maximum file descriptor number that can be opened by this process
      LimitNOFILE=65536
      
      # Specifies the maximum number of processes
      LimitNPROC=4096
      
      # Specifies the maximum size of virtual memory
      LimitAS=infinity
      
      # Specifies the maximum file size
      LimitFSIZE=infinity
      
      # Disable timeout logic and wait until process is stopped
      TimeoutStopSec=0
      
      # SIGTERM signal is used to stop the Java process
      KillSignal=SIGTERM
      
      # Send the signal only to the JVM rather than its control group
      KillMode=process
      
      # Java process is never killed
      SendSIGKILL=no
      
      # When a JVM receives a SIGTERM signal it exits with code 143
      SuccessExitStatus=143
      
      [Install]
      WantedBy=multi-user.target
      
  3. systemctl管理
    systemctl start elasticsearch.service
    systemctl stop elasticsearch.service
    systemctl restart elasticsearch.service
    systemctl status elasticsearch.service


注意事项

  1. elasticsearch不能使用root用户启动
  2. 如果使用elasticsearch用户启动,请确保elasticsearch用户对 elasticsearch6.2.4目录有权限
  3. 注意系统参数有未修改成功,比如:vm.max_map_count
  4. jvm.options配置文件里的-Xms4g、-Xmx4g参数根据自己机器内存设置成合适的值
上一篇下一篇

猜你喜欢

热点阅读