安裝目標:一個namenode 和 2 個datanode,假定已用戶名zhaomeng和密碼zhaomeng進行java
虛擬機:3個centos 64(橋接模式)node
1.192.168.203.129 master_centos64_1 2.192.168.203.130 slave_centos64_2 3.192.168.203.138 slave_centos_3
準備工做:web
1.啓動三個虛擬機master_centos64_1centos
2.檢查ssh是否安裝和sshd是否啓動(能否互相ssh,端口號默認是22)ssh
3.若想配置好記的機器名,能夠sudo vi /etc/hostname將HOSTNAME改爲本身喜歡的oop
4.若想只用機器名,能夠sudo vi /etc/hosts更改路由表 (hosts文件優先於路由器)測試
5.(optional)檢查防火牆iptablecode
6.在三臺機器上建立相同用戶,如zhaomeng, 加入sudoers列表和root用戶組orm
a.useradd -G root zhaomengxml
b.sudovi /etc/sudoers 正加root相似的一行
root ALL(ALL) ALL zhaomeng ALL(ALL) ALL
7.配置用戶zhaomeng在三臺機器相互間免密碼ssh
a.(master1)cd /home/zhaomeng
b.(master1)ssh-keygen以後直接3個回車或者ssh-keygen -t rsa -P '' (在主目錄生成.ssh/idrsa和.ssh、id_rsa.pub)
c.(master1)cat .ssh/id_rsa.pub >> .ssh/authorized_keys
d.(slave2和slave3)執行ab並將id_rsa.pub文件均scp至master1,並執行c
e.(master1)將包含3個公鑰的authorized_keys文件scp至slave2和slave3
f.(master1,slave2,slave3)chmod 600 .ssh/authorized_keys(很是重要,不然不起效)
g.(master1,slave2,slave3)三臺機器之間相互測試時候能夠無密碼ssh (第一次均須要確認是否記住憑證,選擇yes)
8.(master1,slave2,slave3)下載和安裝JDK7,並設置必要的JAVA_HOME和PATH變量
9.(master1)下載hadoop2.6.3,解壓至/home/zhaomeng/hadoop263 (hadoop263下路目錄爲bin sbin etc libexec lib 等)
10.(master1,slave2,slave3)設置環境變量
vi /etc/profile 加入以下內容
export JAVA_HOME=/usr/java/default export HADOOP_HOME=/home/zhaomeng/hadoop export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop export HADOOP_PREFIX=$HADOOP_HOME export HADOOP_LIBEXEC_DIR=$HADOOP_HOME/libexec export PATH=$JAVA_HOME/bin:$PATH export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native export HADOOP_COMMON_HOME=$HADOOP_HOME export HADOOP_HDFS_HOME=$HADOOP_HOME export HADOOP_MAPRED_HOME=$HADOOP_HOME export HADOOP_YARN_HOME=$HADOOP_HOME
並使之生效source /etc/profile
11.(master1)配置HADOOP_HOME/etc/hadoop/core.site.xml hdfs.site.xml yarn.site.xml (mapred-site.xml) slaves 以及hadoop-sne.sh和yarn-env.sh (兩個sh文件主要是加入JAVA_HOME變量)
12.(master1)mkdir logs tmp data
13.(master1)將HADOOP_HOME整個文件夾scp至slave2和slave3,並保持和master1同樣的目錄結構
14.(master1)格式化namenode,執行HADOOP_HOME/bin/hdfs namenode -format
15.(master1)啓動hdfs,執行HADOOP_HOME/sbin/start-dfs.sh
16.(master1)啓動yarn,執行HADOOP_HOME/sbin/start-yarn.sh
17.幾個網址
18.待續
附錄幾個文件
core-site.xml
<configuration> <property> <name>fs.defaultFS</name> <value>hdfs://192.168.203.129:9000</value> </property> <property> <name>hadoop.tmp.dir</name> <value>/home/zhaomeng/hadoop/tmp</value> </property> </configuration>
hdfs-site.xml
<configuration> <property> <name>dfs.webhdfs.enable</name> <value>true</value> </property> <property> <name>dfs.datanode.ipc.address </name> <value>0.0.0.0:50020</value> </property> <property> <name>dfs.datanode.http.address</name> <value>0.0.0.0:50075</value> </property> <property> <name>dfs.replication</name> <value>2</value> </property> <property> <name>dfs.namenode.name.dir</name> <value>file:///home/zhaomeng/hadoop/name</value> </property> <property> <name>dfs.datanode.data.dir</name> <value>file:///home/zhaomeng/hadoop/data</value> </property> </configuration>
yarn-site.xml
<configuration> <property> <name>yarn.nodemanager.aux-services</name> <value>mapreduce_shuffle</value> </property> </configuration>
slaves
slave_centos64_2 slave_centos_3