CentOS7下安装ElasticSearch6.2.4

在centos7下安装es二进制包

1、安装jdk

tar -zxvf jdk-8u181-linux-x64.tar.gz
mv jdk1.8.0_181 /usr/local
cd /usr/local/
ln -s jdk1.8.0_181 java

vim /etc/profile
export JAVA_HOME=/usr/local/java
export JRE_HOME=/usr/local/java/jre
export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH

source /etc/profile

2、下载elasticsearch 并安装
历史版本下载地址 https://www.elastic.co/downloads/past-releases

tar -zxvf elasticsearch-6.2.4.tar.gz -C /usr/local
cd /usr/local
ln -s elasticsearch-6.2.4 elasticsearch

创建一个专门的用户组来运行elasticsearch

groupadd esgroup
useradd esuser -g esgroup -p espassword
chown -R esuser:esgroup /usr/local/elasticsearch

修改文件最大打开数

vim /etc/security/limits.conf
esuser soft nofile 65536
esuser hard nofile 65536
esuser soft nproc 4096
esuer hard nproc 4096

vim /etc/security/limits.d/20-nproc.conf
esuser soft nproc 4096

修改内核参数

vim /etc/sysctl.conf
vm.max_map_count = 655360

sysctl -p

调整JVM的内存大小

vim /usr/local/elasticsearch/bin/elasticsearch
ES_JAVA_OPTS="-Xms512m -Xmx512m"

切换用户并运行

su esuser
bin/elasticsearch
#后台运行
bin/elasticsearch -d
#测试
curl 127.0.0.1:9200

实现远程访问

vim config/elasticsearch.yml
network.host 192.168.1.1

开机自动启动

sudo -u esuser /usr/local/elasticsearch/bin/elasticsearch -d

发表评论