机群搭建简版

1.使用centos6.5

三台虚拟机:主节点:hadoop1 从节点:hadoop2 hadoop3

2.虚拟机创建:

分布式的搭建

1.关闭防火墙:

永久关闭:chkconfig iptables off

验证:chkconfig –list | grep iptables

2.设置静态Ip DNS均可在图形界面设置.

重启网卡:service network restart

验证:cmd ping +ip

配置hosts

在hosts中添加:

192.168.253.113 hadoop1

192.168.253.114.hadoop2

192.168.253.115hadoop3

3。安装:JDK

在usr下建java文件夹

mkdir –p usr /java

chmod u+x jdk-6u45-linux-x64.bin

设置环境变量:vi /etc/profile

增加内容如下:

export JAVA_HOME=/usr/java/jdk

export PATH=$JAVA_HOME/bin:$PATH

使注册表;立即生效:source /etc/profile

Java –version 验证

4.添加用户组和用户

/usr/sbin/groupadd hadoop

/usr/sbin/useradd hadoop –g hadoop

修改密码:passwd hadoop (可选)

创建统一的代码目录:

mkdir –p /opt/hadoop/

设置文件权限:chown –R hadoop:hadoop /opt/hadoop/

5.设置ssh免登录

在hadoop账户下进行执行

cd /home/hadoop

ssh-keygen (一路回车)

cat id_rsa.pud >> authorized_keys

本机登录不成功就是权限问题:改为chmod 600 authorized_keys 即可实现本机的免登陆

scp/home/hadoop/.ssh/id_rsa.pub hadoop@hadoop3doop/.ssh/hadoops1_pudkey

scp/home/hadoop/.ssh/id_rsa.pud hadoop@hadoop2/home/hadoop/.ssh/hadoops2_pudkey

上传完公钥后,合成

cp id_rsa.pub authorized_keys

cat hadoops1_pudkey >> authorized_keys

cat hadoops2_pudkey >> authorized_keys

上传到其投节点

scp authorized_keys hadoops1:/home/hadoop/.ssh/

scp authorized_keys hadoops2:/home/hadoop/.ssh/

设置权限验证即可。

如果不可以就不断的修改文件权限 :chmod 700 authorized chmod 600 authorized

6.安装hadoop

(1) 将hadoop压缩包上传到opt/hadoop/目录下

tar –zxvf hadoop -C /opt/hadoop

(2)对文件重命名:mv hadoop-1.1.2 hadoop

(3)修改文件的用户权限:chown –R hadoop:hadoop hadoop

(4)修改java环境变量(加入hadoop路径)

代码如下:export HADOOP_HOME=/opt/hadoop/hadoop

export PATH=.:$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$PATH

export HADOOP_HOME_WARN_SUPPRESS=1

(5)立即生效:source /etc/profile

(6)配置:hadoop-env.sh

加入:export JAVA_HOME=/usr/java/jdk1.6.0_45/(JDK路径)

(7)配置:core-site.xml

fs.default.name

hdfs://hadoop1:9000

hadoop.tmp.dir

/home/${user.name}/temp

(8)配置:hdfs-site.xml

dfs.replication

2

dfs.name.id

/home/${user.name}/dfs/name

dfs.data.dir

/home/${user.name}/dfs/data

(9)配置:mapred-site.xml

mapred.job.tracker

hadoop1:9001

mapred.system.dir

             /home/${user.name}/mapred/system

        

mapred.local.dir

/home/${user.name}/mapred/local

(10)配置:master

hadoop1

(11)配置:slaves

hadoop2

hadoop3

(12)格式化hadoop

在bin目录下执行:hadoop namenode –format

(13) 单机测试

启动namenode:./hadoop-daemon.sh start namenode

启动:jobtracker: ./hadoop-daemon.sh start jobtracker

启动:secondarynamenode: ./hadoop-daemon.sh start secondarynamenode

启动:DataNode &&TaskTracker:./hadoop-daemon.sh start datanode ./hadoop-daemon.sh start tasktracker

查看进程jps 5个进程

网络查看:hadoop1:50030 hadoop1:50070

(14)将hadoop 复制到其他节点中

scp –r /opt/hadoop/hadoop/ hadoop2:/opt/

scp –r /opt/hadoop/hadoop/ hadoop3:/opt/

(15)按照上步修改环境变量

(16):格式化hadoop。在主节点启动hadoop,./start-all.sh

查看进程:主节点:3个 从节点:2个

你可能感兴趣的:(机群搭建简版)