-j9九游会真人游戏第一品牌

九游会j9·(中国)真人游戏第一品牌
股票代码:688047
请输入搜索条件
九游会j9·(中国)真人游戏第一品牌
邮箱登录
点击图片刷新
忘记密码
点击图片刷新
09-26 2016

龙芯3a2000移植hadoop指南

一、hadoop 简介

             hadoop是一个由apache基金会所开发的分布式系统基础架构。用户可以在不了解分布式底层细节的情况下,开发分布式程序。充分利用集群的威力进行高速运算和存储。

龙芯3a2000上运行hadoop
        hadoop实现了一个(hadoop distributed file system),简称hdfs。hdfs有高的特点,并且设计用来部署在低廉的(low-cost)硬件上;而且它提供高吞吐量(high throughput)来访问的数据,适合那些有着超大数据集(large data set)的应用程序。hdfs放宽了(relax)posix的要求,可以以流的形式访问(streaming access)文件系统中的数据。
        hadoop的框架最核心的设计就是:hdfs和mapreduce。hdfs为海量的数据提供了存储,则mapreduce为海量的数据提供了计算。
        hadoop是一个能够对大量数据进行的框架, 它以一种可靠、高效、可伸缩的方式进行数据处理。维护多个工作数据副本,确保能够针对失败的节点重新。并行工作方式,提高处理速度,之处处理pb级数据。
        hadoop是一个能够让用户轻松架构和使用的平台。用户可以轻松地在hadoop上开发和运行处理海量数据的。它主要有以下几个优点:
                高可靠性: hadoop按位存储和处理数据的能力值得人们信赖。
                高扩展性: hadoop是在可用的计算机集簇间分配数据并完成计算任务的,这些集簇可以方便地扩展到数以千计的节点中。
                高效性: hadoop能够在节点之间动态地移动数据,并保证各个节点的,因此处理速度非常快。
                高容错性:hadoop能够自动保存数据的多个副本,并且能够自动将失败的任务重新分配。
                低成本: 与一体机、商用数据仓库以及qlikview、yonghong z-suite等数据集市相比,hadoop是开源的,项目的软件成本因此会大大降低。
        本文主要涉及以下内容:hadoop源码编译,hadoop在分布式计算云存储系统中的部署和应用,同时也将记录hadoop搭建过程的faq和相对j9九游会真人游戏第一品牌的解决方案。
        hadoop 集群(cluster) 支持如下3种操作模式:
        1. local/standalone mode
         完成下载后,默认情况下hadoop 被配置为standalone 模式,作为单个java进程运行。
        2. pseudo distributed mode
        此种模式下,每个hadoop 守护进程,如hdfs,yarn,mapreduce 等分布式部署在不同的机器上,分别作为独立的java 进程,这种模式有助于开发。
        3. fully distributed mode
        完全分布式部署,需要至少2台机器,作为一个集群,稍后进行详解。
二、移植环境
首先给出本机的软硬件信息,
软件环境:
(1)loongnix1.0 系统(2016.8.10版本)。下载地址 www.loongnix.org
(2)内核版本:3.10.84-all
(3)jdk版本:1.8.0_25-rc16-b17 or later
(4)maven:3.2.2 or later
硬件环境:
(1)开发板类型: loongson-3b-780e-2w-v0.2-demo
(2)固件版本: loongson-pmon-v3.3.0
本例中使用的hadoop的版本为2.7.2, hadoop 源码下载地址,参见附录中的”hadoop downloads” 链接。hadoop 编译依赖findbugs和cmake软件包,建议在编译前通过yum 命令进行自动安装,安装方式如下:
[hadoop@localhost log]$ sudo yum -y install java-1.8.0-openjdk-devel java-1.8.0-openjdk-headless \ java-1.8.0-openjdk findbugs cmake  protobuf-compiler
完成安装后,需要设置如下环境变量,建议将以下内容追加到/et       c/profile文件,并用source 命令使其生效。
export findbugs_home=/usr/share/findbugs
export maven_home=/usr/share/maven
export maven_opts="-xms256m -xmx512m"
export java_home=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.25-5.rc16.fc21.loongson.m
path=/usr/lib64/ccache:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/h
export path=$path:$java_home/bin:$maven_home/bin
build from scratch:首先解压源码到自定义目录(本例采用/usr/local)利用mvn clean package -pdist,native,src -dskiptests -dtar 命令进行编译。
tar xvf hadoop-2.7.2.src.gz -c mkdir /usr/local/
cd  /usr/local/hadoop-2.7.2
mvn clean package -pdist,native,src -dskiptests -dtar 
三、注意事项
(1)本例中采用/usr/local 作为工作目录需要root权限
(2)编译过程报错,可参见对应faq,问题解决后,通过mvn package -pdist,native,src -dskiptests -dtar 命令再次启动编译。
(3)faq的标识由序号(从001开始)和模块名组成,其中者通过冒号间隔。模块名源自maven reactor 涉及的modules名称。
四、faq
001:apache hadoop common
终端报错:
 #
