无外网环境下ES5.x安装sql插件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了无外网环境下ES5.x安装sql插件相关的知识,希望对你有一定的参考价值。
说明:
1、服务器默认不能访问外网,所以网上安装sql插件的方法都不能满足
2、当前ES版本5.6.3
3、sql插件下载地址:https://github.com/NLPchina/elasticsearch-sql
1、下载ES 5.6.3对应的sql插件:
由于服务器不能访问外网,所以只能通过浏览器下载,然后上传到服务器,将插件上传到ES的plugins插件目录
附件是对应插件文件
2、安装sql插件:
[[email protected] plugins]# pwd
/home/tools/es5.6/plugins
[[email protected] plugins]# ll
total 4508
-rw-r--r-- 1 root root 4614236 Jun 1 14:12 elasticsearch-sql-5.6.3.0.zip
将插件解压即可:
#解压插件
[[email protected] plugins]# unzip elasticsearch-sql-5.6.3.0.zip
Archive: elasticsearch-sql-5.6.3.0.zip
creating: elasticsearch/
extracting: elasticsearch/druid.jar
extracting: elasticsearch/elasticsearch-sql-5.6.3.0.jar
extracting: elasticsearch/guava.jar
extracting: elasticsearch/parent-join-client-5.6.3.jar
inflating: elasticsearch/plugin-descriptor.properties
extracting: elasticsearch/reindex-client-5.6.3.jar
[[email protected] plugins]# ll
total 4508
drwxr-xr-x 2 root root 181 Oct 22 2017 elasticsearch
-rw-r--r-- 1 root root 4614236 Jun 1 14:12 elasticsearch-sql-5.6.3.0.zip
#删除插件文件,只保留解压后的目录
[[email protected] plugins]# rm elasticsearch-sql-5.6.3.0.zip
rm: remove regular file ‘elasticsearch-sql-5.6.3.0.zip’? y
[[email protected] plugins]# ll
total 0
drwxr-xr-x 2 root root 181 Oct 22 2017 elasticsearch
重启ES:
sudo -u elasticsearch /home/tools/es5.6//bin/elasticsearch -d
3、下载并提取网站:
点击下载,附件是对应下载的文件
4、将下载提取的网站放到tomcat中运行:
安装tomcat7:
略
将下载的文件(es-sql-site-standalone.zip)放到tomcat7的webapps目录下,解压
[[email protected] webapps]# pwd /home/tools/tomcat7_81/webapps [[email protected] webapps]# ll total 1684 -rw-r--r-- 1 root root 1722956 Apr 20 18:42 es-sql-site-standalone.zip [[email protected] webapps]# unzip es-sql-site-standalone.zip -d sql [[email protected] webapps]# ll total 1684 -rw-r--r-- 1 root root 1722956 Apr 20 18:42 es-sql-site-standalone.zip drwxr-xr-x 4 root root 38 Apr 20 18:56 sql [[email protected] webapps]# ll sql/ total 0 drwxr-xr-x 4 root root 174 May 24 2017 _site drwxr-xr-x 2 root root 79 May 24 2017 site-server
修改es和es-sql配置:
a. 修改ES的elasticsearch.yml,增加跨域的配置(需要重启es才能生效)view plain
http.cors.enabled: true http.cors.allow-origin: "*"
b. 编辑 sql/_site/controllers.js,修改es-sql的连接地址:
if (location.protocol == "file") { url = "http://localhost:9200" } else { url = location.protocol+'//' + location.hostname + (location.port ? ':'+location.port : ''); } }
修改 url 地址为ES服务器的地址:
if (location.protocol == "file") { url = "http://localhost:9200" } else { url = "http://192.168.1.131:19200"; } }
启动tomcat,访问 ip:端口/sql/_site/ 即可
以上是关于无外网环境下ES5.x安装sql插件的主要内容,如果未能解决你的问题,请参考以下文章