PS:6.3 开始 ElasticSearch 自身已经支持SQL查询。
github地址:https://github.com/NLPchina/elasticsearch-sql
一、在线安装
直接执行
./bin/elasticsearch-plugin install https://github.com/NLPchina/elasticsearch-sql/releases/download/6.3.2.0/elasticsearch-sql-6.3.2.0.zip
二、离线安装
下载离线安装包,放在es目录下
[es@jast elasticsearch-6.3.2]$ pwd
/home/es/elasticsearch-6.3.2
[es@jast elasticsearch-6.3.2]$ wget https://github.com/NLPchina/elasticsearch-sql/releases/download/6.3.2.0/elasticsearch-sql-6.3.2.0.zip
安装
./bin/elasticsearch-plugin install file:/home/es/elasticsearch-6.3.2/elasticsearch-sql-6.3.2.0.zip
查看是否安装成功
进入es插件目录查看,是否有相应jar包
[es@jast elasticsearch-6.3.2]$ cd plugins/
[es@jast plugins]$ ls
sql
[es@jast plugins]$ pwd
/home/es/elasticsearch-6.3.2/plugins
[es@jast plugins]$ ls sql/
druid.jar parent-join-client-6.3.2.jar
elasticsearch-sql-6.3.2.0.jar plugin-descriptor.properties
guava.jar reindex-client-6.3.2.jar
重启服务
在Kibana中访问方法为:GET _sql?sql=SELECT * FROM TABLENAME
浏览器访问方法为:http://ip:9200/_sql?sql=SELECT * FROM TABLENAME
三、ElasticSearch SQL 可视化工具
下载服务(支持6.x版本)
wget http://github.com/NLPchina/elasticsearch-sql/releases/download/5.4.1.0/es-sql-site-standalone.zip
解压下载文件,并安装服务
[es@jast el_sql]$ cd site-server/
[es@jast site-server]$ ls
node-server.js package.json site_configuration.json
[es@jast site-server]$ npm install express --save
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN site-server No description
npm WARN site-server No repository field.
npm WARN site-server No license field.+ express@4.17.1
added 50 packages from 37 contributors and audited 126 packages in 19s
found 0 vulnerabilities[es@jast site-server]$
修改默认端口
[es@jast es-web]$ vim site-server/site_configuration.json
{"port":5602
}
执行服务
node node-server.js
访问页面可以直接执行sql了
ps: 7.x http查询方法,使用post查询