锘??xml version="1.0" encoding="utf-8" standalone="yes"?>欧洲亚洲国产精华液,mm1313亚洲国产精品无码试看 ,亚洲视频中文字幕在线http://m.tkk7.com/wangxinsh55/category/53334.htmlzh-cnTue, 16 Sep 2014 21:04:32 GMTTue, 16 Sep 2014 21:04:32 GMT60(杞?Hadoop 瑙i櫎 "Name node is in safe mode" http://m.tkk7.com/wangxinsh55/archive/2013/03/28/397110.htmlSIMONESIMONEThu, 28 Mar 2013 08:55:00 GMThttp://m.tkk7.com/wangxinsh55/archive/2013/03/28/397110.htmlhttp://m.tkk7.com/wangxinsh55/comments/397110.htmlhttp://m.tkk7.com/wangxinsh55/archive/2013/03/28/397110.html#Feedback0http://m.tkk7.com/wangxinsh55/comments/commentRss/397110.htmlhttp://m.tkk7.com/wangxinsh55/services/trackbacks/397110.htmlhttp://39382728.blog.163.com/blog/static/35360069201182710565420/

榪愯hadoop紼嬪簭鏃訛紝 涓旀垜鎶婂畠緇堟浜嗭紝鐒跺悗鍐嶅悜hdfs鍔犳枃浠舵垨鍒犻櫎鏂囦歡鏃訛紝鍑虹幇Name node is in safe mode閿欒錛?br />rmr: org.apache.hadoop.dfs.SafeModeException: Cannot delete /user/hadoop/input. Name node is in safe mode

瑙e喅鐨勫懡浠わ細

bin/hadoop dfsadmin -safemode leave #鍏抽棴safe mode


杞嚜錛?nbsp;http://shutiao2008.iteye.com/blog/318950

 

闄?瀹夊叏妯″紡 瀛︿範錛?/p> safemode妯″紡
NameNode鍦ㄥ惎鍔ㄧ殑鏃跺欓鍏堣繘鍏ュ畨鍏ㄦā寮忥紝濡傛灉datanode涓㈠け鐨刡lock杈懼埌涓瀹氱殑姣斾緥錛?-dfs.safemode.threshold.pct錛夛紝鍒欑郴緇熶細涓鐩村浜庡畨鍏ㄦā寮忕姸鎬佸嵆鍙鐘舵併?br />dfs.safemode.threshold.pct錛堢己鐪佸?.999f錛夎〃紺篐DFS鍚姩鐨勬椂鍊欙紝濡傛灉DataNode涓婃姤鐨刡lock涓暟杈懼埌浜嗗厓鏁版嵁璁板綍鐨刡lock涓暟鐨?.999鍊嶆墠鍙互紱誨紑瀹夊叏妯″紡錛屽惁鍒欎竴鐩存槸榪欑鍙妯″紡銆傚鏋滆涓?鍒橦DFS姘歌繙鏄浜嶴afeMode銆?br />涓嬮潰榪欒鎽樺綍鑷狽ameNode鍚姩鏃剁殑鏃ュ織錛坆lock涓婃姤姣斾緥1杈懼埌浜嗛榾鍊?.9990錛?br />The ratio of reported blocks 1.0000 has reached the threshold 0.9990. Safe mode will be turned off automatically in 18 seconds.
hadoop dfsadmin -safemode leave
鏈変袱涓柟娉曠寮榪欑瀹夊叏妯″紡
1. 淇敼dfs.safemode.threshold.pct涓轟竴涓瘮杈冨皬鐨勫鹼紝緙虹渷鏄?.999銆?br />2. hadoop dfsadmin -safemode leave鍛戒護寮哄埗紱誨紑
http://bbs.hadoopor.com/viewthread.php?tid=61&extra=page%3D1
錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛?br />Safe mode is exited when the minimal replication condition is reached, plus an extension
time of 30 seconds. The minimal replication condition is when 99.9% of the blocks in
the whole filesystem meet their minimum replication level (which defaults to one, and
is set by dfs.replication.min).
瀹夊叏妯″紡鐨勯鍑哄墠鎻?- 鏁翠釜鏂囦歡緋葷粺涓殑99.9%錛堥粯璁ゆ槸99.9%錛屽彲浠ラ氳繃dfs.safemode.threshold.pct璁劇疆錛夌殑Blocks杈懼埌鏈灝忓浠界駭鍒?榛樿鏄?錛屽彲浠ラ氳繃dfs.replication.min璁劇疆)銆?br />dfs.safemode.threshold.pct      float       0.999
The proportion of blocks in the system that must meet the minimum
replication level defined by dfs.rep lication.min before the namenode
will exit safe mode. Setting
this value to 0 or less forces the name-node not to start in safe mode.
Setting this value to more than 1 means the namenode never exits safe
mode.
錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛嶏紞錛?br />鐢ㄦ埛鍙互閫氳繃dfsadmin -safemode value  鏉ユ搷浣滃畨鍏ㄦā寮忥紝鍙傛暟value鐨勮鏄庡涓嬶細
enter - 榪涘叆瀹夊叏妯″紡
leave - 寮哄埗NameNode紱誨紑瀹夊叏妯″紡
get -  榪斿洖瀹夊叏妯″紡鏄惁寮鍚殑淇℃伅
wait - 絳夊緟錛屼竴鐩村埌瀹夊叏妯″紡緇撴潫銆?/div>

SIMONE 2013-03-28 16:55 鍙戣〃璇勮
]]>hadoop闆嗙兢澶勭悊http://m.tkk7.com/wangxinsh55/archive/2013/03/28/397108.htmlSIMONESIMONEThu, 28 Mar 2013 08:29:00 GMThttp://m.tkk7.com/wangxinsh55/archive/2013/03/28/397108.htmlhttp://m.tkk7.com/wangxinsh55/comments/397108.htmlhttp://m.tkk7.com/wangxinsh55/archive/2013/03/28/397108.html#Feedback0http://m.tkk7.com/wangxinsh55/comments/commentRss/397108.htmlhttp://m.tkk7.com/wangxinsh55/services/trackbacks/397108.html璇︾粏鍐呭鏌ョ湅榪欎釜
http://www.cnblogs.com/xia520pi/
榪欎釜鍗氬鐨勫唴瀹?/div>

SIMONE 2013-03-28 16:29 鍙戣〃璇勮
]]>
鎴愬姛緙栬瘧hadoop eclipse鎻掍歡銆傛鏂瑰紡閫傜敤浜巜in 7http://m.tkk7.com/wangxinsh55/archive/2013/03/28/397107.htmlSIMONESIMONEThu, 28 Mar 2013 08:26:00 GMThttp://m.tkk7.com/wangxinsh55/archive/2013/03/28/397107.htmlhttp://m.tkk7.com/wangxinsh55/comments/397107.htmlhttp://m.tkk7.com/wangxinsh55/archive/2013/03/28/397107.html#Feedback0http://m.tkk7.com/wangxinsh55/comments/commentRss/397107.htmlhttp://m.tkk7.com/wangxinsh55/services/trackbacks/397107.html

 

http://www.07net01.com/linux/tongguoeclipsexiangmubianyi_hadoop_1_0_3_eclipse_4_2___juno___plugin_20146_1350034161.html

 


嫻佺▼濡備笅錛?/p>

1.涓嬭澆hadoop 1.0.3 錛坔ttp://hadoop.apache.org/releases.html#Download錛夛紝瑙e帇鍦ㄨ嚜瀹氫箟鐨勪竴涓洰褰曚腑錛堟渶濂藉叏鑻辨枃璺緞錛岃瘯榪囦腑鏂囪礬寰勫嚭浜嗛棶棰橈級銆?/p>

2.Eclipse瀵煎叆..\hadoop-1.0.3\src\contrib\eclipse-plugin欏圭洰錛岄粯璁ら」鐩槸MapReduceTools銆?/p>

3. 鍦ㄩ」鐩甅apReduceTools涓柊寤簂ib鐩綍錛屽茍鎶奾adoop鐨刪adoop-core錛堢敱hadoop鏍圭洰褰曠殑hadoop-*.jar鏀瑰悕 鑾峰緱錛夈乧ommons-cli-1.2.jar銆乧ommons-lang-2.4.jar銆乧ommons-configuration- 1.6.jar銆乯ackson-mapper-asl-1.8.8.jar銆乯ackson-core-asl-1.8.8.jar銆乧ommons- httpclient-3.0.1.jar鎷瘋礉鍒拌鐩綍銆?/p>

4.淇敼涓婄駭鐩綍涓殑build-contrib.xml錛?/p>

鎵懼埌<property name="hadoop.root" location="${root}/../../../"/>淇敼location涓篽adoop1.0.3瀹為檯瑙e帇鐩綍錛屽湪鍏朵笅娣誨姞

<property name="eclipse.home" location="D:/Program Files/eclipse"/>

<property name="version" value="http://x-goder.iteye.com/blog/1.0.3"/>

5.淇敼欏圭洰鐩綍涓嬬殑build.xml錛?/p>

<target name="jar" depends="compile" unless="skip.contrib">

<mkdir dir="${build.dir}/lib"/>

<copy file="${hadoop.root}/hadoop-core-${version}.jar" tofile="${build.dir}/lib/hadoop-core.jar" verbose="true"/>

<copy file="${hadoop.root}/lib/commons-cli-1.2.jar" todir="${build.dir}/lib" verbose="true"/>

<copy file="${hadoop.root}/lib/commons-lang-2.4.jar" todir="${build.dir}/lib" verbose="true"/>

<copy file="${hadoop.root}/lib/commons-configuration-1.6.jar" todir="${build.dir}/lib" verbose="true"/>

<copy file="${hadoop.root}/lib/jackson-mapper-asl-1.8.8.jar" todir="${build.dir}/lib" verbose="true"/>

<copy file="${hadoop.root}/lib/jackson-core-asl-1.8.8.jar" todir="${build.dir}/lib" verbose="true"/>

<copy file="${hadoop.root}/lib/commons-httpclient-3.0.1.jar" todir="${build.dir}/lib" verbose="true"/>

<jar

jarfile="${build.dir}/hadoop-${name}-${version}.jar"

manifest="${root}/META-INF/MANIFEST.MF">

<fileset dir="${build.dir}" includes="classes/ lib/"/>

<fileset dir="${root}" includes="resources/ plugin.xml"/>

</jar>

</target>

6.鍙抽敭eclipse閲岀殑build.xml閫夋嫨run as - ant build銆?/p>

濡傛灉鍑虹幇錛?#8220;杞歡鍖卭rg.apache.hadoop.fs 涓嶅瓨鍦?#8221;鐨勯敊璇垯淇敼build.xml錛?/p>

<path id="hadoop-jars">

<fileset dir="${hadoop.root}/">

<include name="hadoop-*.jar"/>

</fileset>

</path>

鍦?lt;path id="classpath">涓坊鍔狅細<path refid="hadoop-jars"/>

7.絳堿nt緙栬瘧瀹屾瘯鍚庛傜紪璇戝悗鐨勬枃浠跺湪錛歕build\contrib 涓殑 hadoop-eclipse-plugin-1.0.3.jar銆?/p>

8.鏌ョ湅緙栬瘧濂界殑jar鍖呬笅META-INF/MANIFEST.MF 涓嬬殑閰嶇疆灞炴ф槸鍚﹀畬鏁達紝濡傛灉涓嶅畬鏁達紝琛ュ厖瀹屾暣銆?/p>

Bundle-ClassPath: classes/,lib/hadoop-core.jar,lib/commons-cli-1.2.jar
 ,lib/commons-lang-2.4.jar,lib/commons-configuration-1.6.jar,lib/jacks
 on-mapper-asl-1.8.8.jar,lib/jackson-core-asl-1.8.8.jar,lib/commons-ht
 tpclient-3.0.1.jar

9.鏀懼叆eclipse/plugins涓嬶紝閲嶅惎eclipse錛屾煡鐪嬫槸鍚﹀畨瑁呮垚鍔熴?/p>



SIMONE 2013-03-28 16:26 鍙戣〃璇勮
]]>
鍦℉Base閲屼嬌鐢∕apReduce渚嬪瓙http://m.tkk7.com/wangxinsh55/archive/2013/02/22/395572.htmlSIMONESIMONEFri, 22 Feb 2013 06:12:00 GMThttp://m.tkk7.com/wangxinsh55/archive/2013/02/22/395572.htmlhttp://m.tkk7.com/wangxinsh55/comments/395572.htmlhttp://m.tkk7.com/wangxinsh55/archive/2013/02/22/395572.html#Feedback0http://m.tkk7.com/wangxinsh55/comments/commentRss/395572.htmlhttp://m.tkk7.com/wangxinsh55/services/trackbacks/395572.htmlhttp://jeffxie.blog.51cto.com/1365360/305538
鎴戝湪Hadoop鐨勭敤鎴烽偖浠跺垪琛ㄤ腑鐪嬪埌涓浜涘浗鍐呯殑鐢?鎴峰湪璁棶涓浜涘叧浜庡浣曟搷浣滅殑HBase鐨?span >闂錛岃繕鐪嬪埌浜咹Base涓病鏈塃xample銆傝寰楁湁 蹇呰璺熷ぇ瀹?span >鍒嗕韓鑷繁鐨勭粡楠屻?br /> 鍦ㄤ笅闈㈢殑渚嬪瓙涓垜浠垎鏋?span >Apache鐨刲og騫舵妸榪欎簺log榪涜鍒嗘瀽騫舵妸鍒嗘瀽瀹?鐨勭粨鏋滄寜鐢ㄦ埛IP涓篟OW錛屾妸log涓敤鎴風殑璁塊棶鏃墮棿錛岃姹傛柟娉曪紝鐢ㄦ埛璇鋒眰鐨勫崗璁紝鐢ㄦ埛鐨勬祻瑙堝櫒錛屾湇鍔$姸鎬佺瓑鍐欏埌HBase鐨勮〃涓?br />

棣栧厛鎴戜滑瑕佸湪HBase涓緩绔嬫垜浠殑涓涓〃鏉ュ瓨鍌?span >鏁版嵁銆?nbsp; 
  1. public static void creatTable(String table) throws IOException{
  2.             HConnection conn = HConnectionManager.getConnection(conf);
  3.             HBaseAdmin admin = new HBaseAdmin(conf);
  4.             if(!admin.tableExists(new Text(table))){
  5.               System.out.println("1. " + table + " table creating ... please wait");
  6.               HTableDescriptor tableDesc = new HTableDescriptor(table);
  7.               tableDesc.addFamily(new HColumnDescriptor("http:"));
  8.               tableDesc.addFamily(new HColumnDescriptor("url:"));
  9.               tableDesc.addFamily(new HColumnDescriptor("referrer:"));
  10.               admin.createTable(tableDesc);
  11.             } else {
  12.               System.out.println("1. " + table + " table already exists.");
  13.             }
  14.             System.out.println("2. access_log files fetching using map/reduce");
  15.   }
澶嶅埗浠g爜

鐒跺悗鎴戜滑榪愯涓涓狹apReduce浠誨姟鏉ュ彇寰條og涓殑姣忎竴琛?鏁版嵁銆傚洜涓烘垜浠彧瑕佸彇寰楁暟鎹屼笉闇瑕佸緇撴灉榪涜瑙勭害錛屾垜浠彧瑕佺紪鍐欎竴涓狹ap紼嬪簭鍗沖彲銆?nbsp;  
  1. public static class MapClass extends MapReduceBase implements
  2.       Mapper<WritableComparable, Text, Text, Writable> {

  3.     @Override
  4.     public void configure(JobConf job) {
  5.       tableName = job.get(TABLE, "");
  6.     }

  7.     public void map(WritableComparable key, Text value,
  8.         OutputCollector<Text, Writable> output, Reporter reporter)
  9.         throws IOException {
  10.       try {
  11.              AccessLogParser log = new AccessLogParser(value.toString());
  12.         if(table==null)
  13.                 table = new HTable(conf, new Text(tableName));
  14.         long lockId = table.startUpdate(new Text(log.getIp()));
  15.         table.put(lockId, new Text("http:protocol"), log.getProtocol().getBytes());
  16.         table.put(lockId, new Text("http:method"), log.getMethod().getBytes());
  17.         table.put(lockId, new Text("http:code"), log.getCode().getBytes());
  18.         table.put(lockId, new Text("http:bytesize"), log.getByteSize().getBytes());
  19.         table.put(lockId, new Text("http:agent"), log.getAgent().getBytes());
  20.         table.put(lockId, new Text("url:" + log.getUrl()), log.getReferrer().getBytes());
  21.         table.put(lockId, new Text("referrer:" + log.getReferrer()), log.getUrl().getBytes());

  22.         table.commit(lockId, log.getTimestamp());
  23.       } catch (ParseException e) {
  24.         e.printStackTrace();
  25.       } catch (Exception e) {
  26.         e.printStackTrace();
  27.       }
  28.     }
  29.   }
澶嶅埗浠g爜

鎴戜滑鍦∕ap紼嬪簭涓浜庝紶榪涙潵鐨勬瘡涓琛屽厛浜ょ粰AccessLogParser鍘誨鐞嗗湪AccessLogParser寰鋒瀯閫犲櫒涓敤涓涓鍒欒〃杈懼紡"([^ ]*) ([^ ]*) ([^ ]*) \\[([^]]*)\\] \"([^\"]*)\"銆" ([^ ]*) ([^ ]*) \"([^\"]*)\" \"([^\"]*)\".*"鏉ュ尮閰嶆瘡涓琛岀殑log銆傛帴涓嬫潵鎴戜滑鎶婅繖浜汚ccessLogParser澶勭悊鍑烘潵鐨勭粨鏋滄洿鏂板埌HBase鐨勮〃涓幓錛屽ソ鐨勶紝 鎴戜滑鐨勭▼搴忓啓瀹屼簡銆傛垜浠鍚姩涓涓狹apReduce鐨勮瘽鎴戜滑瑕佸宸ヤ綔榪涜閰嶇疆銆?nbsp;  
  1. public static void runMapReduce(String table,String dir) throws IOException{
  2.           Path tempDir = new Path("log/temp");
  3.           Path InputDir = new Path(dir);
  4.           FileSystem fs = FileSystem.get(conf);
  5.           JobConf jobConf = new JobConf(conf, LogFetcher.class);
  6.           jobConf.setJobName("apache log fetcher");
  7.           jobConf.set(TABLE, table);
  8.           Path[] in = fs.listPaths(InputDir);
  9.           if (fs.isFile(InputDir)) {
  10.               jobConf.setInputPath(InputDir);
  11.           } else {
  12.               for (int i = 0; i < in.length; i++) {
  13.                 if (fs.isFile(in[i])) {
  14.                   jobConf.addInputPath(in[i]);
  15.                 } else {
  16.                   Path[] sub = fs.listPaths(in[i]);
  17.                   for (int j = 0; j < sub.length; j++) {
  18.                     if (fs.isFile(sub[j])) {
  19.                       jobConf.addInputPath(sub[j]);
  20.                     }
  21.                   }
  22.                 }
  23.               }
  24.             }
  25.             jobConf.setOutputPath(tempDir);
  26.             jobConf.setMapperClass(MapClass.class);

  27.             JobClient client = new JobClient(jobConf);
  28.             ClusterStatus cluster = client.getClusterStatus();
  29.             jobConf.setNumMapTasks(cluster.getMapTasks());
  30.             jobConf.setNumReduceTasks(0);

  31.             JobClient.runJob(jobConf);
  32.             fs.delete(tempDir);
  33.             fs.close();
  34.   }
澶嶅埗浠g爜

鍦ㄤ笂闈㈢殑浠g爜涓垜浠厛浜х敓涓涓猨obConf瀵硅薄錛岀劧鍚庤瀹氭垜浠殑InputPath鍜孫utputPath錛屽憡璇塎apReduce鎴戜滑鐨凪ap綾伙紝璁?瀹氭垜浠敤澶氬皯涓狹ap浠誨姟鍜孯educe浠誨姟錛岀劧鍚庢垜浠笉浠誨姟鎻愪氦緇橨obClient錛屽叧浜嶮apReduce璺熻緇嗙殑璧勬枡鍦?a target="_blank">Hadoop Wiki涓娿?br /> 涓嬭澆錛氭簮鐮佸拰宸茬紪璇戝ソ鐨?span >jar鏂囦歡example-src.tgz
渚嬪瓙鐨勮繍琛屽懡浠ゆ槸錛?br />
bin/hadoop jar examples.jar logfetcher <access_log file or directory> <table_name>

濡備綍榪愯涓婇潰鐨勫簲鐢ㄧ▼搴忓憿錛熸垜浠亣瀹氳В鍘嬬緝瀹孒adoop鍒嗗彂鍖呯殑鐩綍涓?HADOOP%
鎷瘋礉%HADOOP%\contrib\hbase\bin涓嬬殑鏂囦歡鍒?HADOOP%\bin涓?鎷瘋礉%HADOOP%\contrib\hbase \conf鐨勬枃浠跺埌%HADOOP%\conf涓?鎷瘋礉%HADOOP%\src\contrib\hbase\lib鐨勬枃浠跺埌%HADOOP%\lib 涓?鎷瘋礉%HADOOP%\src\contrib\hbase\hadoop-*-hbase.jar鐨勬枃浠跺埌%HADOOP%\lib涓?鐒跺悗緙栬緫閰?緗枃浠秇base-site.xml璁懼畾浣犵殑hbase.master渚嬪瓙錛?92.168.2.92:60000銆傛妸榪欎簺鏂囦歡鍒嗗彂鍒拌繍琛孒adoop鐨?鏈哄櫒涓婂幓銆傚湪regionservers鏂囦歡娣誨姞涓婅繖浜涘凡鍒嗗彂榪囩殑鍦板潃銆傝繍琛宐in/start-hbase.sh鍛戒護鍚姩HBase錛屾妸浣犵殑 apache log鏂囦歡鎷瘋礉鍒癏DFS鐨刟pache-log鐩綍涓嬶紝絳夊惎鍔ㄥ畬鎴愬悗榪愯涓嬮潰鐨勫懡浠ゃ?br />
bin/hadoop jar examples.jar logfetcher apache-log apache

璁塊棶http://localhost:50030/鑳?鐪嬪埌浣犵殑MapReduce浠誨姟鐨勮繍琛屾儏鍐碉紝璁塊棶http://localhost:60010/鑳?鐪嬪埌HBase鐨勮繍琛屾儏鍐點?br />
hbaseguiinterface.jpg

絳変換鍔apReduce瀹屾垚鍚庤闂?a href="http://localhost:60010/hql.jsp" target="_blank">http://localhost:60010/hql.jsp,鍦≦uery杈撳叆妗嗕腑杈撳叆 SELECT * FROM apache limit=50;銆傚皢浼氱湅鍒板凡緇忔彃鍏ヨ〃涓殑鏁版嵁銆? hqlguiinterface.jpg


SIMONE 2013-02-22 14:12 鍙戣〃璇勮
]]>
Hadoop瀛︿範絎旇涔嬪湪Eclipse涓繙紼嬭皟璇旽adoophttp://m.tkk7.com/wangxinsh55/archive/2013/02/22/395570.htmlSIMONESIMONEFri, 22 Feb 2013 06:06:00 GMThttp://m.tkk7.com/wangxinsh55/archive/2013/02/22/395570.htmlhttp://m.tkk7.com/wangxinsh55/comments/395570.htmlhttp://m.tkk7.com/wangxinsh55/archive/2013/02/22/395570.html#Feedback1http://m.tkk7.com/wangxinsh55/comments/commentRss/395570.htmlhttp://m.tkk7.com/wangxinsh55/services/trackbacks/395570.htmlhttp://m.tkk7.com/yongboy/archive/2012/04/26/376486.html

鎻掍歡

璇濊Hadoop 1.0.2/src/contrib/eclipse-plugin鍙湁鎻掍歡鐨勬簮浠g爜錛岃繖閲岀粰鍑轟竴涓垜鎵撳寘濂界殑瀵瑰簲鐨凟clipse鎻掍歡錛?br />涓嬭澆鍦板潃

涓嬭澆鍚庢墧鍒癳clipse/dropins鐩綍涓嬪嵆鍙紝褰撶劧eclipse/plugins涔熸槸鍙互鐨勶紝鍓嶈呮洿涓鴻交渚匡紝鎺ㄨ崘錛涢噸鍚疎clipse錛屽嵆鍙湪閫忚鍥?Perspective)涓湅鍒癕ap/Reduce銆?/p>

閰嶇疆

鐐瑰嚮钃濊壊鐨勫皬璞″浘鏍囷紝鏂板緩涓涓狧adoop榪炴帴錛?/p>

2

娉ㄦ剰錛屼竴瀹氳濉啓姝g‘錛屼慨鏀逛簡鏌愪簺绔彛錛屼互鍙婇粯璁よ繍琛岀殑鐢ㄦ埛鍚嶇瓑

鍏蜂綋鐨勮緗紝鍙

姝e父鎯呭喌涓嬶紝鍙互鍦ㄩ」鐩尯鍩熷彲浠ョ湅鍒?/p>

image

榪欐牱鍙互姝e父鐨勮繘琛孒DFS鍒嗗竷寮忔枃浠剁郴緇熺殑綆$悊錛氫笂浼狅紝鍒犻櫎絳夋搷浣溿?/p>

涓轟笅闈㈡祴璇曞仛鍑嗗錛岄渶瑕佸厛寤轟簡涓涓洰褰?user/root/input2錛岀劧鍚庝笂浼犱袱涓猼xt鏂囦歡鍒版鐩綍錛?/p>

intput1.txt 瀵瑰簲鍐呭錛欻ello Hadoop Goodbye Hadoop

intput2.txt 瀵瑰簲鍐呭錛欻ello World Bye World

HDFS鐨勫噯澶囧伐浣滃ソ浜嗭紝涓嬮潰鍙互寮濮嬫祴璇曚簡銆?/p>

Hadoop宸ョ▼

鏂板緩涓涓狹ap/Reduce Project宸ョ▼錛岃瀹氬ソ鏈湴鐨刪adoop鐩綍

1

鏂板緩涓涓祴璇曠被WordCountTest錛?/p>

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
package com.hadoop.learn.test;
 
import java.io.IOException;
import java.util.StringTokenizer;
 
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;
import org.apache.hadoop.util.GenericOptionsParser;
import org.apache.log4j.Logger;
 
/**
* 榪愯嫻嬭瘯紼嬪簭
*
* @author yongboy
* @date 2012-04-16
*/
public class WordCountTest {
private static final Logger log = Logger.getLogger(WordCountTest.class);
 
public static class TokenizerMapper extends
Mapper<Object, Text, Text, IntWritable> {
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
 
public void map(Object key, Text value, Context context)
throws IOException, InterruptedException {
log.info("Map key : " + key);
log.info("Map value : " + value);
StringTokenizer itr = new StringTokenizer(value.toString());
while (itr.hasMoreTokens()) {
String wordStr = itr.nextToken();
word.set(wordStr);
log.info("Map word : " + wordStr);
context.write(word, one);
}
}
}
 
public static class IntSumReducer extends
Reducer<Text, IntWritable, Text, IntWritable> {
private IntWritable result = new IntWritable();
 
public void reduce(Text key, Iterable<IntWritable> values,
Context context) throws IOException, InterruptedException {
log.info("Reduce key : " + key);
log.info("Reduce value : " + values);
int sum = 0;
for (IntWritable val : values) {
sum += val.get();
}
result.set(sum);
log.info("Reduce sum : " + sum);
context.write(key, result);
}
}
 
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
String[] otherArgs = new GenericOptionsParser(conf, args)
.getRemainingArgs();
if (otherArgs.length != 2) {
System.err.println("Usage: WordCountTest <in> <out>");
System.exit(2);
}
 
Job job = new Job(conf, "word count");
job.setJarByClass(WordCountTest.class);
 
job.setMapperClass(TokenizerMapper.class);
job.setCombinerClass(IntSumReducer.class);
job.setReducerClass(IntSumReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
 
FileInputFormat.addInputPath(job, new Path(otherArgs[0]));
FileOutputFormat.setOutputPath(job, new Path(otherArgs[1]));
 
System.exit(job.waitForCompletion(true) ? 0 : 1);
}
}

鍙抽敭錛岄夋嫨“Run Configurations”,寮瑰嚭紿楀彛錛岀偣鍑?#8220;Arguments”閫夐」鍗?鍦?#8220;Program argumetns”澶勯鍏堣緭鍏ュ弬鏁?

hdfs://master:9000/user/root/input2 dfs://master:9000/user/root/output2

澶囨敞錛氬弬鏁頒負浜嗗湪鏈湴璋冭瘯浣跨敤錛岃岄潪鐪熷疄鐜銆?/p>

鐒跺悗錛岀偣鍑?#8220;Apply”錛岀劧鍚?#8220;Close”銆傜幇鍦ㄥ彲浠ュ彸閿紝閫夋嫨“Run on Hadoop”錛岃繍琛屻?/p>

浣嗘鏃朵細鍑虹幇綾諱技寮傚父淇℃伅錛?/p>

12/04/24 15:32:44 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
12/04/24 15:32:44 ERROR security.UserGroupInformation: PriviledgedActionException as:Administrator cause:java.io.IOException: Failed to set permissions of path: \tmp\hadoop-Administrator\mapred\staging\Administrator-519341271\.staging to 0700
Exception in thread "main" java.io.IOException: Failed to set permissions of path: \tmp\hadoop-Administrator\mapred\staging\Administrator-519341271\.staging to 0700
    at org.apache.hadoop.fs.FileUtil.checkReturnValue(FileUtil.java:682)
    at org.apache.hadoop.fs.FileUtil.setPermission(FileUtil.java:655)
    at org.apache.hadoop.fs.RawLocalFileSystem.setPermission(RawLocalFileSystem.java:509)
    at org.apache.hadoop.fs.RawLocalFileSystem.mkdirs(RawLocalFileSystem.java:344)
    at org.apache.hadoop.fs.FilterFileSystem.mkdirs(FilterFileSystem.java:189)
    at org.apache.hadoop.mapreduce.JobSubmissionFiles.getStagingDir(JobSubmissionFiles.java:116)
    at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:856)
    at org.apache.hadoop.mapred.JobClient$2.run(JobClient.java:850)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:396)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1093)
    at org.apache.hadoop.mapred.JobClient.submitJobInternal(JobClient.java:850)
    at org.apache.hadoop.mapreduce.Job.submit(Job.java:500)
    at org.apache.hadoop.mapreduce.Job.waitForCompletion(Job.java:530)
    at com.hadoop.learn.test.WordCountTest.main(WordCountTest.java:85)

榪欎釜鏄疻indows涓嬫枃浠舵潈闄愰棶棰橈紝鍦↙inux涓嬪彲浠ユ甯歌繍琛岋紝涓嶅瓨鍦ㄨ繖鏍風殑闂銆?/p>

瑙e喅鏂規硶鏄紝淇敼/hadoop-1.0.2/src/core/org/apache/hadoop/fs/FileUtil.java閲岄潰鐨刢heckReturnValue錛屾敞閲婃帀鍗沖彲錛堟湁浜涚矖鏆達紝鍦╓indow涓嬶紝鍙互涓嶇敤媯鏌ワ級錛?/p>

1 2 3 4 5 6 7 8 9 10 11 12 13
......
private static void checkReturnValue(boolean rv, File p,
FsPermission permission
) throws IOException {
/**
if (!rv) {
throw new IOException("Failed to set permissions of path: " + p +
" to " +
String.format("%04o", permission.toShort()));
}
**/
}
......
view raw FileUtil.java This Gist brought to you by GitHub.

閲嶆柊緙栬瘧鎵撳寘hadoop-core-1.0.2.jar錛屾浛鎹㈡帀hadoop-1.0.2鏍圭洰褰曚笅鐨刪adoop-core-1.0.2.jar鍗沖彲銆?/p>

榪欓噷鎻愪緵涓浠戒慨鏀圭増鐨?a target="_blank">hadoop-core-1.0.2-modified.jar鏂囦歡錛屾浛鎹㈠師hadoop-core-1.0.2.jar鍗沖彲銆?/p>

鏇挎崲涔嬪悗錛屽埛鏂伴」鐩紝璁劇疆濂芥紜殑jar鍖呬緷璧栵紝鐜板湪鍐嶈繍琛學ordCountTest錛屽嵆鍙?/p>

鎴愬姛涔嬪悗錛屽湪Eclipse涓嬪埛鏂癏DFS鐩綍錛屽彲浠ョ湅鍒扮敓鎴愪簡ouput2鐩綍錛?/p>

image

鐐瑰嚮“ part-r-00000”鏂囦歡錛屽彲浠ョ湅鍒版帓搴忕粨鏋滐細

Bye    1
Goodbye    1
Hadoop    2
Hello    2
World    2

鍡紝涓鏍峰彲浠ユ甯窪ebug璋冭瘯璇ョ▼搴忥紝璁劇疆鏂偣錛堝彸閿?–> Debug As – > Java Application錛夛紝鍗沖彲錛堟瘡嬈¤繍琛屼箣鍓嶏紝閮介渶瑕佹敹鍒板垹闄よ緭鍑虹洰褰曪級銆?/p>

鍙﹀錛岃鎻掍歡浼氬湪eclipse瀵瑰簲鐨剋orkspace\.metadata\.plugins\org.apache.hadoop.eclipse涓嬶紝鑷姩鐢熸垚jar鏂囦歡錛屼互鍙婂叾浠栨枃浠訛紝鍖呮嫭Haoop鐨勪竴浜涘叿浣撻厤緗瓑銆?/p>

鍡紝鏇村緇嗚妭錛屾參鎱綋楠屽惂銆?/p>

閬囧埌鐨勫紓甯?/strong>

org.apache.hadoop.ipc.RemoteException: org.apache.hadoop.hdfs.server.namenode.SafeModeException: Cannot create directory /user/root/output2/_temporary. Name node is in safe mode.
The ratio of reported blocks 0.5000 has not reached the threshold 0.9990. Safe mode will be turned off automatically.
    at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.mkdirsInternal(FSNamesystem.java:2055)
    at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.mkdirs(FSNamesystem.java:2029)
    at org.apache.hadoop.hdfs.server.namenode.NameNode.mkdirs(NameNode.java:817)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:563)
    at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1388)
    at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:1384)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:396)
    at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1093)
    at org.apache.hadoop.ipc.Server$Handler.run(Server.java:1382)

鍦ㄤ富鑺傜偣澶勶紝鍏抽棴鎺夊畨鍏ㄦā寮忥細

#bin/hadoop dfsadmin –safemode leave

濡備綍鎵撳寘

灝嗗垱寤虹殑Map/Reduce欏圭洰鎵撳寘鎴恓ar鍖咃紝寰堢畝鍗曠殑浜嬫儏錛屾棤闇澶氳█銆備繚璇乯ar鏂囦歡鐨凪ETA-INF/MANIFEST.MF鏂囦歡涓瓨鍦∕ain-Class鏄犲皠錛?/p>

Main-Class: com.hadoop.learn.test.TestDriver

鑻ヤ嬌鐢ㄥ埌絎笁鏂筳ar鍖咃紝閭d箞鍦∕ANIFEST.MF涓鍔燙lass-Path濂戒簡銆?/p>

鍙﹀鍙嬌鐢ㄦ彃浠舵彁渚涚殑MapReduce Driver鍚戝錛屽彲浠ュ府蹇欐垜浠湪Hadoop涓繍琛岋紝鐩存帴鎸囧畾鍒悕錛屽挨鍏舵槸鍖呭惈澶氫釜Map/Reduce浣滀笟鏃訛紝寰堟湁鐢ㄣ?/p>

涓涓狹apReduce Driver鍙鍖呭惈涓涓猰ain鍑芥暟錛屾寚瀹氬埆鍚嶏細

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
package com.hadoop.learn.test;
 
import org.apache.hadoop.util.ProgramDriver;
 
/**
*
* @author yongboy
* @time 2012-4-24
* @version 1.0
*/
public class TestDriver {
 
public static void main(String[] args) {
int exitCode = -1;
ProgramDriver pgd = new ProgramDriver();
try {
pgd.addClass("testcount", WordCountTest.class,
"A test map/reduce program that counts the words in the input files.");
pgd.driver(args);
 
exitCode = 0;
} catch (Throwable e) {
e.printStackTrace();
}
 
System.exit(exitCode);
}
}

榪欓噷鏈変竴涓皬鎶宸э紝MapReduce Driver綾諱笂闈紝鍙抽敭榪愯錛孯un on Hadoop錛屼細鍦‥clipse鐨剋orkspace\.metadata\.plugins\org.apache.hadoop.eclipse鐩?褰曚笅鑷姩鐢熸垚jar鍖咃紝涓婁紶鍒癏DFS錛屾垨鑰呰繙紼媓adoop鏍圭洰褰曚笅錛岃繍琛屽畠:

# bin/hadoop jar LearnHadoop_TestDriver.java-460881982912511899.jar testcount input2 output3

OK錛屾湰鏂囩粨鏉熴?/p>



SIMONE 2013-02-22 14:06 鍙戣〃璇勮
]]>
Hadoop浣滀笟鎻愪氦鍒嗘瀽錛堜簲錛?/title><link>http://m.tkk7.com/wangxinsh55/archive/2013/02/22/395569.html</link><dc:creator>SIMONE</dc:creator><author>SIMONE</author><pubDate>Fri, 22 Feb 2013 06:05:00 GMT</pubDate><guid>http://m.tkk7.com/wangxinsh55/archive/2013/02/22/395569.html</guid><wfw:comment>http://m.tkk7.com/wangxinsh55/comments/395569.html</wfw:comment><comments>http://m.tkk7.com/wangxinsh55/archive/2013/02/22/395569.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.tkk7.com/wangxinsh55/comments/commentRss/395569.html</wfw:commentRss><trackback:ping>http://m.tkk7.com/wangxinsh55/services/trackbacks/395569.html</trackback:ping><description><![CDATA[<div>http://www.cnblogs.com/spork/archive/2010/04/21/1717592.html</div><br /><div><div class="ymcimwe" id="cnblogs_post_body"><p>銆銆緇忚繃涓婁竴綃囩殑鍒嗘瀽錛屾垜浠煡閬撲簡Hadoop鐨勪綔涓氭彁浜ょ洰鏍囨槸Cluster榪樻槸Local錛屼笌conf鏂囦歡澶瑰唴鐨勯厤緗枃浠跺弬鏁版湁鐫瀵嗗垏鍏崇郴錛屼笉浠呭姝わ紝鍏跺畠鐨勫緢澶氱被閮借窡conf鏈夊叧錛屾墍浠ユ彁浜や綔涓氭椂鍒囪鎶奵onf鏀懼埌浣犵殑classpath涓?/p> <p>銆銆鍥犱負Configuration鏄埄鐢ㄥ綋鍓嶇嚎紼嬩笂涓嬫枃鐨勭被鍔犺澆鍣ㄦ潵鍔犺澆璧勬簮鍜屾枃浠剁殑錛屾墍浠ヨ繖閲屾垜浠噰鐢ㄥ姩鎬佽澆鍏ョ殑鏂瑰紡錛屽厛娣誨姞濂藉搴旂殑渚濊禆搴撳拰璧勬簮錛岀劧鍚庡啀鏋勫緩涓涓猆RLClassLoader浣滀負褰撳墠綰跨▼涓婁笅鏂囩殑綾誨姞杞藉櫒銆?/p> <div><div><a title="澶嶅埗浠g爜"><img src="http://common.cnblogs.com/images/copycode.gif" alt="澶嶅埗浠g爜" /></a></div> <pre><div> <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span><span style="color: #000000;"> ClassLoader getClassLoader() {<br /> ClassLoader parent </span><span style="color: #000000;">=</span><span style="color: #000000;"> Thread.currentThread().getContextClassLoader();<br /> </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (parent </span><span style="color: #000000;">==</span> <span style="color: #0000ff;">null</span><span style="color: #000000;">) {<br /> parent </span><span style="color: #000000;">=</span><span style="color: #000000;"> EJob.</span><span style="color: #0000ff;">class</span><span style="color: #000000;">.getClassLoader();<br /> }<br /> </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (parent </span><span style="color: #000000;">==</span> <span style="color: #0000ff;">null</span><span style="color: #000000;">) {<br /> parent </span><span style="color: #000000;">=</span><span style="color: #000000;"> ClassLoader.getSystemClassLoader();<br /> }<br /> </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">new</span><span style="color: #000000;"> URLClassLoader(classPath.toArray(</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> URL[</span><span style="color: #000000;">0</span><span style="color: #000000;">]), parent);<br /> }</span></div></pre> <div><a title="澶嶅埗浠g爜"><img src="http://common.cnblogs.com/images/copycode.gif" alt="澶嶅埗浠g爜" /></a></div></div> <p>銆銆浠g爜寰堢畝鍗曪紝搴熻瘽灝變笉澶氳浜嗐傝皟鐢ㄤ緥瀛愬涓嬶細</p> <div> <pre><div><span style="color: #000000;"> EJob.addClasspath(</span><span style="color: #000000;">"</span><span style="color: #000000;">/usr/lib/hadoop-0.20/conf</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br /> ClassLoader classLoader </span><span style="color: #000000;">=</span><span style="color: #000000;"> EJob.getClassLoader();<br /> Thread.currentThread().setContextClassLoader(classLoader);</span></div></pre> </div> <p>銆銆璁劇疆濂戒簡綾誨姞杞藉櫒錛屼笅闈㈣繕鏈変竴姝ュ氨鏄鎵撳寘Jar鏂囦歡錛屽氨鏄Project鑷墦鍖呰嚜宸辯殑class涓轟竴涓狫ar鍖咃紝鎴戣繖閲屼互鏍囧噯Eclipse宸ョ▼鏂囦歡澶瑰竷灞涓轟緥錛屾墦鍖呯殑灝辨槸bin鏂囦歡澶歸噷鐨刢lass銆?/p> <div><div><a title="澶嶅埗浠g爜"><img src="http://common.cnblogs.com/images/copycode.gif" alt="澶嶅埗浠g爜" /></a></div> <div class="acw8ksa" id="cnblogs_code_open_e5d79072-c219-44a1-9025-8122614a7142"> <pre><div><span style="color: #0000ff;"> public</span> <span style="color: #0000ff;">static</span><span style="color: #000000;"> File createTempJar(String root) </span><span style="color: #0000ff;">throws</span><span style="color: #000000;"> IOException {<br /> </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (</span><span style="color: #000000;">!</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> File(root).exists()) {<br /> </span><span style="color: #0000ff;">return</span> <span style="color: #0000ff;">null</span><span style="color: #000000;">;<br /> }<br /> Manifest manifest </span><span style="color: #000000;">=</span> <span style="color: #0000ff;">new</span><span style="color: #000000;"> Manifest();<br /> manifest.getMainAttributes().putValue(</span><span style="color: #000000;">"</span><span style="color: #000000;">Manifest-Version</span><span style="color: #000000;">"</span><span style="color: #000000;">, </span><span style="color: #000000;">"</span><span style="color: #000000;">1.0</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br /> </span><span style="color: #0000ff;">final</span><span style="color: #000000;"> File jarFile </span><span style="color: #000000;">=</span><span style="color: #000000;"> File.createTempFile(</span><span style="color: #000000;">"</span><span style="color: #000000;">EJob-</span><span style="color: #000000;">"</span><span style="color: #000000;">, </span><span style="color: #000000;">"</span><span style="color: #000000;">.jar</span><span style="color: #000000;">"</span><span style="color: #000000;">, </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> File(System<br /> .getProperty(</span><span style="color: #000000;">"</span><span style="color: #000000;">java.io.tmpdir</span><span style="color: #000000;">"</span><span style="color: #000000;">)));<br /><br /> Runtime.getRuntime().addShutdownHook(</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> Thread() {<br /> </span><span style="color: #0000ff;">public</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> run() {<br /> jarFile.delete();<br /> }<br /> });<br /><br /> JarOutputStream out </span><span style="color: #000000;">=</span> <span style="color: #0000ff;">new</span><span style="color: #000000;"> JarOutputStream(</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> FileOutputStream(jarFile),<br /> manifest);<br /> createTempJarInner(out, </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> File(root), </span><span style="color: #000000;">""</span><span style="color: #000000;">);<br /> out.flush();<br /> out.close();<br /> </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> jarFile;<br /> }<br /><br /> </span><span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">void</span><span style="color: #000000;"> createTempJarInner(JarOutputStream out, File f,<br /> String base) </span><span style="color: #0000ff;">throws</span><span style="color: #000000;"> IOException {<br /> </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (f.isDirectory()) {<br /> File[] fl </span><span style="color: #000000;">=</span><span style="color: #000000;"> f.listFiles();<br /> </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (base.length() </span><span style="color: #000000;">></span> <span style="color: #000000;">0</span><span style="color: #000000;">) {<br /> base </span><span style="color: #000000;">=</span><span style="color: #000000;"> base </span><span style="color: #000000;">+</span> <span style="color: #000000;">"</span><span style="color: #000000;">/</span><span style="color: #000000;">"</span><span style="color: #000000;">;<br /> }<br /> </span><span style="color: #0000ff;">for</span><span style="color: #000000;"> (</span><span style="color: #0000ff;">int</span><span style="color: #000000;"> i </span><span style="color: #000000;">=</span> <span style="color: #000000;">0</span><span style="color: #000000;">; i </span><span style="color: #000000;"><</span><span style="color: #000000;"> fl.length; i</span><span style="color: #000000;">++</span><span style="color: #000000;">) {<br /> createTempJarInner(out, fl[i], base </span><span style="color: #000000;">+</span><span style="color: #000000;"> fl[i].getName());<br /> }<br /> } </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> {<br /> out.putNextEntry(</span><span style="color: #0000ff;">new</span><span style="color: #000000;"> JarEntry(base));<br /> FileInputStream in </span><span style="color: #000000;">=</span> <span style="color: #0000ff;">new</span><span style="color: #000000;"> FileInputStream(f);<br /> </span><span style="color: #0000ff;">byte</span><span style="color: #000000;">[] buffer </span><span style="color: #000000;">=</span> <span style="color: #0000ff;">new</span> <span style="color: #0000ff;">byte</span><span style="color: #000000;">[</span><span style="color: #000000;">1024</span><span style="color: #000000;">];<br /> </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> n </span><span style="color: #000000;">=</span><span style="color: #000000;"> in.read(buffer);<br /> </span><span style="color: #0000ff;">while</span><span style="color: #000000;"> (n </span><span style="color: #000000;">!=</span> <span style="color: #000000;">-</span><span style="color: #000000;">1</span><span style="color: #000000;">) {<br /> out.write(buffer, </span><span style="color: #000000;">0</span><span style="color: #000000;">, n);<br /> n </span><span style="color: #000000;">=</span><span style="color: #000000;"> in.read(buffer);<br /> }<br /> in.close();<br /> }<br /> }</span></div></pre> </div> <div><a title="澶嶅埗浠g爜"><img src="http://common.cnblogs.com/images/copycode.gif" alt="澶嶅埗浠g爜" /></a></div></div> <p>銆銆榪欓噷鐨勫澶栨帴鍙f槸createTempJar錛屾帴鏀跺弬鏁頒負闇瑕佹墦鍖呯殑鏂囦歡澶規牴璺緞錛屾敮鎸佸瓙鏂囦歡澶規墦鍖呫備嬌鐢ㄩ掑綊澶勭悊娉曪紝渚濇鎶婃枃浠跺す閲岀殑緇撴瀯鍜?鏂囦歡鎵撳寘鍒癑ar閲屻傚緢綆鍗曪紝灝辨槸鍩烘湰鐨勬枃浠舵祦鎿嶄綔錛岄檶鐢熶竴鐐圭殑灝辨槸Manifest鍜孞arOutputStream錛屾煡鏌PI灝辨槑浜嗐?/p> <p>銆銆濂斤紝涓囦簨鍏峰錛屽彧嬈犱笢椋庝簡錛屾垜浠潵瀹炶返涓涓嬭瘯璇曘傝繕鏄嬁WordCount鏉ヤ婦渚嬶細</p> <div><div><a title="澶嶅埗浠g爜"><img src="http://common.cnblogs.com/images/copycode.gif" alt="澶嶅埗浠g爜" /></a></div> <div class="ygcea00" id="cnblogs_code_open_fc92678b-77e8-420b-abab-e1994c50d7ac"> <pre><div> <span style="color: #008000;">//</span><span style="color: #008000;"> Add these statements. XXX</span><span style="color: #008000;"><br /></span><span style="color: #000000;"> <span style="color: #3366ff;">File jarFile </span></span><span style="color: #3366ff;">= EJob.createTempJar("bin");<br /> EJob.addClasspath("/usr/lib/hadoop-0.20/conf");<br /> ClassLoader classLoader =</span><span style="color: #000000;"><span style="color: #3366ff;"> EJob.getClassLoader();<br /> Thread.currentThread().setContextClassLoader(classLoader);</span><br /><br /> Configuration conf </span><span style="color: #000000;">=</span> <span style="color: #0000ff;">new</span><span style="color: #000000;"> Configuration();<br /> String[] otherArgs </span><span style="color: #000000;">=</span> <span style="color: #0000ff;">new</span><span style="color: #000000;"> GenericOptionsParser(conf, args)<br /> .getRemainingArgs();<br /> </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (otherArgs.length </span><span style="color: #000000;">!=</span> <span style="color: #000000;">2</span><span style="color: #000000;">) {<br /> System.err.println(</span><span style="color: #000000;">"</span><span style="color: #000000;">Usage: wordcount <in> <out></span><span style="color: #000000;">"</span><span style="color: #000000;">);<br /> System.exit(</span><span style="color: #000000;">2</span><span style="color: #000000;">);<br /> }<br /><br /> Job job </span><span style="color: #000000;">=</span> <span style="color: #0000ff;">new</span><span style="color: #000000;"> Job(conf, </span><span style="color: #000000;">"</span><span style="color: #000000;">word count</span><span style="color: #000000;">"</span><span style="color: #000000;">);</span><span style="color: #000000;"><br /> job.setJarByClass(WordCountTest.</span><span style="color: #0000ff;">class</span><span style="color: #000000;">);<br /> job.setMapperClass(TokenizerMapper.</span><span style="color: #0000ff;">class</span><span style="color: #000000;">);<br /> job.setCombinerClass(IntSumReducer.</span><span style="color: #0000ff;">class</span><span style="color: #000000;">);<br /> job.setReducerClass(IntSumReducer.</span><span style="color: #0000ff;">class</span><span style="color: #000000;">);<br /> job.setOutputKeyClass(Text.</span><span style="color: #0000ff;">class</span><span style="color: #000000;">);<br /> job.setOutputValueClass(IntWritable.</span><span style="color: #0000ff;">class</span><span style="color: #000000;">);<br /> FileInputFormat.addInputPath(job, </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> Path(otherArgs[</span><span style="color: #000000;">0</span><span style="color: #000000;">]));<br /> FileOutputFormat.setOutputPath(job, </span><span style="color: #0000ff;">new</span><span style="color: #000000;"> Path(otherArgs[</span><span style="color: #000000;">1</span><span style="color: #000000;">]));<br /> System.exit(job.waitForCompletion(</span><span style="color: #0000ff;">true</span><span style="color: #000000;">) </span><span style="color: #000000;">?</span> <span style="color: #000000;">0</span><span style="color: #000000;"> : </span><span style="color: #000000;">1</span><span style="color: #000000;">);</span></div></pre> </div> <div><a title="澶嶅埗浠g爜"><img src="http://common.cnblogs.com/images/copycode.gif" alt="澶嶅埗浠g爜" /></a></div></div> <p>銆銆Run as Java Application銆傘傘?span style="color: #ff0000;">錛侊紒錛?/span><span style="color: #ff0000;">No job jar file set...<span style="color: #000000;"><span style="color: #ff0000;">寮傚父</span>錛岀湅鏉?/span></span>job.setJarByClass(WordCountTest.class)榪欎釜璇彞璁劇疆浣滀笟Jar鍖呮病鏈夋垚鍔熴傝繖鏄負浠涔堝憿錛?/p> <p>鍥犱負榪欎釜鏂規硶浣跨敤浜哤ordCount.class鐨勭被鍔犺澆鍣ㄦ潵瀵繪壘鍖呭惈璇ョ被鐨凧ar鍖咃紝鐒跺悗璁劇疆璇ar鍖呬負浣滀笟鎵鐢ㄧ殑Jar鍖呫備絾鏄垜浠殑浣滀笟 Jar鍖呮槸鍦ㄧ▼搴忚繍琛屾椂鎵嶆墦鍖呯殑錛岃學ordCount.class鐨勭被鍔犺澆鍣ㄦ槸AppClassLoader錛岃繍琛屽悗鎴戜滑鏃犳硶鏀瑰彉瀹冪殑鎼滅儲璺緞錛屾墍浠ヤ嬌 鐢╯etJarByClass鏄棤娉曡緗綔涓欽ar鍖呯殑銆傛垜浠繀欏諱嬌鐢↗obConf閲岀殑setJar鏉ョ洿鎺ヨ緗綔涓欽ar鍖咃紝鍍忎笅闈竴鏍鳳細 </p> <div> <pre><div><span style="color: #000000;">((JobConf)job.getConfiguration()).setJar(jarFile);</span></div></pre> </div> <p> 銆銆濂斤紝鎴戜滑瀵逛笂闈㈢殑渚嬪瓙鍐嶅仛涓嬩慨鏀癸紝鍔犱笂涓婇潰榪欐潯璇彞銆?/p> <div> <pre><div><span style="color: #000000;">Job job </span><span style="color: #000000;">=</span> <span style="color: #0000ff;">new</span><span style="color: #000000;"> Job(conf, </span><span style="color: #000000;">"</span><span style="color: #000000;">word count</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br /></span><span style="color: #008000;">//</span><span style="color: #008000;"> And add this statement. XXX</span><span style="color: #008000;"><br /></span><span style="color: #3366ff;">((JobConf) job.getConfiguration()).setJar(jarFile.toString());</span></div></pre> </div> <p> 銆銆鍐峈un as Java Application錛岀粓浜嶰K浜唦~</p> <p>銆銆璇ョ鏂規硶鐨凴un on Hadoop浣跨敤綆鍗曪紝鍏煎鎬уソ錛屾帹鑽愪竴璇曘傦細錛?/p> <p>銆銆鏈緥瀛愮敱浜庢椂闂村叧緋伙紝鍙湪Ubuntu涓婂仛浜嗕吉鍒嗗竷寮忔祴璇曪紝浣嗙悊璁轟笂鏄彲浠ョ敤鍒扮湡瀹炲垎甯冨紡涓婂幓鐨勩?/p> <p>     <a >>>鐐規垜涓嬭澆<<</a></p> <p> </p> <p>銆銆The end.</p></div></div><img src ="http://m.tkk7.com/wangxinsh55/aggbug/395569.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.tkk7.com/wangxinsh55/" target="_blank">SIMONE</a> 2013-02-22 14:05 <a href="http://m.tkk7.com/wangxinsh55/archive/2013/02/22/395569.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>HBASE鐨凪APREDUCE浠誨姟榪愯寮傚父瑙e喅鍔炴硶錛屾棤闇CYGWIN錛岀函WINDOWS鐜http://m.tkk7.com/wangxinsh55/archive/2013/02/22/395568.htmlSIMONESIMONEFri, 22 Feb 2013 06:03:00 GMThttp://m.tkk7.com/wangxinsh55/archive/2013/02/22/395568.htmlhttp://m.tkk7.com/wangxinsh55/comments/395568.htmlhttp://m.tkk7.com/wangxinsh55/archive/2013/02/22/395568.html#Feedback0http://m.tkk7.com/wangxinsh55/comments/commentRss/395568.htmlhttp://m.tkk7.com/wangxinsh55/services/trackbacks/395568.htmlhttp://m.tkk7.com/paulwong/archive/2012/10/03/388977.html
濡傛灉鏄湪WINDOWS鐨凟CLIPSE涓紝榪愯HBASE鐨凪APREDUCE錛屼細鍑虹幇寮傚父錛岃繖鏄敱浜庨粯璁よ繍琛孧APREDUCE浠誨姟鏄湪鏈湴榪愯錛岃岀敱浜庝細寤虹珛鏂囦歡璧嬫潈闄愭槸鎸夌収UNIX鐨勬柟寮忚繘琛岋紝鍥犳浼氭姤閿欙細

java.lang.RuntimeException: Error while running command to get file permissions : java.io.IOException: Cannot run program "ls": CreateProcess error=2,


瑙e喅鍔炴硶鏄皢浠誨姟鍙戝埌榪愮▼涓繪満錛岄氬父鏄疞INUX涓婅繍琛岋紝鍦╤base-site.xml涓姞鍏ワ細

<property>
   
<name>mapred.job.tracker</name>
   
<value>master:9001</value>
</property>

鍚屾椂闇鎶奌DFS鐨勬潈闄愭満鍒跺叧鎺夛細

<property>
   
<name>dfs.permissions</name>
   
<value>false</value>
</property>


鍙﹀鐢變簬鏄湪榪滅▼涓婃墽琛屼換鍔★紝鑷畾涔夌殑綾繪枃浠訛紝濡侻aper/Reducer絳夐渶鎵撳寘鎴恓ar鏂囦歡涓婁紶錛屽叿浣撹鏂規錛?br />Hadoop浣滀笟鎻愪氦鍒嗘瀽錛堜簲錛?a target="_blank">http://www.cnblogs.com/spork/archive/2010/04/21/1717592.html


鐮旂┒浜嗗ソ鍑犲ぉ錛岀粓浜庢悶娓呮錛孋ONFIGUARATION灝辨槸JOB鐨勯厤緗俊鎭紝榪滅▼JOBTRACKER灝辨槸浠ユ涓哄弬鏁版瀯寤篔OB鍘繪墽琛岋紝鐢變簬榪滅▼涓繪満騫舵病鏈夎嚜瀹氫箟鐨凪APREDUCE綾伙紝闇鎵撴垚JAR鍖呭悗錛屼笂浼犲埌涓繪満澶勶紝浣嗘棤闇姣忔閮芥墜鍔ㄤ紶錛屽彲浠ヤ唬鐮佽緗細

conf.set("tmpjars", "d:/aaa.jar");


鍙︽敞鎰忥紝濡傛灉鍦╓INDOWS緋葷粺涓紝鏂囦歡鍒嗛殧鍙鋒槸“錛?#8221;錛岀敓鎴愮殑JAR鍖呬俊鎭槸浠?#8220;錛?#8221;闂撮殧鐨勶紝鍦ㄨ繙紼嬩富鏈虹殑LINUX涓婃槸鏃犳硶杈ㄥ埆錛岄渶鏀逛負錛?br />
System.setProperty("path.separator", ":");


鍙傝冩枃绔狅細
http://www.cnblogs.com/xia520pi/archive/2012/05/20/2510723.html


浣跨敤hadoop eclipse plugin鎻愪氦Job騫舵坊鍔犲涓涓夋柟jar錛堝畬緹庣増錛?br />http://heipark.iteye.com/blog/1171923 


SIMONE 2013-02-22 14:03 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 又粗又硬免费毛片| 久久亚洲中文字幕精品有坂深雪| 美女巨胸喷奶水视频www免费| 亚洲成AV人片在WWW色猫咪| 国内精自视频品线六区免费 | 亚洲国产成人久久77| 拔擦拔擦8x华人免费久久| 中文字幕不卡高清免费| 亚洲成在人线中文字幕| 亚洲国产人成中文幕一级二级| 免费91麻豆精品国产自产在线观看| 亚洲区精品久久一区二区三区| 免费吃奶摸下激烈视频| 18禁成人网站免费观看| 免费激情网站国产高清第一页| 亚洲色图国产精品| 青青青国产色视频在线观看国产亚洲欧洲国产综合 | 91免费在线播放| 人人公开免费超级碰碰碰视频| 亚洲经典在线观看| 亚洲精品NV久久久久久久久久| 免费黄色福利视频| 成全视成人免费观看在线看| 日韩亚洲国产高清免费视频| 亚洲欧洲日产国码av系列天堂| 成年大片免费视频| 日韩免费无码一区二区三区 | 一级做a爰片久久毛片免费看 | 亚洲乱色熟女一区二区三区丝袜| 精品久久久久成人码免费动漫| 精品97国产免费人成视频| 亚洲AV无码专区亚洲AV桃| 亚洲色图国产精品| 亚洲色大成网站www永久一区 | 亚洲国产主播精品极品网红 | 免费很黄很色裸乳在线观看| 免费A级毛片无码无遮挡内射| baoyu777永久免费视频 | 免费播放在线日本感人片| 看全免费的一级毛片| 亚洲一区二区三区乱码在线欧洲|