我在服务器上以tar的形式安装了两个Elasticsearch节点,并在端口9200和9201上运行。
我希望两个主节点作为同一个集群运行。
每个都运行得很好,但是集群不起作用。
下面是我的elasticsearch.yml文件的网络设置。
节点-1
cluster.name: My-ElasticSearch
node.name: "node-1"
node.roles: [ master,data ]
network.host: 10.0.20.10
http.port: 9200
transport.port: 9300
discovery.seed_hosts: ["10.0.20.10:9300", "10.0.20.10:9301"]
cluster.initial_master_nodes: ["node-1", "node-2"]
http.cors.enabled: true
http.cors.allow-origin: "*"
transport.host: 10.0.20.10节点-1运行日志
[2022-09-27T00:47:12,272][INFO ][o.e.e.NodeEnvironment ] [node-1] using [1] data paths, mounts [[/ (/dev/mapper/ubuntu--vg-ubuntu--lv)]], net usable_space [75.9gb], net total_space [94.9gb], types [ext4]
[2022-09-27T00:47:12,272][INFO ][o.e.e.NodeEnvironment ] [node-1] heap size [3.8gb], compressed ordinary object pointers [true]
[2022-09-27T00:47:12,315][INFO ][o.e.n.Node ] [node-1] node name [node-1], node ID [IHal4DVSRCaUes8HN-VWjA], cluster name [My-ElasticSearch], roles [data, master]
[2022-09-27T00:47:14,805][INFO ][o.e.x.s.Security ] [node-1] Security is disabled
[2022-09-27T00:47:14,851][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [node-1] [controller/1758] [Main.cc@123] controller (64 bit): Version 8.3.3 (Build d2d2e518384d45) Copyright (c) 2022 Elasticsearch BV
[2022-09-27T00:47:15,193][INFO ][o.e.t.n.NettyAllocator ] [node-1] creating NettyAllocator with the following configs: [name=elasticsearch_configured, chunk_size=1mb, suggested_max_allocation_size=1mb, factors={es.unsafe.use_netty_default_chunk_and_page_size=false, g1gc_enabled=true, g1gc_region_size=4mb}]
[2022-09-27T00:47:15,214][INFO ][o.e.i.r.RecoverySettings ] [node-1] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]
[2022-09-27T00:47:15,240][INFO ][o.e.d.DiscoveryModule ] [node-1] using discovery type [multi-node] and seed hosts providers [settings]
[2022-09-27T00:47:16,286][INFO ][o.e.n.Node ] [node-1] initialized
[2022-09-27T00:47:16,287][INFO ][o.e.n.Node ] [node-1] starting ...
[2022-09-27T00:47:16,306][INFO ][o.e.x.s.c.f.PersistentCache] [node-1] persistent cache index loaded
[2022-09-27T00:47:16,307][INFO ][o.e.x.d.l.DeprecationIndexingComponent] [node-1] deprecation component started
[2022-09-27T00:47:16,486][INFO ][o.e.t.TransportService ] [node-1] publish_address {10.0.20.10:9300}, bound_addresses {10.0.20.10:9300}
[2022-09-27T00:47:17,110][INFO ][o.e.b.BootstrapChecks ] [node-1] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2022-09-27T00:47:17,114][WARN ][o.e.c.c.ClusterBootstrapService] [node-1] this node is locked into cluster UUID [YsU25ZUuQRqZNUG3YykAjg] but [cluster.initial_master_nodes] is set to [node-1, node-2]; remove this setting to avoid possible data loss caused by subsequent cluster bootstrap attempts
[2022-09-27T00:47:17,236][INFO ][o.e.c.s.MasterService ] [node-1] elected-as-master ([1] nodes joined)[_FINISH_ELECTION_, {node-1}{IHal4DVSRCaUes8HN-VWjA}{qc71eyIPTjS_SIckpcdmgg}{node-1}{10.0.20.10}{10.0.20.10:9300}{dm} completing election], term: 24, version: 996, delta: master node changed {previous [], current [{node-1}{IHal4DVSRCaUes8HN-VWjA}{qc71eyIPTjS_SIckpcdmgg}{node-1}{10.0.20.10}{10.0.20.10:9300}{dm}]}
[2022-09-27T00:47:17,290][INFO ][o.e.c.s.ClusterApplierService] [node-1] master node changed {previous [], current [{node-1}{IHal4DVSRCaUes8HN-VWjA}{qc71eyIPTjS_SIckpcdmgg}{node-1}{10.0.20.10}{10.0.20.10:9300}{dm}]}, term: 24, version: 996, reason: Publication{term=24, version=996}
[2022-09-27T00:47:17,328][INFO ][o.e.h.AbstractHttpServerTransport] [node-1] publish_address {10.0.20.10:9200}, bound_addresses {[::]:9200}
[2022-09-27T00:47:17,328][INFO ][o.e.n.Node ] [node-1] started {node-1}{IHal4DVSRCaUes8HN-VWjA}{qc71eyIPTjS_SIckpcdmgg}{node-1}{10.0.20.10}{10.0.20.10:9300}{dm}{xpack.installed=true}节点-1状态
ubuntu@elasticsearch:~$ curl http://10.0.20.10:9200/_cluster/health?pretty
{
"cluster_name" : "My-ElasticSearch",
"status" : "red",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 1,
"active_primary_shards" : 17,
"active_shards" : 17,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 4,
"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" : 80.95238095238095
}节点-2
cluster.name: My-ElasticSearch
node.name: node-2
node.roles: [ master ]
network.bind_host: 10.0.20.10
network.host: 10.0.20.10
network.publish_host: 10.0.20.10
http.port: 9201
transport.port: 9301
discovery.seed_hosts: ["10.0.20.10:9300", "10.0.20.10:9301"]
cluster.initial_master_nodes: ["node-1", "node-2"]
http.host: 10.0.20.10
http.cors.enabled: true
http.cors.allow-origin: "*"节点-2运行日志
[2022-09-27T00:53:20,372][INFO ][o.e.e.NodeEnvironment ] [node-2] using [1] data paths, mounts [[/ (/dev/mapper/ubuntu--vg-ubuntu--lv)]], net usable_space [75.9gb], net total_space [94.9gb], types [ext4]
[2022-09-27T00:53:20,372][INFO ][o.e.e.NodeEnvironment ] [node-2] heap size [4.6gb], compressed ordinary object pointers [true]
[2022-09-27T00:53:20,429][INFO ][o.e.n.Node ] [node-2] node name [node-2], node ID [PSaq7WA5RvSJduF-9Uk-KA], cluster name [My-ElasticSearch], roles [master]
[2022-09-27T00:53:23,022][INFO ][o.e.x.s.Security ] [node-2] Security is disabled
[2022-09-27T00:53:23,085][INFO ][o.e.x.m.p.l.CppLogMessageHandler] [node-2] [controller/1995] [Main.cc@123] controller (64 bit): Version 8.3.3 (Build d2d2e518384d45) Copyright (c) 2022 Elasticsearch BV
[2022-09-27T00:53:23,506][INFO ][o.e.t.n.NettyAllocator ] [node-2] creating NettyAllocator with the following configs: [name=elasticsearch_configured, chunk_size=1mb, suggested_max_allocation_size=1mb, factors={es.unsafe.use_netty_default_chunk_and_page_size=false, g1gc_enabled=true, g1gc_region_size=4mb}]
[2022-09-27T00:53:23,531][INFO ][o.e.i.r.RecoverySettings ] [node-2] using rate limit [40mb] with [default=40mb, read=0b, write=0b, max=0b]
[2022-09-27T00:53:23,560][INFO ][o.e.d.DiscoveryModule ] [node-2] using discovery type [multi-node] and seed hosts providers [settings]
[2022-09-27T00:53:24,634][INFO ][o.e.n.Node ] [node-2] initialized
[2022-09-27T00:53:24,635][INFO ][o.e.n.Node ] [node-2] starting ...
[2022-09-27T00:53:24,642][INFO ][o.e.x.d.l.DeprecationIndexingComponent] [node-2] deprecation component started
[2022-09-27T00:53:24,765][INFO ][o.e.t.TransportService ] [node-2] publish_address {10.0.20.10:9301}, bound_addresses {[::]:9301}
[2022-09-27T00:53:25,039][INFO ][o.e.b.BootstrapChecks ] [node-2] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2022-09-27T00:53:25,042][WARN ][o.e.c.c.ClusterBootstrapService] [node-2] this node is locked into cluster UUID [IOwpgSpjQYWX4Vr9f-Cx_g] but [cluster.initial_master_nodes] is set to [node-1, node-2]; remove this setting to avoid possible data loss caused by subsequent cluster bootstrap attempts
[2022-09-27T00:53:25,104][INFO ][o.e.c.s.MasterService ] [node-2] elected-as-master ([1] nodes joined)[_FINISH_ELECTION_, {node-2}{PSaq7WA5RvSJduF-9Uk-KA}{q8Ls3l-mR9u0pUJ4STb58w}{node-2}{10.0.20.10}{10.0.20.10:9301}{m} completing election], term: 19, version: 105, delta: master node changed {previous [], current [{node-2}{PSaq7WA5RvSJduF-9Uk-KA}{q8Ls3l-mR9u0pUJ4STb58w}{node-2}{10.0.20.10}{10.0.20.10:9301}{m}]}
[2022-09-27T00:53:25,164][INFO ][o.e.c.s.ClusterApplierService] [node-2] master node changed {previous [], current [{node-2}{PSaq7WA5RvSJduF-9Uk-KA}{q8Ls3l-mR9u0pUJ4STb58w}{node-2}{10.0.20.10}{10.0.20.10:9301}{m}]}, term: 19, version: 105, reason: Publication{term=19, version=105}
[2022-09-27T00:53:25,194][INFO ][o.e.h.AbstractHttpServerTransport] [node-2] publish_address {10.0.20.10:9201}, bound_addresses {10.0.20.10:9201}
[2022-09-27T00:53:25,195][INFO ][o.e.n.Node ] [node-2] started {node-2}{PSaq7WA5RvSJduF-9Uk-KA}{q8Ls3l-mR9u0pUJ4STb58w}{node-2}{10.0.20.10}{10.0.20.10:9301}{m}{xpack.installed=true}节点-2状态
ubuntu@elasticsearch:~$ curl http://10.0.20.10:9201/_cluster/health?pretty
{
"cluster_name" : "My-ElasticSearch",
"status" : "red",
"timed_out" : false,
"number_of_nodes" : 1,
"number_of_data_nodes" : 0,
"active_primary_shards" : 0,
"active_shards" : 0,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 2,
"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" : 0.0
}所有xpack安全设置都是假的。
下面是从头连接的结果。