# a fatal error has been detected by the java runtime environment:
#
#  sigsegv (0xb) at pc=0x000000ffe18f46fc, pid=5300, tid=1099154321904
#
# jre version: openjdk runtime environment (8.0_25-b17) (build 1.8.0_25-rc16-b17)
# java vm: openjdk 64-bit server vm (25.25-b02 mixed mode linux- compressed oops)
# problematic frame:
# j 62748 c2 scala.tools.asm.classwriter.get(lscala/tools/asm/item;)lscala/tools/asm/item; (49 bytes) @ 0x000000ffe18f46fc [0x000000ffe18f46a0 0x5c]
#
# failed to write core dump. core dumps have been disabled. to enable core dumping, try "ulimit -c unlimited" before starting java again
#
# if you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
#
解决方法:
此问题与jdk的并行gc相关,编译hadoop和spark均有遇到,目前的解决方法:调整/etc/profile 文件maven_opts 环境变量为如下内容:
export maven_opts="-xms3560m -xmx3560m -xx:-useparallelgc -xx:-useparalleloldgc"

002: any-modules

 终端现象: maven 编译过程中构件(xxx.jar和xxx.pom) 无法下载。
 解决方法: 打开maven 配置文件的代理设置选项,并重新安装ca-certificates
#为maven 设置代理
    
    
      proxy01
      true
      http
      ip_address
      port
      localhost
    
    
      proxy02
      true
      https
      ip_address
      port
      localhost
    
  
 
