zoukankan      html  css  js  c++  java
  • elasticsearch 跨集群搜索

    //启动3个集群
    
    bin/elasticsearch -E node.name=cluster0node -E cluster.name=cluster0 -E path.data=cluster0_data -E discovery.type=single-node -E http.port=9200 -E transport.port=9300
    bin/elasticsearch -E node.name=cluster1node -E cluster.name=cluster1 -E path.data=cluster1_data -E discovery.type=single-node -E http.port=9201 -E transport.port=9301
    bin/elasticsearch -E node.name=cluster2node -E cluster.name=cluster2 -E path.data=cluster2_data -E discovery.type=single-node -E http.port=9202 -E transport.port=9302
    
    
    //在每个集群上设置动态的设置
    PUT _cluster/settings
    {
      "persistent": {
        "cluster": {
          "remote": {
            "cluster0": {
              "seeds": [
                "127.0.0.1:9300"
              ],
              "transport.ping_schedule": "30s"
            },
            "cluster1": {
              "seeds": [
                "127.0.0.1:9301"
              ],
              "transport.compress": true,
              "skip_unavailable": true
            },
            "cluster2": {
              "seeds": [
                "127.0.0.1:9302"
              ]
            }
          }
        }
      }
    }
    
    #cURL
    curl -XPUT "http://localhost:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
    {"persistent":{"cluster":{"remote":{"cluster0":{"seeds":["127.0.0.1:9300"],"transport.ping_schedule":"30s"},"cluster1":{"seeds":["127.0.0.1:9301"],"transport.compress":true,"skip_unavailable":true},"cluster2":{"seeds":["127.0.0.1:9302"]}}}}}'
    
    curl -XPUT "http://localhost:9201/_cluster/settings" -H 'Content-Type: application/json' -d'
    {"persistent":{"cluster":{"remote":{"cluster0":{"seeds":["127.0.0.1:9300"],"transport.ping_schedule":"30s"},"cluster1":{"seeds":["127.0.0.1:9301"],"transport.compress":true,"skip_unavailable":true},"cluster2":{"seeds":["127.0.0.1:9302"]}}}}}'
    
    curl -XPUT "http://localhost:9202/_cluster/settings" -H 'Content-Type: application/json' -d'
    {"persistent":{"cluster":{"remote":{"cluster0":{"seeds":["127.0.0.1:9300"],"transport.ping_schedule":"30s"},"cluster1":{"seeds":["127.0.0.1:9301"],"transport.compress":true,"skip_unavailable":true},"cluster2":{"seeds":["127.0.0.1:9302"]}}}}}'
    
    
    #创建测试数据
    curl -XPOST "http://localhost:9200/users/_doc" -H 'Content-Type: application/json' -d'
    {"name":"user1","age":10}'
    
    curl -XPOST "http://localhost:9201/users/_doc" -H 'Content-Type: application/json' -d'
    {"name":"user2","age":20}'
    
    curl -XPOST "http://localhost:9202/users/_doc" -H 'Content-Type: application/json' -d'
    {"name":"user3","age":30}'
    
    
    #查询
    GET /users,cluster1:users,cluster2:users/_search
    {
      "query": {
        "range": {
          "age": {
            "gte": 20,
            "lte": 40
          }
        }
      }
    }
  • 相关阅读:
    leetcode: Combination Sum II
    leetcode: Combination Sum
    leetcode: Count and Say
    leetcode: Sudoku Solver
    leetcode: Linked List Cycle II
    selenium采用xpath方法识别页面元素
    selenium采用find_element_by方法识别页面元素
    selenium中webdriver识别class属性多个值中有空格的解决方案
    解决多个py模块调用同一个python的logging模块,打印日志冲突问题
    封装selenium自动化框架中的截图功能
  • 原文地址:https://www.cnblogs.com/wangchuanfu/p/14200787.html
Copyright © 2011-2022 走看看