分享

完全分布式环境搭建

yunmin 发表于 2015-5-3 15:30:55 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 0 18562
虚拟机:VM10.4
Linux环境:Ubuntu12.4
hadoop-2.5.2
jdk1.7.0_51


其它虚拟机也是按照这个来
1创建root密码:sudo passwd root
2新增一个用户:sudo adduser hadoop
3切换到root
执行
给sudoers增加写权限:chmod u+w /etc/sudoers
编译sudoers文件:vi /etc/sudoers      
在rootALL=(ALL)  ALL下方增加hadoop ALL=(ALL)NOPASSWD:ALL
去掉sudoers文件的写权限:chmod u-w /etc/sudoers
4第一步:sudo nano/etc/hostname改成自己的用户名
  sudo nano /etc/hosts  127.0.1.1注释掉
  并添加上集群所有的iphostname
重启网络sudo/etc/init.d/networking restart

第二部:(slave2出现问题,安装ssh时)
安装jdkhadoop
Usr/lib/jvm   /home/hadoop/hadoop-…..
tar -xzvf
sudo cp/etc/apt/sources.list /etc/apt/sources.list.bak
sudo gedit/etc/apt/sources.list
替换为以下形式:
debhttp://ubuntu.uestc.edu.cn/ubuntu/ precise main restricted universe multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-backports main restricteduniverse multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-proposed main restricteduniverse multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-security main restricteduniverse multiverse
deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-updates main restricted universemultiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise main restricted universemultiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-backports main restricteduniverse multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-proposed main restricteduniverse multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-security main restricteduniverse multiverse
deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-updates main restricteduniverse multiverse
sudo apt-getupdate
(遇到的问题:
我的ubuntu机器上出现下面这个错误。
Reading package lists... Error!
E: Encountered a section with no Package: header
E: Problem with MergeList/var/lib/apt/lists/ftp.sjtu.edu.cn_ubuntu_dists_precise-security_restricted_binary-i386_Packages
E: The package lists or status file could not beparsed or opened.

虽然不知道是怎么回事,但是google出来的结果提示可以按如下方法解决,记录之:
sudo rm /var/lib/apt/lists/* -vf
sudo apt-get update
sudo apt-getinstall ssh
之后:
ssh-keygen -trsa
.ssh/home/hadoop/.ssh
cat~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
插曲:
1)修改文件"authorized_keys" hadoop用户下修改)
chmod 600 ~/.ssh/authorized_keys
2)设置SSH配置
root用户登录服务器修改SSH配置文件"/etc/ssh/sshd_config"的下列内容。
file:///C:/Users/ADMINI~1/AppData/Local/Temp/msohtmlclip1/01/clip_image001.gif
RSAAuthentication yes #
启用 RSA 认证
PubkeyAuthentication yes #
启用公钥私钥配对认证方式
AuthorizedKeysFile .ssh/authorized_keys #
公钥文件路径(和上面生成的文件同)

设置完之后记得重启SSH服务,才能使刚才设置有效。
service sshd restart
第三部:
进入master.ssh目录(hadoop@master)
scp authorized_keys hadoop@slaver1:~/.ssh/authorized_keys_from_master
scp authorized_keyshadoop@slaver2:~/.ssh/authorized_keys_from_master
scp authorized_keys hadoop@slaver3:~/.ssh/authorized_keys_from_master
进入slaver1.ssh目录( hadoop@slaver1)
scp authorized_keys hadoop@master:~/.ssh/authorized_keys_from_slaver1
scp authorized_keyshadoop@slaver2:~/.ssh/authorized_keys_from_slaver1
scp authorized_keys hadoop@slaver3:~/.ssh/authorized_keys_from_slaver1
进入slaver2.ssh目录( hadoop@slaver2)
scp authorized_keys hadoop@master:~/.ssh/authorized_keys_from_slaver2
scp authorized_keyshadoop@slaver1:~/.ssh/authorized_keys_from_slaver2
scp authorized_keys hadoop@slaver3:~/.ssh/authorized_keys_from_slaver2
进入slaver3.ssh目录( hadoop@slaver3)
scp authorized_keys hadoop@master:~/.ssh/authorized_keys_from_slaver3
scp authorized_keyshadoop@slaver1:~/.ssh/authorized_keys_from_slaver3
scp authorized_keys hadoop@slaver2:~/.ssh/authorized_keys_from_slaver3
之后再:进入slaver3
在目录/home/hadoop/.ssh
cat authorized_keys_from_master  >>  authorized_keys
cat authorized_keys_from_slaver1  >>  authorized_keys
cat authorized_keys_from_slaver2  >>  authorized_keys
依此类推:
  1. ssh-rsaAAAAB3NzaC1yc2EAAAADAQABAAABAQC/QbIrshemhtsBnCcOMCMU2fpgqfNe2YXyQKUYB3k99zmtu68HXY1nJL1LBATRkOJPr1Dol8yKJu9CMmwHvwmZdUFxc3aUenin639VKqT7jXEyn1X8ONkCrwMsoKpStHxbUaihUgFODtadmn9AXAKTkYT5jGif2HBbFZ6pTQkCNomZzP/icShWl4hQTRTs5eCA59+8cKdT5MZnQmEabRN2JRcyYZ6dM2n4xDZ87lXYXbA/hzIVjtDWgYCLKzXsPcpIRpf1r1jMhj1YZxlaZA5Ylht6GVNQeg78sul5U08ZmgGikFUNxurfA7zeXH2k4fIhBiUA9YUH6js51YcvmqQbhadoop@slaver1
  2. ssh-rsaAAAAB3NzaC1yc2EAAAADAQABAAABAQDIz2AaRdjZf2mK5hidOcETv/FzIC0c6VlUvyFhwk/zMKAaROKUm4xf0IPd5mKYEIJHtCQAHByV5tUbfdXdyLSO44cMwRw7szZCaw8lpJFz80NGAYSZMS43oLmVSwP7JeCxuohtjwiYo0WK8Ebiv2BhUNdF6qIHzUWW0jVF07uryZPXsjMgnXhYyvbXW/r0iNwmt+NmWz/8CVNLaZXumVFiFii5VnhuD7pHkWHQPuHfjauzD2FcIhq5AblCgOPGDAHxXu8q/Ci+COx/NsPbuhwK6nuaXN3PtDoeIgm4ylgUnw3aOG0ybAtR4kuWcA4LYnSNKmuH7G4IKeBFnEs28/RPhadoop@slaver2
  3. ssh-rsaAAAAB3NzaC1yc2EAAAADAQABAAABAQCykVCGfRCUtEx3Zd6BpTjdsolcvdoob4B27naHq791ZHu8Ayk1ICnZuSzzyz+wE4lV2sDGST4muY5jt4e3n/X0EtW+lXw6cmkyQhDe7CIjb99uDr7ZW5cdnDiLflaBhlL+A3+yxFn6Zo5LBMR4MHSZVsZABdjhrMc1tJQsh4qLz9KlxVs1LiRd/Nv9WO2tf6ZKE64rhGK+2P1yi/w89eK/Ek73Lt5d/M6RPPqb6WSF4fWH1m4fLEhyIPokGt7TsyQ8YQvPK6q04sZsFxj/xYEH4LG27zbCHEic8o0f1iAROQCh/sN3vip5tuXTxzPMs5tKHoAjkDqz8Mq1Vw2lUZ5/hadoop@slaver3
  4. ssh-rsaAAAAB3NzaC1yc2EAAAADAQABAAABAQDcYkSfx5So+Wh8XoMcnxP1PvqSXCH54i/3ZtVum2g5D2usdxRBrqCXhNH2dL4PpNgaGYYr4iR2jdqgmYfI1WJ+52LV1V11fDa4HZctxpSBAK3HgEaAPo8/MN9+SvczAlXQ4CVAdLrsAj0pXk5VcaqRrAzJi2bMiPnts3pRuMFRElSuCUYSLZlIPmhWhBGN5RL12DV5RawVCm0dgK6wZqoPE8bHygguAPwUxASyf9R6C9fJ5BRHvRhathH6/W+AuWajmO5498F11WFWWCtchnQ9vIiSZ4Pe/qcNJVBUW66ooZnnKG3qGUkrAujnipUtT71kAgWT+cLzbIdKTOitCHObhadoop@master
复制代码

第三部其实讲白一点就是直接将各个虚拟机对应的公钥,复制到~/.ssh/authorized_keys
都要启动者,执行ssh 虚拟机时才能运行
第四部:
设置java环境变量
hadoop@master:~$sudo nano /etc/profile
再添加:
exportJAVA_HOME=/usr/lib/jvm/jdk1.7.0_51
exportJRE_HOME=/usr/lib/jvm/jdk1.7.0_51/jre
exportCLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
exportPATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOME/bin
hadoop@master:~$sudo nano /etc/environment
再添加:
exportJAVA_HOME=/usr/lib/jvm/jdk1.7.0_51
exportJRE_HOME=/usr/lib/jvm/jdk1.7.0_51/jre
exportCLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
hadoop@master:~$sudo update-alternatives --install /usr/bin/java java/usr/lib/jvm/jdk1.7.0_51/bin/java 300
hadoop@master:~$sudo update-alternatives --install /usr/bin/javac javac/usr/lib/jvm/jdk1.7.0_51/bin/javac 300
hadoop@master:~$sudo update-alternatives --config java
java –version或者javac查看
ufw disable)关闭防火墙
第五部分:
Hadoop
hadoop@master:~/hadoop-2.5.2$sudo mkdir hdfs
hadoop@master:~/hadoop-2.5.2$sudo mkdir hdfs/name
hadoop@master:~/hadoop-2.5.2$sudo mkdir hdfs/data
hadoop@master:~/hadoop-2.5.2$sudo mkdir tmp
修改权限,保证文件都是在hadoop下操作
hadoop@master:~/hadoop-2.5.2$sudo chown -R hadoop:hadoop hdfs
hadoop@master:~/hadoop-2.5.2$sudo chown -R hadoop:hadoop tmp
hadoop@master:~/hadoop-2.5.2/etc/hadoop$ nano hadoop-env.sh
修改里面的JAVA_HOME
hadoop@master:~/hadoop-2.5.2/etc/hadoop$ nano yarn-env.sh
修改里面的JAVA_HOME
hadoop@master:~/hadoop-2.5.2/etc/hadoop$ nano slaves
(这个文件里面保存所有slave节点)
hadoop@master:~/hadoop-2.5.2$ nano etc/hadoop/core-site.xml
内容如下:
<configuration>
        <property>
               <name>fs.defaultFS</name>
                <value>hdfs://master:8020</value>
        </property>
        <property>
               <name>io.file.buffer.size</name>
               <value>131072</value>
        </property>
        <property>
               <name>hadoop.tmp.dir</name>
                <value>file:/home/hadoop/hadoop-2.5.2/tmp</value>
                <description>Abase forother temporary  directories.</descripti$
        </property>
        <property>
               <name>hadoop.proxyuser.hadoop.hosts</name>
                <value>*</value>
        </property>
        <property>
               <name>hadoop.proxyuser.hadoop.groups</name>
                <value>*</value>
        </property>
</configuration>
编辑mapred-site.xml(需要复制mapred-site.xml.template,并命名为mapred-site.xml
hadoop@master:~/hadoop-2.5.2$ nano etc/hadoop/mapred-site.xml
<configuration>
        <property>   
                            <name>mapreduce.framework.name</name>                                                   
                <value>yarn</value>
        </property>
        <property>
               <name>mapreduce.jobhistory.address</name>
               <value>master:10020</value>
        </property>
        <property>
               <name>mapreduce.jobhistory.webapp.address</name>
               <value>master:19888</value>
        </property>
</configuration>
hadoop@master:~/hadoop-2.5.2/etc/hadoop$ nano yarn-site.xml
<property>
<name>yarn.nodemanager.aux-services</name>
    <value>mapreduce_shuffle</value>
</property>
<property>                                                                  

<name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>
     <value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>
<property>
     <name>yarn.resourcemanager.address</name>
     <value>master:8032</value>
</property>
<property>
      <name>yarn.resourcemanager.scheduler.address</name>
      <value>master:8030</value>
</property>
<property>
      <name>yarn.resourcemanager.resource-tracker.address</name>
      <value>master:8031</value>
</property>
<property>
      <name>yarn.resourcemanager.admin.address</name>
       <value>master:8033</value>
</property>
<property>
       <name>yarn.resourcemanager.webapp.address</name>
       <value>master:8088</value>
</property>
hadoop@master:~/hadoop-2.5.2/etc/hadoop$ nano hdfs-site.xml
内容如下:
<property>
               <name>dfs.namenode.secondary.http-address</name>
               <value>master:9001</value>
        </property>
        <property>
               <name>dfs.namenode.name.dir</name>
                <value>file:/home/hadoop/hadoop-2.5.2/hdfs/name</value>
        </property>
        <property>
               <name>dfs.datanode.data.dir</name>
               <value>file:/home/hadoop/hadoop-2.5.2/hdfs/data</value>
        </property>
        <property>
                <name>dfs.replication</name>
                <value>3</value>
        </property>
        <property>
               <name>dfs.webhdfs.enabled</name>
                <value>true</value>
        </property>
scp -r /home/hadoop/hadoop-2.5.2 hadoop@slaver1:/home/hadoop
scp -r /home/hadoop/hadoop-2.5.2 hadoop@slaver2:/home/hadoop
scp -r /home/hadoop/hadoop-2.5.2 hadoop@slaver3:/home/hadoop
hadoop@slaver3:~/hadoop-2.5.2$bin/hdfs namenode –format或者bin/hadoop namenode format
[hadoop@masterhadoop-2.4.0]$ sbin/start-all.sh
通过查找/home/hadoop/hadoop-2.5.2/bin或者/home/hadoop/hadoop-2.5.2/sbin下的文件可以执行各种命令


没找到任何评论,期待你打破沉寂

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条