#重新安装ca-certificates
sudo yum -y install ca-certificates
注意事项: 凡出现maven 编译过程构件无法下载,均可参考本faq内容进行适当修改。
五、编译结果
maven编译通过后,将在终端显示hadoop 的maven reactor(本次编译的所有maven 模块)和编译时间信息。下面给出的时耗信息,进攻参考不同软硬件平台将会产生差异。
[info] ------------------------------------------------------------------------
[info] reactor summary:
[info]
[info] apache hadoop main ................................. success [ 10.769 s]
[info] apache hadoop project pom .......................... success [  8.793 s]
[info] apache hadoop annotations .......................... success [ 18.834 s]
[info] apache hadoop assemblies ........................... success [  2.414 s]
[info] apache hadoop project dist pom ..................... success [  9.653 s]
[info] apache hadoop maven plugins ........................ success [ 25.215 s]
[info] apache hadoop minikdc .............................. success [ 20.682 s]
[info] apache hadoop auth ................................. success [ 26.240 s]
[info] apache hadoop auth examples ........................ success [ 23.112 s]
[info] apache hadoop common ............................... success [45:23 min]
[info] apache hadoop nfs .................................. success [ 45.079 s]
[info] apache hadoop kms .................................. success [01:27 min]
[info] apache hadoop common project ....................... success [  1.104 s]
[info] apache hadoop hdfs ................................. success [21:45 min]
[info] apache hadoop httpfs ............................... success [02:13 min]
[info] apache hadoop hdfs bookkeeper journal .............. success [ 47.832 s]
[info] apache hadoop hdfs-nfs ............................. success [ 34.029 s]
[info] apache hadoop hdfs project ......................... success [  1.075 s]
[info] hadoop-yarn ........................................ success [  1.354 s]
[info] hadoop-yarn-api .................................... success [07:20 min]
[info] hadoop-yarn-common ................................. success [35:51 min]
[info] hadoop-yarn-server ................................. success [  1.020 s]
[info] hadoop-yarn-server-common .......................... success [01:42 min]
[info] hadoop-yarn-server-nodemanager ..................... success [01:58 min]
[info] hadoop-yarn-server-web-proxy ....................... success [ 25.288 s]
[info] hadoop-yarn-server-applicationhistoryservice ....... success [01:05 min]
[info] hadoop-yarn-server-resourcemanager ................. success [02:52 min]
[info] hadoop-yarn-server-tests ........................... success [ 40.356 s]
[info] hadoop-yarn-client ................................. success [ 54.780 s]
[info] hadoop-yarn-server-sharedcachemanager .............. success [ 24.110 s]
[info] hadoop-yarn-applications ........................... success [  1.017 s]
[info] hadoop-yarn-applications-distributedshell .......... success [ 21.223 s]
[info] hadoop-yarn-applications-unmanaged-am-launcher ..... success [ 17.608 s]
[info] hadoop-yarn-site ................................... success [  1.145 s]
[info] hadoop-yarn-registry ............................... success [ 42.659 s]
[info] hadoop-yarn-project ................................ success [ 34.614 s]
[info] hadoop-mapreduce-client ............................ success [  1.905 s]
[info] hadoop-mapreduce-client-core ....................... success [33:18 min]
[info] hadoop-mapreduce-client-common ..................... success [32:57 min]
[info] hadoop-mapreduce-client-shuffle .................... success [ 28.868 s]
[info] hadoop-mapreduce-client-app ........................ success [01:00 min]
[info] hadoop-mapreduce-client-hs ......................... success [ 46.223 s]
[info] hadoop-mapreduce-client-jobclient .................. success [ 29.643 s]
[info] hadoop-mapreduce-client-hs-plugins ................. success [ 15.580 s]
[info] apache hadoop mapreduce examples ................... success [ 40.229 s]
[info] hadoop-mapreduce ................................... success [ 24.719 s]
[info] apache hadoop mapreduce streaming .................. success [ 33.669 s]
[info] apache hadoop distributed copy ..................... success [ 59.792 s]
[info] apache hadoop archives ............................. success [ 19.986 s]
[info] apache hadoop rumen ................................ success [ 47.303 s]
[info] apache hadoop gridmix .............................. success [ 30.258 s]
[info] apache hadoop data join ............................ success [ 22.306 s]
[info] apache hadoop ant tasks ............................ success [ 19.212 s]
[info] apache hadoop extras ............................... success [ 27.362 s]
[info] apache hadoop pipes ................................ success [  6.723 s]
[info] apache hadoop openstack support .................... success [ 34.857 s]
[info] apache hadoop amazon web services support .......... success [ 37.631 s]
[info] apache hadoop azure support ........................ success [ 30.848 s]
[info] apache hadoop client ............................... success [01:02 min]
[info] apache hadoop mini-cluster ......................... success [  3.409 s]
[info] apache hadoop scheduler load simulator ............. success [ 33.821 s]
[info] apache hadoop tools dist ........................... success [ 55.501 s]
[info] apache hadoop tools ................................ success [  0.768 s]
[info] apache hadoop distribution ......................... success [03:44 min]
[info] ------------------------------------------------------------------------
[info] build success
[info] ------------------------------------------------------------------------
[info] total time: 03:33 h
[info] finished at: 2016-08-01t14:22:17 08:00
[info] final memory: 125m/3096m
[info] ------------------------------------------------------------------------
本例的编译结果位于/usr/local/hadoop-2.7.2/hadoop-dist/target/目录,源码包和二进制包分别为hadoop-2.7.2-src.tar.gz和hadoop-2.7.2.tar.gz。至此hadoop编译结束。
六、hadoop 集群搭建测试
本节采用hadoop ”fully distributed mode” 工作模式,在ip地址分别为10.20.42.22(slave1),10.20.42.22(slave2),10.20.42.199(master)的机器上部署3节点的hadoop集群。
1. 设置ssh免密码登录
ssh免密码登录,假设使用root用户,在每台服务器都生成公钥,再合并到authorized_keys,具体操作如下:
    (1)fadora21默认没有启动ssh无密登录,修改/etc/ssh/sshd_config注释掉以下2行。(每台机器都要设置)
