ELKF之elasticsearch安装配置

来源:互联网 发布:jdk 7 linux x64.tar 编辑:程序博客网 时间:2024/05/29 23:45

  • ELKF之elasticsearch安装配置
    • 第三方依赖
    • 下载安装
    • 配置
      • 配置系统参数
      • 配置环境变量
      • 配置
      • 启动管理

ELKF之elasticsearch安装配置

第三方依赖

  • java运行环境
    java8及以上( Java 1.8.0_73 以上)

下载安装

  • 官方下载地址
    https://www.elastic.co/downloads/elasticsearch
  • 普通用户安装es5.5
    root用户无法启动elasticsearch
$ cd ~$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.5.0.tar.gz$ tar -zxvf elasticsearch-5.5.0.tar.gz

配置

配置系统参数

  • vm.max_map_count
    max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
# sysctl -a | grep "vm.max_map_count"# sysctl -w vm.max_map_count=655360# sysctl -a | grep "vm.max_map_count"
  • 文件描述符配置
    文件描述符配置设置为32k或者64k
    max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
# vim /etc/security/limits.conf   #追加如下,sim为用户名,同时确保用户有此命令权限sim soft nofile 65536sim hard nofile 65536$ cd $ES_HOME && vim bin/elasticsearch  #sim用户修改启动脚本,启动时可打印max file descriptors-Des.max-open-files=true位于如下位置exec "$JAVA" $ES_JAVA_OPTS -Des.max-open-files=true
  • max number of threads
    max number of threads [1024] for user [sim] is too low, increase to at least [2048]
# vim /etc/security/limits.conf   #追加如下sim soft    nproc     4096sim hard    nproc     4096
  • 锁定内存
# vim /etc/security/limits.conf   #追加如下,sim为用户名,同时确保用户有此命令权限sim soft memlock unlimitedsim hard memlock unlimited# vim /etc/sysctl.conf vm.swappiness=0# sysctl -p
  • limitss.conf生效
# vim /etc/pam.d/sshd   #ssh登录生效,追加session required /lib64/security/pam_limits.so# vim /etc/pam.d/login #登录生效,追加session required /lib64/security/pam_limits.so
  • 防火墙配置
# vi /etc/sysconfig/iptables  #添加如下-A INPUT -p tcp -m state --state NEW -m tcp --dport 9200 -j ACCEPT-A INPUT -p tcp -m state --state NEW -m tcp --dport 9300 -j ACCEPT# service iptables restart

配置环境变量

  • 配置全局
# vim /etc/profile.d/elasticsearch.sh  #追加如下export ES_HOME=/home/sim/elasticsearch-5.5.0export PATH=$ES_HOME/bin:$PATH#. /etc/profile#. /etc/bashrc# echo $ES_HOME
  • 配置当前用户
$ vim ~/.bash_profile  #追加如下export ES_HOME=~/elasticsearch-5.5.0export PATH=$ES_HOME/bin:$PATH$ source ~/.bash_profile# echo $ES_HOME

配置

$ echo $ES_HOME$ cd $ES_HOME$ vim config/elasticsearch.yml  #查询如键值项并修改cluster.name: es5-clusternnode.name: es-mainnetwork.host: 0.0.0.0http.port: 9200bootstrap.memory_lock: truebootstrap.system_call_filter: false

启动管理

  • 前台运行
$ cd $ES_HOME && bin/elasticsearch  
  • 后台运行
$ cd $ES_HOME && bin/elasticsearch -d$ tail -f logs/es5-cluster.log