Elasticsearch 插件配置

Elasticsearch Plug-in 官方书说明

我的测试环境是Elasticsear 2.3.5

1.安装Elasticsearch(略)

2.安装Elasticsearch 插件

$ cd /usr/share/elasticsearch/
$ sudo bin/plugin install https://github.com/couchbaselabs/elasticsearch-transport-couchbase/releases/download/3.0.1-cypress/elasticsearch-transport-couchbase-3.0.1-alder-es2.3.5.zip

3.配置Elasticsearch

配置与couchbase通讯的账号密码

/etc/elasticsearch/elasticsearch.yml

couchbase.username: <USERNAME>
couchbase.password: <PASSWORD>
couchbase.maxConcurrentRequests: 1024

配置Elasticsearch索引Template

(不理解可参考:【基础篇】elasticsearch之索引模板Template

$ curl -X PUT http://localhost:9200/_template/couchbase -d @plugins/transport-couchbase/couchbase_template.json

注意一定要用@ 不要用./,否则会报错

配置成功返回

{"acknowledged":true}

创建一个Elasticsearch 索引用来接受couchbase 的桶数据,在配置XDCR时,“远程桶名”应该匹配Elasticsearch索引名称。

$ curl -X PUT http://localhost:9200/travel-sample

成功返回

{"acknowledged":true}

4.现在要配置CoucBaseServer,

打开CoucBaseWeb控制台并选择XDCR > Add Remote Cluster

在对话框中,输入您选择的群集名称、elasticsearch集群正在运行的IP /主机名和端口号(默认情况下,elasticsearch插件监听端口9091)和之前配置在在/etc/elasticsearch/elasticsearch.yml中的用户名/密码。

接下来,选择“Add Replication”选项。

在弹出窗口中,输入源桶、远程集群和远程桶(之前创建的Elasticsearch那个索引)。还确保将XDCR协议版本设置为1,并且将XDCR乐观复制阈值设置为最大值:20971520,以获得最佳性能。然后单击“保存”。

5.现在,elasticsearch的复制集已经启动并运行,可以在Elasticsearch节点上运行全文搜索查询。

$ curl localhost:9200/travel-sample/_search?q=san+francisco

结果:

{
    "took":5,
    "timed_out":false,
    "_shards":{"total":5,"successful":5,"skipped":0,"failed":0},
    "hits":{
        "total":1599,
        "max_score":11.965878,
        "hits":[
            {"_index":"travel-sample","_type":"couchbaseDocument","_id":"landmark_36047","_score":11.965878,"_source":{"meta":{"rev":"1-1508c18bdbb400000000000002000000","flags":33554432,"expiration":0,"id":"landmark_36047"}}},
            {"_index":"travel-sample","_type":"couchbaseDocument","_id":"landmark_25611","_score":11.905596,"_source":{"meta":{"rev":"1-1508c18bb43400000000000002000000","flags":33554432,"expiration":0,"id":"landmark_25611"}}},
            {"_index":"travel-sample","_type":"couchbaseDocument","_id":"landmark_25712","_score":11.905596,"_source":{"meta":{"rev":"1-1508c18bb61e00000000000002000000","flags":33554432,"expiration":0,"id":"landmark_25712"}}}
            ...
        ]
    }
}

Last updated

Was this helpful?