NoNodeAvailableException [没有配置的节点可用:[{#transport#-1} {9aXcbriVQwSLq0iSUXBzrA} {127.0.0.1} {127.0.0.1:9300}]]

时间:2018-06-06 20:54:15

标签: elasticsearch elasticsearch-5 elasticsearch-java-api

    Settings settings =Settings.builder().put("cluster.name", "my-application").build();
    TransportClient client = new PreBuiltTransportClient(settings)
            .addTransportAddress(new TransportAddress(InetAddress.getByName("127.0.0.1"), 9300));

    System.out.println("Culster find");

    IndicesAdminClient indicesAdminClient = client.admin().indices();

    client.admin().indices().prepareCreate("index_naval").get();

    client.admin().indices().prepareCreate("index_naval")
            .setSettings(Settings.builder()
                    .put("index.number_of_shards", 3)
                    .put("index.number_of_replicas", 2)
            )
            .get();

    client.admin().indices().prepareCreate("index_naval")
            .addMapping("\"index_naval_type\": {\n" +
                    "  \"properties\": {\n" +
                    "    \"message\": {\n" +
                    "      \"type\": \"text\"\n" +
                    "    }\n" +
                    "  }\n" +
                    "}")
            .get();

上面是My Java,elasticSearchApp.java代码。 而我的elasticsearch.yml是。

cluster.name:my-application

xpack.security.transport.filter.allow:127.0.0.1

xpack.security.enabled:false

xpack.security.transport.ssl.enabled:false

xpack.security.http.ssl.enabled:false

------------------------------------节点---------- --------------------

node.name:my-rack

node.attr.rack:my-rack

node.master:true

node.data:true

0 个答案:

没有答案