文档章节

CentOS安装ElasticSearch及其问题解决

王孟君
 王孟君
发布于 2017/03/20 10:17
字数 1814
阅读 157
收藏 3

本文记录一次在CentOS上安装ElasticSearch的过程,其中也包含了安装过程中遇到的错误以及相应的解决方法。

ElasticSearch是一个基于Lucene的搜索服务器。它提供了一个分布式多用户能力的全文搜索引擎,基于RESTful web接口。Elasticsearch是用Java开发的,并作为Apache许可条款下的开放源码发布,是当前流行的企业级搜索引擎。设计用于云计算中,能够达到实时搜索,稳定,可靠,快速,安装使用方便。

下载

使用wget下载elasticsearch安装包,本文使用的安装包版本为2.4.0

[root@dev18 srv]# wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.4.0/elasticsearch-2.4.0.tar.gz
--2017-03-19 19:52:16--  https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.4.0/elasticsearch-2.4.0.tar.gz
Resolving download.elastic.co... 107.21.249.70, 54.243.211.74, 107.22.208.105, ...
Connecting to download.elastic.co|107.21.249.70|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 27364449 (26M) [application/gzip]
Saving to: “elasticsearch-2.4.0.tar.gz”

67% [==========================================================================================================================================================>                                                                          ] 18,529,728  3.56K/s   in 13m 54s 

2017-03-19 20:06:12 (21.7 KB/s) - Connection closed at byte 18529728. Retrying.

--2017-03-19 20:06:13--  (try: 2)  https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.4.0/elasticsearch-2.4.0.tar.gz
Connecting to download.elastic.co|107.21.249.70|:443... connected.
HTTP request sent, awaiting response... 206 Partial Content
Length: 27364449 (26M), 8834721 (8.4M) remaining [application/gzip]
Saving to: “elasticsearch-2.4.0.tar.gz”

100%[+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=========================================================================>] 27,364,449   560K/s   in 17s     

2017-03-19 20:06:32 (495 KB/s) - “elasticsearch-2.4.0.tar.gz” saved [27364449/27364449]

[root@dev18 srv]# 

解压缩

使用tar -zvxf elasticsearch-2.4.0.tar.gz命令将elasticsearch安装包解压,如:

