一、安裝環境 硬體:虛擬機 操作系統: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: ...
一、安裝環境
硬體:虛擬機
操作系統: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