您好,欢迎访问三七文档
当前位置:首页 > IT计算机/网络 > 数据库 > 虚拟机集群部署hadoop
使用虚拟机集群部署hadoopHadoop安装模式有3中:单机模式、为分布模式及全分布模式。为了以后学习,直接上全分布模式。又鉴于我大东软个人笔记本的操蛋配置,本来想在本机装三个节点,可惜,装两个就已经卡的跟犊子似的了。所以,本次在虚拟机上装2个操作系统,模拟2个节点。虚拟机安装包:VMware-player-6.0.3-1895310.1404875628.exe安装的操作系统:ubuntu-14.04.1-desktop-i386.iso(linux)jdk:jdk-6u16-linux-i586.binhadoop版本:hadoop-1.0.3.tar.gz注意:之前是在公司安装的,但是过程中有许多需要联网下载的东西无法下载成功(东软集团Internet访问管理策略),所以,强烈建议回家在可以连接互联网的地方安装,省去许多麻烦,我安装的时候就重装了3次,悲催,但鉴于初学,就忍了。Hadoop集群中每个节点的角色如下:主机名:Ubuntu1角色:master、slavesjps结果:NameNode、DataNode、JobTracker、TaskTracker、SecondaryNameNode主机名:Ubuntu2角色:slavesjps结果:DataNode、TaskTracker主机名:本机角色:开发测试环境,安装JDK和eclipse即可,使用hadoop的jar包1、在本机安装虚拟机:VMware-player-6.0.3-1895310.1404875628.exe,安装过程略。2、打开VMWare,新建虚拟机,选择Ubuntu的iso镜像,输入自己想设定的名称,用户名、密码。然后默认安装就可以了。3、同样方式安装第二个虚拟机。4、安装VMWareTools。打开安装的虚拟机,点击VMWARE的Player菜单,选择管理,安装VMWareTools。(必须联网)5、安装成功VMWareTools后,就可以在本机和VMWare之间切换并且直接拖拽拷贝文件了,然后将jdk上传至你建的用户根目录下。我建了一个目录tools,都放在这个目录了。6、安装JDK.(安装Ubuntu后是图形界面,输入CTRL+ALT+T,能打开命令行界面)cdtools、chmodu+x*.bin、./jdk-6u16-linux-i586.bin安装即可。7、配置jdk环境变量:cd~、vi.bashrc、在文件最后输入以下几行:exportJAVA_HOME=/home/hongchq/tools/jdk_1.6.0_16exportJRE_HOME=$JAVA_HOME/jreexportCLASS_PATH=$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATHexportPATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH然后执行:source.bashrc使环境变量生效。测试:java-version。输出安装的jdk版本即安装成功。8、将hadoop-1.0.3.tar.gz上传到tools目录下。解压tar-xvfhadoop-1.0.3.tar.gz.配置Hadoop的环境变量exportHADOOP_HOME=/home/hongchq/tools/hadoop-1.0.3exportPATH=$HADOOP_HOME/bin:$PATH9、修改hadoop目录conf下的masters和slavesmasters中#localhostUbuntu1slaves中#localhostUbuntu1Ubuntu210、修改conf目录下的core-site.xml文件?xmlversion=1.0??xml-stylesheettype=text/xslhref=configuration.xsl?configurationpropertynamehadoop.tmp.dir/namevalue/home/hongchq/tools/hadoop-1.0.3/tmp/valuedescriptionAbaseforothertemporarydirectories./description/propertypropertynamefs.default.name/namevaluehdfs://192.168.11.128:9000/valuedescriptionThenameofthedefaultfilesystem.AURIwhoseschemeandauthoritydeterminetheFileSystemimplementation.Theuri'sschemedeterminestheconfigproperty(fs.SCHEME.impl)namingtheFileSystemimplementationclass.THeuri'sauthorityisusedtodeterminethehost,port,etc.forafilesystem./description/propertypropertynamedfs.name.dir/namevalue/home/hongchq/tools/hadoop-1.0.3/name/valuedescriptionDetermineswhereonthelocalfilesystemtheDFSnamenodeshouldstorethenametable.IFthisisacomma-delimitedlistofdirectoriesthenthenametableisreplicatedinallofthedirectories,forredundancy./description/property/configuration注:/home/hongchq/tools/hadoop-1.0.3/tmp、/home/hongchq/tools/hadoop-1.0.3/name路径需存在。修改hdfs-site.xml?xmlversion=1.0??xml-stylesheettype=text/xslhref=configuration.xsl?configurationpropertynamedfs.replication/namevalue1/valuedescriptionDefaultblockreplication.Theactualnumberofreplicationscanbenspecifiedwhenthefileiscreated.Thedefaultisusedifreplicationisnotspecifiedincreatetime./description/property/configuration修改mapred-site.xml?xmlversion=1.0??xml-stylesheettype=text/xslhref=configuration.xsl?configurationpropertynamemapred.job.tracker/namevalue修改hadoop-env.sh将里面的JAVA_HOME项打开,修改为安装的jdk路径#Thejavaimplementationtouse.Required.exportJAVA_HOME=/home/hongchq/tools/jdk1.6.0_1611、修改hosts文件需要把Ubuntu1和Ubuntu2的主机名和IP添加到虚拟机的hosts文件里,hosts修改后如下:hosts文件样例12、配置SSH无密码验证配置1)登录master节点(Ubuntu1),在用户根目录下创建.ssh目录;cd~、mkdir.ssh。2)在master节点上生成秘钥对。ssh-keygen-trsa3)然后一直回车。默认生成的密钥对保存在.ssh/id_rsa.pub文件中。将其复制一份命名为authorized_keys。将此文件scp到Ubuntu2的.ssh目录下。scpauthorized_keysUbuntu2:/home/hongchq/.ssh/此处注意:Ubuntu安装是默认装了openssh-client,但是openssh-server没有装。所以还要装openssh-server。在联网的环境下,使用如下命令:sudoapk-getinstallopenssh-server然后/etc/init.d/sshstart13、启动hadoop进入hadoop-1.0.3/bin。start-all.sh,如下所示即启动成功:启动hadoop启动hadoop停止:stop-all.sh.停止hadoop
本文标题:虚拟机集群部署hadoop
链接地址:https://www.777doc.com/doc-2026640 .html