1、刪除對應的es 節點
$head = 'Content-Type: application/json';
$json = '';
$res = Curl_es("http://127.0.0.1:9200/my_index_2?pretty",'DELETE',$json,$head);
function Curl_es($url, $method, $data_string, $head)
{
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array($head));
$result = curl_exec($ch);
if (curl_errno($ch)) {
print curl_error($ch);
}
curl_close($ch);
return $result;
}
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
$head = 'Content-Type: application/json';
$json = '{
"index":{
"blocks":{
"read_only_allow_delete":"false"
}
}}';
$res = Curl_es("http://10.10.1.136:9200/_settings?pretty", 'PUT', $json, $head);
3、es設置index.max_result_window(就是from+size,默認大小10000),可通過如下方式修改:
$head = 'Content-Type: application/json';
$json = '{
"index":{
"max_result_window": 10000000
}}';
$res = Curl_es("http://10.10.1.136:9200/_settings?pretty", 'PUT', $json, $head);
echo $res;
