Linux下datax安装

网友投稿 1081 2022-09-03

Linux下datax安装

Linux下datax安装

#!/bin/sh################################################################################################################Script name: installDatax.sh#Script description: Install Datax.#Current Release Version: 1.0.0#Script Owner: He ,Haibo#Latest editor: He, Haibo#Support platform: Linux OS for redhat and centos.#Date: 2021/8/17---first Version for install Datax.#Change log:#Descript:Put software to /var/directory,make ${downLoadIp} as server.#All install software will be in server##################################################################################################################Define Shell variablesexport LANG=en_USosbox=`uname`RHversion=$(cat /proc/version | sed 's/[^0-9]//g' | cut -b -3)####Defile downLoad IPdownLoadIp=192.168.56.100#######Set datax user and password,"is a exampledataxUser=dataxdataxUserPassword= if [[ ! -d /tmp/log ]];then mkdir -p /tmp/log chmod 767 /tmp/log fi dataxLogPath="/tmp/log" dataxLog=datax_$(date +%y%m%d).log}###Get OS Arch Linux or notgetOsArch(){ if [[ "$osbox" == "Linux" ]];then continue else echo "Current OS is $osbox,shell is exit now." | tee $dataxLogPath/$dataxLog echo 0 exit 0 fi}###Get redhat or centosgetOsCentosOrRedhat(){ cat /proc/version | grep -iE "redhat|centos" > /dev/null if [[ $? == 0 ]];then continue else echo "Current OS is not centos or redhat." | tee -a $dataxLogPath/$dataxLog echo 1 exit 1 fi}###Get OS VersiongetOsVerion(){ ###判断系统是否为Redhat,如果不是则退出,支持Redhat|Centos 7版本 cat /proc/version | grep -i redhat > /dev/null if [[ $? == 0 ]];then if [[ "$RHversion" -ge 310 ]];then OSVersion="redhat7" else echo "Current Rehat Version will not support." | tee -a $dataxLogPath/$dataxLog echo 1 exit 1 fi else if [[ "$RHversion" -ge 310 ]];then OSVersion="centos7" else echo "Current Rehat Version will not support." | tee -a $dataxLogPath/$dataxLog echo 1 exit 1 fi fi}###Get firewalld stopped or runningcheckFirewalld(){ if [[ $OSVersion == "redhat7" || $OSVersion == "centos7" ]];then systemctl status firewalld | grep -i running > /dev/null if [[ $? == 0 ]];then systemctl stop firewalld else echo "Firewalld is stopped,Success" | tee -a $dataxLogPath/$dataxLog fi fi}###Get firewalld enable or disabledcheckFirewalldisEnabled(){ systemctl list-unit-files | grep firewalld | grep disabled > /dev/null if [[ $? == 0 ]];then echo "check firewalld disabled.check success." | tee -a $dataxLogPath/$dataxLog else systemctl disable firewalld fi}###Get SeLinux enforcing or notcheckSeLinux(){ cat /etc/selinux/config | grep -w "SELINUX=enforcing" > /dev/null if [[ $? == 0 ]];then sed -i s#SELINUX=enforcing#SELINUX=disabled# /etc/selinux/config setenforce 0 else echo "Current SeLinux is stopped,Success." | tee -a $dataxLogPath/$dataxLog fi}checkPythonVersion(){ which python > /dev/null if [[ $? == 0 ]];then pythonVersion=`python -V 2>&1|awk '{print }'` if [[ $pythonVersion =~ 2.7 ]];then echo "Current Python Version is $pythonVersion,check success." | tee -a $dataxLogPath/$dataxLog else echo "Current Python Version is $pythonVersion,check failed." | tee -a $dataxLogPath/$dataxLog exit 1 fi else echo "Current OS does not hava python." | tee -a $dataxLogPath/$dataxLog fi}checkJavaVersion(){ which java > /dev/null if [[ $? == 0 ]];then javaVersion=`echo $(java -version 2>&1 |awk 'NR==1{gsub(/"/,"");print }')` if [[ "$javaVersion" > "1.8" ]];then echo "Current java version is $javaVersion,check success." | tee -a $dataxLogPath/$dataxLog else echo "Current java version is $javaVersion,check failed." | tee -a $dataxLogPath/$dataxLog exit 1 fi else echo "Current OS does not have java." fi}checkIpValid(){ ping -c 2 ${downLoadIp} >/dev/null if [[ $? == 0 ]];then echo "ping ${downLoadIp} success." | tee -a $dataxLogPath/$dataxLog else echo "ping ${downLoadIp} failed." | tee -a $dataxLogPath/$dataxLog exit 1 fi}installDatax(){###确保/datax目录被单独挂载。 df -h | grep /datax > /dev/null if [[ $? == 0 ]];then wget ${downLoadIp}/software/datax.tar.gz -P /tmp if [[ $? == 0 ]];then tar xvf /tmp/datax.tar.gz -C / > /dev/null else echo "wget datax.tar.gz failed." | tee -a $dataxLogPath/$dataxLog fi else echo "Does not hava /datax" | tee -a $dataxLogPath/$dataxLog fi}installMaven(){ wget ${downLoadIp}/software/apache-maven-3.3.9-bin.tar.gz -P /tmp if [[ $? == 0 ]];then tar xvf /tmp/apache-maven-3.3.9-bin.tar.gz -C /datax > /dev/null else echo "wget apache-maven-3.3.9-bin.tar.gz failed." | tee -a $dataxLogPath/$dataxLog fi}getJarPackages(){ wget ${downLoadIp}/software/ojdbc8.jar -P /datax/plugin/reader/oraclereader/libs wget ${downLoadIp}/software/ojdbc8.jar -P /datax/plugin/writer/oraclewriter/libs}createDataxUser(){ id $dataxUser > /dev/null if [[ $? == 0 ]];then echo "user $dataxUser is already exists." | tee -a $dataxLogPath/$dataxLog else /usr/sbin/useradd ${dataxUser} echo "$dataxUserPassword" | passwd --stdin $dataxUser fi}setProfile(){ cat /home/${dataxUser}/.bash_profile | grep -w 'dataxHome=/datax/bin;export dataxHome' if [[ $? == 0 ]];then echo "Check dataxHome success." | tee -a $dataxLogPath/$dataxLog else echo 'dataxHome=/datax/bin;export dataxHome' >> /home/${dataxUser}/.bash_profile fi cat /home/${dataxUser}/.bash_profile | grep -w 'mavenHome=/datax/apache-maven-3.3.9/bin;export mavenHome' if [[ $? == 0 ]];then echo "Check mavenHome success." | tee -a $dataxLogPath/$dataxLog else echo 'mavenHome=/datax/apache-maven-3.3.9/bin;export mavenHome' >> /home/${dataxUser}/.bash_profile fi su - ${dataxUser} -c "source /home/$dataxUser/.bash_profile"}chownDataxPath(){ chown -R ${dataxUser}:${dataxUser} /datax}main(){ mkdirLogPath getOsArch getOsCentosOrRedhat getOsVerion checkFirewalld checkFirewalldisEnabled checkSeLinux checkpythonVersion checkJavaVersion checkIpValid installDatax installMaven getJarPackages createDataxUser setProfile chownDataxPath}main

DATAX

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:(转)视图userInteractionEnabled交互性
下一篇:PHP 的闭包说明和应用实例(php连接mysql)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~