这篇文章主要给大家分享介绍了ElasticSearch的完整安装教程,文中通过示例代码介绍的非常详细,对大家学习或者使用ElasticSearch具有一定的参考学习价值,需要的朋友们下面来一起学习学习吧
ElasticSearch安装
下载ElasticSearch
官网地址:
https://www.elastic.co/products/elasticsearch
本地下载:https://www.jb51.net/codes/579429.html
上传到ElasticSearch
可以使用第三方工具filezilla
解压elasticsearch-6.4.0.tar.gztar -zxvf elasticsearch-6.4.0.tar.gz
[root@localhost elasticsearch]# tar -zxvf elasticsearch-6.4.0.tar.gz
elasticsearch-6.4.0/
...
进入elasticsearch目录查看文件夹内容 cd elasticsearch-6.4.0
[root@localhost elasticsearch]# cd elasticsearch-6.4.0
[root@localhost elasticsearch-6.4.0]# ll
总用量 436
drwxr-xr-x. 3 root root 4096 8月 29 17:52 bin
drwxr-xr-x. 2 root root 148 8月 18 07:23 config
drwxr-xr-x. 3 root root 4096 8月 18 07:23 lib
-rw-r--r--. 1 root root 13675 8月 18 07:11 LICENSE.txt
drwxr-xr-x. 2 root root 6 8月 18 07:22 logs
drwxr-xr-x. 27 root root 4096 8月 18 07:23 modules
-rw-r--r--. 1 root root 401465 8月 18 07:22 NOTICE.txt
drwxr-xr-x. 2 root root 6 8月 18 07:22 plugins
-rw-r--r--. 1 root root 8511 8月 18 07:11 README.textile
[root@localhost elasticsearch-6.4.0]#
运行bin下面的ealashicsearch./bin/elasticsearch
root@localhost elasticsearch-6.4.0]# ./bin/elasticsearch
[2018-08-29T18:07:52,437][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception in thread [main]
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:140) ~[elasticsearch-6.4.0.jar:6.4.0]
at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:127) ~[elasticsearch-6.4.0.jar:6.4.0]
at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:86) ~[elasticsearch-6.4.0.jar:6.4.0]
at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:124) ~[elasticsearch-cli-6.4.0.jar:6.4.0]
at org.elasticsearch.cli.Command.main(Command.java:90) ~[elasticsearch-cli-6.4.0.jar:6.4.0]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:93) ~[elasticsearch-6.4.0.jar:6.4.0]
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:86) ~[elasticsearch-6.4.0.jar:6.4.0]
Caused by: java.lang.RuntimeException: can not run elasticsearch as root
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:104) ~[elasticsearch-6.4.0.jar:6.4.0]
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:171) ~[elasticsearch-6.4.0.jar:6.4.0]
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:326) ~[elasticsearch-6.4.0.jar:6.4.0]
at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:136) ~[elasticsearch-6.4.0.jar:6.4.0]
... 6 more
[root@localhost elasticsearch-6.4.0]#
出错是因为不能以root用户的方式启动,必须新建一个用户和组
1、创建创建es组
[root@localhost elasticsearch-6.4.0]# groupadd eszu
2、创建es用户
[root@localhost elasticsearch-6.4.0]# useradd esyonghu
3、指定用户密码
[root@localhost elasticsearch-6.4.0]# passwd esyonghu
更改用户 esyonghu 的密码 。
新的 密码:
重新输入新的 密码:
passwd:所有的身份验证令牌已经成功更新。
[root@localhost elasticsearch-6.4.0]#
4、修改文件所属用户
[root@localhost elasticsearch]# chown -R esyonghu elasticsearch-6.4.0
5、修改文件所属组
[root@localhost elasticsearch]# chgrp -R eszu elasticsearch-6.4.0
切换用户到esyonghusu esyonghu, 启动elasticserach./bin/elasticsearch
[root@localhost elasticsearch-6.4.0]# su esyonghu
[esyonghu@localhost elasticsearch-6.4.0]$ ./bin/elasticsearch
[2018-08-30T10:20:25,387][INFO ][o.e.n.Node ] [] initializing ...
[2018-08-30T10:20:25,919][INFO ][o.e.e.NodeEnvironment ] [cRjfMu5] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [14.8gb], net total_space [16.9gb], types [rootfs]
[2018-08-30T10:20:25,920][INFO ][o.e.e.NodeEnvironment ] [cRjfMu5] heap size [1015.6mb], compressed ordinary object pointers [true]
[2018-08-30T10:20:25,925][INFO ][o.e.n.Node ] [cRjfMu5] node name derived from node ID [cRjfMu5qTwmlfTzHHWSAiQ]; set [node.name] to override
[2018-08-30T10:20:25,926][INFO ][o.e.n.Node ] [cRjfMu5] version[6.4.0], pid[1331], build[default/tar/595516e/2018-08-17T23:18:47.308994Z], OS[Linux/3.10.0-862.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_181/25.181-b13]
[2018-08-30T10:20:25,943][INFO ][o.e.n.Node ] [cRjfMu5] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSI