解压安装,配置环境变量
sudo chown -R admin:admin /opt/software/hadoop-2.7.2.tar.gz
sudo chmod -R 755 /opt/software/hadoop-2.7.2.tar.gz
tar -zxvf /opt/software/hadoop-2.7.2.tar.gz -C /opt/module
cd /opt/module/hadoop-2.7.2
sudo vim /etc/profile
vim ~/.bashrc
# HADOOP_ENV
HADOOP_HOME=$BASE_DIR/hadoop-2.5.0-cdh5.3.6
PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
export HADOOP_HOME PATH
source /etc/profile
source ~/.bashrc
修改配置
vim etc/hadoop/core-site.xml
fs.defaultFS
hdfs://hadoop102:9000
hadoop.tmp.dir
/opt/module/hadoop-2.7.2/data/tmp
vim etc/hadoop/hdfs-site.xml
dfs.namenode.secondary.http-address
hadoop103:50090
dfs.replication
3
vim etc/hadoop/yarn-site.xml
yarn.resourcemanager.hostname
hadoop104
yarn.nodemanager.aux-services
mapreduce_shuffle
vim etc/hadoop/mapred-site.xml
mapreduce.framework.name
yarn
vim /opt/module/hadoop-2.7.2/etc/hadoop/slaves
hadoop102
hadoop103
hadoop104
集群分发
方案1:
scp -r /opt/module/hadoop-2.7.2 hadoop103:/opt/module
scp -r /opt/module/hadoop-2.7.2 hadoop104:/opt/module
方案2:
sudo vim /usr/local/bin/xsync
#!/bin/bash
if (( $# == 0 ));then
echo "no args"
exit 0
fi
USER=`whoami`
DIR=`cd -P $(dirname $1);pwd`
TARGET=`basename $1`
MYSELF=`hostname`
for (( host = 102 ; host <= 104 ; host++ ))
do
if [ $MYSELF != hadoop$host ];then
echo "-------- Send $DIR/$TARGET to $USER@hadoop$host ---------"
rsync -rvl $DIR/$TARGET $USER@hadoop$host:$DIR
fi
done
exit 0
sudo chown admin:admin /usr/local/bin/xsync
sudo chmod 755 /usr/local/bin/xsync
xsync /opt/module/hadoop-2.7.2
格式化
[admin@hadoop102 hadoop-2.7.2]$ bin/hdfs namenode -format
启动服务
方案1:逐个节点启动
sbin/hadoop-daemon.sh start|stop namenode|datanode|secondarynamenode
sbin/yarn-daemon.sh start|stop resourcemanager|nodemanager
方案2:逐模块启动(Nn节点启动hdfs,Rm节点启动yarn)
[admin@hadoop102 hadoop-2.7.2]$ sbin/start-dfs.sh
[admin@hadoop102 hadoop-2.7.2]$ sbin/stop-dfs.sh
[admin@hadoop104 hadoop-2.7.2]$ sbin/start-yarn.sh
[admin@hadoop104 hadoop-2.7.2]$ sbin/stop-yarn.sh
方案3:群起
[admin@hadoop102 hadoop-2.7.2]$ sbin/start-all.sh
[admin@hadoop102 hadoop-2.7.2]$ sbin/stop-all.sh
查看运行状态
【jps 查看进程】
[admin@hadoop102 hadoop-2.7.2]$ jps
【浏览器查看端口服务】
http://hadoop102:50070