官网:https://www.elastic.co/cn/downloads/
全套安装包下载地址:https://download.csdn.net/download/zwhfyy/15534349
echo "关闭防火墙"
systemctl stop firewalld.service
systemctl stop firewalld
systemctl disable firewalld
sleep 6s
#修改主机名
hostnamectl set-hostname node-1
#修改主机名
hostnamectl set-hostname node-2
#修改主机名
hostnamectl set-hostname node-3
n1="192.168.31.241"
n2="192.168.31.242"
n3="192.168.31.243"
host_name1="node-1"
host_name2="node-2"
host_name3="node-3"
#修改hosts
echo "$n1 $host_name1 $host_name1" >> /etc/hosts
echo "$n2 $host_name2 $host_name2" >> /etc/hosts
echo "$n3 $host_name3 $host_name3" >> /etc/hosts
hostname
#修改系统设置,并重启服务器
sed -i 's/\/dev\/mapper\/centos-swap/#\/dev\/mapper\/centos-swap/g' /etc/fstab
echo "ulimit=65535" >> /etc/security/limits.conf
echo "vm.max_map_count=262144" >> /etc/sysctl.conf
echo "nproc=4096" >> /etc/security/limits.conf
echo "net.ipv4.tcp_retries2=5" >> /etc/sysctl.conf
reboot
useradd es
mkdir -p /opt/es
cd /opt
chown -R es:es ./es
su - es
cd /opt/es
mkdir -p /opt/es/data/
mkdir -p /opt/es/logs/
cd /opt/es
ll
#每一台服务器都 上传文件并解压缩
tar -xvf elasticsearch-7.11.1-linux-x86_64.tar.gz
cd /opt/es/elasticsearch-7.11.1/bin/
#配置节点1
echo "network.host: 192.168.31.241" >> /opt/es/elasticsearch-7.11.1/config/elasticsearch.yml
echo "node.name: node-1" >> /opt/es/elasticsearch-7.11.1/config/elasticsearch.yml
#配置节点2
echo "network.host: 192.168.31.242" >> /opt/es/elasticsearch-7.11.1/config/elasticsearch.yml
echo "node.name: node-2" >> /opt/es/elasticsearch-7.11.1/config/elasticsearch.yml
#配置节点3
echo "network.host: 192.168.31.243" >> /opt/es/elasticsearch-7.11.1/config/elasticsearch.yml
echo "node.name: node-3" >> /opt/es/elasticsearch-7.11.1/config/elasticsearch.yml
echo "discovery.seed_hosts: [\"node-1\", \"node-2\", \"node-3\"]" >> /opt/es/elasticsearch-7.11.1/config/elasticsearch.yml
echo "cluster.initial_master_nodes: [\"node-1\", \"node-2\", \"node-3\"]" >> /opt/es/elasticsearch-7.11.1/config/elasticsearch.yml
echo "gateway.recover_after_nodes: 2" >> /opt/es/elasticsearch-7.11.1/config/elasticsearch.yml
echo "xpack.security.enabled: true" >> /opt/es/elasticsearch-7.11.1/config/elasticsearch.yml
echo "path.data: /opt/es/data" >> /opt/es/elasticsearch-7.11.1/config/elasticsearch.yml
echo "path.logs: /opt/es/logs" >> /opt/es/elasticsearch-7.11.1/config/elasticsearch.yml
echo "http.port: 9200" >> /opt/es/elasticsearch-7.11.1/config/elasticsearch.yml
echo "node.master: true" >> /opt/es/elasticsearch-7.11.1/config/elasticsearch.yml
echo "node.data: true" >> /opt/es/elasticsearch-7.11.1/config/elasticsearch.yml
echo "http.cors.enabled: true" >> /opt/es/elasticsearch-7.11.1/config/elasticsearch.yml
echo "http.cors.allow-origin: \"*\"" >> /opt/es/elasticsearch-7.11.1/config/elasticsearch.yml
echo "cluster.name: escluster" >> /opt/es/elasticsearch-7.11.1/config/elasticsearch.yml
./elasticsearch
cd /opt/es/elasticsearch-7.11.1/bin/
./elasticsearch-setup-passwords interactive
#输入密码
vi /opt/es/elasticsearch-7.11.1/config/elasticsearch.yml
vi /opt/es/elasticsearch-7.11.1/config/elasticsearch.yml
su - es
cd /opt/es/elasticsearch-7.11.1/bin/
./elasticsearch
./elasticsearch -d
tail -fn100 /opt/es/logs/elasticsearch.log
sysctl vm.max_map_count
sysctl net.ipv4.tcp_retries2
系统设置:
禁用交换
临时 sudo swapoff -a
永久 /etc/fstab 把带有这个的都注释掉swap
打开文件数
/etc/security/limits.conf
ulimit -n 65535
虚拟内存
sysctl -w vm.max_map_count=262144
/etc/sysctl.conf vm.max_map_count=262144
验证方法,重启后执行 sysctl vm.max_map_count
最大线程数
ulimit -u 4096
/etc/security/limits.conf nproc=4096
DNS缓存设置
在JVM options中设置DNS缓存时间
JVM默认将无限期地缓存正主机名解析,并且默认将十秒内缓存负主机名解析。Elasticsearch用默认值覆盖此行为,以将正向查找缓存六十秒,并将负向查找缓存十秒。
es.networkaddress.cache.ttl= and es.networkaddress.cache.negative.ttl=
JNA缓存设置
java.lang.UnsatisfiedLinkerError
failed to map segment from shared object
because JNA is not available
如果遇到这三条错误信息那么在 JVM options中指定 -Djna.tmpdir=<path>
TCP重传超时设置(五次重发对应于大约六秒钟的超时)
sysctl -w net.ipv4.tcp_retries2=5
/etc/sysctl.conf net.ipv4.tcp_retries2=5
验证方法,重启后执行 sysctl net.ipv4.tcp_retries2