一、安装环境
硬件:虚拟机
操作系统:Centos 6.4 64位
IP:192.168.241.128
主机名:admin
安装用户:root
二、安装JDK
安装JDK1.7或者以上版本。这里安装jdk1.7.0_79。
下载地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html
1,下载jdk-7u79-linux-x64.gz,解压到/usr/java/jdk1.7.0_79。
2,在/root/.bash_profile中添加如下配置:
export JAVA_HOME=/usr/java/jdk1.7.0_79
export PATH=$JAVA_HOME/bin:$PATH
3,使环境变量生效,#source ~/.bash_profile
4,安装验证# java -version
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)
三,配置SSH无密码登陆
$ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
验证ssh,# ssh localhost
不需要输入密码即可登录。
如果你是集群的形式,那么可以参考http://blog.csdn.net/se7en_q/article/details/47671425
四,安装Hadoop2.7
1,下载Hadoop2.7.1
下载地址:http://mirrors.hust.edu.cn/apache/hadoop/common/stable2/hadoop-2.7.1.tar.gz
2,解压安装
1),复制 hadoop-2.7.1.tar.gz 到/usr/hadoop目录下,
然后#tar -xzvf hadoop-2.7.1.tar.gz
解压,解压后目录为:/usr/hadoop/hadoop-2.7.1
2),在/usr/hadoop/目录下,建立tmp、hdfs/name、hdfs/data目录,执行如下命令
#mkdir /usr/hadoop/tmp
#mkdir /usr/hadoop/hdfs
#mkdir /usr/hadoop/hdfs/data
#mkdir /usr/hadoop/hdfs/name
3),设置环境变量,#vi ~/.bash_profile
# set hadoop path
export HADOOP_HOME=/usr/hadoop/hadoop-2.7.1
export PATH=$PATH:$HADOOP_HOME/bin
4),使环境变量生效,$source ~/.bash_profile
5)hadoop version查看是否安装成功
hich: command not found
[root@f795f10ac377 /]# yum install which
3,Hadoop配置
进入$HADOOP_HOME/etc/hadoop目录,配置 hadoop-env.sh等。涉及的配置文件如下:
hadoop-2.7.1/etc/hadoop/hadoop-env.sh
hadoop-2.7.1/etc/hadoop/yarn-env.sh
hadoop-2.7.1/etc/hadoop/core-site.xml
hadoop-2.7.1/etc/hadoop/hdfs-site.xml
hadoop-2.7.1/etc/hadoop/mapred-site.xml
hadoop-2.7.1/etc/hadoop/yarn-site.xml
1)配置hadoop-env.sh
# The java implementation to use.
#export JAVA_HOME=${JAVA_HOME}
export JAVA_HOME=/usr/java/jdk1.7.0_79
2)配置yarn-env.sh
#export JAVA_HOME=/home/y/libexec/jdk1.7.0/
export JAVA_HOME=/usr/java/jdk1.7.0_79
3)配置core-site.xml
添加如下配置:
<configuration>
<property>
<name>fs.default.name</name> <value>hdfs://localhost:9000</value> <description>HDFS的URI,文件系统://namenode标识:端口号</description> </property> <property> <name>hadoop.tmp.dir</name> <value>/usr/hadoop/tmp</value> <description>namenode上本地的hadoop临时文件夹</description> </property> </configuration>
4),配置hdfs-site.xml
添加如下配置
<configuration>
<!—hdfs-site.xml-->
<property> <name>dfs.name.dir</name> <value>/usr/hadoop/hdfs/name</value> <description>namenode上存储hdfs名字空间元数据 </description> </property> <property> <name>dfs.data.dir</name> <value>/usr/hadoop/hdfs/data</value> <description>datanode上数据块的物理存储位置</description> </property> <property> <name>dfs.replication</name> <value>1</value> <description>副本个数,配置默认是3,应小于datanode机器数量</description> </property> </configuration>
5),配置mapred-site.xml
添加如下配置:
<configuration>
<property>
<name>mapreduce.framework.name</name> <value>yarn</value> </property> </configuration>
6),配置yarn-site.xml
添加如下配置:
<configuration>
<property>
<name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> <property> <name>yarn.resourcemanager.webapp.address</name> <value>${yarn.resourcemanager.hostname}:8088</value> </property> </configuration>
4,Hadoop启动
1)格式化namenode
$ bin/hdfs namenode –format
2)启动NameNode 和 DataNode 守护进程
$ sbin/start-dfs.sh
3)启动ResourceManager 和 NodeManager 守护进程
$ sbin/start-yarn.sh
5,启动验证
1)执行jps命令,有如下进程,说明Hadoop正常启动
# jps
6097 NodeManager
11044 Jps
7497 -- process information unavailable
8256 Worker
5999 ResourceManager
5122 SecondaryNameNode
8106 Master
4836 NameNode
4957 DataNode
6、访问控制台
http://10.16.47.100:50070
http://10.16.47.100:8088