一、节点搭建
下载Elasticsearch
地址: https://www.elastic.co/cn/downloads/elasticsearch 最新版本
1.解压三个tar.gz文件
tar -zxvf jdk-8u171-linux-x64.tar.gz
tar -zxvf elasticsearch-7.3.0-linux-x86_64.tar.gz
2.配置jdk环境变量
vim /etc/profile
在profile结尾添加如下内容:
export JAVA_HOME=/opt/yyjzy/servers/jdk1.8.0_231
export CLASSPATH=
:
C
L
A
S
S
P
A
T
H
:
:CLASSPATH:
:CLASSPATH:JAVA_HOME/lib/
export PATH=
P
A
T
H
:
PATH:
PATH:JAVA_HOME/bin
让修改生效:
source /etc/profile
检查jdk
java -version
jdk配置完成!
配置Elasticsearch
1.编辑vim /opt/yyjzy/servers/elasticsearch-7.3.0
/config/elasticsearch.yml ,注意冒号后面有个空格。
vim /opt/yyjzy/servers/elasticsearch-7.3.0
/config/elasticsearch.yml
添加如下配置:
cluster.name: my-es #集群名称 ---
network.host: 192.168.21.16
node.name: node-1 # 节点名称
node.master: true #当前节点是否可以被选举为master节点,是:true、否:false --- network.host: 0.0.0.0
http.port: 9200
transport.port: 9300 # ---
#初始化一个新的集群时需要此配置来选举master
cluster.initial_master_nodes: ["node-1","node-2","node-3"] #写入候选主节点的设备地址 ---
discovery.seed_hosts: ["127.0.0.1:9300", "127.0.0.1:9301","127.0.0.1:9302"] http.cors.enabled: true
http.cors.allow-origin: "*"
2.按需修改vim /opt/yyjzy/servers/elasticsearch-7.3.0/config/jvm.options内存设置
vim /opt/yyjzy/servers/elasticsearch-7.3.0/config/jvm.options
根据实际情况修改占用内存,默认都是1G,单机1G内存,启动会占用700m+然后在安装kibana 后,基本上无法运行了,运行了一会就挂了报内存不足。 内存设置超出物理内存,也会无法启 动,启动报错。
-Xms1g
-Xmx1g
3.添加es用户,es默认root用户无法启动,需要改为其他用户
useradd estest
修改密码
passwd estest
改变es目录拥有者账号
chown -R estest /opt/yyjzy/servers/elasticsearch-7.3.0
4.修改/etc/sysctl.conf
vim /etc/sysctl.conf
末尾添加:vm.max_map_count=655360
执行sysctl -p 让其生效
sysctl -p
5.修改/etc/security/limits.conf
vim /etc/security/limits.conf
末尾添加:
* soft nofile 65536
* hard nofile 65536
* soft nproc 4096
* hard nproc 4096
#启动 一定要用estest用户来执行 cd bin/
./elasticsearch
二、第二节点配置
- 拷贝原来的ES节点elasticsearch 并命名为elasticsearch1,并授权
cp /opt/yyjzy/servers/elasticsearch-7.3.0
/opt/yyjzy/servers/elasticsearch-7.3.01 -rf
chown -R estest /opt/yyjzy/servers/elasticsearch-7.3.01
进入elasticsearch-7.3.01
目录config文件夹,修改elasticsearch.yml配置文件并保存。
# 修改node.name 和 http.port transport.port
node.name: node-2
http.port: 9201
transport.port: 9301
#启动从环境1 一定要用estest用户来执行 cd bin/
./elasticsearch
2.第三节点配置
拷贝第一个节点 并命名为elasticsearch-7.3.02,并授权
chown -R estest /opt/yyjzy/servers/elasticsearch-7.3.02
进入elasticsearch-7.3.02
目录config文件夹,修改elasticsearch.yml配置文件并保存。
# 修改node.name 和 http.port transport.port
node.name: node-3
http.port: 9202
transport.port: 9302
#启动从环境1 一定要用estest用户来执行 cd bin/
./elasticsearch
简单验证
http://192.168.21.16:9200/_cat/health?v