Programing

ES 클러스터를 설정하는 방법은 무엇입니까?

lottogame 2020. 10. 15. 07:19
반응형

ES 클러스터를 설정하는 방법은 무엇입니까?


elasticsearch 클러스터를 실행하려는 5 대의 컴퓨터가 있고 모두 공유 드라이브에 연결되어 있다고 가정합니다. 세 가지 모두가 볼 수 있도록 Elasticsearch의 단일 사본을 해당 공유 드라이브에 넣었습니다. 모든 컴퓨터의 공유 드라이브에서 elasticsearch를 시작하면 클러스터링이 자동으로 마법을 작동합니까? 아니면 elasticsearch가 5 대의 컴퓨터에서 실행된다는 것을 깨닫도록 특정 설정을 구성해야합니까? 그렇다면 관련 설정은 무엇입니까? 복제본 구성에 대해 걱정해야합니까? 아니면 자동으로 처리됩니까?


아주 쉽습니다.

각 머신에 ElasticSearch의 자체 사본이 있어야합니다 (지금 가지고있는 머신을 복사하기 만하면됩니다). 이유는 각 머신 / 노드가 클러스터 전체에 걸쳐 분할 된 자체 파일을 유지하기 때문입니다.

정말로해야 할 일은 클러스터 이름을 포함하도록 구성 파일을 편집하는 것뿐입니다.

모든 머신이 동일한 클러스터 이름을 갖는 경우 elasticsearch가 나머지를 자동으로 수행합니다 (머신이 모두 동일한 네트워크에있는 한).

시작하려면 여기를 읽으십시오 : https://www.elastic.co/guide/en/elasticsearch/guide/current/deploy.html

인덱스 (데이터가가는 곳)를 만들 때 원하는 복제본 수를 정의합니다 (클러스터 전체에 분산 됨).


일반적으로 자동으로 처리됩니다.

자동 검색이 작동하지 않는 경우. 유니 캐스트 검색을 활성화하여 탄력적 검색 구성 파일 편집

노드 1 :

    cluster.name: mycluster
    node.name: "node1"
    node.master: true
    node.data: true
    discovery.zen.ping.multicast.enabled: false
    discovery.zen.ping.unicast.hosts: ["node1.example.com"]

노드 2 :

    cluster.name: mycluster
    node.name: "node2"
    node.master: false
    node.data: true
    discovery.zen.ping.multicast.enabled: false
    discovery.zen.ping.unicast.hosts: ["node1.example.com"]

노드 3,4,5에 대해서도 마찬가지입니다. 노드 1을 마스터로 만들고 나머지는 데이터 노드로만 만듭니다.

편집 : ES 규칙 N에 따라 N/2+1노드가있는 경우 규칙에 따라 노드는 장애 조치 메커니즘의 마스터 여야합니다.하지만 데이터 노드 일 수도 있고 아닐 수도 있습니다.

또한 자동 검색이 작동하지 않는 경우 가장 가능성이 높은 이유는 네트워크가이를 허용하지 않기 때문입니다 (따라서 비활성화 됨). 여러 서버에서 너무 많은 자동 검색 핑이 발생하면 해당 핑을 관리하는 리소스로 인해 다른 서비스가 올바르게 실행되지 않습니다.

예를 들어, 10,000 개의 노드 클러스터와 10,000 개의 모든 노드가 자동 핑을 수행한다고 생각해보십시오.


ES 2.0.2에서 @KannarKK가 제안한 단계를 시도했지만 클러스터를 시작하고 실행할 수 없었습니다. 분명히 마스터에서 tcp 포트 번호를 설정했듯이 슬레이브 구성에서 무언가를 알아 냈습니다. discovery.zen.ping.unicast.hosts는 검색을 위해 IP 주소 (tcp 포트 번호)와 함께 마스터의 포트 번호가 필요합니다. 따라서 다음 구성을 시도하면 나를 위해 작동합니다.

노드 1

cluster.name: mycluster
node.name: "node1"
node.master: true
node.data: true
http.port : 9200
tcp.port : 9300
discovery.zen.ping.multicast.enabled: false
# I think unicast.host on master is redundant.
discovery.zen.ping.unicast.hosts: ["node1.example.com"]

노드 2

cluster.name: mycluster
node.name: "node2"
node.master: false
node.data: true
http.port : 9201
tcp.port : 9301
discovery.zen.ping.multicast.enabled: false
# The port number of Node 1
discovery.zen.ping.unicast.hosts: ["node1.example.com:9300"]

Elastic Search 7 은 클러스터 초기화를위한 구성을 변경했습니다. 중요한 점은 ES 인스턴스가 일반적으로 인덱스에서 작업을 수행하는 데 사용되는 HTTP 프로토콜이 아닌 전송 계층 (TCP)을 사용하여 내부적으로 통신한다는 것입니다. 아래는 2 대의 머신 클러스터에 대한 샘플 구성입니다.

cluster.name: cluster-new
node.name: node-1
node.master: true
node.data: true
bootstrap.memory_lock: true
network.host: 0.0.0.0
http.port: 9200
transport.host: 102.123.322.211
transport.tcp.port: 9300
discovery.seed_hosts: [“102.123.322.211:9300”,"102.123.322.212:9300”]
cluster.initial_master_nodes: 
        - "node-1"
        - "node-2”

머신 2 구성 :-

cluster.name: cluster-new
node.name: node-2
node.master: true
node.data: true
bootstrap.memory_lock: true
network.host: 0.0.0.0
http.port: 9200
transport.host: 102.123.322.212
transport.tcp.port: 9300
discovery.seed_hosts: [“102.123.322.211:9300”,"102.123.322.212:9300”]
cluster.initial_master_nodes: 
        - "node-1"
        - "node-2”

cluster.name : 이것은 클러스터의 일부가 될 모든 시스템에서 동일합니다.

node.name : Identifier for the ES instance. Defaults to machine name if not given.

node.master: specifies whether this ES instance is going to be master or not

node.data: specifies whether this ES instance is going to be data node or not(hold data)

bootsrap.memory_lock: disable swapping.You can start the cluster without setting this flag. But its recommended to set the lock.More info: https://www.elastic.co/guide/en/elasticsearch/reference/master/setup-configuration-memory.html

network.host: 0.0.0.0 if you want to expose the ES instance over network. 0.0.0.0 is different from 127.0.0.1( aka localhost or loopback address). It means all IPv4 addresses on the machine. If machine has multiple ip addresses with a server listening on 0.0.0.0, the client can reach the machine from any of the IPv4 addresses.

http.port: port on which this ES instance will listen to for HTTP requests

transport.host: The IPv4 address of the host(this will be used to communicate with other ES instances running on different machines). More info: https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-transport.html

transport.tcp.port: 9300 (the port where the machine will accept the tcp connections)

discovery.seed_hosts: This was changed in recent versions. Initialise all the IPv4 addresses with TCP port(important) of ES instances that are going to be part of this cluster. This is going to be same across all ES instances that are part of this cluster.

cluster.initial_master_nodes: node names(node.name) of the ES machines that are going to participate in master election.(Quorum based decision making :- https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-discovery-quorums.html#modules-discovery-quorums)

참고URL : https://stackoverflow.com/questions/16821101/how-to-set-up-es-cluster

반응형