前言
hadoop安装版本为:hadoop-2.7.1。
下载hadoop
Linux终端:wget http://mirrors.cnnic.cn/apache/hadoop/common/hadoop-2.7.1/hadoop-2.7.1.tar.gz
配置SSH
1.配置ssh:ssh-keygen -t rsa -P "";
2.密钥启用SSH访问本地计算机:cat /home/hduser_/.ssd/id_rsa.pub >> /home/hduser_/.ssh/authorized_keys;
修改hadoop配置
1.解压hadoop 到 usr/local/hadoop;
2.配置hadoop环境变量到~/.bashrc:
#Set HADOOP_HOME export HADOOP_HOME=/usr/local/hadoop export PATH=$PATH:$HADOOP_HOME/bin
1.配置JAVA_HOME到hadoop-env.sh:vi /usr/local/hadoop/etc/hadoop/hadoop-env.sh;
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Set Hadoop-specific environment variables here. # The only required environment variable is JAVA_HOME. All others are # optional. When running a distributed configuration it is best to # set JAVA_HOME in this file, so that it is correctly defined on # remote nodes. # The java implementation to use. export JAVA_HOME=/usr/java/jdk1.7.0_80 # 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}
2.在$HADOOP_HOME/etc/hadoop/core-site.xml 文件配置hadoop存储数据相关参数,
vi /usr/local/hadoop/etc/hadoop/core-site.xml,修改如下:
hadoop.tmp.dir /app/hadoop/tmp Parent directory for other temporary directories. fs.defaultFS hdfs://localhost:54310 The name of the default file system.
3.创建存储文件目录:mkdir -p /app/hadoop/tmp;
4.授予权限:chmod 750 /app/hadoop/tmp
Map Reduce配置
1.设置hadoop环境变量:vi /etc/profile.d/hadoop.sh;
export HADOOP_HOME=/usr/local/hadoop
2.授权:chmod +x /etc/profile.d/hadoop.sh;
3.配置mapred,先在模板复制mapred-site.xml ,再编辑:
复制:cp $HADOOP_HOME/etc/hadoop/mapred-site.xml.template $HADOOP_HOME/etc/hadoop/mapred-site.xml;
编辑:vi $HADOOP_HOME/etc/hadoop/mapred-site.xml
mapreduce.jobtracker.address localhost:54311 MapReduce job tracker runs at this host and port.
配置HDFS
1,编辑hdfs-site.xml配置:vi $HADOOP_HOME/etc/hadoop/hdfs-site.xml;
dfs.replication 1 Default block replication. dfs.datanode.data.dir /home/hduser_/hdfs
2.创建配置指定的目录:mkdir -p /home/hduser_/hdfs
3.授权:chmod 750 /home/hduser_/hdfs