HTML5¼¼Êõ

C#ÂëÅ©µÄ´óÊý¾Ý֮· - ʹÓÃC#±àдMR×÷Òµ - hystar(2)

×ÖºÅ+ ×÷ÕߣºH5Ö®¼Ò À´Ô´£ºH5Ö®¼Ò 2017-06-08 08:00 ÎÒÒªÆÀÂÛ( )

ÒªÔËÐÐÕâ¸öʾÀý£¬ÐèÒªÔÚWindowsÉÏ°²×°Ç°ÃæÌáµ½µÄMicrosoft HDInsight Emulator for Windows Azure¡£Õâ¸ö¹¤¾ßÐèҪͨ¹ýMicrosoft Web Platform InstallerÀ´°²×°£¬ËÑË÷hdinsight£¬½á¹ûµÚÒ»Ïî¾ÍÊÇÎÒÃÇÒª°²×°µÄ¹¤¾ß£º µã

ÒªÔËÐÐÕâ¸öʾÀý£¬ÐèÒªÔÚWindowsÉÏ°²×°Ç°ÃæÌáµ½µÄMicrosoft HDInsight Emulator for Windows Azure¡£Õâ¸ö¹¤¾ßÐèҪͨ¹ýMicrosoft Web Platform InstallerÀ´°²×°£¬ËÑË÷hdinsight£¬½á¹ûµÚÒ»Ïî¾ÍÊÇÎÒÃÇÒª°²×°µÄ¹¤¾ß£º

µã»÷Ìí¼Ó - °²×°£¬ÄÍÐĵȺò¸ö°ëСʱ£¨ÐèÒªÏÂÔØ´óÔ¼1.2GµÄÎļþ£©

ÕâÆäÖÐ×îÖØÒªµÄ²¿·Ö¾ÍÊÇÓÃÓÚWindowsƽ̨µÄHDP(Hortonworks Data Platform for Windows)£¬ÆäËùʹÓõÄÊÇOpenJDK1.7µÄÒ»¸ö·ÖÖ§ - AZUL¹«Ë¾µÄZulu¡£

°²×°Íê³Éºó£¬×ÀÃæ»á¶à³ö3¸ö¿ì½Ý·½Ê½£º

Hadoop Command LineÊÇÒ»¸öÃüÁîÐеĿì½Ý·½Ê½£¬ÔÚÕâ¸ö¿ØÖÆ̨ÖÐÎÒÃÇ¿ÉÒÔÖ±½ÓʹÓÃÈçhadoop fsÕâÑùµÄÃüÁĬÈÏ°²×°Ï¿ØÖÆ̨½øÈëºóĿ¼ΪC:\hdp\hadoop-2.4.0.2.1.3.0-1981£¬hadoopµÈÓ¦ÓóÌÐò¾ÍÔÚÕâ¸öĿ¼ÏµÄbinĿ¼ÖС£
Õâ¸öĿ¼µÄÉϼ¶Ä¿Â¼ÖÐ(C:\hdp)°üº¬ÁËһЩÅú´¦Àí¼°PowerShell½Å±¾£¬ÎÒÃǾÍʹÓÃÆäÖеÄstart_local_hdp_services.cmdºÍstop_local_hdp_services.cmdÀ´ÆðÍ£Õâ¸öWindowsÉϵĴóÊý¾Ý¼¯Èº¡£
ÔËÐÐstart_local_hdp_services.cmdÊäÈëÏÂÃæµÄÐÅÏ¢±íʾÒѾ­³É¹¦Æô¶¯¡£

starting zkServer starting namenode starting secondarynamenode starting datanode starting resourcemanager starting timelineserver starting nodemanager starting jobhistoryserver starting hiveserver2 starting metastore starting derbyserver starting templeton starting oozieservice Sent all start commands. total services 13 running services 13

ÔËÐÐÁíÍâÁ½¸ö¿ì½Ý·½Ê½·Ö±ð¿ÉÒÔ¿´µ½HDFSºÍYARNµÄ״̬¡£
ΪÁËÔËÐкóÃæµÄ³ÌÐò£¬»¹ÐèÒª¸øHDFS´´½¨Ò»¸öÖ÷Ŀ¼

