欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

flink集群一键安装脚本 -- java运行环境配置

程序员文章站 2022-06-06 16:57:28
...

前期准备,java运行环境

  • 准备8u144版本jdk:jdk-8u144-linux-x64.rpm

多次从官网下载该rpm包失败,因此需要自己下载好该安装包

#!/bin/bash

################ 准备java环境 ######################
DOWNLOAD_PATH=""
JDK_PATH="jdk1.8.0_144" # "jre1.8.0_161/"
JAVA_JDK="jdk-8u144-linux-x64.rpm" # "jre-8u161-linux-x64.rpm"
ETC_PROFILE="/etc/profile"

if [ ! -f ${DOWNLOAD_PATH}${JAVA_JDK} ];then
    echo "downloadding ${JAVA_JDK}";
    # wget -O ${JAVA_JDK} http://javadl.oracle.com/webapps/download/AutoDL?BundleId=230531_2f38c3b165be4555a1fa6e98c45e0808 # 下载java源码包
fi

chmod -x ${DOWNLOAD_PATH}${JAVA_JDK}
rpm -ivh ${DOWNLOAD_PATH}${JAVA_JDK}

sed -i "/^JAVA_HOME=/d" ${ETC_PROFILE};
sed -i "/^JAVA_BIN=/d" ${ETC_PROFILE};
sed -i "/^PATH=\$PATH:\$JAVA_HOME\/bin/d" ${ETC_PROFILE};
sed -i "/^CLASSPATH=.:/d" ${ETC_PROFILE};
sed -i "/^export JAVA_HOME/d" ${ETC_PROFILE};

echo -e "\n" >> ${ETC_PROFILE};
echo -e "JAVA_HOME=/usr/java/${JDK_PATH}" >> ${ETC_PROFILE};
echo -e "JAVA_BIN=/usr/java/${JDK_PATH}" >> ${ETC_PROFILE};
echo -e "PATH=\$PATH:\$JAVA_HOME/bin" >> ${ETC_PROFILE};
echo -e "CLASSPATH=.:\$JAVA_HOME/lib/dt.jar:\$JAVA_HOME/lib/tools.jar" >> ${ETC_PROFILE};
echo -e "export JAVA_HOME JAVA_BIN PATH CLASSPATH\n" >> ${ETC_PROFILE};

if [ $? -ne 0 ] ;then
    exit 1;
fi;
source /etc/profile
echo "java version is:";
java -version

############### java环境搭建完成 ###################
相关标签: java bash flink