ElasticSearch使用教程

CentOS7上ElasticSearch安装

  • 安装解压

    1
    2
     tar -zxvf elasticsearch-7.0.0-beta1-linux-x86_64.tar.gz
    mv elasticsearch-7.0.0-beta1 /usr/local/elasticsearch
  • 启动(失败)

    1
    2
    3
     cd /usr/local/elasticsearch/
    cd /bin
    ./elasticsearch
  • elasticsearch5.0默认分配jvm空间大小为2g,需要改小一点

    1
    2
    3
    vim config/jvm.options  
    -Xms2g → -Xms512m
    -Xmx2g → -Xmx512m
  • 在 Linux 环境中,elasticsearch 不允许以 root 权限来运行!所以需要创建一个非root用户,以非root用户来起es

    1
    2
    3
    4
    groupadd elk  # 创建用户组elk
    useradd elk -g elk -p 88888888 # 创建新用户elk,-g elk 设置其用户组为 elk,-p 88888888 设置其密码8个8
    chown -R elk:elk /usr/local/elasticsearch # 更改 /elasticsearch 文件夹及内部文件的所属用户及组为 elk:elk
    su elk # 切换到非root用户elk下来
  • 修改config/elasticsearch.yml中的network.host为network.host: 0.0.0.0以便让外网任何IP都能来访问时。

    1
    2
    3
    4
    5
    6
    7
    8
    su root
    vim /etc/security/limits.conf

    * soft nofile 300000
    * hard nofile 300000
    * soft nproc 102400
    * soft memlock unlimited
    * hard memlock unlimited
  • 先要切换到root用户;然后可以执行以下命令,设置 vm.max_map_count ,但是重启后又会恢复为原值

    1
    sysctl -w vm.max_map_count=262144
  • 持久性的做法是在 /etc/sysctl.conf 文件中修改 vm.max_map_count 参数:

    1
    2
    echo "vm.max_map_count=262144" > /etc/sysctl.conf
    sysctl -p
  • the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured

  • Elasticsearch 通关教程(六): 自动发现机制 - Zen Discoveryedit

  • elk 启动

    1
    2
    3
    4
    su elk
    cd /usr/local/elasticsearch/
    cd /bin
    ./elasticsearch
  • 安装可视化插件 elasticsearch-head

    1
    2
    3
    4
    git clone git://github.com/mobz/elasticsearch-head.git
    cd elasticsearch-head
    npm install # 此处我试图用cnpm install有问题,用npm可以
    npm run start
-------------本文结束感谢您的阅读-------------
undefined