hadoop fs -mkdir -p /user/username #usernameÊǵ±Ç°µÇ½µÄWindowsÓû§Ãû ´´½¨²âÊÔÊý¾Ý²¢ÔËÐÐMRÈÎÎñ

ΪÁËÔËÐгÌÐò£¬Ê×ÏÈÏòHDFSÖÐÌí¼Ó²âÊÔÊäÈëÊý¾Ý¡£´´½¨Ò»¸öÎı¾Îļþinput.txt£¬Ã¿ÐÐÒ»¸öÊý×Ö£¬ÀàËÆ£º

9 16 25 36 81

½«¸ÃÎļþÉÏ´«µ½FisrtJobÖÐÅäÖõÄÄǸöĿ¼£º

hadoop fs -mkdir input hadoop fs -mkdir input/SqrtJob #Èç¹ûĿ¼²»´æÔÚ£¬ÏÈ´´½¨ hadoop fs -put input.txt input/SqrtJob/input.txt

ʣϵľÍÊDZàÒëÕâ¸ö³ÌÐò²¢Í¨¹ýMRRunnerÖ´ÐУ¬ÎÒÃDzâÊÔÏîÄ¿µÄÃû×ÖΪHadoopNet£¬±àÒëºóµÃµ½HadoopNet.exe¡£
ͨ¹ý´úÂë¿ÉÒÔ¿´µ½£¬ÎÒÃÇûÓÐÔÚMainº¯ÊýÖÐʵÏÖÈκδúÂ룬ÎÒÃÇÒª½éÉܵĵÚÒ»ÖÖÌá½»×÷ÒµµÄ·½Ê½ÊÇʹÓÃMRRunnerÀ´Ìá½»£¬½«Êä³öµÄexe×÷ΪdllʹÓã¬ÔËÐÐÏÂÃæµÄÃüÁ

MRRunner.exe -dll HadoopNET.exe

²»³öÒâÍâµÄ»°£¬MR»á¿ªÊ¼Ö´ÐС£Êä³öÖеÄÇ°°ë²¿·Ö²¿·ÖÄÚÈÝÊÇMRÖ´Ðйý³ÌÖеÄÈÕÖ¾¡£×îºó»á´òӡʵ¼ÊÌá½»µÄHadoopƽ̨µÄÃüÁMRRunnerµÄ×÷ÓÃÒ²¾ÍÔÚÓÚÉú³ÉÕâÑùµÄÒ»ÌõÃüÁî²¢½«ÆäÌá½»µ½Hadoop StreamingÀ´´¦Àí£º

>>CMD: C:\hdp\hadoop-2.4.0.2.1.3.0-1981\bin\hadoop.cmd jar C:\hdp\hadoop-2.4.0.2.1.3.0-1981\share\hadoop\tools\lib\hadoop-streaming-2.4.0.2.1.3.0-1981.jar -D "mapred.reduce.tasks=0" -D "mapred.map.max.attempts=1" -D "mapred.reduce.max.attempts=1" -files "hdfs:///user/username/dotnetcli/bbc29713-7dfb-4e33-944e-68a42230383c/app/HadoopNET.exe,hdfs:///user/username/dotnetcli/bbc29713-7dfb-4e33-944e-68a42230383c/app/Microsoft.Hadoop.MapReduce.dll,hdfs:///username/hystar/dotnetcli/bbc29713-7dfb-4e33-944e-68a42230383c/app/Microsoft.Hadoop.WebClient.dll,hdfs:///user/username/dotnetcli/bbc29713-7dfb-4e33-944e-68a42230383c/app/Newtonsoft.Json.dll,hdfs:///user/username/dotnetcli/bbc29713-7dfb-4e33-944e-68a42230383c/app/Microsoft.Hadoop.MapDriver.exe,hdfs:///user/username/dotnetcli/bbc29713-7dfb-4e33-944e-68a42230383c/app/Microsoft.Hadoop.ReduceDriver.exe,hdfs:///user/username/dotnetcli/bbc29713-7dfb-4e33-944e-68a42230383c/app/Microsoft.Hadoop.CombineDriver.exe,hdfs:///user/username/dotnetcli/bbc29713-7dfb-4e33-944e-68a42230383c/app/Microsoft.WindowsAzure.Management.Framework.Threading.dll" -input hdfs:///user/hystar/input/SqrtJob -output hdfs:///user/hystar/output/SqrtJob -mapper Microsoft.Hadoop.MapDriver.exe -reducer NONE -cmdenv "MSFT_HADOOP_MAPPER_DLL=HadoopNET.exe" -cmdenv "MSFT_HADOOP_MAPPER_TYPE=HadoopNET.FirstMapper"

