21-win10下ElasticSearch.6.1.0安装SQL插件

简介:win10下ElasticSearch.6.1.0安装SQL插件

5.安装sql

5.0 es配置

安装es http://blog.csdn.net/qq_21383435/article/details/79275543


cluster.name: elasticsearch
node.name: "lcc_node"
node.master: true
# 指定该节点是否存储索引数据,默认为true。
node.data: true

# 设置默认索引分片个数,默认为5片。
#index.number_of_shards: 1

# 设置默认索引副本个数,默认为1个副本。如果采用默认设置,而你集群只配置了一台机器,
# 那么集群的健康度为yellow,也就是所有的数据都是可用的,但是某些复制没有被分配
#index.number_of_replicas: 1

# 设置配置文件的存储路径,默认是es根目录下的config文件夹。
#path.conf: J:\elasticsearch\elasticsearch-6.2.1\config

# 设置索引数据的存储路径,默认是es根目录下的data文件夹,可以设置多个存储路径,用逗号隔开
#path.data: J:\elasticsearch\elasticsearch-6.2.1\data

# 设置临时文件的存储路径,默认是es根目录下的work文件夹。
#path.work: J:\elasticsearch\elasticsearch-6.2.1\worker

# 设置日志文件的存储路径,默认是es根目录下的logs文件夹
# path.logs: /path/to/logs

# 设置为true来锁住内存不进行swapping。因为当jvm开始swapping时es的效率 会降低,
# 所以要保证它不swap,可以把ES_MIN_MEM和ES_MAX_MEM两个环境变量设置成同一个值,
# 并且保证机器有足够的内存分配给es。 同时也要允许elasticsearch的进程可以锁住内存,
# linux下启动es之前可以通过`ulimit -l unlimited`命令设置。
# bootstrap.mlockall: true

network.host: 127.0.0.1
http.port: 9200

http.cors.enabled: true
http.cors.allow-origin: "*"

action.auto_create_index : .security,.monitoring*,.watches,.triggered_watches,.watcher-history*
#xpack.security.enabled : false
#xpack.monitoring.enabled : true
#xpack.graph.enabled : false
#xpack.watcher.enabled : false
#xpack.ml.enabled : false


# 单个命令来删除所有数据可能会导致可怕的后果。这个设置使删除只限于特定名称指向的数据, 而不允许通过指定 _all 或通配符来删除指定索引库。
action.destructive_requires_name: true

#index.number_of_replicas: 0
#cluster.routing.allocation.enable : all

5.1 解决方法:命令安装(未成功)

J:\elasticsearch\elasticsearch-6.1.0\bin>elasticsearch-plugin  -u https://github.com/NLPchina/elasticsearch-sql/releases/download/1.4.7/elasticsearch-sql-1.4.7.zip --install sql
A tool for managing installed elasticsearch plugins

Commands
--------
list - Lists installed elasticsearch plugins
install - Install a plugin
remove - removes a plugin from Elasticsearch

Non-option arguments:
command

Option         Description
------         -----------
-h, --help     show help
-s, --silent   show minimal output
-v, --verbose  show verbose output
ERROR: u is not a recognized option

5.2 解决方法:直接下载(未成功)

直接下载解压J:\elasticsearch\elasticsearch-6.1.0\plugins\sql


运行保持报错
J:\elasticsearch\elasticsearch-6.1.0\bin>elasticsearch.bat
[2018-02-28T22:36:51,531][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [lcc_node] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: org.elasticsearch.bootstrap.BootstrapException: java.nio.file.NoSuchFileException: J:\elasticsearch\elasticsearch-6.1.0\plugins\sql\plugin-descriptor.properties

Caused by: java.nio.file.NoSuchFileException: J:\elasticsearch\elasticsearch-6.1.0\plugins\sql\plugin-descriptor.properties

再次命令运行

J:\elasticsearch\elasticsearch-6.1.0\bin>elasticsearch-plugin install https://github.com/NLPchina/elasticsearch-sql/releases/download/6.1.0.0/elasticsearch-sql-6.1.0.0.zip
-> Downloading https://github.com/NLPchina/elasticsearch-sql/releases/download/6.1.0.0/elasticsearch-sql-6.1.0.0.zip
Exception in thread "main" java.net.ConnectException: Connection timed out: connect

Caused by: java.net.ConnectException: Connection timed out: connect

5.3 解决方法:直接下载(未成功)

然后我尝试下载一个包elasticsearch-sql-elastic6.1.0.zip 放到目录J:\elasticsearch\elasticsearch-6.1.0\plugins\elasticsearch-sql-elastic6.1.0.zip 下,继续执行安装命令,结果如下

J:\elasticsearch\elasticsearch-6.1.0\bin>elasticsearch-plugin install https://github.com/NLPchina/elasticsearch-sql/releases/download/6.1.0.0/elasticsearch-sql-6.1.0.0.zip
-> Downloading https://github.com/NLPchina/elasticsearch-sql/releases/download/6.1.0.0/elasticsearch-sql-6.1.0.0.zip
[==============================================>  ] 95%??

5.4 解决方法:下载后编译(未成功)

J:\elasticsearch\elasticsearch-6.1.0\plugins\sql>mvn package
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for 
。。。。

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.nlpcn.es4sql.MainTestSuite
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
。。。。。
Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 13.492 sec <<< FAILURE!
org.nlpcn.es4sql.MainTestSuite  Time elapsed: 13.487 sec  <<< ERROR!
NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{LZaXsYCYTji0MrMH5yj4MA}{localhost}{127.0.0.1:9300}]]
        at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:347)
   。。。。。
