elasticsearch分布式安装

install elasticsearch

  • **下载安装jdk8 **

  • 下载“elasticsearch-5.5.2.tar.gz”解压到/usr/local/elasticsearch目录下。

  • 启动elasticsearch

    es规定root不能启动es,所以创建一个es用户来启动

    #操作系统为centos7.4 虚拟机安装,内存较小。
    useradd es
    passwd es
    
    mkdir elasticsearch/data
    mkdir elasticsearch/logs
    
    chown -R es:es /usr/local/elasticsearch
    

    编辑配置文件config/elasticsearch.yml

    network.host: 0.0.0.0
    http.port: 9200
    

    切换到es用户,启动es

    su es
    ./bin/elasticsearch -d
    
  • 可能遇到的错误:

    [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

    解决办法:

    vim /etc/security/limits.conf
    
    # 在最后追加
    es hard nofile 65536
    es soft nofile 65536
    

    重新登录es用户,查看是否修改成功

    ulimit -Hn
    65536
    

    问题:

    [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

    解决:

    vim /etc/sysctl.conf
    
    #在最后追加
    vm.max_map_count=262144
    
    #使用sysctl -p 重新加载查看
    sysctl -p
    

    问题:

    cannot allocate memory…

    解决:

    #减少默认分配的内存大小
    vim config/jvm.options
    
    -Xms512m
    -Xmx512m
    

  • 关闭elasticsearch

    jps | grep elasticsearch
    
    kill -9 {pid}
    

分布式集群部署


vim config/elasticsearch.yml

#master

http.cors.enabled: true

http.cors.allow-origin: “*”

cluster.name: abel

node.name: master

node.master: true

#生产环境时换成实际IP

network.host: 0.0.0.0

http.port: 9200

重新解压安装包到另一个目录,修改slave的配置文件

#slave

cluster.name: abel

node.name: slave1

network.host: 0.0.0.0

http.port: 9501

#生产环境时换成实际master ip

discovery.zen.ping.unicast.hosts: [“127.0.0.1”]

elasticsearch-head插件安装


  • 下载解压

    wget https://github.com/mobz/elasticsearch-head/archive/master.zip
    unzip master.zip
    cd elasticsearch-head-master/
    
    

  • 安装npm

    #先安装nodejs
    curl --silent --location https://rpm.nodesource.com/setup_8.x | bash -
    yum install -y nodejs
    #查看版本
    node -v
    npm -v
    
    npm install
    #国内用这个源
    npm install -g cnpm --registry=https://registry.npm.taobao.org
    
    npm install -g grunt --registry=https://registry.npm.taobao.org
    
    
    #安装grunt依赖包
    npm install grunt-contrib-clean --registry=https://registry.npm.taobao.org
    npm install grunt-contrib-concat --registry=https://registry.npm.taobao.org
    npm install grunt-contrib-watch --registry=https://registry.npm.taobao.org
    npm install grunt-contrib-connect --registry=https://registry.npm.taobao.org
    npm install grunt-contrib-copy --registry=https://registry.npm.taobao.org
    npm install grunt-contrib-jasmine --registry=https://registry.npm.taobao.org
    
    #启动
    npm run start
    

    浏览器中输入9100端口即可打开head插件界面

    elasticsearch分布式安装_第1张图片

你可能感兴趣的:(INSTALL,elasticsearch)