1.获取插件安装地址:https://github.com/NLPchina/elasticsearch-sql 选择与自己elasticsearch对应的版本,我这里的是6.8.0.0版本
./bin/elasticsearch-plugin install https://github.com/NLPchina/elasticsearch-sql/releases/download/6.8.0.0/elasticsearch-sql-6.8.0.0.zip
2.进入elasticsearch目录安装elasticsearch-sql插件,执行
cd /data/elasticsearch/ && ./elasticsearch-plugin install https://github.com/NLPchina/elasticsearch-sql/releases/download/6.8.0.0/elasticsearch-sql-6.8.0.0.zip
安装成功
3.修改elasticsearch配置文件,增加下面参数配置 【看样子应该是允许跨域访问的配置,因为下面的elasticsearch-sql web界面安装需要跨域访问】
vim /data/elasticsearch/config/elasticsearch.yml
http.cors.enabled: true http.cors.allow-credentials: true http.cors.allow-origin: "/.*/" http.cors.allow-headers: WWW-Authenticate,X-Requested-With,X-Auth-Token,Content-Type,Content-Length,Authorization
4.重启elasticsearch
supervisorctl restart elasticsearch
5.手动创建进入目录/data/elasticsearch/esplugin/elasicsearc-sql/
mkdir -p /data/elasticsearch/esplugin/elasicsearc-sql/ && cd /data/elasticsearch/esplugin/elasicsearc-sql/
6.下载elasticsearch 执行sql的程序包:es-sql-site-standalone.zip
wget https://github.com/NLPchina/elasticsearch-sql/releases/download/5.4.1.0/es-sql-site-standalone.zip
7.安装nodejs
yum install -y nodejs
8.解压es-sql-site-standalone.zip
unzip -o es-sql-site-standalone.zip
9.进入site-server,安装express,并保存
cd site-server/ && npm install express --save
10.使用screen运行es-sql-site-standalone
screen -S es_sql_web
node node-server.js
11.crul + a + d 退出screen
12.访问es-sql-site-standalone elasticsearch 执行sql语句界面
参数解析: http://es-sql-site-standalone_ip地址:8080/ :执行sql语句界面的地址 base_uri:elasticsearch api地址 username:登陆elasticsearch的用户名 password:登陆elasticsearch的密码 注意:如果elasticsearch没有开启认证,则不用用户密码这两个参数
13.平台使用方法
示例sql执行语句:SELECT fields.host_ip,server,name,message FROM bbh-game-2020.4.23 where name="gt"
fields.host_ip,server,name,message : 字段名
bbh-game-2020.4.23 : es中的索引名
Search : 支持模糊搜索,比较方便