#rsaauthentication yes
#pubkeyauthentication yes
    (2)在集群中的每台机器上,打开shell终端输入命令,ssh-keygen -t rsa,生成key,不要输入密码,一直回车,/root就会生成.ssh文件夹,这个文件一般是隐藏的。(每台服务器都要设置)
    (3)合并slave节点的公钥到authorized_keys文件。在master服务器,进入/root/.ssh目录,使用如下命令:
cat id_rsa.pub>> authorized_keys
ssh root@10.20.42.22 cat ~/.ssh/id_rsa.pub>> authorized_keys
ssh root@10.20.42.10 cat ~/.ssh/id_rsa.pub>> authorized_keys
    (4)把master服务器的authorized_keys、known_hosts复制到slave服务器的/root/.ssh目录
    (5)终端输入ssh root@10.20.42.22和ssh root@10.20.42.10进行验证是否免密登陆配置成功
2. 搭建hadoop 3节点集群
搭建思路:准备1台主服务器和2台从服务器,从主服务器可以ssh免密登录从服务器器。hadoop压缩包采用上节编译结果:hadoop-2.7.2.tar.gz。 3台服务器的概要信息如下:
master 10.20.42.199
slave1 10.20.42.22
slave2 10.20.42.10
搭建前提: 服务器需要安装jdk并设置好java_hom等环境变量。可参考下面的例子:
#编辑/etc/profile 文件并设置java_home等环境变量 
 vi /etc/profile
export java_home=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.25-6.b17.rc16.fc21.loongson.mips64el
export classpath=.:$java_home/jre/lib/rt.jar:$java_home/lib/dt.jar:$java_home/lib/tools.jar
export path=$path:$java_home/bin 
#使环境变量生效 并且验证jdk 是否生效
source /etc/profile && java -version
 开始搭建
解压hadoop-2.7.2.tar.gz 软件包,笔者的工作目录为/home/loongson/,没有特殊说明下面的配置文件均来自master服务器
(1)解压hadoop软件包: tar -xvf hadoop-2.7.2.tar.gz  -c  /home/loongson
(2)在/home/loongson/hadoop-2.7.2目录下手动创建tmp、hdfs、hdfs/data、hdfs/name文件夹。
(3)配置/home/hadoop/hadoop-2.7.2/etc/hadoop目录下的core-site.xml(ip设置成master的地址)
    
        
        fs.defaultfs
        hdfs://10.20.42.199:9000
        
        
        hadoop.tmp.dir
        file:/home/loongson/hadoop/tmp
        
        
        io.file.buffer.size
        131702
        
    
(4)配置/home/loongson/hadoop-2.7.2/etc/hadoop目录下的hdfs-site.xml(ip设置成master的地址)
    
        
        dfs.namenode.name.dir
        file:/home/loongson/hadoop/dfs/name
        
        
        dfs.datanode.data.dir
        file:/home/loongson/hadoop/dfs/data
        
        
        dfs.replication
        2
        
        
        dfs.namenode.secondary.http-address
        10.20.42.199:9001
        
        
        dfs.webhdfs.enabled
        true
        
    
(5)配置/home/loongson/hadoop-2.7.2/etc/hadoop目录下的mapred-site.xml.template(ip设置成master的地址)
    
        
        mapreduce.framework.name
        yarn
        
        
        mapreduce.jobhistory.address
        10.20.42.199:10020
        
        
        mapreduce.jobhistory.webapp.address
        10.20.42.199:19888
        
    
(6)配置/home/loongson/hadoop-2.7.2/etc/hadoop目录下的yarn-site.xml(ip设置成master的地址)
    
        
        yarn.nodemanager.aux-services
        mapreduce_shuffle
        
        
        yarn.nodemanager.auxservices.mapreduce.shuffle.class
        org.apache.hadoop.mapred.shufflehandler
        
        
        yarn.resourcemanager.address
        10.20.42.199:8032
        
        
        yarn.resourcemanager.scheduler.address
        10.20.42.199:8030
        
        
        yarn.resourcemanager.resource-tracker.address
        10.20.42.199:8031
        
        
        yarn.resourcemanager.admin.address
        10.20.42.199:8033
        
        
        yarn.resourcemanager.webapp.address
        10.20.42.199:8088
        
        
        yarn.nodemanager.resource.memory-mb
        768
        
    
