Es 全文 PHP 操作


 

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;


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM