1、删除对应的es 节点
1$head = 'Content-Type: application/json'; 2$json = ''; 3$res = Curl_es("http://127.0.0.1:9200/my_index_2?pretty",'DELETE',$json,$head); 4 5function Curl_es($url, $method, $data_string, $head) 6{ 7 $ch = curl_init($url); 8 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); 9 curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); 10 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 11 curl_setopt($ch, CURLOPT_HTTPHEADER, array($head)); 12 $result = curl_exec($ch); 13 if (curl_errno($ch)) { 14 print curl_error($ch); 15 } 16 curl_close($ch); 17 return $result; 18}
2、retrying failed action with response code: 403 ({"type"=>"cluster_block_exception", "reason"=>"blocked by: [FORBIDDEN/12/index read-only / allow delete (api)]
这是由于ES新节点的数据目录data存储空间不足,导致从master主节点接收同步数据的时候失败,此时ES集群为了保护数据,会自动把索引分片index置为只读read-only
1$head = 'Content-Type: application/json'; 2$json = '{ 3 "index":{ 4 "blocks":{ 5 "read_only_allow_delete":"false" 6 } 7 }}'; 8$res = Curl_es("http://10.10.1.136:9200/_settings?pretty", 'PUT', $json, $head);
3、es设置index.max_result_window(就是from+size,默认大小10000),可通过如下方式修改:
1$head = 'Content-Type: application/json'; 2$json = '{ 3 "index":{ 4 "max_result_window": 10000000 5 }}'; 6$res = Curl_es("http://10.10.1.136:9200/_settings?pretty", 'PUT', $json, $head); 7echo $res;