(7)修改位于/home/loongson/hadoop-2.7.2/etc/hadoop目录hadoop-env.sh,yarn-env.sh中的java_home等环境变量。
export java_home=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.25-6.b17.rc16.fc21.loongson.mips64el
(8)配置/home/loongson/hadoop-2.7.2/etc/hadoop目录下的slaves文件,增加2个从slave节点,
10.20.42.10
10.20.42.22
(9)将上述配置好的hadoop-2.7.2(位于master机器上)使用scp复制到各个slave节点对应位置上
scp -r /home/loongson/hadoop-2.7.2 10.20.42.10:/home/loongson
scp -r /home/loongson/hadoop-2.7.2 10.20.42.22:/home/loongson
(10)在master服务器启动hadoop,从节点会自动启动,进入/home/loongson/hadoop-2.7.2目录
    (1)关闭机器防火墙:service iptables stop (主从都设置)
    (2)初始化node节点:bin/hdfs namenode -format
    (3)启动全部node: sbin/start-all.sh
this script is deprecated. instead use start-dfs.sh and start-yarn.sh
16/09/02 08:49:56 warn util.nativecodeloader: unable to load native-hadoop library for your platform... 
using builtin-java classes where applicable
starting namenodes on [hadoop-master-001]
hadoop-master-001: starting namenode, logging to /home/loongson/hadoop-2.7.2/logs/hadoop-root-namenode-
        localhost.localdomain.out
        10.20.42.22: starting datanode, logging to /home/loongson/hadoop-2.7.2/logs/hadoop-root-datanode-localhost.localdomain.out
        10.20.42.22: /home/loongson/hadoop-2.7.2/bin/hdfs: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.25-6.b17.rc16.fc21.loongson.mips64el
        10.20.42.22: /home/loongson/hadoop-2.7.2/bin/hdfs: line 304: /usr/lib/jvm/java-1.8.0-
        openjdk-1.8.0.25-6.b17.rc16.fc21.loongson.mips64el/bin/java: 成功
        10.20.42.10: starting datanode, logging to /home/loongson/hadoop-2.7.2/logs/hadoop-root-datanode-localhost.localdomain.out
        starting secondary namenodes [hadoop-master-001]
        hadoop-master-001: secondarynamenode running as process 18418. stop it first.
        16/09/02 08:50:33 warn util.nativecodeloader: unable to load native-hadoop library for your platform... using builtin-java 
        classes where applicable
        starting yarn daemons
        resourcemanager running as process 16937. stop it first.
        10.20.42.10: starting nodemanager, logging to /home/loongson/hadoop-2.7.2/logs/yarn-root-nodemanager-localhost.localdomain.out
        10.20.42.22: starting nodemanager, logging to /home/loongson/hadoop-2.7.2/logs/yarn-root-nodemanager-localhost.localdomain.out
        10.20.42.22: /home/loongson/hadoop-2.7.2/bin/yarn: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.25-6.b17.rc16.fc21.loongson.mips64el
        10.20.42.22: /home/loongson/hadoop-2.7.2/bin/yarn: line 333: /usr/lib/jvm/java-1.8.0-
        openjdk-1.8.0.25-6.b17.rc16.fc21.loongson.mips64el/bin/java: 成功
    (4)暂停全部节点的命令: sbin/stop-all.sh
    (5)输入jps命令: 如果从节点和主节点显示类似如下,说明节点搭建成功
    master:
    32497 oservermain
    3506 secondarynamenode
    3364 datanode
    5654 jps
    2582 ogremlinconsole
    16937 resourcemanager
    3263 namenode
    slaves:
    21580 jps
    20622 datanode
(11)从浏览器访问: 查看hadop运行情况。下面给出从浏览器打开,看到的hadoop的运行情况截图:
hadoop运行预览和概要信息:
hadoop运行情况:
七、下载成品
如果觉得上面的移植过程太复杂,笔者已经准备好了移植完的二进制,可以直接下载运行:
http://www.loongnix.org/index.php/apache_hadoop-2.7.2
八、总结
hadoop-2.7.2 在loongnix1.0 系统上正确完成源码编译和搭建小集群测试,可以作为开发者移植hadoop和进行集群测试的示范过程。

j9九游国际真人 copyright © 2008-2022 龙芯中科技术股份有限公司

本网站由龙芯3c5000服务器提供强劲动力

网站地图