[root@dev18 srv]# tar -zvxf elasticsearch-2.4.0.tar.gz 
elasticsearch-2.4.0/README.textile
elasticsearch-2.4.0/LICENSE.txt
elasticsearch-2.4.0/NOTICE.txt
elasticsearch-2.4.0/modules/
elasticsearch-2.4.0/modules/lang-groovy/
elasticsearch-2.4.0/modules/reindex/
elasticsearch-2.4.0/modules/lang-expression/
elasticsearch-2.4.0/modules/lang-groovy/plugin-security.policy
elasticsearch-2.4.0/modules/lang-groovy/plugin-descriptor.properties
elasticsearch-2.4.0/modules/lang-groovy/groovy-2.4.6-indy.jar
elasticsearch-2.4.0/modules/lang-groovy/lang-groovy-2.4.0.jar
elasticsearch-2.4.0/modules/reindex/plugin-descriptor.properties
elasticsearch-2.4.0/modules/reindex/reindex-2.4.0.jar
elasticsearch-2.4.0/modules/lang-expression/plugin-security.policy
elasticsearch-2.4.0/modules/lang-expression/plugin-descriptor.properties
elasticsearch-2.4.0/modules/lang-expression/asm-commons-5.0.4.jar
elasticsearch-2.4.0/modules/lang-expression/antlr4-runtime-4.5.1-1.jar
elasticsearch-2.4.0/modules/lang-expression/lang-expression-2.4.0.jar
elasticsearch-2.4.0/modules/lang-expression/lucene-expressions-5.5.2.jar
elasticsearch-2.4.0/modules/lang-expression/asm-5.0.4.jar
elasticsearch-2.4.0/config/elasticsearch.yml
elasticsearch-2.4.0/config/logging.yml
elasticsearch-2.4.0/bin/plugin.bat
elasticsearch-2.4.0/bin/elasticsearch.in.bat
elasticsearch-2.4.0/bin/service.bat
elasticsearch-2.4.0/bin/elasticsearch.bat
elasticsearch-2.4.0/bin/elasticsearch-service-mgr.exe
elasticsearch-2.4.0/bin/elasticsearch-service-x64.exe
elasticsearch-2.4.0/bin/elasticsearch-service-x86.exe
elasticsearch-2.4.0/bin/elasticsearch.in.sh
elasticsearch-2.4.0/bin/elasticsearch
elasticsearch-2.4.0/bin/plugin
elasticsearch-2.4.0/lib/lucene-core-5.5.2.jar
elasticsearch-2.4.0/lib/lucene-backward-codecs-5.5.2.jar
elasticsearch-2.4.0/lib/lucene-analyzers-common-5.5.2.jar
elasticsearch-2.4.0/lib/lucene-queries-5.5.2.jar
elasticsearch-2.4.0/lib/lucene-memory-5.5.2.jar
elasticsearch-2.4.0/lib/lucene-highlighter-5.5.2.jar
elasticsearch-2.4.0/lib/lucene-join-5.5.2.jar
elasticsearch-2.4.0/lib/lucene-queryparser-5.5.2.jar
elasticsearch-2.4.0/lib/lucene-sandbox-5.5.2.jar
elasticsearch-2.4.0/lib/lucene-suggest-5.5.2.jar
elasticsearch-2.4.0/lib/lucene-misc-5.5.2.jar
elasticsearch-2.4.0/lib/lucene-grouping-5.5.2.jar
elasticsearch-2.4.0/lib/lucene-spatial-5.5.2.jar
elasticsearch-2.4.0/lib/lucene-spatial3d-5.5.2.jar
elasticsearch-2.4.0/lib/spatial4j-0.5.jar
elasticsearch-2.4.0/lib/guava-18.0.jar
elasticsearch-2.4.0/lib/securesm-1.0.jar
elasticsearch-2.4.0/lib/hppc-0.7.1.jar
elasticsearch-2.4.0/lib/joda-time-2.9.4.jar
elasticsearch-2.4.0/lib/joda-convert-1.2.jar
elasticsearch-2.4.0/lib/jackson-core-2.8.1.jar
elasticsearch-2.4.0/lib/jackson-dataformat-smile-2.8.1.jar
elasticsearch-2.4.0/lib/jackson-dataformat-yaml-2.8.1.jar
elasticsearch-2.4.0/lib/snakeyaml-1.15.jar
elasticsearch-2.4.0/lib/jackson-dataformat-cbor-2.8.1.jar
elasticsearch-2.4.0/lib/netty-3.10.6.Final.jar
elasticsearch-2.4.0/lib/compress-lzf-1.0.2.jar
elasticsearch-2.4.0/lib/t-digest-3.0.jar
elasticsearch-2.4.0/lib/HdrHistogram-2.1.6.jar
elasticsearch-2.4.0/lib/commons-cli-1.3.1.jar
elasticsearch-2.4.0/lib/jsr166e-1.1.0.jar
elasticsearch-2.4.0/lib/elasticsearch-2.4.0.jar
elasticsearch-2.4.0/lib/jts-1.13.jar
elasticsearch-2.4.0/lib/compiler-0.8.13.jar
elasticsearch-2.4.0/lib/log4j-1.2.17.jar
elasticsearch-2.4.0/lib/apache-log4j-extras-1.2.17.jar
elasticsearch-2.4.0/lib/jna-4.1.0.jar
[root@dev18 srv]# 

重命名解压后的elasticsearch目录名elasticsearch-2.4.0。

[root@dev18 srv]# mv elasticsearch-2.4.0 elasticsearch
[root@dev18 srv]# cd elasticsearch
[root@dev18 elasticsearch]# ll
total 44
drwxr-xr-x 2 root root  4096 Mar 19 20:15 bin
drwxr-xr-x 2 root root  4096 Mar 19 20:15 config
drwxr-xr-x 2 root root  4096 Mar 19 20:15 lib
-rw-rw-r-- 1 1000 1000 11358 Aug 24  2016 LICENSE.txt
drwxrwxr-x 5 1000 1000  4096 Aug 29  2016 modules
-rw-rw-r-- 1 1000 1000   150 Aug 24  2016 NOTICE.txt
-rw-rw-r-- 1 1000 1000  8700 Aug 24  2016 README.textile
[root@dev18 elasticsearch]# 

启动遇到问题

进入elasticsearch的bin目录,尝试使用./elasticsearch -d命令启动elasticsearch。

[root@dev18 elasticsearch]# cd bin
[root@dev18 bin]# ll
total 324
-rwxr-xr-x 1 1000 1000   5551 Aug 24  2016 elasticsearch
-rw-rw-r-- 1 1000 1000    909 Aug 24  2016 elasticsearch.bat
-rw-rw-r-- 1 1000 1000   3307 Aug 24  2016 elasticsearch.in.bat
-rwxr-xr-x 1 1000 1000   2814 Aug 24  2016 elasticsearch.in.sh
-rw-rw-r-- 1 1000 1000 104448 Jul 27  2016 elasticsearch-service-mgr.exe
-rw-rw-r-- 1 1000 1000 103936 Jul 27  2016 elasticsearch-service-x64.exe
-rw-rw-r-- 1 1000 1000  80896 Jul 27  2016 elasticsearch-service-x86.exe
-rwxr-xr-x 1 1000 1000   2992 Aug 24  2016 plugin
-rw-rw-r-- 1 1000 1000   1303 Aug 24  2016 plugin.bat
-rw-rw-r-- 1 1000 1000   6872 Aug 24  2016 service.bat
[root@dev18 bin]# ./elasticsearch -d 

