es安装elasticsearch-sql插件

根据现有ES版本,安装对应版本的插件

[es@hxl ~]$ cd elasticsearch
[es@hxl elasticsearch]$ ./bin/elasticsearch-plugin install https://github.com/NLPchina/elasticsearch-sql/releases/download/6.5.0.0/elasticsearch-sql-6.5.0.0.zip

安装完sql插件后,最好重启一下es!


2、安装elasticsearch-sql前端页面

2.1 安装及更新一些依赖包
[root@hxl ~]# yum -y install epel-release
[root@hxl ~]# yum -y install npm
[root@hxl ~]# yum -y update openssl

2.2 下载安装elasticsearch-sql前端页面,并使用node命令启动
[es@hxl ~]$ wget https://github.com/NLPchina/elasticsearch-sql/releases/download/5.4.1.0/es-sql-site-standalone.zip
[es@hxl ~]$ unzip es-sql-site-standalone.zip
[es@hxl ~]$ cd site-server/
[es@hxl site-server]$ npm install express --save
[es@hxl site-server]$ node node-server.js

2.3 启动成功后,直接访问es主机地址的8080端口即可

3、elasticsearch-sql前端web默认端口修改

有时候可能8080端口我们已经有在使用了,这样elasticsearch-sql就没办法正常启动了,需要修改一下配置文件,重新启动即可。
[es@hxl ~]$ vi site-server/site_configuration.json
{
"port":9090
}
[es@hxl ~]$

4、使用sql查询es数据报错Cannot POST /_sql处理

测试使用sql查询es索引数据,发现有如下报错:
Error:"<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8">
直接修改web页面右上角文本框中连接地址为es节点查询地址,然后直接点下方search重新查询即可
如下,地址后面必须带上/
http://192.168.1.136:19200/


5.遇到错误1
Error:Error occured! response is not avalible.
解决办法,修改es配置文件
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

6.安装了xpack不想输入用户名密码
修改elasticsearch.yml,添加:

xpack.security.enabled: false

7.用户密码验证访问
​要是es部署了x-pack的话,需要用户和密码验证,则es-sql采用如下访问:
​http://192.168.1.136:8080/?username=elastic&password=elastic&base_uri=http://192.168.1.136:19200​

格式为:​http://es-sql-host:8080/?username=elastic&password=elastic&base_uri=es-server:19200​

原文地址:https://www.cnblogs.com/hxlasky/p/10316160.html