ElasticSearch5.6-安装常见错误
ElasticSearch是一个用Java开发的基于Lucene的搜索服务器。它可以提供一个分布式多用户能力的全文搜索引擎,基于RESTfulweb接口。现阶段它主要为Apache许可条款下的开放源码发布,也是当前流行的企业级搜索引擎。Elasticsearch设计主要用于云计算中,ElasticSearch实时搜索,稳定,可靠,快速,安装使用方便的优点,很好的解决大数据查询缓慢问题。 现在我们来安装使用 ElasticSearch,可以这样说5.6以上的版本,安装时出的问题是比较多的,但我们可以通过提示来解决这些问题。基于我们是测试使用,我只需在一台上安装就可以了,首先 ElasticSearch是基于java来开发的,所以我们好安装java包。
1
2
3
# yum install-y *jdk 安装java环境
# cd /usr/local/src/
# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.3.tar.gz
##官网下载5.6以上的版本
1
2
3
4
# java -version###查看java版本
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)###可以看到已经安装java的最新版本了。
##解压安装 ElasticSearch
1
2
3
4
5
6
7
8
9
# tar -xf elasticsearch-5.6.3.tar.gz ##解压
# cd elasticsearch-5.6.3
# ls
binconfiglibLICENSE.txtmodulesNOTICE.txtpluginsREADME.textile
# vim config/
elasticsearch.ymljvm.options log4j2.properties
# vim config/elasticsearch.yml###修改下面两项
network.host: 172.25.0.30 ###为本地ip,监听主机
discovery.zen.minimum_master_nodes: 1 ###我这里只有一台,所以修改为1
接下来我们启动看看
错误一:
我们会发现启动错误。会弹出下面的报错,抱错如下图:
主要原因是已经有提示了:Caused by: java.lang.RuntimeException: can not run elasticsearch as root,说是不能在root用户下运行,接下来我们换个用户来运行。
1
2
3
# useradd dashuju
# su - dashuju
$ cd /usr/local/src/elasticsearch-5.6.3/
错误二:
启动后我们发现了错误
1
2
3
$ ./elasticsearch
Exception in thread "main" 2017-11-12 12:17:55,776 main ERROR No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'log4j2.debug' to show Log4j2 internal initialization logging.
2017-11-12 12:17:56,319 main ERROR Could not register mbeans java.security.AccessControlException: access denied ("javax.management.MBeanTrustPermission" "register")
这也是根据问题原因去解决,解决方法如下:
1
2
# yum install -y log4j* ###安装log4j包
# chown dashuju:dashuju -R/usr/local/src/elasticsearch-5.6.3###给予elasticsearch权限
错误三:
继续启动:
1
2
3
4
$ ./elasticsearch
ERROR: bootstrap checks failed ##还有错误,这个是要改文件数,这个因为太多我就不放图了。
: max file descriptors for elasticsearch process is too low, increase to at least
: max virtual memory areas vm.max_map_count is too low, increase to at least
我们改一下限制的文件数就可以了
1
2
3
4
5
6
7
8
9
# cat /etc/sysctl.conf
vm.max_map_count=655360
# cat /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
# sysctl -p
vm.max_map_count = 655360
注:###最好重启一下,然后执行一遍
1
2
3
4
5
6
7
8
9
10
11
12
13
14
$ ./elasticsearch
# netstat -ntpl ###查看一下服务,可以看到elasticsearch已经起来了,端口9200和9300
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1178/sshd
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 847/rsync
tcp6 0 0 :::111 :::* LISTEN 1/systemd
tcp6 0 0 172.25.0.30:9200 :::* LISTEN 1650/java
tcp6 0 0 :::2224 :::* LISTEN 866/ruby
tcp6 0 0 172.25.0.30:9300 :::* LISTEN 1650/java
tcp6 0 0 :::22 :::* LISTEN 1178/sshd
tcp6 0 0 :::873 :::* LISTEN 847/rsync
tcp6 0 0 :::3306 :::* LISTEN 1436/mysqld
再访问以下我们9200端口,也已经成功了,可以看到elasticsearch的信息了。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# curl 172.25.0.30:9200
{
"name" : "XjOLC6R",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "45286kMyRMqEsjgH04lQCg",
"version" : {
"number" : "5.6.3",
"build_hash" : "1a2f265",
"build_date" : "2017-10-06T20:33:39.012Z",
"build_snapshot" : false,
"lucene_version" : "6.6.1"
},
"tagline" : "You Know, for Search"
}
个人总结:elasticsearch的安装使用并不难,我们在使用是只要是注意它启用时,所提示的错误,然后针对性的解决就可以。以上是我在安装使用elasticsearch所遇到问题,希望能帮到大家。
000000
页:
[1]