1 存在未分片索引
1)找出未分片的索引
curl xxx/_cat/shards?v | grep UNASSIGNED
2)查看未分配的原因
curl -XGET 'http://xxx/_cluster/allocation/explain?pretty' -d '{
"index": "index_name",
"shard": 0,
"primary": true
}'
3)根據(jù)原因進(jìn)行處理纳寂,目前遇到過以下三種情況:
a. 某個節(jié)點的某個磁盤滿(手動移動分片到大磁盤機器即可闯两,最好用大磁盤機器)
b. allocation 限制盯串,不能分配(修改allocation的規(guī)則即可)
c. 重試次數(shù)達(dá)到限制,依然不能分配(手動嘗試即可 curl -XPOST 'xxx/_cluster/reroute?retry_failed&pretty')
2 下線剔除某臺機器
1) 不能用數(shù)組的形式
curl -XPUT 'http: //xxx/_cluster/settings?pretty' -d'{
"transient": {
"cluster.routing.allocation.exclude._ip": ["ip1","ip2","ip3"]
}
}'
2)逗號后面不能有空格
curl -XPUT 'http: //xxx/_cluster/settings?pretty' -d'{
"transient": {
"cluster.routing.allocation.exclude._ip": "ip1, ip2, ip3"
}
}'
3)正確的寫法
curl -XPUT 'http: //xxx/_cluster/settings?pretty' -d'{
"transient": {
"cluster.routing.allocation.exclude._ip": "ip1,ip2,ip3"
}
}'
3 機器突然重啟胖缤,ES節(jié)點不能正常啟動
這種主要是因為狀態(tài)文件為空導(dǎo)致的育苟,查看日志抖僵,找出狀態(tài)文件路徑晋渺,刪除即可。
Error injecting constructor, ElasticsearchException[java.io.IOException: failed to read [id:2, legacy:false, file:/data2/search/data/nodes/0/indices/QNpDowX_TwiIiqZlB9e92g/_state/state-2.st]]; nested: IOException[failed to read [id:2, legacy:false, file:/data2/search/data/nodes/0/indices/QNpDowX_TwiIiqZlB9e92g/_state/state-2.st]]; nested: IllegalStateException[class org.apache.lucene.store.BufferedChecksumIndexInput cannot seek backwards (pos=-16 getFilePointer()=0)];
at org.elasticsearch.gateway.GatewayMetaState.<init>(Unknown Source)
while locating org.elasticsearch.gateway.GatewayMetaState
Caused by: ElasticsearchException[java.io.IOException: failed to read [id:2, legacy:false, file:/data2/search/data/nodes/0/indices/QNpDowX_TwiIiqZlB9e92g/_state/state-2.st]]; nested: IOException[failed to read [id:2, legacy:false, file:/data2/search/data/nodes/0/indices/QNpDowX_TwiIiqZlB9e92g/_state/state-2.st]]; nested: IllegalStateException[class org.apache.lucene.store.BufferedChecksumIndexInput cannot seek backwards (pos=-16 getFilePointer()=0)];
找出空文件刪除即可:
find /data*/search/data/nodes/0/indices/ | grep state | grep "\.st" | xargs ls -l | awk '{if($5==0)print $0}'
-rw-rw-r-- 1 search search 0 Oct 1 22:53 /data2/search/data/nodes/0/indices/QNpDowX_TwiIiqZlB9e92g/_state/state-2.st
-rw-rw-r-- 1 search search 0 Oct 1 22:53 /data3/search/data/nodes/0/indices/QNpDowX_TwiIiqZlB9e92g/_state/state-2.st
-rw-rw-r-- 1 search search 0 Oct 1 22:53 /data4/search/data/nodes/0/indices/QNpDowX_TwiIiqZlB9e92g/_state/state-1.st
-rw-rw-r-- 1 search search 0 Oct 1 22:53 /data4/search/data/nodes/0/indices/QNpDowX_TwiIiqZlB9e92g/_state/state-2.st
4 查詢提示shard數(shù)達(dá)到限制
"reason" : "Trying to query 1344 shards, which is over the limit of 1000. This limit exists because querying
many shards at the same time can make the job of the coordinating node very CPU and/or memory
intensive. It is usually a better idea to have a smaller number of larger shards. Update
[action.search.shard_count.limit] to a greater value if you really want to query that many shards at the same time."
修改配置即可:
curl -u admin:admin -XPUT 'https://localhost:9200/_cluster/settings' -H 'Content-Type: application/json' -d'
{
"persistent" : {
"action.search.shard_count.limit" : "1500"
}
}
'
or
curl -u admin:admin -XPUT 'https://localhost:9200/_cluster/settings' -H 'Content-Type: application/json' -d'
{
"transient" : {
"action.search.shard_count.limit" : "1500"
}
}
'
persistent :重啟后依然有效
transient :重啟后無效
5 standard分詞器無法以逗號分割兩個數(shù)字字母字符串
我開發(fā)了一個分詞器a脓斩。有天查詢的時候發(fā)現(xiàn)木西,標(biāo)準(zhǔn)分詞器要比a查出的數(shù)據(jù)量少一半。查看不同文檔的分詞效果:
curl -XGET 'xx/xx/xx/AV9zRnrjq2szramqtpAT/_termvector?fields=strdescription&pretty=true'
發(fā)現(xiàn)標(biāo)準(zhǔn)分詞沒能將字符串分成想要的形式随静,比如說:
curl -XPOST 'xxx/_analyze?pretty' -H 'Content-Type: application/json' -d'
{
"tokenizer": "standard",
"text": "2d711b09bd0db0ad240cc83b30dd8014,2d711b09bd0db0ad240cc83b30dd8014,2d711b09bd0db0ad240cc83b30dd8014,2d711b09bd0db0ad240cc83b30dd8014"
}
'
針對與這種字符串我們期望字符串能夠按照逗號分割八千,但是用標(biāo)準(zhǔn)分詞你會發(fā)現(xiàn),這個字符串的term是它自己燎猛。具體原因應(yīng)該是:逗號兩邊都是數(shù)字恋捆,我們知道針對于一個大數(shù)字比如說10,000,我們喜歡在數(shù)字間加一個逗號重绷,所以上述字符串無法分割沸停。
解決方案:將逗號變?yōu)榭崭窦纯伞?/strong>