I followed this link to create an elasticsearch 2 nodes cluster on Azure: this link
the installation and configuring went good.
When i started to check the cluster i found a strange behaviour from the php client.
I declared 2 hosts in the client:
$ELSEARCH_SERVER = array("dns1:9200","dns2:9200");
$params = array();
$params['hosts'] = $ELSEARCH_SERVER;
$dstEl = new Elasticsearch\Client($params);
the excpected behaviour is that it will try to insert the documents to "dns1" and if it fails it will automatically change to "dns2". but, for some reason when one of the servers is down on insertion the php client throws an exception that it couldn't connect to host and only.
Is there any way to cause the client automatically choose an online server?
thnx
Solution: After debugging the the elasticsearch php client I found a retry mechansim that allows the client to jump to the next server from the pool if the previous is down. this mechanism is disabled by default
to enable this mechanism you need to initialize the Client with a parameter called retries:
$params = array();
$params['hosts'] = $ELSEARCH_SERVER;
$params['retries'] = count($ELSEARCH_SERVER);
$dstEl = new Elasticsearch\Client($params);
Hope it will help you guys
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.