Hadoop系列之一:hadoop部署安装

简述:一个分布式系统基础架构,由Apache基金会开发。用户可以在不了解分布式底层细节的情况下,开发分布式程序。充分利用集群的威力高速运算和存储。Hadoop实现了一个分布式文件系统(Hadoop Distributed File System),简称HDFS。HDFS有着高容错性的特点,并且设计用来部署在低廉的(low-cost)硬件上。而且它提供高传输率(high throughput)来访问应用程序的数据,适合那些有着超大数据集(large data set)的应用程序。HDFS放宽了(relax)POSIX的要求(requirements)这样可以流的形式访问(streaming access)文件系统中的数据。
官方网站:http://hadoop.apache.org/
环境:
CentOS 6.0 x64
IP配置:
主机名             IP                 角色
ha01          10.0.0.232          namenode&jobtracker
ha02          10.0.0.233          datanode&tasktracker
ha03          10.0.0.234          datanode&tasktracker
ha04          10.0.0.235          datanode&tasktracker
准备工作:
1、所有服务器添加hosts 文件

  1. vi /etc/hosts
  2. 10.0.0.232   ha01
  3. 10.0.0.233   ha02
  4. 10.0.0.234   ha03
  5. 10.0.0.235   ha04

2、添加用户hadoop,并对此用户做信任关系

  1. groupadd -g 690  hadoop
  2. useradd -g hadoop hadoop -u 690

从ha01到 ha02、ha03、ha03做SSH信任。
此处略,详见我的文章:ssh无密码登录验证技术 http://www.elain.org/?p=62
安装部署:
java环境安装:

  1. cd /root/tools
  2. wget http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-linux-x64.rpm
  3. rpm -ivh jdk-7-linux-x64.rpm
  4.  
  5. scp jdk-7-linux-x64.rpm ha02:/root/tools/
  6. scp jdk-7-linux-x64.rpm ha03:/root/tools/
  7. scp jdk-7-linux-x64.rpm ha04:/root/tools/

依次安装即可
验证java环境

  1. [root@ha01 tools]# java -version
  2. java version "1.6.0_17"
  3. OpenJDK Runtime Environment (IcedTea6 1.7.4) (rhel-1.21.b17.el6-x86_64)
  4. OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode)

安装hadoop

  1. cd /root/tools
  2. wget http://mirror.bjtu.edu.cn/apache/hadoop/core/hadoop-0.20.2/hadoop-0.20.2.tar.gz
  3. tar zxvf hadoop-0.20.2.tar.gz
  4. mv hadoop-0.20.2 /elain/apps/hadoop
  5. chown -R hadoop.hadoop /elain/apps/hadoop

建立hadoop所需目录(也可不建立,hadoop启动时会自动创建)

  1. mkdir -p /data/hadoop/{name,data01,data02,data03,tmp}
  2. chown -R hadoop.hadoop /data/hadoop/{name,data01,data02,data03,tmp}

配置

  1. cd /elain/apps/hadoop

配置java路径

  1. vi /elain/apps/hadoop/conf/hadoop-env.sh
  2.  
  3. export JAVA_HOME=/usr/java/jdk1.7.0

核心配置

  1. vi conf/core-site.xml
  1. <configuration>
  2. <property>
  3.       <name>fs.default.name</name>
  4.       <value>hdfs://ha01:9000</value>
  5.   </property>
  6. </configuration>
  1. vi mapred-site.xml
  1. <configuration>
  2.    <property>
  3.          <name>mapred.job.tracker</name>
  4.          <value>hdfs://ha01:9001</value>
  5.                        </property>
  6. </configuration>

站点节点配置

  1. vi conf/hdfs-site.xml
  1. <configuration>
  2.    <property>
  3.       <name>dfs.replication</name>
  4.             <value>3</value>
  5.                        </property>
  6.    <property>
  7.             <name>dfs.name.dir</name>
  8.             <value>/data/hadoop/name</value>
  9.                        </property>
  10.    <property>
  11.             <name>dfs.data.dir</name>
  12.             <value>/data/hadoop/data01,/data/hadoop/data02,/data/hadoop/data03</value>
  13.                        </property>
  14.    <property>
  15.             <name>dfs.tmp.dir</name>
  16.             <value>/data/hadoop/tmp</value>
  17.                        </property>
  18.    <property>
  19.             <name>dfs.block.size</name>
  20.             <value>2097152</value>
  21.                        </property>
  22.  
  23. </configuration>

主节点名称:masters
ha01
数据节点名称:slaves
ha02
ha03
ha04
初始化namenode节点

  1. /elain/apps/hadoop/bin/hadoop namenode -format

注:在此区分大小写,需输入大写Y

  1. scp -r /elain/apps/hadoop ha02:/elain/apps/
  2. scp -r /elain/apps/hadoop ha03:/elain/apps/
  3. scp -r /elain/apps/hadoop ha04:/elain/apps/
  4. ssh ha02 'chown -R hadoop.hadoop /elain/apps/hadoop'
  5. ssh ha03 'chown -R hadoop.hadoop /elain/apps/hadoop'
  6. ssh ha04 'chown -R hadoop.hadoop /elain/apps/hadoop'

启动HDFS服务
在/elain/apps/hadoop/bin下有很多命令
start-all.sh       启动所有的Hadoop进程 ,包括namenode, datanode,jobtracker,tasktrack,secondarynamenode。
stop-all.sh        停止所有的Hadoop。
start-mapred.sh    启动Map/Reduce进程 ,包括Jobtracker和Tasktrack。
stop-mapred.sh     停止Map/Reduce进程
start-dfs.sh       启动Hadoop DFS进程 ,Namenode和Datanode。
stop-dfs.sh        停止DFS进程

  1. [root@ha01 conf]# /elain/apps/hadoop/bin/start-all.sh
  2. starting namenode, logging to /elain/apps/hadoop/bin/../logs/hadoop-root-namenode-ha01.out
  3. ha02: starting datanode, logging to /elain/apps/hadoop/bin/../logs/hadoop-root-datanode-ha02.out
  4. ha03: starting datanode, logging to /elain/apps/hadoop/bin/../logs/hadoop-root-datanode-ha03.out
  5. ha04: starting datanode, logging to /elain/apps/hadoop/bin/../logs/hadoop-root-datanode-ha04.out
  6. ha01: starting secondarynamenode, logging to /elain/apps/hadoop/bin/../logs/hadoop-root-secondarynamenode-ha01.out
  7. starting jobtracker, logging to /elain/apps/hadoop/bin/../logs/hadoop-root-jobtracker-ha01.out
  8. ha04: starting tasktracker, logging to /elain/apps/hadoop/bin/../logs/hadoop-root-tasktracker-ha04.out
  9. ha02: starting tasktracker, logging to /elain/apps/hadoop/bin/../logs/hadoop-root-tasktracker-ha02.out
  10. ha03: starting tasktracker, logging to /elain/apps/hadoop/bin/../logs/hadoop-root-tasktracker-ha03.out

在Master、Slave可以使用jps查看Hadoop启动状况
验证:

  1. [root@ha01 conf]# jps
  2. 10955 SecondaryNameNode
  3. 11123 Jps
  4. 11027 JobTracker
  5. 10828 NameNode
  1. [root@ha02 ~]# jps
  2. 5163 DataNode
  3. 5299 Jps
  4. 5259 TaskTracker

转载自http://www.elain.org

你可能感兴趣的:(hadoop,职场,休闲)