https://www.elastic.co/cn/subscriptions
Elasticsearch x-pack 监控功能
ES:优化
JVM最大最小内存调整
关闭swap分区
vm.max_map_count调整
ulimit调整
磁盘性能
ealasticsearch-dump ---->ES 的备份数据工具
网址:https://github.com/taskrabbit/elasticsearch-dump
git clone https://github.com/taskrabbit/elasticsearch-dump.git
npm install elasticdump -g
导出数据:
elasticdump --input=http://192.168.189.118:9200/vipinfo1 --output=$ |gzip >/data/vipinfo1.json.gz
++++++++++++++
es 防脑裂配置:
discovery.zen.minimum_master_nodes: 2
discovery.zen.fd.ping_interval: 10s ##间隔
discovery.zen.fd.ping_timeout: 60s ##超时
discovery.zen.fd.ping_tretries: 6 ## 重试
如果不是跨机房,这三个参数不用配。只需要配第一个
两个机房中间的线路断掉了,会重试6次,进行连接。每次间隔10秒钟,什么时候失败,如果60秒没有回应,就认为这一次连接失败了。
+++++++++++++++++++++++
中文分词器:
先插入一些数据:
curl -XPOST http://192.168.189.118:9200/index/fulltext/1 -H 'Content-Type:application/json' -d'
{"content":"美国留给伊拉克的是个烂摊子吗"}'
curl -XPOST http://192.168.189.118:9200/index/fulltext/2 -H 'Content-Type:application/json' -d'
{"content":"公安部:各地校车将享最高路权"}'
curl -XPOST http://192.168.189.118:9200/index/fulltext/3 -H 'Content-Type:application/json' -d'
{"content":"中韩渔警冲突调查:韩警平均每天扣1艘中国渔船"}'
curl -XPOST http://192.168.189.118:9200/index/fulltext/4 -H 'Content-Type:application/json' -d'
{"content":"中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"}'
查询:
curl -XPOST http://192.168.189.118:9200/index/fulltext/_search?pretty -H 'Content-Type:application/json' -d'
{
"query" : { "match" : { "content" : "中国" }},
"highlight" : {
"pre_tags" : ["<tag1>", "<tag2>"],
"post_tags" : ["</tag1>", "</tag2>"],
"fields" : {
"content" : {}
}
}
}'
查询的时候,分把 中国 分开,分成 ,中 国 ,找出,含有,中 含有国的内容,给搜索出来。
这不是我们想要的结果,于是就要安装一个中文分词器:
++++++++++++++++
中文分词器,官网:
https://github.com/medcl/elasticsearch-analysis-ik
安装,以插件方式安装,所有节点都要安装。
cd /usr/share/elasticsearch/bin/
./elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.6.0/elasticsearch-analysis-ik-6.6.0.zip
要对应你的elasticsearch 的版本
装完之后,所有ES节点都要重启服务。
+++++++++++++
先创建索引
curl -XPUT http://192.168.189.118:9200/index5
创建索引的时候指定分词器
curl -XPOST http://192.168.189.118:9200/index5/fulltext/_mapping -H 'Content-Type:application/json' -d'
{
"properties": {
"content": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word"
}
}
}'
然后,再插入一些数据
先插入一些数据:
curl -XPOST http://192.168.189.118:9200/index5/fulltext/1 -H 'Content-Type:application/json' -d'
{"content":"美国留给伊拉克的是个烂摊子吗"}'
curl -XPOST http://192.168.189.118:9200/index5/fulltext/2 -H 'Content-Type:application/json' -d'
{"content":"公安部:各地校车将享最高路权"}'
curl -XPOST http://192.168.189.118:9200/index5/fulltext/3 -H 'Content-Type:application/json' -d'
{"content":"中韩渔警冲突调查:韩警平均每天扣1艘中国渔船"}'
curl -XPOST http://192.168.189.118:9200/index5/fulltext/4 -H 'Content-Type:application/json' -d'
{"content":"中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"}'
再次搜索:中国
curl -XPOST http://192.168.189.118:9200/index5/_search?pretty -H 'Content-Type:application/json' -d'
{
"query" : { "match" : { "content" : "中国" }},
"highlight" : {
"pre_tags" : ["<tag1>", "<tag2>"],
"post_tags" : ["</tag1>", "</tag2>"],
"fields" : {
"content" : {}
}
}
}
'
curl -XPOST http://192.168.189.118:9200/index5/fulltext/_search?pretty -H 'Content-Type:application/json' -d'
{
"query" : { "match" : { "content" : "中国" }},
"highlight" : {
"pre_tags" : ["<tag1>", "<tag2>"],
"post_tags" : ["</tag1>", "</tag2>"],
"fields" : {
"content" : {}
}
}
}'
++++++++++++++++++