遇到问题 (不能以root账号进行启动elasticSearch -- 

Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root.

详细问题如下:

[root@dev18 bin]# ./elasticsearch -d
[root@dev18 bin]# Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root.
	at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:94)
	at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:160)
	at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:286)
	at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Refer to the log for complete error details.

 

针对上述问题 (don't run elasticsearch as root.),本文给出两种解决方案~

解决方法

方法1

在启动elasticsearch的时候,指定允许root启动~ 如:

[root@dev18 bin]# ./elasticsearch -Des.insecure.allow.root=true

[root@dev18 bin]# ./elasticsearch -Des.insecure.allow.root=true
[2017-03-20 09:09:11,160][WARN ][bootstrap                ] running as ROOT user. this is a bad idea!
[2017-03-20 09:09:11,189][WARN ][bootstrap                ] unable to install syscall filter: seccomp unavailable: CONFIG_SECCOMP not compiled into kernel, CONFIG_SECCOMP and CONFIG_SECCOMP_FILTER are needed
[2017-03-20 09:09:11,893][INFO ][node                     ] [Bobster] version[2.4.0], pid[1388], build[ce9f0c7/2016-08-29T09:14:17Z]
[2017-03-20 09:09:11,893][INFO ][node                     ] [Bobster] initializing ...
[2017-03-20 09:09:13,159][INFO ][plugins                  ] [Bobster] modules [lang-groovy, reindex, lang-expression], plugins [], sites []
[2017-03-20 09:09:13,211][INFO ][env                      ] [Bobster] using [1] data paths, mounts [[/ (/dev/mapper/vg0-lv_root)]], net usable_space [8.8gb], net total_space [24.9gb], spins? [possibly], types [ext4]
[2017-03-20 09:09:13,211][INFO ][env                      ] [Bobster] heap size [1007.3mb], compressed ordinary object pointers [true]
[2017-03-20 09:09:16,788][INFO ][node                     ] [Bobster] initialized
[2017-03-20 09:09:16,789][INFO ][node                     ] [Bobster] starting ...
[2017-03-20 09:09:16,879][INFO ][transport                ] [Bobster] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}, {[::1]:9300}
[2017-03-20 09:09:16,887][INFO ][discovery                ] [Bobster] elasticsearch/o1NR_vrsS_mDyTstiSgGEQ
[2017-03-20 09:09:20,076][INFO ][cluster.service          ] [Bobster] new_master {Bobster}{o1NR_vrsS_mDyTstiSgGEQ}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
[2017-03-20 09:09:20,113][INFO ][http                     ] [Bobster] publish_address {127.0.0.1:9200}, bound_addresses {127.0.0.1:9200}, {[::1]:9200}
[2017-03-20 09:09:20,114][INFO ][node                     ] [Bobster] started
[2017-03-20 09:09:20,162][INFO ][gateway                  ] [Bobster] recovered [0] indices into cluster_state

这种方式能够启动,但是elasticsearch会提示,使用ROOT账户运行,这是一个不好的主意

[WARN ][bootstrap                ] running as ROOT user. this is a bad idea!

方法2 

鉴于方法1不是一个很好的方式,我们应该寻求其它的方法 -- 

创建一个elasticsearch相关的账号~

(1) 首先,创建一个分组,取名为esgroup,然后,往该分组中添加用户es,并设置es账户的密码。

[root@dev18 bin]# groupadd esgroup
[root@dev18 bin]# useradd -g esgroup es
[root@dev18 bin]# passwd es
Changing password for user es.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@dev18 bin]# 

(2)修改elasticsearch目录权限~

[root@dev18 elasticsearch]# chown -R root .
[root@dev18 elasticsearch]# chown -R es .
[root@dev18 elasticsearch]# chgrp -R esgroup .

(3)使用新创建的账号es来登录终端, 并使用 ./elasticsearch -d命令启动elasticsearch

[es@dev18 ~]$ cd /srv/elasticsearch
[es@dev18 elasticsearch]$ cd bin
[es@dev18 bin]$ ./elasticsearch -d

(4)验证

在方法2中,通过前面的(1)、(2)、(3)三个步骤之后,elasticsearch已经运行~

所以,我们需要做一下验证,看elasticsearch是否正常启动~

使用ps -ef|grep elasticsearch查看进程~

