1、下载安装包
https://www.elastic.co/cn/downloads/past-releases#elasticsearch
elasticsearch-7.0.0-linux-x86_64.tar.gz
2、修改系统参数
vim /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 65536
* hard nproc 131072
# 修改线程数 root默认开启任意个 其他用户默认1024个线程 elasticsearch至少需要4096+个线程池做预备 **
echo "vm.max_map_count=262144" >> /etc/sysctl.conf
# 加载系统参数
sysctl -p
3、创建elasticsearch 安装目录 添加elasticsearch用户 (3台服务器均要)
mkdir -p /data/elasticsearch
mkdir -p /data/elasticsearch/data
mkdir -p /data/elasticsearch/logs
# 创建用户组
groupadd elasticsearch
# 创建用户 elasticsearch
useradd elasticsearch -g elasticsearch -p elasticsearch
4、开始安装
上传安装包到服务器(仅上传到其中一台服务器即可,后续进行scp即可传送到另外的服务器)
tar -zxvf elasticsearch-7.0.0-linux-x86_64.tar.gz -C /data/elasticsearch
5、配置环境
# 配置Java环境,使用elasticsearch自带的
export JAVA_HOME=/data/elasticsearch/elasticsearch-7.0.0/jdk
export PATH=$JAVA_HOME/bin:$PATH
# 更新环境变量
source /etc/profile
# 查看Java版本
java -version
openjdk 12 2019-03-19
OpenJDK Runtime Environment (build 12+33)
OpenJDK 64-Bit Server VM (build 12+33, mixed mode, sharing)
编辑elasticsearch.ymal
cd /data/elasticsearch/elasticsearch-7.0.0/config
mv elasticsearch.yml elasticsearch.yml.bak
vi elasticsearch.yml
cluster.name: escluster
node.name: base0-1
node.master: true
node.data: true
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
http.port: 9200
transport.tcp.port: 9300
network.host: 0.0.0.0
discovery.seed_hosts: ["192.168.100.13:9300","192.168.100.119:9300","192.168.100.78:9300"]
cluster.initial_master_nodes: ["base0-1","base0-2","base0-3"]
http.cors.enabled: true
http.cors.allow-origin: "*"
配置jvm参数
按照服务器配置调整Java虚拟机内存,在config\jvm.options配置文件中调整内存大小 。其中,Xms参数表示堆空间的初始值,Xmx参数表示堆空间的最大值,应该把最小和最大JVM堆设置成相同的值
vim /data/elasticsearch/elasticsearch-7.0.0/config/jvm.options
# 修改 -Xms和-Xmx数值
-Xms4g
-Xmx4g
6、集群配置
拷贝/data/elasticsearch目录下的elasticsearch-7.0.0到另外两台服务器
scp elasticsearch-7.0.0 root@base0-2:/data/elasticsearch/
scp elasticsearch-7.0.0 root@base0-3:/data/elasticsearch/
修改base0-2服务器elasticsearch.yml配置文件
vi elasticsearch.yml
cluster.name: escluster
node.name: base0-2
node.master: true
node.data: true
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
http.port: 9200
transport.tcp.port: 9300
network.host: 0.0.0.0
discovery.seed_hosts: ["192.168.100.13:9300","192.168.100.119:9300","192.168.100.78:9300"]
cluster.initial_master_nodes: ["base0-1","base0-2","base0-3"]
http.cors.enabled: true
http.cors.allow-origin: "*"
修改base0-3服务器elasticsearch.yml配置文件
vi elasticsearch.yml
cluster.name: escluster
node.name: base0-3
node.master: true
node.data: true
path.data: /data/elasticsearch/data
path.logs: /data/elasticsearch/logs
http.port: 9200
transport.tcp.port: 9300
network.host: 0.0.0.0
discovery.seed_hosts: ["192.168.100.13:9300","192.168.100.119:9300","192.168.100.78:9300"]
cluster.initial_master_nodes: ["base0-1","base0-2","base0-3"]
http.cors.enabled: true
http.cors.allow-origin: "*"
7、启动elasticsearch
文件夹授权(3台服务器均要)
chown -R elasticsearch:elasticsearch /data/elasticsearch
启动elasticsearch
# 启动es需要普通用户
su - elasticsearch
进入到启动文件目录下
cd /data/elasticsearch/elasticsearch-7.0.0/bin/
启动
nohup ./elasticsearch &
后台运行
./bin/elasticsearch –d
退出普通,以root用户查看9200端口是否开启
netstat -tunlp | grep 9200
tcp6 0 0 :::9200 :::* LISTEN 9875/java