目录
1.解压
2.文件重命名
3.配置环境变量
4.hadoop-env.sh
5.core-site.xml
6. hdfs-site.xml
7. mapred-site.xml
8.yarn-site.xml
9.完整脚本代码(注意修改主机名)
10.重启环境变量
11.初始化
12.启动服务
13.jps查询节点
1.解压
tar -zxf /opt/install/hadoop-3.1.3.tar.gz -C /opt/soft/
2.文件重命名
mv /opt/soft/hadoop-3.1.3 /opt/soft/hadoop313
3.配置环境变量
sed -i '73a\export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop' /etc/profile
sed -i '73a\export HADOOP_LIBEXEC_DIR=$HADOOP_HOME/libexec' /etc/profile
sed -i '73a\export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native' /etc/profile
sed -i '73a\export HADOOP_INSTALL=$HADOOP_HOME' /etc/profile
sed -i '73a\export HADOOP_YARN_HOME=$HADOOP_HOME' /etc/profile
sed -i '73a\export HADOOP_HDFS_HOME=$HADOOP_HOME' /etc/profile
sed -i '73a\export HADOOP_COMMON_HOME=$HADOOP_HOME' /etc/profile
sed -i '73a\export HADOOP_MAPRED_HOME=$HADOOP_HOME' /etc/profile
sed -i '73a\export YARN_NODEMANAGER_USER=root' /etc/profile
sed -i '73a\export YARN_RESOURCEMANAGER_USER=root' /etc/profile
sed -i '73a\export HDFS_ZKFC_USER=root' /etc/profile
sed -i '73a\export HDFS_JOURNALNODE_USER=root' /etc/profile
sed -i '73a\export HDFS_SECONDARYNAMENODE_USER=root' /etc/profile
sed -i '73a\export HDFS_DATANODE_USER=root' /etc/profile
sed -i '73a\export HDFS_NAMENODE_USER=root' /etc/profile
sed -i '73a\export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HADOOP_HOME/lib' /etc/profile
sed -i '73a\export HADOOP_HOME=/opt/soft/hadoop313' /etc/profile
sed -i '73a\#HADOOP_HOME' /etc/profile
4.hadoop-env.sh
#hadoop-env.sh
sed -i '53a\export JAVA_HOME=/opt/soft/jdk180' /opt/soft/hadoop313/etc/hadoop/hadoop-env.sh
5.core-site.xml
#core-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <value>*</value>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <name>hadoop.proxyuser.root.groups</name>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <value>*</value>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <name>hadoop.proxyuser.root.hosts</name>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <description>读写队列缓存:128k</description>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <value>131072</value>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <name>io.file.buffer.size</name>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <value>root</value>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <name>hadoop.http.staticuser.user</name>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <description>namenode上本地的hadoop临时文件夹</description>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <value>/opt/soft/hadoop313/data</value>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <name>hadoop.tmp.dir</name>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <value>hdfs://cp145:9000</value>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <name>fs.defaultFS</name>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
6. hdfs-site.xml
#hdfs-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <description>关闭权限验证</description>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <value>false</value>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <name>dfs.permissions.enabled</name>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <description>datanode上数据块的物理存储位置目录</description>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <value>/opt/soft/hadoop313/data/dfs/data</value>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <name>dfs.datanode.data.dir</name>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <description>namenode上存储hdfsq名字空间元数据的目录</description>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <value>/opt/soft/hadoop313/data/dfs/name</value>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <name>dfs.namenode.name.dir</name>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <description>hadoop中每一个block文件的备份数量</description>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <value>1</value>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <name>dfs.replication</name>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
7. mapred-site.xml
#mapred-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <value>1024</value>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <name>mapreduce.reduce.memory.mb</name>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <value>1024</value>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <name>mapreduce.map.memory.mb</name>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <value>cp145:19888</value>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <name>mapreduce.jobhistory.webapp.address</name>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <value>cp145:10020</value>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <name>mapreduce.jobhistory.address</name>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <value>/opt/soft/hadoop313/etc/hadoop:/opt/soft/hadoop313/share/hadoop/common/lib/*:/opt/soft/hadoop313/share/hadoop/common/*:/opt/soft/hadoop313/share/hadoop/hdfs/*:/opt/soft/hadoop313/share/hadoop/hdfs/lib/*:/opt/soft/hadoop313/share/hadoop/mapreduce/*:/opt/soft/hadoop313/share/hadoop/mapreduce/lib/*:/opt/soft/hadoop313/share/hadoop/yarn/*:/opt/soft/hadoop313/share/hadoop/yarn/lib/*</value>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <name>mapreduce.application.classpath</name>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <final>true</final>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <description>job执行框架:local,classic or yarn</description>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <value>yarn</value>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <name>mapreduce.framework.name</name>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
8.yarn-site.xml
#yarn-site.xml
sed -i '17a\ </property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <value>/opt/soft/hadoop313/yarndata/log</value>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <name>yarn.nodemanager.log-dirs</name>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ </property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <value>/opt/soft/hadoop313/yarndata/yarn</value>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <name>yarn.nodemanager.local-dirs</name>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ </property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <value>mapreduce_shuffle</value>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <name>yarn.nodemanager.aux-services</name>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ </property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <value>cp145:8042</value>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <name>yarn.nodemanager.webapp.address</name>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ </property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <value>cp145:8050</value>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <name>yarn.nodemanager.address</name>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ </property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <value>cp145:8040</value>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <name>yarn.nodemanager.localizer.address</name>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ </property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler</value>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <name>yarn.resourcemanager.scheduler.class</name>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ </property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <value>20000</value>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <name>yarn.resourcemanager.connect.retry-interval.ms</name>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
9.完整脚本代码(注意修改主机名)
#! /bin/bash
echo 'auto install hadoop begining....'
#global var
hadoop=true
if [ "$hadoop" = true ];then
echo 'hadoop install set true'
echo 'setup hadoop 3'
tar -zxf /opt/install/hadoop-3.1.3.tar.gz -C /opt/soft/
mv /opt/soft/hadoop-3.1.3 /opt/soft/hadoop313
sed -i '73a\export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop' /etc/profile
sed -i '73a\export HADOOP_LIBEXEC_DIR=$HADOOP_HOME/libexec' /etc/profile
sed -i '73a\export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native' /etc/profile
sed -i '73a\export HADOOP_INSTALL=$HADOOP_HOME' /etc/profile
sed -i '73a\export HADOOP_YARN_HOME=$HADOOP_HOME' /etc/profile
sed -i '73a\export HADOOP_HDFS_HOME=$HADOOP_HOME' /etc/profile
sed -i '73a\export HADOOP_COMMON_HOME=$HADOOP_HOME' /etc/profile
sed -i '73a\export HADOOP_MAPRED_HOME=$HADOOP_HOME' /etc/profile
sed -i '73a\export YARN_NODEMANAGER_USER=root' /etc/profile
sed -i '73a\export YARN_RESOURCEMANAGER_USER=root' /etc/profile
sed -i '73a\export HDFS_ZKFC_USER=root' /etc/profile
sed -i '73a\export HDFS_JOURNALNODE_USER=root' /etc/profile
sed -i '73a\export HDFS_SECONDARYNAMENODE_USER=root' /etc/profile
sed -i '73a\export HDFS_DATANODE_USER=root' /etc/profile
sed -i '73a\export HDFS_NAMENODE_USER=root' /etc/profile
sed -i '73a\export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HADOOP_HOME/lib' /etc/profile
sed -i '73a\export HADOOP_HOME=/opt/soft/hadoop313' /etc/profile
sed -i '73a\#HADOOP_HOME' /etc/profile
#hadoop-env.sh
sed -i '53a\export JAVA_HOME=/opt/soft/jdk180' /opt/soft/hadoop313/etc/hadoop/hadoop-env.sh
#core-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <value>*</value>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <name>hadoop.proxyuser.root.groups</name>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <value>*</value>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <name>hadoop.proxyuser.root.hosts</name>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <description>读写队列缓存:128k</description>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <value>131072</value>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <name>io.file.buffer.size</name>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <value>root</value>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <name>hadoop.http.staticuser.user</name>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <description>namenode上本地的hadoop临时文件夹</description>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <value>/opt/soft/hadoop313/data</value>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <name>hadoop.tmp.dir</name>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <value>hdfs://cp145:9000</value>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <name>fs.defaultFS</name>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/core-site.xml
#hdfs-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <description>关闭权限验证</description>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <value>false</value>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <name>dfs.permissions.enabled</name>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <description>datanode上数据块的物理存储位置目录</description>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <value>/opt/soft/hadoop313/data/dfs/data</value>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <name>dfs.datanode.data.dir</name>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <description>namenode上存储hdfsq名字空间元数据的目录</description>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <value>/opt/soft/hadoop313/data/dfs/name</value>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <name>dfs.namenode.name.dir</name>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <description>hadoop中每一个block文件的备份数量</description>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <value>1</value>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <name>dfs.replication</name>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/hdfs-site.xml
#mapred-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <value>1024</value>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <name>mapreduce.reduce.memory.mb</name>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <value>1024</value>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <name>mapreduce.map.memory.mb</name>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <value>cp145:19888</value>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <name>mapreduce.jobhistory.webapp.address</name>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <value>cp145:10020</value>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <name>mapreduce.jobhistory.address</name>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <value>/opt/soft/hadoop313/etc/hadoop:/opt/soft/hadoop313/share/hadoop/common/lib/*:/opt/soft/hadoop313/share/hadoop/common/*:/opt/soft/hadoop313/share/hadoop/hdfs/*:/opt/soft/hadoop313/share/hadoop/hdfs/lib/*:/opt/soft/hadoop313/share/hadoop/mapreduce/*:/opt/soft/hadoop313/share/hadoop/mapreduce/lib/*:/opt/soft/hadoop313/share/hadoop/yarn/*:/opt/soft/hadoop313/share/hadoop/yarn/lib/*</value>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <name>mapreduce.application.classpath</name>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ </property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <final>true</final>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <description>job执行框架:local,classic or yarn</description>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <value>yarn</value>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <name>mapreduce.framework.name</name>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
sed -i '19a\ <property>' /opt/soft/hadoop313/etc/hadoop/mapred-site.xml
#yarn-site.xml
sed -i '17a\ </property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <value>/opt/soft/hadoop313/yarndata/log</value>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <name>yarn.nodemanager.log-dirs</name>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ </property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <value>/opt/soft/hadoop313/yarndata/yarn</value>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <name>yarn.nodemanager.local-dirs</name>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ </property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <value>mapreduce_shuffle</value>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <name>yarn.nodemanager.aux-services</name>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ </property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <value>cp145:8042</value>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <name>yarn.nodemanager.webapp.address</name>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ </property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <value>cp145:8050</value>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <name>yarn.nodemanager.address</name>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ </property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <value>cp145:8040</value>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <name>yarn.nodemanager.localizer.address</name>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ </property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <value>org.apache.hadoop.yarn.server.resourcemanager.scheduler.fair.FairScheduler</value>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <name>yarn.resourcemanager.scheduler.class</name>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ </property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <value>20000</value>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <name>yarn.resourcemanager.connect.retry-interval.ms</name>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
sed -i '17a\ <property>' /opt/soft/hadoop313/etc/hadoop/yarn-site.xml
echo 'setup hadoop 3 success!!!'
fi
10.重启环境变量
[root@lxm148 opt]# source /etc/profile
11.初始化
[root@lxm148 yarndata]# hdfs namenode -format
12.启动服务
[root@lxm148 yarndata]# start-all.sh