1. 先安装java
1)检查系统中是否已经安装了java:
java -version
2)进一步查看JDK信息:
rpm -qa | grep java
3)卸载openJDK
rpm -e --nodeps tzdata-java-2012c-1.el6.noarch
rpm -e --nodeps java-1.7.0-openjdk-1.7.0.45-1.45.1.11.1.el6.x86_64
4)安装JDK
rpm -ivh jdk-7-linux-i586.rpm
JDK默认安装在/usr/java中,使用rpm 的 --prefix参数修改安装目录
5) 查看安装是否正常
java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) Client VM (build 24.45-b08, mixed mode, sharing)
6)配置环境变量
vim /etc/profile
在文件中加入以下内容:
JAVA_HOME=/usr/java/jdk1.7.0_45
JRE_HOME=/usr/java/jdk1.7.0_45/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
7)是配置生效
source /etc/profile
8)查看PATH
echo $PATH
2. es安装
1) 将es压缩文件移到/opt中
mv elasticsearch-2.1.1.tar.gz /opt cd /opt
2)解压,重命名
tar zxvf elasticsearch-2.1.1.tar.gz
mv elasticsearch-2.1.1 elasticsearch
3)用root用户运行es会报错
Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root.
at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:93)
at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:144)
at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:285)
at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Refer to the log for complete error details.
4)由于ElasticSearch可以接收用户输入的脚本并且执行,为了系统安全考虑, 建议创建一个单独的用户用来运行ElasticSearch
groupadd elsearch
useradd elsearch -g elsearch -p elasticsearch
5)更改elasticsearch文件夹及内部文件的所属用户及组为elsearch:elsearch
cd /opt
chown -R elsearch:elsearch elasticsearch
6)切换到elsearch用户再启动
su elsearch cd elasticsearch/bin
./elasticsearch
7)ElasticSearch后端启动命令
./elasticsearch -d
————————————————————我是单纯的分割线————————————————————————————
ElasticSearch 5.x.0 安装部署常见错误或问题
问题一:
bin/elasticsearch-plugin install x-pack
补:启动异常:ERROR: bootstrap checks failed
system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk
问题原因:因为Centos6不支持SecComp,而ES5.2.1默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动。详见 :https://github.com/elastic/elasticsearch/issues/22899
解决方法:在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false