#! /bin/bash
#上传jdk-8u201-linux-x64.tar.gz和elasticsearch到/opt下
yum install -y gzip
#准备jdk环境
cd /opt
java -version
if [ $? -eq 0 ]
then
rpm -ivh elasticsearch-7.7.1-x86_64.rpm
#手撕一个elasticsearch.yml.bak
cat >/etc/elasticsearch/elasticsearch.yml.bak <<EOF
cluster.name: elk-cluster
node.master: true
node.data: true
node.name: elk01
path.data: /data/es-data
path.logs: /var/log/elasticsearch
#当前主机ip地址
network.host: 192.168.175.171
http.port: 9200
#节点数(node)为n-1,n为主+从之和
discovery.zen.minimum_master_nodes: 1
http.cors.enabled: true
http.cors.allow-origin: "*"
#写有可能成为主的IP地址或域名
#写域名注意要在/etc/hosts下做相应记录
discovery.seed_hosts: ["elk01","elk02"]
cluster.initial_master_nodes: ["elk01","elk02"]
EOF
else
cd /opt
echo "请稍后,正在为你解压..."
gunzip jdk-8u201-linux-x64.tar.gz
tar -xvhf jdk-8u201-linux-x64.tar
cp -r /opt/jdk1.8.0_201/ /usr/local/jdk
echo 'export JAVA_HOME=/usr/local/jdk' >> /etc/profile
echo 'export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar' >> /etc/profile
echo 'export PATH=$PATH:$JAVA_HOME/bin' >> /etc/profile
source /etc/profile
fi
elasticsearch自动安装脚本(elasticsearch-7.7.1-x86_64.rpm)
最新推荐文章于 2023-03-25 10:57:07 发布