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 : 支持模糊搜索,比較方便