ES集群手动搭建步骤V1.0(基于elasticsearch-7.3.0版本)

ES集群手动搭建步骤V1.0(基于elasticsearch-7.3.0版本)

本文档适用于搭建ES集群,支持两种类型的操作系统:Centos 6.5、Centos 7.3。

1 修改操作系统参数

#文件:/etc/security/limits.d/90-nproc.conf

echo '*       -    nproc     65536'	>> /etc/security/limits.d/90-nproc.conf
echo '*       -    nofile    65536'	>> /etc/security/limits.d/90-nproc.conf
echo '*       -    memlock   unlimited'	>> /etc/security/limits.d/90-nproc.conf

ulimit -a
#文件:/etc/sysctl.conf

echo 'vm.max_map_count=262144'	>> /etc/sysctl.conf
echo 'vm.swappiness=0'			>> /etc/sysctl.conf
echo 'vm.overcommit_memory=1'	>> /etc/sysctl.conf
echo 'vm.zone_reclaim_mode=0'	>> /etc/sysctl.conf

sysctl -p
#大内存页

echo never > /sys/kernel/mm/transparent_hugepage/enabled

echo never > /sys/kernel/mm/transparent_hugepage/defrag
#文件:/etc/rc.d/rc.local
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
	echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi

if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
	echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi

chmod +x /etc/rc.d/rc.local

2 软件部署

2.1 创建es用户及属主

root用户操作

groupadd es -g 750 && useradd -g es -u 750  es  

2.2 修改用户环境变量

cd /home/es
echo 'export JAVA_HOME=/home/es/software/java' >> .bashrc
echo 'export ES_HOME=/home/es/software/elasticsearch' >> .bashrc
echo 'export CLASSPATH=$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar' >> .bashrc
echo 'export PATH=$JAVA_HOME/bin:$ES_HOME/bin:$PATH' >> .bashrc

2.3 创建相关目录

软件目录

su - es -c "mkdir /home/es/software"  

日志目录

su - es -c "mkdir –p /home/es/logs"  

数据目录

mkdir  /data/es-lyh

2.4 上传软件包

上传软件包到/home/es/software目录下

scp elasticsearch-7.3.0-linux-x86_64.tar.gz $ip:/home/es/software

scp jdk-8u201-linux-x64.tar.gz $ip:/home/es/software

解压软件包并做软连接

cd /home/es/software
tar -zxvf elasticsearch-7.3.0-linux-x86_64.tar.gz
rm -f elasticsearch-7.3.0-linux-x86_64.tar.gz
ln -s elasticsearch-7.3.0 elasticsearch
tar -zxvf jdk-8u201-linux-x64.tar.gz
rm -f jdk-8u201-linux-x64.tar.gz
ln -s jdk1.8.0_201 java
chown -R es:es /home/es

3 配置文件修改

切换到es用户下执行

su - es

cd /home/es/software/elasticsearch/config/

3.1 192.168.168.1节点

3.1.1 修改elasticsearch.yml

cluster.name: es-lyh
node.name: node-1
node.master: true
node.data: true
path.data: /data/es-lyh
path.logs: /home/es/logs
network.host: 192.168.168.1
discovery.zen.ping.unicast.hosts: ["192.168.168.1","192.168.168.2","192.168.168.3"]
xpack.ml.enabled: false

3.1.2 修改jvm.options

修改为机器内存的1/4到1/2范围。(例如:16G的机器就修改为8G)

-Xms8g
-Xmx8g

3.2 192.168.168.2节点

3.2.1 修改elasticsearch.yml

cluster.name: es-lyh
node.name: node-2
node.master: true
node.data: true
path.data: /data/es-lyh
path.logs: /home/es/logs
network.host: 192.168.168.2
discovery.zen.ping.unicast.hosts: ["192.168.168.1","192.168.168.2","192.168.168.3"]
xpack.ml.enabled: false

3.2.2 修改jvm.options

修改为机器内存的1/4到1/2范围。(例如:16G的机器就修改为8G)

-Xms8g
-Xmx8g

3.3 192.168.168.3节点

3.3.1 修改elasticsearch.yml

cluster.name: es-lyh
node.name: node-3
node.master: true
node.data: true
path.data: /data/es-lyh
path.logs: /home/es/logs
network.host: 192.168.168.3
discovery.zen.ping.unicast.hosts: ["192.168.168.1","192.168.168.2","192.168.168.3"]
xpack.ml.enabled: false

3.3.2 修改jvm.options

修改为机器内存的1/4到1/2范围。(例如:16G的机器就修改为8G)

-Xms8g
-Xmx8g

4 依次启动所有节点Elasticsearch服务

切换到es用户下执行

su - es

cd /home/es/software/elasticsearch/bin/

./elasticsearch -d

5 验证

#es用户下jps -ml查看对应角色进程是否存在
su - es
jps -ml

#查看集群监控状态

curl http://192.168.168.1:9200/_cat/health?v

#查看节点状态
curl http://192.168.168.1:9200/_cat/nodes?v

你可能感兴趣的:(elasticsearch,linux,大数据)