Linux安装elasticsearch

  1. 作者QQ:67065435 QQ群:821635552

  2. 安装JAVA

  3. 安装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
    
  4. 创建数据目录

    mkdir /data
    mkdir /data/search
    useradd elasticsearch
    chown -R elasticsearch:elasticsearch /data/search
    chown -R elasticsearch:elasticsearch /usr/local/elasticsearch
    
  5. 修改配置文件

    vim /usr/local/elasticsearch/config/elasticsearch.yml
    node.name: node-1
    node.attr.rack: r1
    path.data: /data/search
    network.host: 127.0.0.1
    http.port: 9200
    ESC
    :wq
    
  6. 系统配置

    su root
    
    vim /etc/sysctl.conf
    # 分配512M内存(1G内存的服务器)
    vm.max_map_count=524288
    ESC
    :wq
    
    # 重载sysctl.conf配置
    sysctl -p
    
    vim /usr/local/elasticsearch/config/jvm.options
    # 分配512M内存(1G内存的服务器)
    -Xms512M
    # 分配512M内存(1G内存的服务器)
    -Xmx512M
    -XX:-AssumeMP
    ESC
    :wq
    
    # 编辑limits.conf
    vim /etc/security/limits.conf
    * hard nofile 65535
    * soft nofile 65535
    ESC
    :wq
    
  7. 启动elasticsearch

    su elasticsearch
    /usr/local/elasticsearch/bin/elasticsearch -d
    
  8. 防火墙配置

    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
    
  9. 检查是否成功运行

    curl http://127.0.0.1:9200
    
  10. 进程管理

    cd /etc/systemd/system
    
    vim search.service
    
    [Unit]
    Description=Start elasticsearch on boot.
    After=default.target network.target
    
    [Service]
    User=elasticsearch
    Group=elasticsearch
    Type=forking
    ExecStart=/usr/local/elasticsearch/bin/elasticsearch -d
    PrivateTmp=false
    Restart=always
    
    [Install]
    WantedBy=multi-user.target
    
    ESC
    :wq
    
    systemctl daemon-reload
    systemctl enable search
    systemctl start search
    

CURL管理所有索引

  1. 创建一个索引

    curl -XPUT 'http://127.0.0.1:9200/test_key1?pretty'
    
  2. 查看所有索引

    curl 'http://127.0.0.1:9200/_cat/indices'
    
  3. 删除指定索引

    curl -XDELETE 'http://127.0.0.1:9200/test_key1?pretty'
    

Console管理所有索引

  1. 创建一个索引

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

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

    DELETE /*
    DELETE /_all
    
  4. 参考链接

  5. 参考链接

Copyright © 豆包嘿嘿~ 2012-∞ 冀ICP备17033181号 all right reserved,powered by Gitbook修订: 2012-12-31 12:00:00

results matching ""

    No results matching ""