CentOS7.X安装elasticsearch-5.6.2

  1. 云栖社区>
  2. 博客>
  3. 正文

CentOS7.X安装elasticsearch-5.6.2

qq2233466866 2018-06-11 15:41:44 浏览1502
展开阅读全文

elasticsearch(ES)

  1. 安装JAVA_JDK
  2. 安装elasticsearch

    cd /root
    wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.2.tar.gz
    tar -zxvf elasticsearch-5.6.2.tar.gz
    mv /root/elasticsearch-5.6.2 /usr/local/elasticsearch
  3. 修改配置文件

    vim /usr/local/elasticsearch/config/elasticsearch.yml
    
    # node.name
    node.name: node-1
    # node.attr
    node.attr.rack: r1
    # 数据路径
    path.data: /usr/local/elasticsearch/data
    # 日志路径
    path.logs: /usr/local/elasticsearch/logs
    # IP绑定
    network.host: [局域网ip]
    # 设置端口
    http.port: 9200
    
    ESC
    :wq
  4. 运存分配

    vim /usr/local/elasticsearch/config/jvm.options
    
    # 分配1G内存(2G内存的服务器)
    -Xms1G
    # 分配1G内存(2G内存的服务器)
    -Xmx1G
    -XX:-AssumeMP
    
    ESC
    :wq
  5. 系统配置

    su root
    # 编辑sysctl.conf
    vim /etc/sysctl.conf
    # 设置最大内存占用1G(2G内存服务器)
    vm.max_map_count=1048576
    
    ESC
    :wq
    
    # 重载sysctl.conf配置
    sysctl -p
    
    # 编辑limits.conf
    vim /etc/security/limits.conf
    
    elasticsearch hard nofile 65536
    elasticsearch soft nofile 65536
    
    ESC
    :wq
  6. 启动elasticsearch

    useradd elasticsearch
    chown -R elasticsearch:elasticsearch /usr/local/elasticsearch
    su elasticsearch
    /usr/local/elasticsearch/bin/elasticsearch -d \
    -p /usr/local/elasticsearch/logs/elasticsearch.pid
  7. 防火墙配置

    su root
    systemctl enable firewalld
    systemctl start firewalld
    firewall-cmd --zone=public --add-port=9200/tcp --permanent
    firewall-cmd --zone=public --add-port=9300/tcp --permanent
    firewall-cmd --reload
  8. 检查是否成功运行

    curl http://[服务器局域网]:9200
  9. 开机启动

    su root
    vim /etc/rc.local
    
    su elasticsearch -c "/usr/local/elasticsearch/bin/elasticsearch -d -p /usr/local/elasticsearch/logs/elasticsearch.pid"
    
    ESC
    :wq

CURL管理所有索引

  1. 创建一个索引

    curl -XPUT 'http://[ip]:[port]/[index_name]?pretty'
  2. 查看所有索引

    curl 'http://[ip]:[port]/_cat/indices'
  3. 删除指定索引

    curl -XDELETE 'http://[ip]:[port]/[index_name]?pretty'

Console管理所有索引

  1. 创建一个索引

    PUT /[index_name]
  2. 删除多个索引

    DELETE /index_*
    DELETE /index_1,index_2
  3. 删除所有索引

    DELETE /*
    DELETE /_all
  4. 领支付宝红包支持作者
    扫码领支付宝红包

网友评论

登录后评论
0/500
评论
qq2233466866
+ 关注