CentOS7.X安裝elasticsearch-5.6.2

qq2233466866發表於2018-06-11

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. 系統配置

    su root
    # 編輯sysctl.conf
    vim /etc/sysctl.conf
    # 設定最大記憶體佔用1G(1024x1024)
    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
  5. 啟動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
  6. 防火牆配置

    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
  7. 檢查是否成功執行

    curl http://[伺服器區域網]:9200
  8. 開機啟動

    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. 領支付寶紅包支援作者
    掃碼領支付寶紅包


相關文章