本文共 8924 字,大约阅读时间需要 29 分钟。
- 一:所需安装配置包
- 二:CentOS6.4x64 主机名配置
- 三:journalnode 配置zookeeper 安装
- 四:在namenode节点上部署hadoop 2.5.2
- 五:hadoop 集群的测试:
系统:CentOS 6.4 X64软件:Hadoop-2.5.2.tar.gz native-2.5.2.tar.gz zookeeper-3.4.6.tar.gz jdk-7u67-linux-x64.tar.gz将所有软件安装上传到/home/hadoop/yangyang/ 下面
vim /etc/hosts (五台虚拟机全部配置) 192.168.3.1 namenode1.hadoop.com 192.168.3.2 namenode2.hadoop.com 192.168.3.3 journalnode1.hadoop.com 192.168.3.4 journalnode2.hadoop.com 192.168.3.5 journalnode3.hadoop.com
角色分配表:
所有服务器均配置------------- ssh-keygen ----------------一直到最后:每台机器会生成一个id_rsa.pub 文件,将所有的密钥生成导入一个authorized_keys文件里面 cat id.rsa.pub >> authorized_keys 然后从新分发到每台服务器的 .ssh/目录下面。最后进行测试。
所有服务器均配置。 安装jdk tar -zxvf jdk-7u67-linux-x64.tar.gz mv jdk-7u67-linux-x64 jdk 环境变量配置 vim .bash_profile 到最后加上:
export JAVA_HOME=/home/hadoop/yangyang/jdkexport CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jarexport HADOOP_HOME=/home/hadoop/yangyang/hadoopPATH=$PATH:$HOME/bin:$JAVA_HOME/bin:${HADOOP_HOME}/bin
等所有软件安装部署完毕在进行: source .bash_profile java –version
以 namenode1.hadoop.com 配置 作为NTP SERVER, 其它节点同步NTP 配置:Namenode1.hadoop.com去网上同步时间
echo “ntpdate –u 202.112.10.36 ” >> /etc/rc.d/rc.local #加入到开机自启动 vim /etc/ntp.conf取消下面两行的##vim /etc/sysconfig/ntpd增加:
#service ntpd restart #chkconfig ntpd on
其它节点 配置计划任务处理将从namenode1.hadoop.com 同步时间crontab –e */10 * * * * /usr/sbin/ntpdate namnode1.hadoop.com
Namenode2.hadoop.com
Journalnode1.hadoop.com
Jornalnode2.hadoop.com
Journalndoe3.hadoop.com
mv zookeeper-3.4.6 /home/hadoop/yangyang/zookeepercd /home/yangyang/hadoop/zookeeper/confcp -p zoo_sample.cfg zoo.cfgvim zoo.cfg更改dataDir 目录 dataDir=/home/hadoop/yangyang/zookeeper/data配置journal主机的server.1=journalnode1.hadoop.com:2888:3888server.2=journalnode2.hadoop.com:2888:3888server.3=journalnode3.hadoop.com:2888:3888
mkdir /home/hadoop/yangyang/zookeeper/dataecho “1” > /home/hadoop/yangyang/zookeeper/myidcd /home/hadoop/yangyang/scp –r zookeeper hadoop@journalnode2.hadoop.com:/home/hadoop/yangyang/scp –r zookeeper hadoop@journalnode3.hadoop.com:/home/hadoop/yangyang/
Journalnode2.hadoop.com : echo “2” > /home/hadoop/yangyang/zookeeper/data/myid Journalnode3.hadoop.com: echo “3” > /home/hadoop/yangyang/zookeeper/myid - 3.4 所有journalnode 节点启动zookeeper。 cd /home/hadoop/yangyang/zookeeper/bin ./zkServer.sh start---------------------显示以下内容为正常---------------------------
tar –zxvf hadoop-2.5.2.tar.gz mv hadoop-2.5.2 /home/hadoop/yangyang/hadoop/
cd /home/hadoop/yangyang/hadoop/ vim etc/hadoop/hadoop-env.sh增加jdk 的环境变量
export JAVA_HOME=/home/hadoop/yangyang/jdkexport HADOOP_PID_DIR=/home/hadoop/yangyang/hadoop/data/tmpexport HADOOP_SECURE_DN_PID_DIR=/home/hadoop/yangyang/hadoop/data/tmp
vim etc/hadoop/mapred-env.sh增加jdk 的环境export JAVA_HOME=/home/hadoop/yangyang/jdkexport HADOOP_MAPRED_PID_DIR=/home/hadoop/yangyang/hadoop/data/tmpvim etc/hadoop/yarn-env.shexport JAVA_HOME=/home/hadoop/yangyang/jdk
vim etc/hadoop/core-site.xmlfs.defaultFS hdfs://mycluster hadoop.tmp.dir /home/hadoop/yangyang/hadoop/data/tmp ha.zookeeper.quorum journalnode1.hadoop.com:2181,journalnode2.hadoop.com:2181,journalnode3.hadoop.com:2181
vim etc/hadoop/hdfs-site.xmldfs.replication 3 dfs.nameservices mycluster dfs.ha.namenodes.mycluster nn1,nn2 dfs.namenode.rpc-address.mycluster.nn1 namenode1.hadoop.com:8020 dfs.namenode.http-address.mycluster.nn1 namenode1.hadoop.com:50070 dfs.namenode.rpc-address.mycluster.nn2 namenode2.hadoop.com:8020 dfs.namenode.http-address.mycluster.nn2 namenode2.hadoop.com:50070 dfs.namenode.shared.edits.dir qjournal://journalnode1.hadoop.com:8485;journalnode2.hadoop.com:8485;journalnode3.hadoop.com:8485/mycluster dfs.journalnode.edits.dir /home/hadoop/yangyang/hadoop/data/jn dfs.ha.automatic-failover.enabled true dfs.client.failover.proxy.provider.masters org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider dfs.ha.fencing.methods sshfenceshell(/bin/true) dfs.ha.fencing.ssh.private-key-files /home/hadoop/.ssh/id_rsa dfs.ha.fencing.ssh.connect-timeout 30000
vim etc/hadoop/mapred-site.xmlmapreduce.framework.name yarn mapreduce.jobhistory.address journalnode3.hadoop.com:10020 mapreduce.jobhistory.webapp.address journalnode3.hadoop.com:19888
vim etc/hadoop/yarn-site.xmlyarn.resourcemanager.ha.enabled true yarn.resourcemanager.cluster-id RM_HA_ID yarn.resourcemanager.ha.rm-ids rm1,rm2 yarn.resourcemanager.hostname.rm1 namenode1.hadoop.com yarn.resourcemanager.hostname.rm2 namenode2.hadoop.com yarn.resourcemanager.recovery.enabled true yarn.resourcemanager.store.class org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore yarn.resourcemanager.zk-address journalnode1.hadoop.com:2181,journalnode2.hadoop.com:2181,journalnode3.hadoop.com:2181 yarn.nodemanager.aux-services mapreduce_shuffle
rm -rf lib/native/*tar –zxvf hadoop-native-2.5.2.tar.gz –C hadoop/lib/nativecd hadoop/lib/native/
vim etc/hadoop/slavesjournalnode1.hadoop.comjournalnode2.hadoop.comjournalnode3.hadoop.com
cd /home/hadoop/yangyang/ scp –r hadoop hadoop@namenode2.hadoop.com:/home/hadoop/yangyang/ scp –r hadoop hadoop@journalnode1.hadoop.com:/home/hadoop/yangyang/ scp –r hadoop hadoop@journalnode2.hadoop.com:/home/hadoop/yangyang/ scp –r hadoop hadoop@journalnode3.hadoop.com:/home/hadoop/yangyang/
cd /home/hadoop/yangyang/hadoop/sbin ./ hadoop-daemon.sh start journalnode ---------------------------显示内容--------------------------
cd /home/hadoop/yangyang/hadoop/bin ./hdfs namenode –format![17.png-101.7kB][17]将namenode1上生成的data文件夹复制到namenode2的相同目录下scp -r hadoop/data/ hadoop@namenode2.hadoop.com:/home/hadoop/yangyang/hadoop
cd /home/hadoop/yangyang/hadoop/bin ./ hdfs zkfc –formatZK###4.12 启动hdfs 与yarn 服务:
./start-dfs.sh ./ start-yarn.sh
cd /home/hadoop/yangyang/hadoop/sbin ./yarn-daemon.sh start resourcemanager
查看namenodehttp://namenode1.hadoop.com:50070/
http://namenode2.hadoop.com:50070/
查看resourcemangerhttp://namenode1.hadoop.com:8088/
http://namenode2.hadoop.com:8088/
cd /home/hadoop/yangyang/hadoop/sbin/./mr-jobhistory-daemon.sh start historyserver
杀掉namenode1.haoop.com 上的namenode
namenode2.haoop.com 的stundby 则切换为active状态。
启动namenode1.hadoop.com 的namenode 节点 cd /home/hadoop/yangyang/hadoop/sbin/./hadoop-daemon.sh start namenode
打开namenode1.hadoop.com 的浏览器
hadoop fs –mkdir /input hadoop fs –put file1 /input/
在运行wordcount 时 杀掉 namenode1.hadoop.com 的resourcemanager运行wordcount cd /home/hadoop/yangyang/hadoop/share/hadoop/mapreduceyarn jar hadoop-mapreduce-examples-2.5.2.jar wordcount /input/file1 /output
杀掉namenode1.hadoop.com 上的rescourcemanager
Namenode2.hadoop.com 的yarn 切换为actvie
Wordcount 运行执行结束:
查看jobhistory 页面
转载于:https://blog.51cto.com/flyfish225/2096436