Hadoop2.6.5單機安裝
一,安裝環境
硬體:虛擬機器
作業系統:Centos-7 64位
主機名:linux01
安裝使用者:root
二,安裝JDK
安裝JDK1.6或者以上版本。這裡安裝jdk1.8.0。
下載地址:http://www.oracle.com/technetwork/java/javase/downloads/index.html
1,下載jdk-8u181-linux-x64.rpm,解壓/usr/java/jdk1.8.0。
2,在/etc/profile中新增如下配置:
#jdk1.8 export JAVA_HOME=/usr/java/jdk1.8.0 export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin export JAVA_HOME CLASSPATH PATH
3,使環境變數生效,#source ~/.profile
4,安裝驗證# java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
三,配置SSH無密碼登陸
$ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa $ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
驗證ssh,# ssh localhost
不需要輸入密碼即可登入。
2,解壓安裝
1),複製 hadoop-2.6.5.tar.gz 到/root/hadoop目錄下,
然後#tar -xzvf hadoop-2.6.5.tar.gz
解壓,解壓後目錄為:/root/hadoop/hadoop-2.6.5
2),在/root /hadoop/目錄下,建立tmp、hdfs/name、hdfs/data目錄,執行如下命令
#mkdir /root/hadoop/tmp
#mkdir /root/hadoop/hdfs
#mkdir /root/hadoop/hdfs/data
#mkdir /root/hadoop/hdfs/name
3),設定環境變數,#vi ~/.bash_profile
編輯insert
儲存退出esc :wq :q!(退出不儲存)
# set hadoop path
export HADOOP_HOME=/root /hadoop/hadoop-2.6.5
export PATH=$PATH:$HADOOP_HOME/bin
4),使環境變數生效,$source ~/.bash_profile
3,Hadoop配置
進入$HADOOP_HOME/etc/hadoop目錄,配置 hadoop-env.sh等。涉及的配置檔案如下:
hadoop-2.6.5/etc/hadoop/hadoop-env.sh
hadoop-2.6.5/etc/hadoop/yarn-env.sh
hadoop-2.6.5/etc/hadoop/core-site.xml
hadoop-2.6.5/etc/hadoop/hdfs-site.xml
hadoop-2.6.5/etc/hadoop/mapred-site.xml
hadoop-2.6.5/etc/hadoop/yarn-site.xml
1)配置hadoop-env.sh
# The java implementation to use.
#export JAVA_HOME=${JAVA_HOME}
export JAVA_HOME=/usr/lib/jdk1.8.0
2)配置yarn-env.sh
#export JAVA_HOME=/home/y/libexec/jdk1.6.0/
export JAVA_HOME=/usr/lib/jdk1.8.0
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>/root/hadoop/tmp</value>
<description>namenode上本地的hadoop臨時資料夾</description>
</property>
</configuration>
4),配置hdfs-site.xml
新增如下配置
<configuration>
<!—hdfs-site.xml-->
<property>
<name>dfs.name.dir</name>
<value>/root/hadoop/hdfs/name</value>
<description>namenode上儲存hdfs名字空間元資料 </description>
</property>
<property>
<name>dfs.data.dir</name>
<value>/root/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}:8099</value>
</property>
</configuration>
4,Hadoop啟動
1)格式化namenode
[[email protected] hadoop]# cd /root/hadoop/hadoop-2.6.5
[[email protected] hadoop-2.6.5]# bin/hadoop namenode -forma
2)啟動NameNode 和 DataNode 守護程序
$ sbin/ ./start-dfs.sh
3)啟動ResourceManager 和 NodeManager 守護程序
$ sbin/ ./start-yarn.sh
5,啟動驗證
1)執行jps命令,有如下程序,說明Hadoop正常啟動
# jps
54679 NameNode
54774 DataNode
15741 Jps
9664 Master
55214 NodeManager
55118 ResourceManager
54965 SecondaryNameNode
2)在瀏覽器中輸入:http://192.168.2.2:8099/cluster 即可看到YARN的ResourceManager的介面。注意:預設埠是8088,這裡我設定了yarn.resourcemanager.webapp.address為:${yarn.resourcemanager.hostname}:8099