08月04, 2017

elasticsearch2安装及导入导出

环境准备

JDK7+

软件准备

wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/rpm/elasticsearch/2.3.2/elasticsearch-2.3.2.rpm

插件

/usr/share/elasticsearch/bin/plugin install mobz/elasticsearch-head

配置

默认路径:etc/elasticsearch/config/elasticsearch.yml

#集群名(同一个集群,名称必须相同)
cluster.name: my-application
#服务节点名(每个服务节点不一样)
node.name: node-1
#数据存储路径
path.data: /www/data/elasticsearch
#服务日志路径
path.logs: /www/log/elasticsearch
#服务ip地址
network.host: 0.0.0.0
#服务端口
http.port: 9200

默认路径:/etc/sysconfig/elasticsearch
#设置为可用内存的50%
ES_HEAP_SIZE = 1g
#其余参数参考说明进行调优(JVM)

elasticsearch-tools

安装

npm install -g elasticsearch-tools

使用

# 查看所有索引
curl '192.168.1.54:9201/_cat/indices?v'

##
es-export-bulk --url http://192.168.1.54:9201 --file /www/backups/index_esIndex.json --index esIndex

es-import-bulk --url http://127.0.0.1:9200 --file /www/backups/index_esIndex.json

##
es-export-mappings --url http://192.168.1.54:9201 --file /www/backups/es.mappings.json

es-import-mappings --url http://127.0.0.1:9200 --file /www/backups/es.mappings.json

##
es-export-aliases --url http://192.168.1.54:9201 --file /www/backups/es.aliases.json

es-import-aliases --url http://127.0.0.1:9200 --file /www/backups/es.aliases.json


##
es-export-settings --url http://192.168.1.54:9201 --file /www/backups/es_intbee.settings.json

es-import-settings --url http://127.0.0.1:9200 --file /www/backups/es_intbee.settings.json

es 删除索引指定类型全部数据

/usr/share/elasticsearch/bin/plugin install delete-by-query
/usr/share/elasticsearch/bin/plugin remove delete-by-query
curl -XDELETE 'http://localhost:9200/index/data/_query' -d '{"query":{"match_all":{}}}'

5.5.3
curl -X POST 'http://localhost:9202/index/type/_delete_by_query' -d '{"query":{"match_all":{}}}'

curl -X GET 'http://localhost:9202/index/type/_search'

本文链接:https://blog.jnliok.com/post/elasticsearch-install.html

-- EOF --

Comments