最近在系统的学习hadoop
课程第一步是安装hadoop1.x,具体安装步骤如下:
一、系统安装
本文使用centos6.5安装,具体安装步骤省略
二、jdk安装
下载jdk1.7.0_51解压,在环境中
设置环境变量:
vi /etc/profile,添加如下行:
export JAVA_HOME=/usr/local/jdk1.7.0_51
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
由于在centos下安装,选择需要设置jdk版本
update-alternatives --install /usr/bin/java java /export/home/es/jdk1.7.0_51/bin/java 60
update-alternatives --config java
![](https://i-blog.csdnimg.cn/blog_migrate/50ce052704c1f1ce4573cca6f2b58c9a.png)
三、linux基本参数设置
设置防火墙:
vi /etc/selinux/config
![](https://i-blog.csdnimg.cn/blog_migrate/05ff5012cf9d289f51778a6664b9b4bf.png)
将红框标示部分,设置为disabled
![](https://i-blog.csdnimg.cn/blog_migrate/27ba9fb29243a953e7c59bec869a750c.png)
查看防火墙情况,并关闭
service iptables status
service ip6tables status
service iptables stop
service ip6tables stop
chkconfig iptables off
chkconfig ip6tables off
四,免密码登陆
设置使用免密码登陆方式
![](https://i-blog.csdnimg.cn/blog_migrate/a891377962e992c80390a009ece8b09b.png)
vi /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
将这三个部分的注释去掉,使用RSA验证方式
![](https://i-blog.csdnimg.cn/blog_migrate/d1bb434a02fd9ce21f6cabe7c38388af.png)
生成公钥
[hadoop@vm .ssh]$ pwd
/export/home/hadoop/.ssh
[hadoop@vm .ssh]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
......
[hadoop@vm .ssh]$ cp id_rsa.pub authorized_keys
[hadoop@vm .ssh]$ ls
authorized_keys id_rsa id_rsa.pub
修改hosts文件:
[hadoop@vm conf]$ more /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.2.201 vm.master
192.168.2.202 vm.slave1
192.168.2.203 vm.slave2
修改hostname![](https://i-blog.csdnimg.cn/blog_migrate/2432e07ca96086730adb30e57019576a.png)
[hadoop@vm etc]$ vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=vm.master
四,修改hadoop配置文件
[hadoop@vm conf]$ pwd
/export/home/hadoop/hadoop-1.2.1/conf
修改
core-site.xml
![](https://i-blog.csdnimg.cn/blog_migrate/b81a59159894831dacc27ab4db8960fb.png)
[hadoop@vm conf]$ vi core-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
修改hdfs-site.xml
![](https://i-blog.csdnimg.cn/blog_migrate/64f91246d6ae84792871a32b6b49ac69.png)
[hadoop@vm conf]$ vi hdfs-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>dfs.replications</name>
<value>1</value>
</property>
</configuration>
修改mapred-site.xml![](https://i-blog.csdnimg.cn/blog_migrate/81a119169f37634f8a6a04c1560acfcb.png)
[hadoop@vm conf]$ vi mapred-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!-- Put site-specific property overrides in this file. -->
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>localhost:9001</value>
</property>
</configuration>
设置JAVA_HOME
![](https://i-blog.csdnimg.cn/blog_migrate/e149d5730112aef01329631436f2d041.png)
五,尝试启动
format namenode
![](https://i-blog.csdnimg.cn/blog_migrate/fd5a7e92744c96c538ed51d15385f969.png)
尝试启动
![](https://i-blog.csdnimg.cn/blog_migrate/1b499b4fb551829239c3a1c990a7b7b9.png)
搭建完毕
![](https://i-blog.csdnimg.cn/blog_migrate/1b499b4fb551829239c3a1c990a7b7b9.png)
搭建完毕