org.nlpcn.es4sql.MainTestSuite  Time elapsed: 13.491 sec  <<< ERROR!
NoNodeAvailableException[None of the configured nodes are available: [{#transport#-1}{LZaXsYCYTji0MrMH5yj4MA}{localhost}{127.0.0.1:9300}]]
        at org.elasticsearch.client.transport.TransportClientNodesService.ensureNodesAreAvailable(TransportClientNodesService.java:347)
     。。。。。。

Results :

Tests in error:
  org.nlpcn.es4sql.MainTestSuite: None of the configured nodes are available: [{#transport#-1}{LZaXsYCYTji0MrMH5yj4MA}{localhost}{127.0.0.1:9300}]
  org.nlpcn.es4sql.MainTestSuite: None of the configured nodes are available: [{#transport#-1}{LZaXsYCYTji0MrMH5yj4MA}{localhost}{127.0.0.1:9300}]

Tests run: 2, Failures: 0, Errors: 2, Skipped: 0

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 28.277 s
[INFO] Finished at: 2018-02-28T23:45:57+08:00
[INFO] Final Memory: 24M/170M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4:test (default-test) on project elasticsearch-sql: There are test failures.
[ERROR]
[ERROR] Please refer to J:\elasticsearch\elasticsearch-6.1.0\plugins\sql\target\surefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
'cmd' 不是内部或外部命令,也不是可运行的程序
或批处理文件。

J:\elasticsearch\elasticsearch-6.1.0\plugins\sql>

5.5 解决方法:命令安装(成功)

网友说,6.2.0的没有这个插件,然后,让我修改成6.1.0的,结果还是不对
最后查询
https://github.com/NLPchina/elasticsearch-sql/issues/610

https://github.com/NLPchina/elasticsearch-sql/issues/615

Exception:Unknown properties in plugin descriptor: [jvm, site] since 6.1.3 #615

First thank you for a great work

The plugin don't work since 6.1.3   es-sql从6.1.3后开始就不工作了

And can you please update to 6.2.2  请更新到6.2.2

但是更新到6.2.2后,发现https://github.com/NLPchina/elasticsearch-sql(这个网页有安装命令,往下拉)现在最大的es-sql版本为6.1.0,还没更新出来6.2.2

所以我使用了es6.1.0去尝试

D:\elasticsearch\elasticsearch-6.1.0\bin>elasticsearch-plugin install https://github.com/NLPchina/elasticsearch-sql/releases/download/6.1.0.0/elasticsearch-sql-6.1.0.0.zip
-> Downloading https://github.com/NLPchina/elasticsearch-sql/releases/download/6.1.0.0/elasticsearch-sql-6.1.0.0.zip
[=================================================] 100%??
-> Installed sql

D:\elasticsearch\elasticsearch-6.1.0\bin>

然后在D:\elasticsearch\elasticsearch-6.1.0\plugins目录下有个sql文件夹

21-win10下ElasticSearch.6.1.0安装SQL插件_第1张图片

然后事实证明,最新不一定最好

启动出现,下面一句话就对了

D:\elasticsearch\elasticsearch-6.1.0\bin>elasticsearch.bat
[2018-03-01T13:46:34,606][INFO ][o.e.p.PluginsService     ] [node-120.0.0銆?] loaded plugin [sql]

执行这个命令,可能报错

2018-03-01 21:42:03,406 main ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")
        at java.security.AccessControlContext.checkPermission(AccessControlContext.java:472)
        at java.lang.SecurityManager.checkPermission(SecurityManager.java:585)

这个是权限问题,因为不是linux系统,所以这里暂时不管,我也没找到解决方法

但是我的最后访问http://localhost:9200/_plugin/sql/ 居然没反应
看官方文档
https://github.com/NLPchina/elasticsearch-sql
发现

Basic Usage
On elasticsearch 1.x / 2.x, visit the elasticsearch-sql web front-end:

http://localhost:9200/_plugin/sql/

On elasticsearch 5.x/6.x, download and extract site.

Then start the web front-end like this:

cd site-server
npm install express --save
node node-server.js 

然后我去下载download and extract site.这几个字对应的包,然后解压

21-win10下ElasticSearch.6.1.0安装SQL插件_第2张图片
执行命令

D:\elasticsearch\es-sql-site-standalone\site-server>npm install express --save
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN site-server No description
npm WARN site-server No repository field.
npm WARN site-server No license field.

+ express@4.16.2
added 49 packages in 17.728s

D:\elasticsearch\es-sql-site-standalone\site-server>node node-server.js

访问
21-win10下ElasticSearch.6.1.0安装SQL插件_第3张图片

es的head如下http://localhost:9100/

21-win10下ElasticSearch.6.1.0安装SQL插件_第4张图片

使用查询语句

http://localhost:9200/_sql?sql=select * from indexName limit 10

这里写图片描述

但是我新建一个索引

PUT /megacorp
{
  "settings":{
           "number_of_shards":1,     
           "number_of_replicas":0
  }
}


POST /megacorp/employee/1
{
    "first_name" : "John",
    "last_name" :  "Smith",
    "age" :        25,
    "about" :      "I love to go rock climbing",
    "interests": [ "sports", "music" ]
}

再次查询

21-win10下ElasticSearch.6.1.0安装SQL插件_第5张图片

https://github.com/NLPchina/elasticsearch-sql

https://www.cnblogs.com/lyh421/p/7453965.html

http://blog.csdn.net/mvpboss1004/article/details/74892917

http://www.cnblogs.com/binshen/p/7419066.html

http://cloud.51cto.com/art/201505/476450.htm

你可能感兴趣的:(21-win10下ElasticSearch.6.1.0安装SQL插件)