ʹÓôúÂëÀ´Ìá½»MR×÷Òµ

ÁíÒ»¸öÔËÐÐMR³ÌÐòµÄ·½Ê½¾ÍÊÇʹÓôúÂ룬ÎÒÃÇÔÚMainº¯ÊýÖÐÌí¼ÓÈçÏ´úÂ룺

var hadoop = Hadoop.Connect(); hadoop.MapReduceJob.ExecuteJob<FirstJob>();

±àÒëÉú³ÉHadoopNET.exe¡£Õâ´ÎÎÒÃDz»ÐèÒªMRRunner¿ÉÒÔÖ±½ÓÔËÐÐHadoop.exe¡£
Ö´Ðйý³ÌºÍÖ´Ðнá¹û¶¼ÓëʹÓÃMRRunnerÒ»Ö¡£

×¢ÒâÕâ¸ö²âÊÔÓÃ;µÄ´óÊý¾Ýƽ̨£¬ÔÚMRÈÎÎñÊä³öĿ¼ÒÑ´æÔÚʱ»á×Ô¶¯½«Æäɾ³ý£¬¶ø²»ÊÇÏñÔ­ÉúHadoopƽ̨ÄÇÑùÓöµ½Êä³öĿ¼´æÔÚʱ±¨´í´¦Àí¡£

Microsoft.Azure.Management.HDInsight.Job

ºóÀ´£¬Î¢Èí¼¼Êõ·Ï߸ı䣬·ÏÆúÁËAzure Service Manager (ASM)-based toolsÖÐÒ»ÁÐЩ¹¤¾ß£¬°üÀ¨ÃüÁîÐÐCLI£¬PowerShell ºÍHDInsight .NET SDK£¨ÉÏһС½Ú½éÉܵÄMicrosoft.WindowsAzure.Management.HDInsightºÍMicrosoft.Hadoop.Client¶¼±»·ÏÆúÁË£©¡£È«ÃæתÏòAzure Resource ManagerËù°üº¬µÄһЩÁпâÓ빤¾ß¡£
ËäȻ΢Èí×ÜÊDZäÀ´±äÈ¥£¬µ«ÕâÒ²ÊÇΪÁËÓ­ºÏ¿ªÔ´ÉçÇø±ä»¯£¬ÒÔ¼°ÈÃ×ÔÉí²úÆ·¸üÓÐÌåϵ£¬¸üÓпÉÀ©Õ¹ÐÔµÄÎÞÄÎÖ®¾Ù¡£
ÐµĹ¤¾ßÖÐÓëMapReduceÏà¹ØµÄ¿âΪMicrosoft.Azure.Management.HDInsight.Jobϵ½Ò»ÏµÁÐÀà¡£²»Í¬ÓÚ֮ǰµÄ¿â£¬ÐµĿâÖ»ÊÇÌṩһÖÖͨ¹ý.NETƽ̨¼¼Êõ£¨°üÀ¨C#ÓëPowerShell£©À´Ìá½»MRÈÎÎñµÄ·½·¨¡£¶øûÓÐÔÙÌṩһЩ¸¨ÖúµÄÀàÓÃÓÚ±àдMRÈÎÎñ£¬ÐµÄMRÈÎÎñ±àдӦ¸ÃÊǽè¼øÁËPythonµÈÀûÓÃHadoop Streaming½øÐдóÊý¾Ý´¦ÀíµÄ·½·¨£¬½«MapºÍReduce·Ö±ð±àд³É¿ÉÒÔ¶ÀÁ¢Ö´ÐеijÌÐò£¬È»ºóÌá½»µ½Hadoop StreamingÈ¥Ö´ÐС£ÏÂÎÄ»á¸ø³öÒ»¸öʾÀý¡£
ʹÓÃ.NET C#±àдµÄMRÈÎÎñ£¬ÐèÒª»ùÓÚWindowsµÄAzure HDInsight»·¾³À´ÔËÐС£Õâ¸öĿǰûÓÐÄ£ÄâÆ÷£¬ËùÒÔÎÒÃÇʹÓÃÕæʵ»·¾³À´²âÊÔ¡£

