本文档适用于搭建ES集群,支持两种类型的操作系统:Centos 6.5、Centos 7.3。
#文件:/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
root用户操作
groupadd es -g 750 && useradd -g es -u 750 es
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
软件目录
su - es -c "mkdir /home/es/software"
日志目录
su - es -c "mkdir –p /home/es/logs"
数据目录
mkdir /data/es-lyh
上传软件包到/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
切换到es用户下执行
su - es
cd /home/es/software/elasticsearch/config/
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
修改为机器内存的1/4到1/2范围。(例如:16G的机器就修改为8G)
-Xms8g
-Xmx8g
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
修改为机器内存的1/4到1/2范围。(例如:16G的机器就修改为8G)
-Xms8g
-Xmx8g
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
修改为机器内存的1/4到1/2范围。(例如:16G的机器就修改为8G)
-Xms8g
-Xmx8g
切换到es用户下执行
su - es
cd /home/es/software/elasticsearch/bin/
./elasticsearch -d
#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