为什么节点不分簇?请让我know...TT
(我在发帖之前对这个问题进行了编辑,因为我做得不好。)
val请求曲线
ubuntu@elasticsearch:~$ curl http://10.0.20.10:9200/
{
"name" : "node-1",
"cluster_name" : "My-ElasticSearch",
"cluster_uuid" : "YsU25ZUuQRqZNUG3YykAjg",
"version" : {
"number" : "8.3.3",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "801fed82df74dbe537f89b71b098ccaff88d2c56",
"build_date" : "2022-07-23T19:30:09.227964828Z",
"build_snapshot" : false,
"lucene_version" : "9.2.0",
"minimum_wire_compatibility_version" : "7.17.0",
"minimum_index_compatibility_version" : "7.0.0"
},
"tagline" : "You Know, for Search"
}
ubuntu@elasticsearch:~$ curl http://10.0.20.10:9201/
{
"name" : "node-2",
"cluster_name" : "My-ElasticSearch",
"cluster_uuid" : "IOwpgSpjQYWX4Vr9f-Cx_g",
"version" : {
"number" : "8.3.3",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "801fed82df74dbe537f89b71b098ccaff88d2c56",
"build_date" : "2022-07-23T19:30:09.227964828Z",
"build_snapshot" : false,
"lucene_version" : "9.2.0",
"minimum_wire_compatibility_version" : "7.17.0",
"minimum_index_compatibility_version" : "7.0.0"
},
"tagline" : "You Know, for Search"
}发布于 2022-09-27 08:44:07
我遵循马克·瓦尔科姆的方法,结果成功了。
在开始之前,您需要预先设置seed_host和initial_master_nodes。
但是,在运行时,我必须在时限内运行其余的节点。
运行第一个节点时,将显示以下消息。然后需要运行第二个节点。
[2022-09-27T07:44:01,557][WARN ][o.e.c.c.ClusterFormationFailureHelper] [node-1] master not discovered yet, this node has not previously joined a bootstrapped cluster, and this node must discover master-eligible nodes [node-1, node-2] to bootstrap a cluster: have discovered [{node-1}{NBsKhaguTKiH_JNJ6DkRYw}{zmC5Tel1QIWGl1eUq4fLXQ}{node-1}{10.20.0.10}{10.20.0.10:9300}{dm}]; discovery will continue using [10.0.20.10:9300, 10.0.20.10:9301] from hosts providers and [{node-1}{NBsKhaguTKiH_JNJ6DkRYw}{zmC5Tel1QIWGl1eUq4fLXQ}{node-1}{10.20.0.10}{10.20.0.10:9300}{dm}] from last-known cluster state; node term 0, last-accepted version 0 in term 0但是我想向已经创建的集群中添加一个节点。
这种方法太不方便了。
如果有人知道如何将节点添加到已经创建的集群中,请通知我。
https://stackoverflow.com/questions/73861141
复制相似问题