之前的记录有点混乱 ,今天有这个需求刚好重装安装配置下 。

#先安装java
#jdk 1.8

cd /usr/tmp
wget https://www.isres.com/file/jdk-linux-x64.tar.gz
tar -zxvf jdk-linux-x64.tar.gz
mv jdk1.8.0_131 /usr/local/jdk1.8.0
vi /etc/profile

export JAVA_HOME=/usr/local/jdk1.8.0
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

source /etc/profile
java -version

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.1.2.tar.gz
#博客已经下载了一份
tar -zxvf elasticsearch-6.1.2.tar.gz
mv elasticsearch-6.1.2 /usr/local/

创建运行用户

groupadd es
useradd  esuser -g es -p GFdw#$%78Pokk
chown -R esuser:es /usr/local/elasticsearch-6.1.2

基本环境设置

vi /etc/security/limits.conf

* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

vi /etc/security/limits.d/90-nproc.conf
 
* soft nproc 1024
#修改为
* soft nproc 4096

vi /etc/sysctl.conf
添加下面配置:

vm.max_map_count=655360

并执行命令:

sysctl -p
mkdir /es_data/
mkdir /es_data/data
mkdir /es_data/log
chown  -R esuser:es /es_data

cd  /usr/local/elasticsearch-6.1.2
vim config/elasticsearch.yml

bootstrap.memory_lock: false
bootstrap.system_call_filter: false


path.data: /es_data/data
path.logs: /es_data/log

network.host: 192.168.1.221

#安装权限控制的插件 一定要启动后才能运行 创建密码
bin/elasticsearch-plugin install x-pack
#安装完成后
#保存并启动

runuser -l esuser -c '/usr/local/elasticsearch-6.1.2/bin/elasticsearch -d'


#创建密码
bin/x-pack/setup-passwords auto




#防火墙开 9200