ÕâÀïûÓÐʹÓÃÊÀ¼Í»¥ÁªÔËÓªµÄAzure£¬¶øÊÇʹÓÃÁËAzureÈ«Çò·þÎñ£¬µØÇøÑ¡ÔñÏã¸Û£¬¿ÉÒÔʹÓôó½µÄÊÖ»úºÅºÍ´ó½·¢ÐеÄVisa¿¨½øÐÐÑéÖ¤¼´¿É˳Àû¼¤»î1600HKDµÄÊÔÓöî¶È¡£

¡¡

1.±¾Õ¾×ñÑ­ÐÐÒµ¹æ·¶£¬ÈκÎתÔصĸå¼þ¶¼»áÃ÷È·±ê×¢×÷ÕߺÍÀ´Ô´£»2.±¾Õ¾µÄÔ­´´ÎÄÕ£¬ÇëתÔØʱÎñ±Ø×¢Ã÷ÎÄÕÂ×÷ÕߺÍÀ´Ô´£¬²»×ðÖØÔ­´´µÄÐÐΪÎÒÃǽ«×·¾¿ÔðÈΣ»3.×÷ÕßͶ¸å¿ÉÄܻᾭÎÒÃDZ༭Ð޸Ļò²¹³ä¡£

Ïà¹ØÎÄÕÂ
  • Êý¾Ý¿â±íÉè¼Æ£¬Ã»ÓÐ×îºÃÖ»ÓÐ×îÊʺϣ¨ÁÚ½Ó±í¡¢Â·¾¶Ã¶¾Ù¡¢Ç¶Ì×¼¯¡¢±Õ°ü±í£© - ССÇéÒâ

    Êý¾Ý¿â±íÉè¼Æ£¬Ã»ÓÐ×îºÃÖ»ÓÐ×îÊʺϣ¨ÁÚ½Ó±í¡¢Â·¾¶Ã¶¾Ù¡¢Ç¶Ì×¼¯¡¢±Õ°ü

    2017-06-08 08:00

  • HTML5±Ê¼Ç3¡ª¡ªWeb StorageºÍ±¾µØÊý¾Ý¿â - ×ÞÇí¿¡

    HTML5±Ê¼Ç3¡ª¡ªWeb StorageºÍ±¾µØÊý¾Ý¿â - ×ÞÇí¿¡

    2017-06-07 16:00

  • RedisÖеÄÊý¾Ý½á¹¹Óë³£ÓÃÃüÁî - Ñ©·Éºè

    RedisÖеÄÊý¾Ý½á¹¹Óë³£ÓÃÃüÁî - Ñ©·Éºè

    2017-06-04 11:03

  • ÿÌì4ÒÚÐÐSQLite¶©µ¥´óÊý¾Ý²âÊÔ£¨Ô´Â룩 - ´óʯͷ

    ÿÌì4ÒÚÐÐSQLite¶©µ¥´óÊý¾Ý²âÊÔ£¨Ô´Â룩 - ´óʯͷ

    2017-06-02 13:01

ÍøÓѵãÆÀ
·