#!/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.xml ----------' core_path="/opt/soft/hadoop260/etc/hadoop/core-site.xml" sed -i '19a' $core_path sed -i '19a hadoop.proxyuser.bigdata.groups * ' $core_path sed -i '19a hadoop.proxyuser.bigdata.hosts * ' $core_path sed -i "19a hadoop.tmp.dir /opt/soft/hadoop260/hadooptmp " $core_path echo '---------- 修改配置hdfs-site.xml ----------' hdfs_path="/opt/soft/hadoop260/etc/hadoop/hdfs-site.xml" sed -i "19a fs.defaultFS hdfs://$hostname:9000 " $hdfs_path sed -i '19a dfs.namenode.secondary.http-address $hostname:50090 ' $hdfs_path echo '---------- 修改配置mapred-site.xml ----------' 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 dfs.replication 1 " $mapred_path sed -i "19a mapreduce.jobhistory.webapp.address $hostname:19888 " $mapred_path sed -i '19a mapreduce.jobhistory.address $hostname:10020 ' $mapred_path echo '---------- 修改配置yarn-site.xml ----------' yarn_path="/opt/soft/hadoop260/etc/hadoop/yarn-site.xml" sed -i '15a mapreduce.framework.name yarn ' $yarn_path sed -i '15a yarn.log-aggregation.retain-seconds 86400 ' $yarn_path sed -i "15a yarn.log-aggregation-enable true " $yarn_path sed -i '15a yarn.resourcemanager.hostname $hostname ' $yarn_path sed -i '15a yarn.nodemanager.aux-services.mapreduce.shuffle.class org.apache.hadoop.mapred.ShuffleHandler ' $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 yarn.nodemanager.aux-services mapreduce_shuffle
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)