Centos 7.0 安装 hadoop
一、安装环境
硬件:虚拟机
操作系统:Centos 7.0 64位
IP:192.168.120.150
hadoop-2.7.0.tar.gz 链接:http://pan.baidu.com/s/1eRT0tk2 密码:ymim
jdk-8u45-linux-x64.tar.gz 链接:http://pan.baidu.com/s/1eSaRUGa 密码:f4ue
二、安装JDK
1,下载jdk-8u45-linux-x64.tar.gz,解压到/usr/java/jdk1.8.0_45。
2,在/root/.bash_profile中添加如下配置:
export JAVA_HOME=/usr/java/jdk1.8.0_45
export PATH=$JAVA_HOME/bin:$PATH
3,使环境变量生效,#source ~/.bash_profile
4,安装验证# java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-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.0
1,下载Hadoop2.7.0
2,解压安装
1),复制 hadoop-2.7.0.tar.gz 到/usr/hadoop目录下,
然后#tar -xzvf hadoop-2.7.0.tar.gz 解压,解压后目录为:/usr/hadoop/hadoop-2.7.0
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.0
export PATH=$PATH:$HADOOP_HOME/bin
4),使环境变量生效,$source ~/.bash_profile
3,Hadoop配置
进入$HADOOP_HOME/etc/hadoop目录,配置 hadoop-env.sh等。涉及的配置文件如下:
hadoop-2.7.0/etc/hadoop/hadoop-env.sh
hadoop-2.7.0/etc/hadoop/yarn-env.sh
hadoop-2.7.0/etc/hadoop/core-site.xml
hadoop-2.7.0/etc/hadoop/hdfs-site.xml
hadoop-2.7.0/etc/hadoop/mapred-site.xml
hadoop-2.7.0/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.8.0_45
2)配置yarn-env.sh
#export JAVA_HOME=/home/y/libexec/jdk1.7.0/
export JAVA_HOME=/usr/java/jdk1.8.0_45
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>192.168.120.150:8099</value>
</property>
</configuration>
4,Hadoop启动
1)格式化namenode
cd hadoop/hadoop-2.7.0/sbin/
./hdfs namenode –format
2)启动NameNode 和 DataNode 守护进程
.start-dfs.sh
3)启动ResourceManager 和 NodeManager 守护进程
.sbin/start-yarn.sh
5,启动验证
1)执行jps命令,有如下进程,说明Hadoop正常启动
# jps
71072 ResourceManager
71171 NodeManager
72690 Jps
6,登录hadoop
http:192.168.120.150:8099