linux脚本自动安装jdkhadoopzookeeper,单机版

Posted honconM

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux脚本自动安装jdkhadoopzookeeper,单机版相关的知识,希望对你有一定的参考价值。

编辑脚本

[root@mihaoyu151 ~]# ll /opt/install/
total 773684
-rw-r--r--. 1 root root 433895552 Oct 25 17:59 hadoop-2.6.0-cdh5.14.2.tar.gz
-rw-r--r--. 1 root root 128523051 Oct 25 17:59 hive-1.1.0-cdh5.14.2.tar.gz
-rw-r--r--. 1 root root 195094741 Oct 20 22:25 jdk-8u221-linux-x64.tar.gz
-rw-r--r--. 1 root root  34731946 Nov  3 19:09 zookeeper-3.4.5-cdh5.14.2.tar.gz

[root@mihaoyu151 ~]# vi /opt/mysyssh/autoinstall.sh
#!/bin/bash

jdk=true
zk=true
hadoop=true

hostname=`hostname`
echo "current host name is $hostname"
whoami=`whoami`
echo "current user is $whoami"

installdir=/opt/soft
if [ ! -d "$installdir" ]
then
	mkdir $installdir
fi

if [ "$jdk" = true ]
then
	echo "---------- 安装jdk ----------"
	tar -zxf /opt/install/jdk-8u221-linux-x64.tar.gz -C /opt/soft/
	mv /opt/soft/jdk1.8.0_221 /opt/soft/jdk180
	echo "#jdk" >> /etc/profile
	echo "export JAVA_HOME=/opt/soft/jdk180" >> /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
fi

if [ "$hadoop" = true ]
then
	echo '---------- 安装hadoop ----------'
	tar -zxf /opt/install/hadoop-2.6.0-cdh5.14.2.tar.gz -C /opt/soft
	mv /opt/soft/hadoop-2.6.0-cdh5.14.2 /opt/soft/hadoop260

	echo '---------- 修改配置hadoop-env.sh ----------'
	sed -i "/^export JAVA_HOME=/cexport JAVA_HOME=$JAVA_HOME/" /opt/soft/hadoop260/etc/hadoop/hadoop-env.sh

	echo '---------- 修改配置mapred-env.sh ----------'
	sed -i "/^# export JAVA_HOME=/cexport JAVA_HOME=$JAVA_HOME/" /opt/soft/hadoop260/etc/hadoop/mapred-env.sh

	echo '---------- 修改配置yarn-env.sh ----------'
	sed -i "/^# export JAVA_HOME=/cexport JAVA_HOME=$JAVA_HOME/" /opt/soft/hadoop260/etc/hadoop/yarn-env.sh

	echo '---------- 修改配置core-site.sh ----------'
	core_path="/opt/soft/hadoop260/etc/hadoop/core-site.xml"
	sed -i '19a\\<property><name>hadoop.proxyuser.bigdata.groups</name><value>*</value></property>' $core_path
	sed -i '19a\\<property><name>hadoop.proxyuser.bigdata.hosts</name><value>*</value></property>' $core_path
	sed -i '19a\\<property><name>hadoop.tmp.dir</name><value>/opt/soft/hadoop260/hadooptmp</value></property>' $core_path
	sed -i "19a\\<property><name>fs.defaultFS</name><value>hdfs://$hostname:9000</value></property>" $core_path

	echo '---------- 修改配置hdfs-site.sh ----------'
	hdfs_path="/opt/soft/hadoop260/etc/hadoop/hdfs-site.xml"
	sed -i "19a\\<property><name>dfs.namenode.secondary.http-address</name><value>$hostname:50090</value></property>" $hdfs_path
	sed -i '19a\\<property><name>dfs.replication</name><value>1</value></property>' $hdfs_path

	echo '---------- 修改配置mapred-site.sh ----------'
    mapred_path="/opt/soft/hadoop260/etc/hadoop/mapred-site.xml"
	cp /opt/soft/hadoop260/etc/hadoop/mapred-site.xml.template /opt/soft/hadoop260/etc/hadoop/mapred-site.xml
	sed -i "19a\\<property><name>mapreduce.jobhistory.webapp.address</name><value>$hostname:19888</value></property>" $mapred_path
	sed -i "19a\\<property><name>mapreduce.jobhistory.address</name><value>$hostname:10020</value></property>" $mapred_path
	sed -i '19a\\<property><name>mapreduce.framework.name</name><value>yarn</value></property>' $mapred_path

	echo '---------- 修改配置yarn-site.sh ----------'
    yarn_path="/opt/soft/hadoop260/etc/hadoop/yarn-site.xml"
	sed -i '15a\\<property><name>yarn.log-aggregation.retain-seconds</name><value>86400</value></property>' $yarn_path
    sed -i '15a\\<property><name>yarn.log-aggregation-enable</name><value>true</value></property>' $yarn_path
    sed -i "15a\\<property><name>yarn.resourcemanager.hostname</name><value>$hostname</value></property>" $yarn_path
    sed -i '15a\\<property><name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name><value>org.apache.hadoop.mapred.ShuffleHandler</value></property>' $yarn_path
    sed -i '15a\\<property><name>yarn.nodemanager.aux-services</name><value>mapreduce_shuffle</value></property>' $yarn_path

	echo '---------- 修改配置slaves ----------'
	sed -i "s/localhost/$hostname/g" /opt/soft/hadoop260/etc/hadoop/slaves

	echo "#hadoop" >> /etc/profile
	echo 'export HADOOP_HOME=/opt/soft/hadoop260' >> /etc/profile
    echo 'export HADOOP_MAPRED_HOME=$HADOOP_HOME' >> /etc/profile
    echo 'export HADOOP_COMMON_HOME=$HADOOP_HOME' >> /etc/profile
    echo 'export HADOOP_HDFS_HOME=$HADOOP_HOME' >> /etc/profile
    echo 'export YARN_HOME=$HADOOP_HOME' >> /etc/profile
    echo 'export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native' >> /etc/profile
	echo 'export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib"' >> /etc/profile
	echo 'export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin' >> /etc/profile

	/opt/soft/hadoop260/bin/hadoop namenode -format
fi

if [ "$zk" = true ]
then
    echo "---------- 安装zookeeper ----------"
    tar -zxf /opt/install/zookeeper-3.4.5-cdh5.14.2.tar.gz -C /opt/soft/
    mv /opt/soft/zookeeper-3.4.5-cdh5.14.2 /opt/soft/zookeeper345
    cp /opt/soft/zookeeper345/conf/zoo_sample.cfg /opt/soft/zookeeper345/conf/zoo.cfg
	sed -i '/^dataDir=/cdataDir=/opt/soft/zookeeper345/datatmp' /opt/soft/zookeeper345/conf/zoo.cfg
	echo "server.1=$hostname:2888:3888" >> /opt/soft/zookeeper345/conf/zoo.cfg
	mkdir -p /opt/soft/zookeeper345/datatmp/
	echo "1"> /opt/soft/zookeeper345/datatmp/myid

	echo "#zookeeper" >> /etc/profile
	echo 'export ZOOKEEPER_HOME=/opt/soft/zookeeper345' >> /etc/profile
	echo 'export PATH=$PATH:$ZOOKEEPER_HOME/bin' >> /etc/profile	
fi

运行脚本

[root@mihaoyu151 ~]# /opt/mysyssh/autoinstall.sh 
current host name is mihaoyu151
current user is root
---------- 安装jdk ----------
---------- 安装hadoop ----------
---------- 修改配置hadoop-env.sh ----------
---------- 修改配置mapred-env.sh ----------
---------- 修改配置yarn-env.sh ----------
---------- 修改配置core-site.sh ----------
---------- 修改配置hdfs-site.sh ----------
---------- 修改配置mapred-site.sh ----------
---------- 修改配置yarn-site.sh ----------
---------- 修改配置slaves ----------
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.

21/11/08 21:05:46 INFO namenode.NameNode: STARTUP_MSG: 
/************************************************************
STARTUP_MSG: Starting NameNode
STARTUP_MSG:   user = root
STARTUP_MSG:   host = mihaoyu151/192.168.133.151
STARTUP_MSG:   args = [-format]
STARTUP_MSG:   version = 2.6.0-cdh5.14.2
STARTUP_MSG:   classpath = /opt/soft/hadoop260/etc/hadoop:/opt/soft/hadoop260/share/hadoop/common/lib/api-util-1.0.0-M20.jar:/opt/soft/hadoop260/share/hadoop/common/lib/logredactor-1.0.3.jar:/opt/soft/hadoop260/share/hadoop/common/lib/activation-1.1.jar:/opt/soft/hadoop260/share/hadoop/common/lib/commons-codec-1.4.jar:/opt/soft/hadoop260/share/hadoop/common/lib/junit-4.11.jar:/opt/soft/hadoop260/share/hadoop/common/lib/jsr305-3.0.0.jar:/opt/soft/hadoop260/share/hadoop/common/lib/commons-configuration-1.6.jar:/opt/soft/hadoop260/share/hadoop/common/lib/netty-3.10.5.Final.jar:/opt/soft/hadoop260/share/hadoop/common/lib/commons-beanutils-core-1.8.0.jar:/opt/soft/hadoop260/share/hadoop/common/lib/slf4j-api-1.7.5.jar:/opt/soft/hadoop260/share/hadoop/common/lib/httpclient-4.2.5.jar:/opt/soft/hadoop260/share/hadoop/common/lib/api-asn1-api-1.0.0-M20.jar:/opt/soft/hadoop260/share/hadoop/common/lib/zookeeper-3.4.5-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/common/lib/jetty-6.1.26.cloudera.4.jar:/opt/soft/hadoop260/share/hadoop/common/lib/jaxb-api-2.2.2.jar:/opt/soft/hadoop260/share/hadoop/common/lib/commons-cli-1.2.jar:/opt/soft/hadoop260/share/hadoop/common/lib/mockito-all-1.8.5.jar:/opt/soft/hadoop260/share/hadoop/common/lib/jackson-jaxrs-1.8.8.jar:/opt/soft/hadoop260/share/hadoop/common/lib/hadoop-auth-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/common/lib/commons-el-1.0.jar:/opt/soft/hadoop260/share/hadoop/common/lib/commons-net-3.1.jar:/opt/soft/hadoop260/share/hadoop/common/lib/jersey-json-1.9.jar:/opt/soft/hadoop260/share/hadoop/common/lib/commons-logging-1.1.3.jar:/opt/soft/hadoop260/share/hadoop/common/lib/jsch-0.1.42.jar:/opt/soft/hadoop260/share/hadoop/common/lib/commons-lang-2.6.jar:/opt/soft/hadoop260/share/hadoop/common/lib/jettison-1.1.jar:/opt/soft/hadoop260/share/hadoop/common/lib/curator-recipes-2.7.1.jar:/opt/soft/hadoop260/share/hadoop/common/lib/snappy-java-1.0.4.1.jar:/opt/soft/hadoop260/share/hadoop/common/lib/gson-2.2.4.jar:/opt/soft/hadoop260/share/hadoop/common/lib/avro-1.7.6-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/common/lib/commons-compress-1.4.1.jar:/opt/soft/hadoop260/share/hadoop/common/lib/guava-11.0.2.jar:/opt/soft/hadoop260/share/hadoop/common/lib/java-xmlbuilder-0.4.jar:/opt/soft/hadoop260/share/hadoop/common/lib/protobuf-java-2.5.0.jar:/opt/soft/hadoop260/share/hadoop/common/lib/paranamer-2.3.jar:/opt/soft/hadoop260/share/hadoop/common/lib/jersey-server-1.9.jar:/opt/soft/hadoop260/share/hadoop/common/lib/hamcrest-core-1.3.jar:/opt/soft/hadoop260/share/hadoop/common/lib/commons-io-2.4.jar:/opt/soft/hadoop260/share/hadoop/common/lib/jackson-xc-1.8.8.jar:/opt/soft/hadoop260/share/hadoop/common/lib/jsp-api-2.1.jar:/opt/soft/hadoop260/share/hadoop/common/lib/jersey-core-1.9.jar:/opt/soft/hadoop260/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar:/opt/soft/hadoop260/share/hadoop/common/lib/commons-math3-3.1.1.jar:/opt/soft/hadoop260/share/hadoop/common/lib/xmlenc-0.52.jar:/opt/soft/hadoop260/share/hadoop/common/lib/commons-digester-1.8.jar:/opt/soft/hadoop260/share/hadoop/common/lib/servlet-api-2.5.jar:/opt/soft/hadoop260/share/hadoop/common/lib/log4j-1.2.17.jar:/opt/soft/hadoop260/share/hadoop/common/lib/xz-1.0.jar:/opt/soft/hadoop260/share/hadoop/common/lib/jasper-compiler-5.5.23.jar:/opt/soft/hadoop260/share/hadoop/common/lib/stax-api-1.0-2.jar:/opt/soft/hadoop260/share/hadoop/common/lib/jets3t-0.9.0.jar:/opt/soft/hadoop260/share/hadoop/common/lib/jetty-util-6.1.26.cloudera.4.jar:/opt/soft/hadoop260/share/hadoop/common/lib/jasper-runtime-5.5.23.jar:/opt/soft/hadoop260/share/hadoop/common/lib/hadoop-annotations-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/common/lib/htrace-core4-4.0.1-incubating.jar:/opt/soft/hadoop260/share/hadoop/common/lib/httpcore-4.2.5.jar:/opt/soft/hadoop260/share/hadoop/common/lib/commons-beanutils-1.9.2.jar:/opt/soft/hadoop260/share/hadoop/common/lib/commons-collections-3.2.2.jar:/opt/soft/hadoop260/share/hadoop/common/lib/jaxb-impl-2.2.3-1.jar:/opt/soft/hadoop260/share/hadoop/common/lib/apacheds-kerberos-codec-2.0.0-M15.jar:/opt/soft/hadoop260/share/hadoop/common/lib/curator-client-2.7.1.jar:/opt/soft/hadoop260/share/hadoop/common/lib/commons-httpclient-3.1.jar:/opt/soft/hadoop260/share/hadoop/common/lib/apacheds-i18n-2.0.0-M15.jar:/opt/soft/hadoop260/share/hadoop/common/lib/curator-framework-2.7.1.jar:/opt/soft/hadoop260/share/hadoop/common/lib/asm-3.2.jar:/opt/soft/hadoop260/share/hadoop/common/hadoop-common-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/common/hadoop-common-2.6.0-cdh5.14.2-tests.jar:/opt/soft/hadoop260/share/hadoop/common/hadoop-nfs-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/hdfs:/opt/soft/hadoop260/share/hadoop/hdfs/lib/commons-codec-1.4.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/leveldbjni-all-1.8.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/jsr305-3.0.0.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/netty-3.10.5.Final.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/jetty-6.1.26.cloudera.4.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/commons-cli-1.2.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/commons-el-1.0.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/commons-logging-1.1.3.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/commons-lang-2.6.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/guava-11.0.2.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/protobuf-java-2.5.0.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/jersey-server-1.9.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/commons-io-2.4.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/jsp-api-2.1.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/jersey-core-1.9.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/commons-daemon-1.0.13.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/xmlenc-0.52.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/servlet-api-2.5.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/log4j-1.2.17.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/xml-apis-1.3.04.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/jackson-core-asl-1.8.8.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/jetty-util-6.1.26.cloudera.4.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/xercesImpl-2.9.1.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/jasper-runtime-5.5.23.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/htrace-core4-4.0.1-incubating.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/jackson-mapper-asl-1.8.8.jar:/opt/soft/hadoop260/share/hadoop/hdfs/lib/asm-3.2.jar:/opt/soft/hadoop260/share/hadoop/hdfs/hadoop-hdfs-2.6.0-cdh5.14.2-tests.jar:/opt/soft/hadoop260/share/hadoop/hdfs/hadoop-hdfs-nfs-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/hdfs/hadoop-hdfs-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/activation-1.1.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/commons-codec-1.4.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/aopalliance-1.0.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/leveldbjni-all-1.8.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/javax.inject-1.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/jsr305-3.0.0.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/jersey-client-1.9.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/zookeeper-3.4.5-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/jline-2.11.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/jetty-6.1.26.cloudera.4.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/jaxb-api-2.2.2.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/commons-cli-1.2.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/jackson-jaxrs-1.8.8.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/guice-servlet-3.0.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/jersey-json-1.9.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/commons-logging-1.1.3.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/commons-lang-2.6.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/jettison-1.1.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/commons-compress-1.4.1.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/guava-11.0.2.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/protobuf-java-2.5.0.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/jersey-guice-1.9.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/jersey-server-1.9.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/commons-io-2.4.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/jackson-xc-1.8.8.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/jersey-core-1.9.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/guice-3.0.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/servlet-api-2.5.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/log4j-1.2.17.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/xz-1.0.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/jackson-core-asl-1.8.8.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/stax-api-1.0-2.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/jetty-util-6.1.26.cloudera.4.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/commons-collections-3.2.2.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/jackson-mapper-asl-1.8.8.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/jaxb-impl-2.2.3-1.jar:/opt/soft/hadoop260/share/hadoop/yarn/lib/asm-3.2.jar:/opt/soft/hadoop260/share/hadoop/yarn/hadoop-yarn-applications-unmanaged-am-launcher-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/yarn/hadoop-yarn-server-tests-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/yarn/hadoop-yarn-applications-distributedshell-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/yarn/hadoop-yarn-server-common-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/yarn/hadoop-yarn-server-resourcemanager-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/yarn/hadoop-yarn-server-nodemanager-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/yarn/hadoop-yarn-server-web-proxy-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/yarn/hadoop-yarn-registry-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/yarn/hadoop-yarn-server-applicationhistoryservice-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/yarn/hadoop-yarn-api-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/yarn/hadoop-yarn-client-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/yarn/hadoop-yarn-common-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/aopalliance-1.0.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/leveldbjni-all-1.8.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/javax.inject-1.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/junit-4.11.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/netty-3.10.5.Final.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/guice-servlet-3.0.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/snappy-java-1.0.4.1.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/avro-1.7.6-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/commons-compress-1.4.1.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/protobuf-java-2.5.0.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/paranamer-2.3.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/jersey-guice-1.9.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/jersey-server-1.9.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/hamcrest-core-1.3.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/commons-io-2.4.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/jersey-core-1.9.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/guice-3.0.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/log4j-1.2.17.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/xz-1.0.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/jackson-core-asl-1.8.8.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/hadoop-annotations-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/jackson-mapper-asl-1.8.8.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/lib/asm-3.2.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/hadoop-mapreduce-client-hs-plugins-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/hadoop-mapreduce-client-nativetask-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/hadoop-mapreduce-client-shuffle-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/hadoop-mapreduce-client-core-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/hadoop-mapreduce-client-jobclient-2.6.0-cdh5.14.2-tests.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/hadoop-mapreduce-client-common-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/hadoop-mapreduce-client-hs-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/share/hadoop/mapreduce/hadoop-mapreduce-client-app-2.6.0-cdh5.14.2.jar:/opt/soft/hadoop260/contrib/capacity-scheduler/*.jar:/opt/soft/hadoop260/contrib/capacity-scheduler/*.jar
STARTUP_MSG:   build = http://github.com/cloudera/hadoop -r 5724a4ad7a27f7af31aa725694d3df09a68bb213; compiled by 'jenkins' on 2018-03-27T20:40Z
STARTUP_MSG:   java = 1.8.0_221
************************************************************/
21/11/08 21:05:46 INFO namenode.NameNode: registered UNIX signal handlers for [TERM, HUP, INT]
21/11/08 21:05:46 INFO namenode.NameNode: createNameNode [-format]
21/11/08 21:05:46 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Formatting using clusterid: CID-72401b47-cf55-4358-b4bd-0eeda2a14904
21/11/08 21:05:46 INFO namenode.FSEditLog: Edit logging is async:true
21/11/08 21:05:46 INFO namenode.FSNamesystem: No KeyProvider found.
21/11/08 21:05:46 INFO namenode.FSNamesystem: fsLock is fair: true
21/11/08 21:05:46 INFO blockmanagement.DatanodeManager: dfs.block.invalidate.limit=1000
21/11/08 21:05:46 INFO blockmanagement.DatanodeManager: dfs.namenode.datanode.registration.ip-hostname-check=true
21/11/08 21:05:46 INFO blockmanagement.BlockManager: dfs.namenode.startup.delay.block.deletion.sec is set to 000:00:00:00.000
21/11/08 21:05:46 INFO blockmanagement.BlockManager: The block deletion will start around 2021 Nov 08 21:05:46
21/11/08 21:05:46 INFO util.GSet: Computing capacity for map BlocksMap
21/11/08 21:05:46 INFO util.GSet: VM type       = 64-bit
21/11/08 21:05:46 INFO util.GSet: 2.0% max memory 966.7 MB = 19.3 MB
21/11/08 21:05:46 INFO util.GSet: capacity      = 2^21 = 2097152 entries
21/11/08 21:05:46 INFO blockmanagement.BlockManager: dfs.block.access.token.enable=false
21/11/08 21:05:46 INFO blockmanagement.BlockManager: defaultReplication         = 1
21/11/08 21:05:46 INFO blockmanagement.BlockManager: maxReplication             = 512
21/11/08 21:05:46 INFO blockmanagement.BlockManager: minReplication             = 1
21/11/08 21:05:46 INFO blockmanagement.BlockManager: maxReplicationStreams      = 2
21/11/08 21:05:46 INFO blockmanagement.BlockManager: replicationRecheckInterval = 3000
21/11/08 21:05:46 INFO blockmanagement.BlockManager: encryptDataTransfer        = false
21/11/08 21:05:46 INFO blockmanagement.BlockManager: maxNumBlocksToLog          = 1000
21/11/08 21:05:46 INFO namenode.FSNamesystem: fsOwner             = root (auth:SIMPLE)
21/11/08 21:05:46 INFO namenode.FSNamesystem: supergroup          = supergroup
21/11/08 21:05:46 INFO namenode.FSNamesystem: isPermissionEnabled = true
21/11/08 21:05:46 INFO namenode.FSNamesystem: HA Enabled: false
21/11/08 21:05:46 INFO namenode.FSNamesystem: Append Enabled: true
21/11/08 21:05:47 INFO util.GSet: Computing capacity for map INodeMap
21/11/08 21:05:47 INFO util.GSet: VM type       = 64-bit
21/11/08 21:05:47 INFO util.GSet: 1.0% max memory 966.7 MB = 9.7 MB
21/11/08 21:05:47 INFO util.GSet: capacity      = 2^20 = 1048576 entries
21/11/08 21:05:47 INFO namenode.FSDirectory: POSIX ACL inheritance enabled? false
21/11/08 21:05:47 INFO namenode.NameNode: Caching file names occuring more than 10 times
21/11/08 21:05:47 INFO snapshot.SnapshotManager: Loaded config captureOpenFiles: false, skipCaptureAccessTimeOnlyChange: false, snapshotDiffAllowSnapRootDescendant: true
21/11/08 21:05:47 INFO util.GSet: Computing capacity for map cachedBlocks
21/11/08 21:05:47 INFO util.GSet: VM type       = 64-bit
21/11/08 21:05:47 INFO util.GSet: 0.25% max memory 966.7 MB = 2.4 MB
21/11/08 21:05:47 INFO util.GSet: capacity      = 2^18 = 262144 entries
21/11/08 21:05:47 INFO namenode.FSNamesystem: dfs.namenode.safemode.threshold-pct = 0.9990000128746033
21/11/08 21:05:47 INFO namenode.FSNamesystem: dfs.namenode.safemode.min.datanodes = 0
21/11/08 21:05:47 INFO namenode.FSNamesystem: dfs.namenode.safemode.extension     = 30000
21/11/08 21:05:47 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.window.num.buckets = 10
21/11/08 21:05:47 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.num.users = 10
21/11/08 21:05:47 INFO metrics.TopMetrics: NNTop conf: dfs.namenode.top.windows.minutes = 1,5,25
21/11/08 21:05:47 INFO namenode.FSNamesystem: Retry cache on namenode is enabled
21/11/08 21:05:47 INFO namenode.FSNamesystem: Retry cache will use 0.03 of total heap and retry cache entry expiry time is 600000 millis
21/11/08 21:05:47 INFO util.GSet: Computing capacity for map NameNodeRetryCache
21/11/08 21:05:47 INFO util.GSet: VM type       = 64-bit
21/11/08 21:05:47 INFO util.GSet: 0.029999999329447746% max memory 966.7 MB = 297.0 KB
21/11/08 21:05:47 INFO util.GSet: capacity      = 2^15 = 32768 entries
21/11/08 21:05:47 INFO namenode.FSNamesystem: ACLs enabled? false
21/11/08 21:05:47 INFO namenode.FSNamesystem: XAttrs enabled? true
21/11/08 21:05:47 INFO namenode.FSNamesystem: Maximum size of an xattr: 16384
21/11/08 21:05:47 INFO namenode.FSImage: Allocated new BlockPoolId: BP-398451707-192.168.133.151-1636376747180
21/11/08 21:05:47 INFO common.Storage: Storage directory /opt/soft/hadoop260/hadooptmp/dfs/name has been successfully formatted.
21/11/08 21:05:47 INFO namenode.FSImageFormatProtobuf: Saving image file /opt/soft/hadoop260/hadooptmp/dfs/name/current/fsimage.ckpt_0000000000000000000 using no compression
21/11/08 21:05:47 INFO namenode.FSImageFormatProtobuf: Image file /opt/soft/hadoop260/hadooptmp/dfs/name/current/fsimage.ckpt_0000000000000000000 of size 321 bytes saved in 0 seconds.
21/11/08 21:05:47 INFO namenode.NNStorageRetentionManager: Going to retain 1 images with txid >= 0
21/11/08 21:05:47 INFO util.ExitUtil: Exiting with status 0
21/11/08 21:05:47 INFO namenode.NameNode: SHUTDOWN_MSG: 
/************************************************************
SHUTDOWN_MSG: Shutting down NameNode at mihaoyu151/192.168.133.151
************************************************************/
---------- 安装zookeeper ----------
[root@mihaoyu151 ~]# source /etc/profile

查看是否安装成功

[root@mihaoyu151 ~]# java -version
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)
[root@mihaoyu151 ~]# javac
Usage: javac <options> <source files>
where possible options include:
  -g                         Generate all debugging info
  -g:none                    Generate no debugging info
  -g:{lines,vars,source}     Generate only some debugging info
  -nowarn                    Generate no warnings
  -verbose                   Output messages about what the compiler is doing
  -deprecation               Output source locations where deprecated APIs are used
  -classpath <path>          Specify where to find user class files and annotation processors
  -cp <path>                 Specify where to find user class files and annotation processors
  -sourcepath <path>         Specify where to find input source files
  -bootclasspath <path>      Override location of bootstrap class files
  -extdirs <dirs>            Override location of installed extensions
  -endorseddirs <dirs>       Override location of endorsed standards path
  -proc:{none,only}          Control whether annotation processing and/or compilation is done.
  -processor <class1>[,<class2>,<class3>...] Names of the annotation processors to run; bypasses default discovery process
  -processorpath <path>      Specify where to find annotation processors
  -parameters                Generate metadata for reflection on method parameters
  -d <directory>             Specify where to place generated class files
  -s <directory>             Specify where to place generated source files
  -h <directory>             Specify where to place generated native header files
  -implicit:{none,class}     Specify whether or not to generate class files for implicitly referenced files
  -encoding <encoding>       Specify character encoding used by source files
  -source <release>          Provide source compatibility with specified release
  -target <release>          Generate class files for specific VM version
  -profile <profile>         Check that API used is available in the specified profile
  -version                   Version information
  -help                      Print a synopsis of standard options
  -Akey[=value]              Options to pass to annotation processors
  -X                         Print a synopsis of nonstandard options
  -J<flag>                   Pass <flag> directly to the runtime system
  -Werror                    Terminate compilation if warnings occur
  @<filename>                Read options and filenames from file

