您的位置:首页 > 数据库 > MySQL

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

2015-05-09 13:58 746 查看
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



                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: