首页 文章 精选 留言 我的

精选列表

搜索[hadoop],共8432篇文章
优秀的个人博客,低调大师

Hadoop基础入门学习笔记(基本概念)

一、数据块(blck) HDFS(Hadp Distributed File System)默认的最基本的存储单位是64M的数据块。 和普通文件系统相同的是,HDFS中的文件是被分成64M一块的数据块存储的。 不同于普通文件系统的是,HDFS中,如果一个文件小于一个数据块的大小,并不占用整个数据块存储空间。 二、元数据节点(Namende)和数据节点(datande) 元数据节点用来管理文件系统的命名空间 其将所有的文件和文件夹的元数据保存在一个文件系统树中。 这些信息也会在硬盘上保存成以下文件:命名空间镜像(namespace image)及修改日志(edit lg) 其还保存了一个文件包括哪些数据块,分布在哪些数据节点上。然而这些信息并不存储在硬盘上,而是在系统启动的时候从数据节点收集而成的。 数据节点是文件系统中真正存储数据的地方。 客户端(client)或者元数据信息(namende)可以向数据节点请求写入或者读出数据块。 其周期性的向元数据节点回报其存储的数据块信息。 从元数据节点(secndary namende) 从元数据节点并不是元数据节点出现问题时候的备用节点,它和元数据节点负责不同的事情。 其主要功能就是周期性将元数据节点的命名空间镜像文件和修改日志合并,以防日志文件过大。这点在下面会详细叙述。 合并过后的命名空间镜像文件也在从元数据节点保存了一份,以防元数据节点失败的时候,可以恢复。 1、 元数据节点文件夹结构 VERSIN文件是java prperties文件,保存了HDFS的版本号。 layutVersin是一个负整数,保存了HDFS的持续化在硬盘上的数据结构的格式版本号。 namespaceID是文件系统的唯一标识符,是在文件系统初次格式化时生成的。 cTime此处为0 strageType表示此文件夹中保存的是元数据节点的数据结构。 1 2 3 4 namespaceID=1232737062 cTime=0 strageType=NAME_NDE layutVersin=-18 2、文件系统命名空间映像文件及修改日志 当文件系统客户端(client)进行写操作时,首先把它记录在修改日志中(edit lg) 元数据节点在内存中保存了文件系统的元数据信息。在记录了修改日志后,元数据节点则修改内存中的数据结构。 每次的写操作成功之前,修改日志都会同步(sync)到文件系统。 fsimage文件,也即命名空间映像文件,是内存中的元数据在硬盘上的checkpint,它是一种序列化的格式,并不能够在硬盘上直接修改。 同数据的机制相似,当元数据节点失败时,则最新checkpint的元数据信息从fsimage加载到内存中,然后逐一重新执行修改日志中的操作。 从元数据节点就是用来帮助元数据节点将内存中的元数据信息checkpint到硬盘上的 checkpint的过程如下: 从元数据节点通知元数据节点生成新的日志文件,以后的日志都写到新的日志文件中。 从元数据节点用http get从元数据节点获得fsimage文件及旧的日志文件。 从元数据节点将fsimage文件加载到内存中,并执行日志文件中的操作,然后生成新的fsimage文件。 从元数据节点将新的fsimage文件用http pst传回元数据节点 元数据节点可以将旧的fsimage文件及旧的日志文件,换为新的fsimage文件和新的日志文件(第一步生成的),然后更新fstime文件,写入此次checkpint的时间。 这样元数据节点中的fsimage文件保存了最新的checkpint的元数据信息,日志文件也重新开始,不会变的很大了。 3、从元数据节点的目录结构 4、数据节点的目录结构 数据节点的VERSION文件格式如下: 1 2 3 4 5 namespaceID=1232737062 storageID=DS-1640411682-127.0.1.1-50010-1254997319480 cTime=0 storageType=DATA_NODE layoutVersion=-18 blk_<id>保存的是HDFS的数据块,其中保存了具体的二进制数据。 blk_<id>.meta保存的是数据块的属性信息:版本信息,类型信息,和checksum 当一个目录中的数据块到达一定数量的时候,则创建子文件夹来保存数据块及数据块属性信息。 本文转自南非蚂蚁51CTO博客,原文链接:http://blog.51cto.com/ixdba/1428278 ,如需转载请自行联系原作者

优秀的个人博客,低调大师

Hadoop运维记录系列(二十一)

Zeppelin启用https过程和Hack内核以满足客户需求的记录。 原因是这客户很有意思,该客户中国分公司的人为了验证内网安全性,从国外找了一个***测试小组对Zeppelin和其他产品进行***测试,结果发现Zeppelin主要俩问题,一个是在内网没用https,一个是zeppelin里面可以执行shell命令和python语句。其实这不算大问题,zeppelin本来就是干这个用的。但是***小组不了解zeppelin是做什么的,认为即使在内网里,执行shell命令能查看操作系统的一些文件是大问题,然后发生的事就不说了,不是我们的问题了。 不过既然他们要求整改,我们也只好配合,虽然大家都觉得内网域名加https属于脱了裤子放屁,然后不让zeppelin干他本来应该干的事就更过分了,但鉴于客户是甲方,也只好hack源码了。 于是某个周末用了4个小时完成所有工作。 先记录下zeppelin加https访问,我们有自己的域名证书,所以直接用即可。如果没有域名证书,需要自签发,那么可以看第二部分,双向认证步骤。 https第一部分,已有域名添加jks: opensslpkcs12-export-inxxx.com.crt-inkeyxxx.com.key-outxxx.com.pkcs12 keytool-importkeystore-srckeystorexxx.com.pkcs12-destkeystorexxx.com.jks-srcstoretypepkcs12 https第二部分,自签发证书双向认证添加jks #生成root私钥和证书文件。 opensslgenrsa-outroot.key(pem)2048#Generaterootkeyfile opensslreq-x509-new-keyroot.key(pem)-outroot.crt#Generaterootcertfile #创建客户端私钥和证书以及证书请求文件csr opensslgenrsa-outclient.key(pem)2048#Generateclientkeyfile opensslreq-new-keyclient.key(pem)-outclient.csr#Generateclientcertrequestfile opensslx509-req-inclient.csr-CAroot.crt-CAkeyroot.key(pem)-CAcreateserial-days3650-outclient.crt#Userootcerttogenerateclientcertfile #生成服务器端私钥,证书和证书请求文件csr opensslgenrsa-outserver.key(pem)2048#Generateserverkeyfile,useinZeppelin opensslreq-new-keyserver.key(pem)outserver.csr@Generateservercertrequestfile opensslx509-req-inserver.csr-CAroot.crt-CAkeyroot.key(pem)-CAcreateserial-days3650-outserver.crt#Userootcerttogenerateservercertfile #生成客户端端jks文件 opensslpkcs12-export-inclient.crt-inkeyclient.key(pem)-outclient.pkcs12#Packagetopkcs12format,mustinputapassword,youshouldrememberthepassword keytool-importkeystore-srckeystoreclient.pkcs12-destkeystoreclient.jks-srcstoretypepkcs12#Theclientpasswordyoujustinputatlaststep #生成服务器端jks文件 opensslpkcs12-export-inserver.crt-inkeyserver.key(pem)-outserver.pkcs12@Packagetopkcs12format,mustinputapassword,youshouldrememberthepassword keytool-importkeystore-srckeystoreserver.pkcs12-destkeystoreserver.jks-srcstoretypepkcs12#Theserverpasswordyoujustinputatlaststep 如果是不需要双向认证,只要单向自签发,不创建客户端的各种就可以了。 然后找个地把这些文件放过去,再修改zeppelin配置即可。 mkdir-p/etc/zeppelin/conf/ssl cpserver.crtserver.jks/etc/zeppelin/conf/ssl <property> <name>zeppelin.server.ssl.port</name> <value>8443</value> <description>Serversslport.(usedwhensslpropertyissettotrue)</description> </property> <property> <name>zeppelin.ssl</name> <value>true</value> <description>ShouldSSLbeusedbytheservers?</description> </property> <property> <name>zeppelin.ssl.client.auth</name> <value>false</value> <description>ShouldclientauthenticationbeusedforSSLconnections?</description> </property> <property> <name>zeppelin.ssl.keystore.path</name> <value>/etc/zeppelin/conf/ssl/xxx.com.jks</value> <description>PathtokeystorerelativetoZeppelinconfigurationdirectory</description> </property> <property> <name>zeppelin.ssl.keystore.type</name> <value>JKS</value> <description>Theformatofthegivenkeystore(e.g.JKSorPKCS12)</description> </property> <property> <name>zeppelin.ssl.keystore.password</name> <value>passwordwhichyouinputongeneratingserverjksstep</value> <description>Keystorepassword.CanbeobfuscatedbytheJettyPasswordtool</description> </property> 然后反代那里也加上443的ssl证书以及443转8443的upstream即可。 然后是hack zeppelin源码加入关键字限制,这个确实找了一小会zeppelin发送执行源码给interpreter的地方,zeppelin架构比较清晰,但是代码挺复杂的,用到了很多小花活儿。比如thrift,interpreter脚本里建立nc监听。然后各个解释器插件用socket跟interpreter脚本通信,前端angular,后端jetty,还用shiro做验证和授权。回头可以单开好几篇说说zeppelin安装,使用和详细配置,做这项目基本把zeppelin摸透了。 找到发送前端编写内容给interpreter的java代码,然后用很生硬的办法限制执行命令。具体那个.java文件的名字我就不说了,有悬念有惊喜。我不写java,只负责读源码找到代码位置,hack的java是同事写的。然后编译,替换jar包,完成。后面改了改配置,后续的***测试顺利通过。 staticHashSet<String[]>blockedCodeString=newHashSet<>(); static{ blockedCodeString.add(newString[]{"import","os"}); blockedCodeString.add(newString[]{"import","sys"}); blockedCodeString.add(newString[]{"import","subprocess"}); blockedCodeString.add(newString[]{"import","pty"}); blockedCodeString.add(newString[]{"import","socket"}); blockedCodeString.add(newString[]{"import","commands"}); blockedCodeString.add(newString[]{"import","paramiko"}); blockedCodeString.add(newString[]{"import","pexpect"}); blockedCodeString.add(newString[]{"import","BaseHTTPServer"}); blockedCodeString.add(newString[]{"import","ConfigParser"}); blockedCodeString.add(newString[]{"import","platform"}); blockedCodeString.add(newString[]{"import","popen2"}); blockedCodeString.add(newString[]{"import","copy"}); blockedCodeString.add(newString[]{"import","SocketServer"}); blockedCodeString.add(newString[]{"import","sysconfig"}); blockedCodeString.add(newString[]{"import","tty"}); blockedCodeString.add(newString[]{"import","xmlrpmlib"}); blockedCodeString.add(newString[]{"etc"}); blockedCodeString.add(newString[]{"boot"}); blockedCodeString.add(newString[]{"dev"}); blockedCodeString.add(newString[]{"lib"}); blockedCodeString.add(newString[]{"lib64"}); blockedCodeString.add(newString[]{"lost+found"}); blockedCodeString.add(newString[]{"mnt"}); blockedCodeString.add(newString[]{"proc"}); blockedCodeString.add(newString[]{"root"}); blockedCodeString.add(newString[]{"sbin"}); blockedCodeString.add(newString[]{"selinux"}); blockedCodeString.add(newString[]{"usr"}); blockedCodeString.add(newString[]{"passwd"}); blockedCodeString.add(newString[]{"useradd"}); blockedCodeString.add(newString[]{"userdel"}); blockedCodeString.add(newString[]{"rm"}); blockedCodeString.add(newString[]{"akka"}); blockedCodeString.add(newString[]{"groupadd"}); blockedCodeString.add(newString[]{"groupdel"}); blockedCodeString.add(newString[]{"mkdir"}); blockedCodeString.add(newString[]{"rmdir"}); blockedCodeString.add(newString[]{"ping"}); blockedCodeString.add(newString[]{"nc"}); blockedCodeString.add(newString[]{"telnet"}); blockedCodeString.add(newString[]{"ftp"}); blockedCodeString.add(newString[]{"scp"}); blockedCodeString.add(newString[]{"ssh"}); blockedCodeString.add(newString[]{"ps"}); blockedCodeString.add(newString[]{"hostname"}); blockedCodeString.add(newString[]{"uname"}); blockedCodeString.add(newString[]{"vim"}); blockedCodeString.add(newString[]{"nano"}); blockedCodeString.add(newString[]{"top"}); blockedCodeString.add(newString[]{"cat"}); blockedCodeString.add(newString[]{"more"}); blockedCodeString.add(newString[]{"less"}); blockedCodeString.add(newString[]{"chkconfig"}); blockedCodeString.add(newString[]{"service"}); blockedCodeString.add(newString[]{"netstat"}); blockedCodeString.add(newString[]{"iptables"}); blockedCodeString.add(newString[]{"ip"}); blockedCodeString.add(newString[]{"route"}); blockedCodeString.add(newString[]{"curl"}); blockedCodeString.add(newString[]{"wget"}); blockedCodeString.add(newString[]{"sysctl"}); blockedCodeString.add(newString[]{"touch"}); blockedCodeString.add(newString[]{"scala.sys.process"}); blockedCodeString.add(newString[]{"0.0.0.0"}); blockedCodeString.add(newString[]{"git"}); blockedCodeString.add(newString[]{"svn"}); blockedCodeString.add(newString[]{"hg"}); blockedCodeString.add(newString[]{"cvs"}); blockedCodeString.add(newString[]{"exec"}); blockedCodeString.add(newString[]{"ln"}); blockedCodeString.add(newString[]{"kill"}); blockedCodeString.add(newString[]{"rsync"}); blockedCodeString.add(newString[]{"lsof"}); blockedCodeString.add(newString[]{"crontab"}); blockedCodeString.add(newString[]{"libtool"}); blockedCodeString.add(newString[]{"automake"}); blockedCodeString.add(newString[]{"autoconf"}); blockedCodeString.add(newString[]{"make"}); blockedCodeString.add(newString[]{"gcc"}); blockedCodeString.add(newString[]{"cc"}); } staticbooleanallMatch(Stringaim,String[]checker){ if(checker==null||checker.length<1){ returnfalse; }else{ //bydefault,treatasmatch,everynotmatchchangeit for(Stringi:checker){ if(!aim.matches(".*\\b"+i+"\\b.*")){ returnfalse; } } returntrue; } } staticStringanyMatch(Stringaim,HashSet<String[]>all)throwsException{ if(aim.contains("FUCKP&G")){ thrownewException("Howdoyouknowthis????"); }else{ for(String[]one:all){ if(allMatch(aim,one)){ StringBuildersb=newStringBuilder(); for(Strings:one){ sb.append(s+""); } returnsb.toString(); } } thrownewException("Noonematch"); } } //......此处是个public类 try{ StringmatchesStrings=anyMatch(st,blockedCodeString); result=newInterpreterResult(Code.ERROR,"Containsdangerouscode:"+matchesStrings); }catch(Exceptionme){//nomatchany scheduler.submit(job); while(!job.isTerminated()){ synchronized(jobListener){ try{ jobListener.wait(1000); }catch(InterruptedExceptione){ logger.info("ExceptioninRemoteInterpreterServerwhileinterpret,jobListener.wait",e); } } } if(job.getStatus()==Status.ERROR){ result=newInterpreterResult(Code.ERROR,Job.getStack(job.getException())); }else{ result=(InterpreterResult)job.getReturn(); //incaseofjobabortinPENDINGstatus,resultcanbenull if(result==null){ result=newInterpreterResult(Code.KEEP_PREVIOUS_RESULT); } } } //......直到该public类结束 因为客户有deadline限制,所以快速定位源码位置的过程还是挺有意思的,比较紧张刺激,在这个以小时计算deadline压力下,什么intelliJ, Eclipse都不好使啊,就grep和vi最好用,从找到到改完,比客户定的deadline提前了好几个小时。

优秀的个人博客,低调大师

Hadoop on Windows with Eclipse -03- Set Environment Variables

Set Environment Variables The next step is to set up the PATH environment variable so that Eclipse IDE can access Cygwin commands here To set environment variables follow these steps: Find "My Computer" icon either on the desktop or in the start menu, right-click on it and selectPropertiesitem from the menu. When you see the Properties dialog box, click on theEnvironment Variablesbutton as shown below WhenEnvironment Variablesdialog shows up, click on thePathvariable located in theSystem Variablesbox and then click theEditbutton. WhenEditdialog appears append the following text to the end of theVariable valuefield: ;c:\cygwin64\bin;c:\cygwin64\usr\sbin Note: If you installed cygwin in the non-standard location, correct the above value accordingly. Close all three dialog boxes by pressing OK button of each dialog box.

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Mario

Mario

马里奥是站在游戏界顶峰的超人气多面角色。马里奥靠吃蘑菇成长,特征是大鼻子、头戴帽子、身穿背带裤,还留着胡子。与他的双胞胎兄弟路易基一起,长年担任任天堂的招牌角色。

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册