ElasticSearch安装常见错误
ElasticSearch是一个用Java开发的基于Lucene的搜索服务器。它可以提供一个分布式多用户能力的全文搜索引擎,基于RESTfulweb接口。现阶段它主要为Apache许可条款下的开放源码发布,也是当前流行的企业级搜索引擎。Elasticsearch设计主要用于云计算中,ElasticSearch实时搜索,稳定,可靠,快速,安装使用方便的优点,很好的解决大数据查询缓慢问题。
现在我们来安装使用 ElasticSearch,可以这样说5.6以上的版本,安装时出的问题是比较多的,但我们可以通过提示来解决这些问题。
基于我们是测试使用,我只需在一台上安装就可以了,首先 ElasticSearch是基于java来开发的,所以我们好安装java包。
[[email protected] ~]# yum install -y *jdk 安装java环境 [[email protected] ~]# cd /usr/local/src/ [[email protected] src]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.3.tar.gz
##官网下载5.6以上的版本
[[email protected] ~]# 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
[[email protected] src]# tar -xf elasticsearch-5.6.3.tar.gz ##解压 [[email protected] src]# cd elasticsearch-5.6.3 [[email protected] elasticsearch-5.6.3]# ls bin config lib LICENSE.txt modules NOTICE.txt plugins README.textile [[email protected] elasticsearch-5.6.3]# vim config/ elasticsearch.yml jvm.options log4j2.properties [[email protected] elasticsearch-5.6.3]# 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用户下运行,接下来我们换个用户来运行。
[[email protected] bin]# useradd dashuju [[email protected] bin]# su - dashuju [[email protected] ~]$ cd /usr/local/src/elasticsearch-5.6.3/
错误二:
启动后我们发现了错误
[[email protected] bin]$ ./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")
这也是根据问题原因去解决,解决方法如下:
[[email protected] ~]# yum install -y log4j* ###安装log4j包 [[email protected] ~]# chown dashuju:dashuju -R /usr/local/src/elasticsearch-5.6.3 ###给予elasticsearch权限
错误三:
继续启动:
[[email protected] bin]$ ./elasticsearch ERROR: [2] bootstrap checks failed ##还有错误,这个是要改文件数,这个因为太多我就不放图了。 [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536] [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
我们改一下限制的文件数就可以了
[[email protected] src]# cat /etc/sysctl.conf vm.max_map_count=655360 [[email protected] src]# cat /etc/security/limits.conf * soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4096 [[email protected] ~]# sysctl -p vm.max_map_count = 655360
注:###最好重启一下,然后执行一遍
[[email protected] bin]$ ./elasticsearch [[email protected] ~]# 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的信息了。
[[email protected] ~]# 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所遇到问题,希望能帮到大家。
时间: 2024-10-03 22:38:54