elasticsearch(ES)

  1. 参考链接

  2. 参考配置

  3. 安装JAVA_JDK

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

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

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

     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
    
  8. 启动elasticsearch

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

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

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

     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
    
@耿志环 2012-∞ 冀ICP备17033181号, powered by Gitbook修订: 2019-08-05 17:09:02

results matching ""

    No results matching ""