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

来源:互联网 发布:windows 多线程 编辑:程序博客网 时间:2024/06/04 18:45

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





0 1
原创粉丝点击