[es@dev18 bin]$ ps -ef|grep elasticsearch
es        1656     1 29 09:17 pts/3    00:00:09 /usr/java/jdk1.7.0_71/bin/java -Xms256m -Xmx1g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -Dfile.encoding=UTF-8 -Djna.nosys=true -Des.path.home=/srv/elasticsearch -cp /srv/elasticsearch/lib/elasticsearch-2.4.0.jar:/srv/elasticsearch/lib/* org.elasticsearch.bootstrap.Elasticsearch start -d
es        1714  1624  0 09:18 pts/3    00:00:00 grep elasticsearch
[es@dev18 bin]$ 

使用curl -X GET http://localhost:9200查看信息~

[es@dev18 bin]$ curl -X GET http://localhost:9200
{
  "name" : "George Tarleton",
  "cluster_name" : "elasticsearch",
  "version" : {
    "number" : "2.4.0",
    "build_hash" : "ce9f0c7394dee074091dd1bc4e9469251181fc55",
    "build_timestamp" : "2016-08-29T09:14:17Z",
    "build_snapshot" : false,
    "lucene_version" : "5.5.2"
  },
  "tagline" : "You Know, for Search"
}
[es@dev18 bin]$ 

至此,默认条件配置的elasticsearch就成功了~ 后续就可以玩elasticsearch相关的其它功能了~~

© 著作权归作者所有

王孟君

王孟君

粉丝 231
博文 94
码字总数 221044
作品 0
杭州
高级程序员
私信 提问
Nginx + Naxsi + Nxapi + ElasticSearch + Kibana 安装

Author: Xu FC Platform: CentOS 7 -- Linux localhost.localdomain 3.10.0-693.21.1.el7.x8664 #1 SMP Wed Mar 7 19:03:37 UTC 2018 x8664 x8664 x86_64 GNU/Linux 安装依赖 安装 libssl: ......

捞小虾
2018/05/07
0
0
centos 7( linux )下安装elasticsearch教程

目录 概述 环境准备 elaticsearch简介 安装elasticsearch 彩蛋 概述 很久没有写博客了,最近在做全文检索的项目,发现elasticsearch踩了不少坑,百度点进去又是坑,在此记录一下自己的踩坑历程。...

java_龙
2018/10/15
570
0
如何在 Linux 上安装 Elasticsearch 和 Kibana

获取我们关于安装两者的简化说明。 如果你渴望学习基于开源 Lucene 库的著名开源搜索引擎 Elasticsearch,那么没有比在本地安装它更好的方法了。这个过程在 Elasticsearch 网站中有详细介绍,...

作者: Seth Kenlon
08/13
0
0
ELK5.0 (Elasticsearch Logstash Kibana) 搭建部署

Elasticsearch+Logstash+Kibana 实时在线日志分析系统 文件下载地址:https://www.elastic.co/downloads/past-releases 环境 centOS 6.8 jdk1.8 一、安装Elasticsearch 1.下载好安装包 并解压...

飓风2000
2018/09/13
39
0
mysql数据同步到elasticsearch

环境 centos7.2 php5.5.7 mysql5.7 安装elasticsearch 下载地址:https://www.elastic.co/downloads/elasticsearch 安装2.4.6 gdebi elasticsearch-6.5.0.deb //配置内容...cluster.name: zp......

剑客生涯
05/05
0
0

没有更多内容

加载失败,请刷新页面

加载更多

对比ubuntu与centos系统 ​​​​

CentOS与Ubuntu该如何选择,哪个更好用。笔者在自媒体平台收集了一些网友的观点,较为经典,分享给大家。至于应该选择哪个,希望看完本文章后,读者心中有数。 观点1:CentOS适用于服务器,U...

老孟的Linux私房菜
今天
12
0
Java的基本类型

一、Java的基本类型 Java的基本类型有哪些? boolean char byte short int long float double ? 延伸思考 思考一:为什么有的书籍说Java存在第9种数据类型? 实际上,JAVA中还存在另外一种基...

yumoop
今天
14
0
OSChina 周四乱弹 —— 富婆小时候

Osc乱弹歌单(2019)请戳(这里) 【今日歌曲】 @猿敲月下码 :#今日歌曲推荐# 分享陈慧娴的单曲《夜机》 《夜机》- 陈慧娴 手机党少年们想听歌,请使劲儿戳(这里) @開源中國張學友 :早上...

小小编辑
今天
23
0
MyMinimad ── Linux下用libmad写的mp3解码播放程序(四)

优化了内存使用,不再使用mmap映射整个文件到内存 /* * 本程序是从 minimad 改进而来,如要更详细的说明请参看 minimad.c * * Gu Zhou, 2009/12/25, SiChuan University, China *...

代码强国
今天
18
0
Minikube安装

1、下载Minikube二进制文件 sudo curl -Lo minikube https://kubernetes.oss-cn-hangzhou.aliyuncs.com/minikube/releases/latest/minikube-linux-amd64 2、设置权限 sudo chmod +x minikube......

RogueQ
今天
11
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部