ElasticSearch从入门到精通 (ElasticSearch安装)

1、下载安装包

ElasticSearch各个版本下载地址 建议使用迅雷下载速度比较快。

2、安装jdk

ElasticSearch 是java程序,需要依赖jdk,第一步是确保正确安装Java SE环境。Elasticsearch需要Java 6或更高版本。安装过程略,可参考之前安装教程。
确保java环境:java -version

3、解压ElasticSearch、运行

在安装的bin目录下
前台运行:./bin/elasticsearch
后台守护进程运行:./bin/elasticsearch -d
elasticsearch在工作时一般使用2个端口号:第1个是
使用HTTP协议与REST API通信的端口,第2个是传输模块(transport module),是用来在集群内以及Java客户端和集群之间通信的端口。HTTP API的默认端口号是9200。
开放9200端口号
/sbin/iptables -I INPUT -p tcp –dport 9200-j ACCEPT
保存配置
/etc/rc.d/init.d/iptables save
改变IP
vim /usr/local/elasticsearch/config/elasticsearch.yml
network.host: 你的IP

4、在浏览器访问http://ip:9200

在这里插入图片描述

5、安装过程可能出现的问题以及解决方案

错误1、unable to load JNA native support library, native methods will be disabled.
解决方案
在lib目录下,删除或者备份jna-4.5.1.jar
mv jna-4.5.1.jar jna-4.5.1.jar.bak
然后执行:wget http://repo1.maven.org/maven2/net/java/dev/jna/jna/4.5.1/jna-4.5.1.jar

错误2、can not run elasticsearch as root不能以root用户进行启动
解决方案
添加新用户:adduser hyperchain
passwd hyperchain密码需要输入两次。提示密码无效不用管,因为密码过于简单
切换到新创建的用户:su hyperchain

错误3、java.nio.file.AccessDeniedException: /usr/local/elasticsearch/config/jvm.options
解决方案
给新建用户elasticsearch文件夹的权限
要先切换到root账号 su root
chown -R hyperchain:hyperchain /usr/local/elasticsearch

错误4、unable to install syscall filter:
java.lang.UnsupportedOperationException: seccomp unavailable: ‘i386’ architecture unsupported。这只是一个警告,不影响运行,因为Centos版本太低。

错误5、X-Pack is not supported and Machine Learning is not available for [linux-x86]; you can use the other X-Pack features (unsupported) by setting xpack.ml.enabled: false in elasticsearch.yml
解决方案
vim /usr/local/elasticsearch/config/elasticsearch.yml
添加xpack.ml.enabled: false

错误6、bootstrap checks failed
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
max number of threads [1024] for user [WangZX] is too low, increase to at least [4096]
在建立索引时,尤其是有很多分片和副本的情况下,Elasticsearch将创建很多文件。所以,系统不能限制打开的文件描述符小于65536个
解决方案
vim /etc/security/limit.conf 添加
hyperchain soft nofile 65536
hyperchain hard nofile 131072
hyperchain soft nproc 4096
hyperchain hard nproc 4096

错误7、max virtual memory areas vm.max_map_count [65530] is too low,
increase to at least [262144]
解决方案
vim /etc/sysctl.conf
添加vm.max_map_count=655360
执行sysctl -p

错误8、system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
解决方案
vim /usr/local/elasticsearch/config/elasticsearch.yml
添加bootstrap.memory_lock: false
bootstrap.system_call_filter: false

错误9、JVM is using the client VM [Java HotSpot™ Client VM] but should be using a server VM for the best
解决方案

vim[jre安装目录]/lib/i386/jvm.cfg 更改配置默认-client在第一行

-server KNOWN
-client IF_SERVER_CLASS -server
-minimal KNOWN

JDK包括2个JVM的实现
Java HotSpot Client VM(-client),为在客户端环境中减少启动时间而优化;
Java HotSpot Server VM(-server),为在服务器环境中最大化程序执行速度而设计。
Server VM启动比Client VM慢,运行比Client VM快。
需要将vm设置为-server KNOWN

发布了136 篇原创文章 · 获赞 30 · 访问量 21万+

猜你喜欢

转载自blog.csdn.net/qq_33029793/article/details/103071319