Centos 6.5 机群搭建及问题解决

Centos 6.5 完全分布式搭

三个虚拟机:一主两从 主节点:hadoopm 从节点:hadoops1 hadoops2 网络模式:仅与主机通信

1.关闭防火墙:

永久关闭:chkconfig iptables off

验证:chkconfig –list | grep iptables

2.设置静态IP(这里选择的是仅与主机相连)

方法—:

(1)选择电脑图标选择网络编辑

 

(2)设置静态IP 选择manual 设置ip 网段网关 DNS 重启网卡即可 查看输入:ipconfig

 

方法二:

(1)设置IP

vi /etc/sysconfig/network-scripts/ifcfg-eth0

(2).设置DNS

vi /etc/resolv.conf

(3).重启网卡

Sevice network restart

验证cmd输入:ping 192.168.253.111

3.设置修改主机名,设置hosts

(1)修改主机名:

vi /etc/sysconfig/network

(2)配置hosts

vi /etc/hosts

4.添加用户组

/usr/sbin/groupadd hadoop

/usr/sbin/useradd hadoop –g hadoop

修改密码:passwd hadoop

创建:mkdir -p /opt/modules/hadoop/

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

5.设置SSH免登录 (必须要设置密码)

在hadoop账户下:执行

cd/home/hadoop

ssh-keygen -q -t rsa -N "" -f /home/hadoop/.ssh/id_rsa

cd /home/hadoop/.ssh

scp/home/hadoop/.ssh/id_rsa.pub [email protected]:/home/hadoop/.ssh/hadoops1_pudkey

scp/home/hadoop/.ssh/id_rsa.pud hadoop@hadoopm:/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/

验证:

ssh hadoopm

ssh hadoops1

ssh hadoops2

 

6.安装JDK

1.新建java目录在usr目录下上传JDk

mkdir /usr/java

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

./ jdk-6u45-linux-x64.bin

 

配置环境变量:

vi /etc/profile.d/java.sh

export JAVA_HOME=/usr/java/jdk1.6.0_45

export PATH=$JAVA_HOME/bin:$PATH

 

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

Java –version

 

7.安装hadoop

上传Hadoop 的安装包到/opt/modules/hadoop

解压:tar -zxvf hadoop-1.1.2.tar.gz

 

对hadoop 进行重命名:

mv hadoop-1.1.2 /hadoop

对hadoop进行配置:

(1)java环境变量的修改:

export JAVA_HOME=/usr/java/jdk1.6.0_45

export HADOOP_HOME=/opt/modules/hadoop/hadoop-1.1.2/

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

export HADOOP_HOME_WARN_SUPPRESS=1

立即生效:source /etc/profile

(2)配置hadoop-env.sh

export JAVA_HOME=/usr/java/jdk1.6.0_45/

(3)配置core-site.xml

vi core-site.xml

<property>

<name>fs.default.name</name>

<value>hdfs://hadoopm:9000</value>

<description>hadoop namenode</description>

</property>

<property>

<name>hadoop.tmp.dir</name>

<value>/home/${user.name}/temp</value>

<description,>数据存放位置</description>

</property>

(4)配置hdfs-site.xml

<property>

    <name>dfs.replication</name>

    <value>2</value>

    <description>HDFS数据保存份数,通常是3 </description>

</property>

<property>

<name>dfs.name.id</name>

<value>/home/${user.name}/dfs/name</value>

<description,>数据存放位置</description>

</property>

<property>

<name>dfs.data.dir</name>

<value>/home/${user.name}/dfs/data</value>

<description,>数据存放位置</description>

</property>

对mapred-site.xml 进行设置

<property>

<name>mapred.job.tracker</name>

<value>hadoopmr:9001</value>

</property>

<property>

<name>mapred.system.dir</name>

<value>/home/${user.name}/mapred/system</value>

<description,>数据存放位置</description>

</property>

<property>

<name>mapred.local.dir</name>

<value>/home/${user.name}/mapred/local</value>

<description,>数据存放位置</description>

</property>

对master 进行设置:

hadoopm

对slaves 进行设置 完全分布的设置

hadoops1

hadoops2

测试:

单机测试

格式化:/hadoop-1.1.2/bin/hadoop namenode –format

启动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)个 查看网络:hadoopm:50070

Hadoopm:50030

 

复制hadoopm中hadoop到hadoops1 和hadoops2 中

scp -r /opt/modules/hadoop/hadoop-1.1.2/ hadoops1:/opt/modules/hadoop/

scp -r /opt/modules/hadoop/hadoop-1.1.2/ hadoops2:/opt/modules/hadoop/

 

修改java环境变量:

 

格式化hadoop1 hadoop2中的HDFS文件系统

hadoop namenode –formate

启动hadoopm 主节点:./start-all.sh

查看:jps

主节点:5个

从节点: 2个

网络查看:

hadoopm:50030

hadoopm:50070

 

查看;jobtracker 和trasktracker是否正常

查看namenode 和datanode

问题总结:

1.ssh 免登录问题的解决:在设置新的账户时也设置上密码,在第一次传输公钥时会提示不断地输入密码,你无法解决。

2.在java环境变量设置,需要把传送完hadoop时对它进行配置更新,否则会提示找不到hadoop。

你可能感兴趣的:(Centos 6.5 机群搭建及问题解决)