ElasticSearch安裝SQL插件下載地址(中國大佬開發的,膜拜ing):https://github.com/NLPchina/elasticsearch-sqlnode
一、記得選擇和本身Elasticsearch對應的版本哦!若是你的是集羣默認,每一個節點都要按照這個SQL插件的哦,因爲個人是僞分佈集羣模式,個人安裝操做以下所示:linux
注意:安裝成功之後,是在/home/hadoop/soft/elasticsearch-5.4.3/plugins這個目錄下面的。請注意進行查收。git
1 [elsearch@slaver4 soft]$ ls 2 elasticsearch-5.4.3 elasticsearch-head-master el_slave node-v8.16.2-linux-x64 nohup.out 3 [elsearch@slaver4 soft]$ cd elasticsearch-5.4.3/ 4 [elsearch@slaver4 elasticsearch-5.4.3]$ ls 5 bin config data hs_err_pid11491.log lib LICENSE.txt logs modules NOTICE.txt plugins README.textile 6 [elsearch@slaver4 elasticsearch-5.4.3]$ ./bin/elasticsearch-plugin install https://github.com/NLPchina/elasticsearch-sql/releases/download/5.4.3.0/elasticsearch-sql-5.4.3.0.zip 7 -> Downloading https://github.com/NLPchina/elasticsearch-sql/releases/download/5.4.3.0/elasticsearch-sql-5.4.3.0.zip 8 [=================================================] 100% 9 -> Installed sql 10 [elsearch@slaver4 elasticsearch-5.4.3]$ ls 11 bin config data hs_err_pid11491.log lib LICENSE.txt logs modules NOTICE.txt plugins README.textile 12 [elsearch@slaver4 elasticsearch-5.4.3]$ cd plugins/ 13 [elsearch@slaver4 plugins]$ ls 14 elasticsearch-analysis-ik sql 15 [elsearch@slaver4 plugins]$ cd sql/ 16 [elsearch@slaver4 sql]$ ls 17 druid.jar elasticsearch-sql-5.4.3.0.jar guava.jar plugin-descriptor.properties 18 [elsearch@slaver4 sql]$
二、我在一個節點執行的,安裝成功之後,而後將解壓到plugins目錄下sql目錄拷貝到其餘es的節點的plugins目錄下面便可。以下所示:github
1 [elsearch@slaver4 soft]$ ls 2 elasticsearch-5.4.3 elasticsearch-head-master el_slave node-v8.16.2-linux-x64 nohup.out 3 [elsearch@slaver4 soft]$ cd elasticsearch-5.4.3/plugins/ 4 [elsearch@slaver4 plugins]$ ls 5 elasticsearch-analysis-ik sql 6 [elsearch@slaver4 plugins]$ cp -r sql/ /home/hadoop/soft/el_slave/elasticsearch-5.4.3-slaver1/plugins/ 7 [elsearch@slaver4 plugins]$ cp -r sql/ /home/hadoop/soft/el_slave/elasticsearch-5.4.3-slaver2/plugins/ 8 [elsearch@slaver4 plugins]$ ls /home/hadoop/soft/el_slave/elasticsearch-5.4.3-slaver1/plugins/ 9 elasticsearch-analysis-ik sql 10 [elsearch@slaver4 plugins]$ ls /home/hadoop/soft/el_slave/elasticsearch-5.4.3-slaver2/plugins/ 11 elasticsearch-analysis-ik sql 12 [elsearch@slaver4 plugins]$
三、若是你的僞分佈集羣啓動着呢,須要中止集羣,而後重啓集羣,查看安裝的SQL插件是否好使。sql
1 [elsearch@slaver4 soft]$ ls 2 elasticsearch-5.4.3 elasticsearch-head-master el_slave node-v8.16.2-linux-x64 nohup.out 3 [elsearch@slaver4 soft]$ jps 4 8048 Elasticsearch 5 9428 Jps 6 7928 Elasticsearch 7 7998 Elasticsearch 8 [elsearch@slaver4 soft]$ kill `ps -ef | grep Elasticsearch | grep -v grep | awk '{print $2}'` 9 [elsearch@slaver4 soft]$ jps 10 9480 Jps 11 [elsearch@slaver4 soft]$ cd elasticsearch-5.4.3/ 12 [elsearch@slaver4 elasticsearch-5.4.3]$ ls 13 bin config data hs_err_pid11491.log lib LICENSE.txt logs modules NOTICE.txt plugins README.textile 14 [elsearch@slaver4 elasticsearch-5.4.3]$ cd bin/ 15 [elsearch@slaver4 bin]$ ls 16 elasticsearch elasticsearch.in.sh elasticsearch-plugin elasticsearch-service-mgr.exe elasticsearch-systemd-pre-exec hs_err_pid9127.log 17 elasticsearch.bat elasticsearch-keystore elasticsearch-plugin.bat elasticsearch-service-x64.exe elasticsearch-translog 18 elasticsearch.in.bat elasticsearch-keystore.bat elasticsearch-service.bat elasticsearch-service-x86.exe elasticsearch-translog.bat 19 [elsearch@slaver4 bin]$ ./elasticsearch -d 20 [elsearch@slaver4 bin]$ cd ../../el_slave/ 21 [elsearch@slaver4 el_slave]$ ls 22 elasticsearch-5.4.3-slaver1 elasticsearch-5.4.3-slaver2 23 [elsearch@slaver4 el_slave]$ cd elasticsearch-5.4.3-slaver1/ 24 [elsearch@slaver4 elasticsearch-5.4.3-slaver1]$ ls 25 bin config data hs_err_pid11491.log lib LICENSE.txt logs modules NOTICE.txt plugins README.textile 26 [elsearch@slaver4 elasticsearch-5.4.3-slaver1]$ cd bin/ 27 [elsearch@slaver4 bin]$ ls 28 elasticsearch elasticsearch.in.sh elasticsearch-plugin elasticsearch-service-mgr.exe elasticsearch-systemd-pre-exec 29 elasticsearch.bat elasticsearch-keystore elasticsearch-plugin.bat elasticsearch-service-x64.exe elasticsearch-translog 30 elasticsearch.in.bat elasticsearch-keystore.bat elasticsearch-service.bat elasticsearch-service-x86.exe elasticsearch-translog.bat 31 [elsearch@slaver4 bin]$ ./elasticsearch -d 32 [elsearch@slaver4 bin]$ cd ../../elasticsearch-5.4.3-slaver2/ 33 [elsearch@slaver4 elasticsearch-5.4.3-slaver2]$ ls 34 bin config data hs_err_pid11491.log lib LICENSE.txt logs modules NOTICE.txt plugins README.textile 35 [elsearch@slaver4 elasticsearch-5.4.3-slaver2]$ cd bin/ 36 [elsearch@slaver4 bin]$ ls 37 elasticsearch elasticsearch.in.sh elasticsearch-plugin elasticsearch-service-mgr.exe elasticsearch-systemd-pre-exec 38 elasticsearch.bat elasticsearch-keystore elasticsearch-plugin.bat elasticsearch-service-x64.exe elasticsearch-translog 39 elasticsearch.in.bat elasticsearch-keystore.bat elasticsearch-service.bat elasticsearch-service-x86.exe elasticsearch-translog.bat 40 [elsearch@slaver4 bin]$ ./elasticsearch -d 41 [elsearch@slaver4 bin]$ jps 42 9520 Elasticsearch 43 9651 Jps 44 9637 Elasticsearch 45 9578 Elasticsearch 46 [elsearch@slaver4 bin]$
四、此時,你就可使用瀏覽器進行測試,http://192.168.110.133:9200/_sql?sql=select * from player limit 10,個人測試以下所示:express
注意:from後面跟的是你的索引Index哦!別查詢錯誤了。npm
五、而後你可使用界面的形式寫SQL,感受很喜歡這種方式哦!下載SQL的Server,方式以下所示:json
注意:下面這個插件使用的是node編寫的,因此須要node相關的依賴包,以前弄過,這裏省略了。在一臺節點安裝便可哦!vim
1 [elsearch@slaver4 hadoop]$ wget http://github.com/NLPchina/elasticsearch-sql/releases/download/5.4.1.0/es-sql-site-standalone.zip 2 --2019-10-21 22:05:36-- http://github.com/NLPchina/elasticsearch-sql/releases/download/5.4.1.0/es-sql-site-standalone.zip 3 Resolving github.com (github.com)... 13.229.188.59 4 Connecting to github.com (github.com)|13.229.188.59|:80... connected. 5 HTTP request sent, awaiting response... 301 Moved Permanently 6 Location: https://github.com/NLPchina/elasticsearch-sql/releases/download/5.4.1.0/es-sql-site-standalone.zip [following] 7 --2019-10-21 22:05:36-- https://github.com/NLPchina/elasticsearch-sql/releases/download/5.4.1.0/es-sql-site-standalone.zip 8 Connecting to github.com (github.com)|13.229.188.59|:443... connected. 9 HTTP request sent, awaiting response... 302 Found 10 Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/23282991/0a751200-5085-11e7-9ec9-63ecd48186af?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20191021%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20191021T140536Z&X-Amz-Expires=300&X-Amz-Signature=5567d99816d092aa1f694ced016c9793776db7eef8d195bc50aa24cf14381b34&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Des-sql-site-standalone.zip&response-content-type=application%2Foctet-stream [following] 11 --2019-10-21 22:05:37-- https://github-production-release-asset-2e65be.s3.amazonaws.com/23282991/0a751200-5085-11e7-9ec9-63ecd48186af?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20191021%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20191021T140536Z&X-Amz-Expires=300&X-Amz-Signature=5567d99816d092aa1f694ced016c9793776db7eef8d195bc50aa24cf14381b34&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Des-sql-site-standalone.zip&response-content-type=application%2Foctet-stream 12 Resolving github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.146.235 13 Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.146.235|:443... connected. 14 HTTP request sent, awaiting response... 200 OK 15 Length: 1722956 (1.6M) [application/octet-stream] 16 Saving to: ‘es-sql-site-standalone.zip’ 17 18 100%[=======================================================================================================================================================================>] 1,722,956 81.5KB/s in 27s 19 20 2019-10-21 22:06:05 (63.4 KB/s) - ‘es-sql-site-standalone.zip’ saved [1722956/1722956]
開始執行解壓縮操做,命令以下所示:瀏覽器
注意:因爲unzip是解壓縮到當前目錄,你能夠將.zip的包刪除掉。
1 [elsearch@slaver4 hadoop]$ cd soft/ 2 [elsearch@slaver4 soft]$ ls 3 elasticsearch-5.4.3 elasticsearch-head-master el_slave node-v8.16.2-linux-x64 nohup.out 4 [elsearch@slaver4 soft]$ mkdir el_sql 5 [elsearch@slaver4 soft]$ cp ../es-sql-site-standalone.zip ./el_sql/ 6 [elsearch@slaver4 soft]$ ls 7 elasticsearch-5.4.3 elasticsearch-head-master el_slave el_sql node-v8.16.2-linux-x64 nohup.out 8 [elsearch@slaver4 soft]$ cd el_sql/ 9 [elsearch@slaver4 el_sql]$ ls 10 es-sql-site-standalone.zip 11 [elsearch@slaver4 el_sql]$ unzip es-sql-site-standalone.zip
六、開始安裝你的圖形化插件,以下所示:
1 [elsearch@slaver4 el_sql]$ cd site-server/ 2 [elsearch@slaver4 site-server]$ ls 3 node-server.js package.json site_configuration.json 4 [elsearch@slaver4 site-server]$ npm install express --save 5 npm notice created a lockfile as package-lock.json. You should commit this file. 6 npm WARN site-server No description 7 npm WARN site-server No repository field. 8 npm WARN site-server No license field. 9 10 + express@4.17.1 11 added 50 packages from 37 contributors and audited 126 packages in 19.057s 12 found 0 vulnerabilities 13 14 [elsearch@slaver4 site-server]$
七、修改SQL的Server的端口,vi site_configuration.json。默認端口號是8080,若是沒有佔用的話,能夠直接使用的。操做以下所示:
1 [elsearch@slaver4 site-server]$ vim site_configuration.json
八、安裝成功之後啓動你的服務,以下所示:
前臺啓動方式以下所示:node node-server.js
後臺啓動方式以下所示:node node-server.js &
1 [elsearch@slaver4 site-server]$ node node-server.js
九、啓動成功之後能夠查看界面,以下所示:
十、圖形化界面使用以下所示:
注意:記得修改右上角的地址哦!
更多案例,能夠參考https://github.com/NLPchina/elasticsearch-sql
做者:別先生
博客園:https://www.cnblogs.com/biehongli/
若是您想及時獲得我的撰寫文章以及著做的消息推送,能夠掃描上方二維碼,關注我的公衆號哦。