[root@mihaoyu151 ~]# hadoop version
Hadoop 2.6.0-cdh5.14.2
Subversion http://github.com/cloudera/hadoop -r 5724a4ad7a27f7af31aa725694d3df09a68bb213
Compiled by jenkins on 2018-03-27T20:40Z
Compiled with protoc 2.5.0
From source with checksum 302899e86485742c090f626a828b28
This command was run using /opt/soft/hadoop260/share/hadoop/common/hadoop-common-2.6.0-cdh5.14.2.jar
[root@mihaoyu151 ~]# start-all.sh 
This script is Deprecated. Instead use start-dfs.sh and start-yarn.sh
21/11/08 21:06:35 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Starting namenodes on [mihaoyu151]
mihaoyu151: starting namenode, logging to /opt/soft/hadoop260/logs/hadoop-root-namenode-mihaoyu151.out
mihaoyu151: starting datanode, logging to /opt/soft/hadoop260/logs/hadoop-root-datanode-mihaoyu151.out
Starting secondary namenodes [mihaoyu151]
mihaoyu151: starting secondarynamenode, logging to /opt/soft/hadoop260/logs/hadoop-root-secondarynamenode-mihaoyu151.out
21/11/08 21:06:53 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
starting yarn daemons
starting resourcemanager, logging to /opt/soft/hadoop260/logs/yarn-root-resourcemanager-mihaoyu151.out
mihaoyu151: starting nodemanager, logging to /opt/soft/hadoop260/logs/yarn-root-nodemanager-mihaoyu151.out
[root@mihaoyu151 ~]# mr-jobhistory-daemon.sh start historyserver
starting historyserver, logging to /opt/soft/hadoop260/logs/mapred-root-historyserver-mihaoyu151.out
[root@mihaoyu151 ~]# jps
8305 NameNode
8420 DataNode
9221 Jps
8710 ResourceManager
8822 NodeManager
8569 SecondaryNameNode
9100 JobHistoryServer    
[root@mihaoyu151 ~]# zkServer.sh start
JMX enabled by default
Using config: /opt/soft/zookeeper345/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
[root@mihaoyu151 ~]# zkServer.sh status
JMX enabled by default
Using config: /opt/soft/zookeeper345/bin/../conf/zoo.cfg
Mode: standalone
[root@mihaoyu151 ~]# zkCli.sh 
Connecting to localhost:2181
2021-11-08 21:07:52,377 [myid:] - INFO  [main:Environment@100] - Client environment:zookeeper.version=3.4.5-cdh5.14.2--1, built on 03/27/2018 20:39 GMT
2021-11-08 21:07:52,379 [myid:] - INFO  [main:Environment@100] - Client environment:host.name=mihaoyu151
2021-11-08 21:07:52,379 [myid:] - INFO  [main:Environment@100] - Client environment:java.version=1.8.0_221
2021-11-08 21:07:52,380 [myid:] - INFO  [main:Environment@100] - Client environment:java.vendor=Oracle Corporation
2021-11-08 21:07:52,380 [myid:] - INFO  [main:Environment@100] - Client environment:java.home=/opt/soft/jdk180/jre
2021-11-08 21:07:52,380 [myid:] - INFO  [main:Environment@100] - Client environment:java.class.path=/opt/soft/zookeeper345/bin/../build/classes:/opt/soft/zookeeper345/bin/../build/lib/*.jar:/opt/soft/zookeeper345/bin/../share/zookeeper/zookeeper-3.4.5-cdh5.14.2.jar:/opt/soft/zookeeper345/bin/../share/zookeeper/slf4j-log4j12-1.7.5.jar:/opt/soft/zookeeper345/bin/../share/zookeeper/slf4j-api-1.7.5.jar:/opt/soft/zookeeper345/bin/../share/zookeeper/netty-3.10.5.Final.jar:/opt/soft/zookeeper345/bin/../share/zookeeper/log4j-1.2.16.jar:/opt/soft/zookeeper345/bin/../share/zookeeper/jline-2.11.jar:/opt/soft/zookeeper345/bin/../src/java/lib/*.jar:/opt/soft/zookeeper345/bin/../conf:.:/opt/soft/jdk180/lib/dt.jar:/opt/soft/jdk180/lib/tools.jar
2021-11-08 21:07:52,381 [myid:] - INFO  [main:Environment@100] - Client environment:java.library.path=/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
2021-11-08 21:07:52,381 [myid:] - INFO  [main:Environment@100] - Client environment:java.io.tmpdir=/tmp
2021-11-08 21:07:52,381 [myid:] - INFO  [main:Environment@100] - Client environment:java.compiler=<NA>
2021-11-08 21:07:52,381 [myid:] - INFO  [main:Environment@100] - Client environment:os.name=Linux
2021-11-08 21:07:52,381 [myid:] - INFO  [main:Environment@100] - Client environment:os.arch=amd64
2021-11-08 21:07:52,381 [myid:] - INFO  [main:Environment@100] - Client environment:os.version=3.10.0-1062.el7.x86_64
2021-11-08 21:07:52,381 [myid:] - INFO  [main:Environment@100] - Client environment:user.name=root
2021-11-08 21:07:52,381 [myid:] - INFO  [main:Environment@100] - Client environment:user.home=/root
2021-11-08 21:07:52,385 [myid:] - INFO  [main:Environment@100] - Client environment:user.dir=/opt
2021-11-08 21:07:52,386 [myid:] - INFO  [main:ZooKeeper@438] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@27fa135a
2021-11-08 21:07:52,406 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@975] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
Welcome to ZooKeeper!
JLine support is enabled
2021-11-08 21:07:52,494 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@852] - Socket connection established, initiating session, client: /127.0.0.1:58988, server: localhost/127.0.0.1:2181
2021-11-08 21:07:52,521 [myid:] - INFO  [main-SendThread(localhost:2181):ClientCnxn$SendThread@

以上是关于linux脚本自动安装jdkhadoopzookeeper,单机版的主要内容,如果未能解决你的问题,请参考以下文章

linux自动部署--sh脚本安装jdk,tomcat,mysqlclient

linux自动部署--sh脚本安装jdk,tomcat,mysqlclient

Linux中自动安装脚本

怎么在安装linux虚拟机时自动设定?linux使用kickstart自动安装脚本安装系统

linux下PXE无人值守环境自动安装脚本

linux下通过脚本文件自动安装虚拟机