elasticsearch 1.5 + mysql安装配置与简单使用

1.下载es:

https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.5.2.deb


2.安装:

dpkg -i elasticsearch-1.5.1.deb

3.启动es

/etc/init.d/elasticsearch start


4.mysql导入插件:

./bin/plugin -url http://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-river-jdbc/1.5.0.2/elasticsearch-river-jdbc-1.5.0.2-plugin.zip-install river-jdbc


5.创建jdbc driver:

curl -xput 'http://localhost:9200/_river/my_jdbc_river/_meta' -d '

{
    "type" : "jdbc",
    "jdbc" : {
        "url" : "jdbc:mysql://localhost:3306/xxx",
        "user" : "root",
        "password" : "xxx",
        "sql" : "select id,timestamp from xxxx",
      "index":"table",
      "type":"db"
    }
}'

6.删除:

curl -xdelete 'http://182.92.181.250:9200/db/table'


7.其他配置

可以通过schedule参数来配置es的定时更新。


8.客户端

当然也可以使用es的java客户端来操作增删改查

例如:

Client client = new TransportClient().addTransportAddress(new InetSocketTransportAddress("182.92.181.250", 9300));
GetResponse response = client.prepareGet().setIndex("_river").setType("table").execute().actionGet();
maven地址:
<dependency>
  <groupId>org.elasticsearch</groupId> 
  <artifactId>elasticsearch</artifactId> 
  <version>1.5.1</version> 
</dependency>
</pre>参考链接:<p></p><pre>
http://www.elasticsearch.cn/guide/
https://www.elastic.co/downloads
https://github.com/jprante/elasticsearch-jdbc#time-based-selecting
https://github.com/elastic/elasticsearch



 



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值