Last active
December 28, 2016 23:20
-
-
Save fedesilva/9416eef2468c7c944b46843f1b657d73 to your computer and use it in GitHub Desktop.
ES 5.1 java client fails to connect to single node cluster in localhost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ======================== Elasticsearch Configuration ========================= | |
# | |
# NOTE: Elasticsearch comes with reasonable defaults for most settings. | |
# Before you set out to tweak and tune the configuration, make sure you | |
# understand what are you trying to accomplish and the consequences. | |
# | |
# The primary way of configuring a node is via this file. This template lists | |
# the most important settings you may want to configure for a production cluster. | |
# | |
# Please see the documentation for further information on configuration options: | |
# <https://www.elastic.co/guide/en/elasticsearch/reference/5.0/settings.html> | |
# | |
# ---------------------------------- Cluster ----------------------------------- | |
# | |
# Use a descriptive name for your cluster: | |
# | |
cluster.name: counselytics | |
# | |
# ------------------------------------ Node ------------------------------------ | |
# | |
# Use a descriptive name for the node: | |
# | |
#node.name: node-1 | |
# | |
# Add custom attributes to the node: | |
# | |
#node.attr.rack: r1 | |
# | |
# ----------------------------------- Paths ------------------------------------ | |
# | |
# Path to directory where to store the data (separate multiple locations by comma): | |
# | |
#path.data: /path/to/data | |
# | |
# Path to log files: | |
# | |
#path.logs: /path/to/logs | |
# | |
# ----------------------------------- Memory ----------------------------------- | |
# | |
# Lock the memory on startup: | |
# | |
#bootstrap.memory_lock: true | |
# | |
# Make sure that the heap size is set to about half the memory available | |
# on the system and that the owner of the process is allowed to use this | |
# limit. | |
# | |
# Elasticsearch performs poorly when the system is swapping the memory. | |
# | |
# ---------------------------------- Network ----------------------------------- | |
# | |
# Set the bind address to a specific IP (IPv4 or IPv6): | |
# | |
#network.host: 192.168.0.1 | |
network.host: 10.0.1.2 | |
# | |
# Set a custom port for HTTP: | |
# | |
#http.port: 9200 | |
# | |
# For more information, see the documentation at: | |
# <https://www.elastic.co/guide/en/elasticsearch/reference/5.0/modules-network.html> | |
# | |
# --------------------------------- Discovery ---------------------------------- | |
# | |
# Pass an initial list of hosts to perform discovery when new node is started: | |
# The default list of hosts is ["127.0.0.1", "[::1]"] | |
# | |
#discovery.zen.ping.unicast.hosts: ["host1", "host2"] | |
# | |
# Prevent the "split brain" by configuring the majority of nodes (total number of nodes / 2 + 1): | |
# | |
#discovery.zen.minimum_master_nodes: 3 | |
# | |
# For more information, see the documentation at: | |
# <https://www.elastic.co/guide/en/elasticsearch/reference/5.0/modules-discovery-zen.html> | |
# | |
# ---------------------------------- Gateway ----------------------------------- | |
# | |
# Block initial recovery after a full cluster restart until N nodes are started: | |
# | |
#gateway.recover_after_nodes: 3 | |
# | |
# For more information, see the documentation at: | |
# <https://www.elastic.co/guide/en/elasticsearch/reference/5.0/modules-gateway.html> | |
# | |
# ---------------------------------- Various ----------------------------------- | |
# | |
# Require explicit names when deleting indices: | |
# | |
#action.destructive_requires_name: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
f@Omoikane:~/Workshop/elasticsearch/elasticsearch-5.0.2$ curl http://10.0.1.2:9200/_cluster/health?pretty=true | |
{ | |
"cluster_name" : "counselytics", | |
"status" : "green", | |
"timed_out" : false, | |
"number_of_nodes" : 1, | |
"number_of_data_nodes" : 1, | |
"active_primary_shards" : 0, | |
"active_shards" : 0, | |
"relocating_shards" : 0, | |
"initializing_shards" : 0, | |
"unassigned_shards" : 0, | |
"delayed_unassigned_shards" : 0, | |
"number_of_pending_tasks" : 0, | |
"number_of_in_flight_fetch" : 0, | |
"task_max_waiting_in_queue_millis" : 0, | |
"active_shards_percent_as_number" : 100.0 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Created by f on 10/25/16. | |
*/ | |
import java.nio.file._ | |
import java.net.InetAddress | |
import org.elasticsearch.action.admin.cluster.state.ClusterStateRequestBuilder | |
import org.elasticsearch.client.ElasticsearchClient | |
import org.elasticsearch.client.transport.TransportClient | |
import org.elasticsearch.index.query.{QueryBuilder, QueryBuilders} | |
import org.elasticsearch.common.settings.Settings | |
import org.elasticsearch.common.transport.InetSocketTransportAddress | |
import org.elasticsearch.transport.client.PreBuiltTransportClient | |
//val host = "127.0.0.1" | |
val host = "10.0.1.2" | |
val port = 9300 | |
val clusterName = "counselytics" | |
val ineta = InetAddress.getByName(host) | |
val insta = new InetSocketTransportAddress(ineta, port) | |
//initialize client | |
val settings = | |
Settings.builder() | |
.put("cluster.name", clusterName) | |
.put("client.transport.ping_timeout", "5s") | |
.put("client.transport.sniff", false) | |
.put("client.transport.ignore_cluster_name", true) | |
.build() | |
val client = new PreBuiltTransportClient(settings).addTransportAddress(insta) | |
val q = client.prepareSearch().setQuery(QueryBuilders.termQuery("hashtags", "fede")) | |
val r = q.execute().actionGet() | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> :load services/transition-queues/src/test/scripts/config.scala | |
Loading services/transition-queues/src/test/scripts/config.scala... | |
import java.nio.file._ | |
import com.csl.common.util.OptionSyntax._ | |
import com.csl.transitions._ | |
import com.typesafe.config._ | |
import java.net.InetAddress | |
import org.elasticsearch.action.admin.cluster.state.ClusterStateRequestBuilder | |
import org.elasticsearch.client.ElasticsearchClient | |
import org.elasticsearch.client.transport.TransportClient | |
import org.elasticsearch.index.query.{QueryBuilder, QueryBuilders} | |
import org.elasticsearch.common.settings.Settings | |
import org.elasticsearch.common.transport.InetSocketTransportAddress | |
import org.elasticsearch.transport.client.PreBuiltTransportClient | |
host: String = 10.0.1.2 | |
port: Int = 9300 | |
clusterName: String = counselytics | |
ineta: java.net.InetAddress = /10.0.1.2 | |
insta: org.elasticsearch.common.transport.InetSocketTransportAddress = 10.0.1.2:9300 | |
settings: org.elasticsearch.common.settings.Settings = org.elasticsearch.common.settings.Settings@45d00dd8 | |
client: org.elasticsearch.client.transport.TransportClient = org.elasticsearch.transport.client.PreBuiltTransportClient@1ac3526f | |
q: org.elasticsearch.action.search.SearchRequestBuilder = | |
{ | |
"query" : { | |
"term" : { | |
"hashtags" : { | |
"value" : "fede", | |
"boost" : 1.0 | |
} | |
} | |
}, | |
"ext" : { } | |
} | |
org.elasticsearch.client.transport.NoNodeAvailableException: None of the configured nodes are available: [{#transport#-1}{CNMkfq--T8mzs0iBNN8SDg}{10.0.1.2}{10.0.1.2:9300}] | |
at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:328) | |
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:226) | |
at org.elasticsearch.client.transport.TransportProxyClient.execute(TransportProxyClient.java:59) | |
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:345) | |
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:403) | |
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:80) | |
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:54) | |
... 65 elided | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment