Centos6.5下安装elasticsearch(安装过程中遇到的问题及解决)

安装Elasticsearch

1、安装Java
为了建立Elasticsearch,第一步是确保正确安装Java SE环境。Elasticsearch需要Java 6或更高版本。我下载的是elasticsearch-6.4.0版本,在安装的时候需要JDK8。
JDK下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html
配置环境变量
vim /etc/profile
这里写图片描述
重新加载配置文件【否则环境变量不会生效】
source /etc/profile

2、安装Elasticsearch
http://www.elasticsearch.org/download/下载,解压。
这里写图片描述

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、安装过程中出现的错误和解决方案
错误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 WangZX
passwd luochao密码需要输入两次。提示密码无效不用管,因为密码过于简单
切换到新创建的用户:su WangZX

错误3、java.nio.file.AccessDeniedException: /usr/local/elasticsearch/config/jvm.options
解决方案
给新建用户elasticsearch文件夹的权限
要先切换到root账号 su root
chown -R WangZX:WangZX /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 添加
WangZX soft nofile 65536
WangZX hard nofile 131072
WangZX soft nproc 4096
WangZX 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(TM) 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

5、在浏览器访问http://ip:9200
这里写图片描述
说明安装成功!

猜你喜欢

转载自blog.csdn.net/qq_27046951/article/details/82696990