'Tribe'에 해당되는 글 2건

  1. 2015.12.09 [Elasticsearch] Tribe Node
  2. 2014.02.17 [elasticsearch] tribe node into 1.0.0

[Elasticsearch] Tribe Node

Elastic/Elasticsearch 2015. 12. 9. 12:05

tribe node는 서로 다른 cluster로 구성된 elasticsearch의 데이터에 대해서 질의 또는 색인이 가능 하도록 제공하는 기능 입니다.

RDBMS의 view 와 비슷한 개념이라고 생각 하시면 쉽습니다.


참고문서)

https://www.elastic.co/guide/en/elasticsearch/reference/2.1/modules-tribe.html

https://www.elastic.co/blog/clustering_across_multiple_data_centers

https://www.elastic.co/blog/tribe-node


이제 부터 간단하게 구성하는 방법을 살펴 보겠습니다.

elasticsearch 다운로드와 설치 과정은 아래 링크 참고하세요.

- https://www.elastic.co/guide/en/elasticsearch/reference/current/_installation.html

https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-configuration.html


1. 노드구성

위에서 이야기 한 것과 같이 서로 다른 Cluster라고 했습니다.

그렇기 때문에 standalone 구성의 cluster 두 개를 준비 하겠습니다.

더불어 tribe node 도 하나 구성을 합니다.

- 총 3개의 노드


2. 노드설정

- Cluster 1

[elasticsearch.yml]

cluster.name: t1-cluster

node.name: t1-node

http.port: 9201

transport.tcp.port: 9301

index.number_of_shards: 1

index.number_of_replicas: 0


- Cluster 2

[elasticsearch.yml]

cluster.name: t2-cluster

node.name: t2-node

http.port: 9202

transport.tcp.port: 9302

index.number_of_shards: 1

index.number_of_replicas: 0


- Tribe Node(cluster)

[elasticsearch.yml]

tribe.t1.cluster.name: "t1-cluster"

tribe.t1.discovery.zen.ping.multicast.enabled: false

tribe.t1.discovery.zen.ping.unicast.hosts: ["localhost:9301"]

tribe.t2.cluster.name: "t2-cluster"

tribe.t2.discovery.zen.ping.multicast.enabled: false

tribe.t2.discovery.zen.ping.unicast.hosts: ["localhost:9302"]

tribe.blocks.write: true

tribe.blocks.metadata: true

cluster.name: "tribe-cluster"

node.name: "tribe-node"

http.port: 9200


3. 클러스터실행

생성한 3개의 클러스터를 실행 합니다.


4. Cluste 1과 Cluster 2에 Index 생성 및 색인

그냥 구성 샘플이라 문서 하나씩만 색인 하겠습니다.


Cluster 1)

- sample1.json

{"index":{"_index":"db", "_type":"tbl"}}

{"number":"1","name":"MALICE MIZER","url":"http://www.last.fm/music/MALICE+MIZER","picture":"http://userserve-ak.last.fm/serve/252/10808.jpg","@timestamp":"2000-10-06T19:20:25.000Z"}


$ curl -XPOST http://localhost:9201/db/tbl/_bulk --data-binary @sample1.json


Cluster 2)

- sample2.json

{"index":{"_index":"db2", "_type":"tbl"}}

{"number":"2","name":"Diary of Dreams","url":"http://www.last.fm/music/Diary+of+Dreams","picture":"http://userserve-ak.last.fm/serve/252/3052066.jpg","@timestamp":"2001-10-06T19:20:25.000Z"}


$ curl -XPOST http://localhost:9202/db2/tbl/_bulk --data-binary @sample2.json


5. Tribe Node(Cluster)를 이용한 질의

질의) Cluster 1

$ curl -XGET "http://localhost:9200/db/_search" -d'

{

    "query": {

        "match_all": {}

    }

}'


결과)

{

   "took": 24,

   "timed_out": false,

   "_shards": {

      "total": 1,

      "successful": 1,

      "failed": 0

   },

   "hits": {

      "total": 1,

      "max_score": 1,

      "hits": [

         {

            "_index": "db",

            "_type": "tbl",

            "_id": "AVFhPAntBw75btupmZWX",

            "_score": 1,

            "_source": {

               "number": "1",

               "name": "MALICE MIZER",

               "url": "http://www.last.fm/music/MALICE+MIZER",

               "picture": "http://userserve-ak.last.fm/serve/252/10808.jpg",

               "@timestamp": "2000-10-06T19:20:25.000Z"

            }

         }

      ]

   }

}


질의) Cluster 2

curl -XGET "http://localhost:9200/db2/_search" -d'

{

    "query": {

        "match_all": {}

    }

}'


결과)

{

   "took": 16,

   "timed_out": false,

   "_shards": {

      "total": 1,

      "successful": 1,

      "failed": 0

   },

   "hits": {

      "total": 1,

      "max_score": 1,

      "hits": [

         {

            "_index": "db2",

            "_type": "tbl",

            "_id": "AVFha2Vz4YXacqLkqH0V",

            "_score": 1,

            "_source": {

               "number": "2",

               "name": "Diary of Dreams",

               "url": "http://www.last.fm/music/Diary+of+Dreams",

               "picture": "http://userserve-ak.last.fm/serve/252/3052066.jpg",

               "@timestamp": "2001-10-06T19:20:25.000Z"

            }

         }

      ]

   }

}


View 질의) Tribe Node(Cluster)

$ curl -XGET "http://localhost:9200/_search" -d'

{

    "query": {

        "match_all": {}

    }

}'


결과)

{

   "took": 12,

   "timed_out": false,

   "_shards": {

      "total": 2,

      "successful": 2,

      "failed": 0

   },

   "hits": {

      "total": 2,

      "max_score": 1,

      "hits": [

         {

            "_index": "db",

            "_type": "tbl",

            "_id": "AVFhPAntBw75btupmZWX",

            "_score": 1,

            "_source": {

               "number": "1",

               "name": "MALICE MIZER",

               "url": "http://www.last.fm/music/MALICE+MIZER",

               "picture": "http://userserve-ak.last.fm/serve/252/10808.jpg",

               "@timestamp": "2000-10-06T19:20:25.000Z"

            }

         },

         {

            "_index": "db2",

            "_type": "tbl",

            "_id": "AVFha2Vz4YXacqLkqH0V",

            "_score": 1,

            "_source": {

               "number": "2",

               "name": "Diary of Dreams",

               "url": "http://www.last.fm/music/Diary+of+Dreams",

               "picture": "http://userserve-ak.last.fm/serve/252/3052066.jpg",

               "@timestamp": "2001-10-06T19:20:25.000Z"

            }

         }

      ]

   }

}


※ 부가적으로 alias 기능과 함께 활용하시면 아주 유용하게 사용하실 수 있습니다.

:

[elasticsearch] tribe node into 1.0.0

Elastic/Elasticsearch 2014. 2. 17. 17:25

1.0.0 에 들어온 기능인데 이게 물건이내요.

문서만 일단 봤는데 ㅎㅎ 유용하게 써먹을 수 있을 것 같습니다.


http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/modules-tribe.html


간단하게 설명 하면 cluster 간 federated search 기능을 제공 하는 것입니다. :)

node.client 가 왜 생겼는지도 알겠내요. (꼭 이것 때문에 생긴건 아니겠지만...)

: