任务描述
知识点:
重 点:
内 容:
任务指导
Hadoop是一个由Apache基金会所开发的分布式系统基础架构。用户可以在不了解分布式底层细节的情况下,开发分布式程序。充分利用集群的威力进行高速运算和存储。任务主要内容:下载安装Hadoop包,配置环境变量,配置Hadoop集群
1. 创建Hadoop目录
2. 解压Hadoop安装包
3. 创建Hadoop数据存放的目录(例如:tmp、hdfs、hdfs/data、hdfs/name等目录)
4. 配置Hadoop环境变量
5. 修改Hadoop配置文件
任务实现
[ root@master ~]# mkdir /home/hadoop
[ root@master ~]# cd /home/software/
[ root@master software ]# tar -zxvf /home/software/hadoop-2.9.2.tar.gz -C /home/hadoop/
[ root@master software ]# cd ~
[ root@master ~]# mkdir -p /home/hadoop/tmp
[ root@master ~]# mkdir -p /home/hadoop/hdfs/data
[ root@master ~]# mkdir -p /home/hadoop/hdfs/name
[ root@master ~]# vim /etc/profile
export HADOOP_HOME=/home/hadoop/hadoop-2.9.2
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
[ root@master ~]# source /etc/profile
[ root@master ~]# cd /home/hadoop/hadoop-2.9.2/etc/hadoop/
fs.defaultFS
hdfs://master:9000
hadoop.tmp.dir
file:/home/hadoop/tmp
io.file.buffer.size
131702
dfs.namenode.name.dir
file:/home/hadoop/hdfs/name
dfs.datanode.data.dir
file:/home/hadoop/hdfs/data
dfs.replication
2
dfs.namenode.secondary.http-address
master:9001
dfs.webhdfs.enabled
true
dfs.permissions.enabled
false
然后开始配置/home/hadoop/hadoop-2.9.2/etc/hadoop/mapred-site.xml文件,配置内容如下:
dfs.permissions
false
mapreduce.jobhistory.address
master:10020
mapreduce.job.tracker
hdfs://master:8001
true
yarn.nodemanager.aux-services
mapreduce_shuffle
yarn.nodemanager.auxservices.mapreduce.shuffle.class
org.apache.hadoop.mapred.ShuffleHandler
yarn.resourcemanager.address
master:8032
yarn.nodemanager.resource.memory-mb
4096
1)输入【vim hadoop-env.sh】打开准备修改的配置文件hadoop-env.sh,加入JAVA_HOME环境变量。
……
# The java implementation to use.
export JAVA_HOME=/home/java/jdk1.8.0_221
# The jsvc implementation to use. Jsvc is required to run secure datanodes
# that bind to privileged ports to provide authentication of data transfer
# protocol. Jsvc is not required if SASL is configured for authentication of
# data transfer protocol using non-privileged ports.
#export JSVC_HOME=${JSVC_HOME}
export HADOOP_CONF_DIR=${HADOOP_CONF_DIR:-"/etc/hadoop"}
……
2)输入【vim yarn-env.sh】打开准备修改的配置文件修改配置文件yarn-env.sh,加入JAVA_HOME环境变量。
……
# User for YARN daemons
export HADOOP_YARN_USER=${HADOOP_YARN_USER:-yarn}
# resolve links - $0 may be a softlink
export YARN_CONF_DIR="${YARN_CONF_DIR:-$HADOOP_YARN_HOME/conf}"
# some Java parameters
export JAVA_HOME=/home/java/jdk1.8.0_221
……
3)输入【vim mapred-env.sh】打开准备修改的配置文件mapred-env.sh,加入JAVA_HOME环境变量。
……
# See the License for the specific language governing permissions and
# limitations under the License.
export JAVA_HOME=/home/java/jdk1.8.0_221
export HADOOP_JOB_HISTORYSERVER_HEAPSIZE=1000
export HADOOP_MAPRED_ROOT_LOGGER=INFO,RFA
#export HADOOP_JOB_HISTORYSERVER_OPTS=
……
slave1
slave2
[ root@master hadoop ]# scp -rq /home/hadoop/ root@slave1:/home/
[ root@master hadoop ]# scp -rq /home/hadoop/ root@slave2:/home/
[ root@master hadoop ]# scp -rq /etc/profile root@slave1:/etc/profile
[ root@master hadoop ]# scp -rq /etc/profile root@slave2:/etc/profile
[ root@master ~]# source /etc/profile