ÒªÔËÐÐÕâ¸öʾÀý£¬ÐèÒªÔÚ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ÊäÈëÏÂÃæµÄÐÅÏ¢±íʾÒѾ³É¹¦Æô¶¯¡£
ÔËÐÐÁíÍâÁ½¸ö¿ì½Ý·½Ê½·Ö±ð¿ÉÒÔ¿´µ½HDFSºÍYARNµÄ״̬¡£
ΪÁËÔËÐкóÃæµÄ³ÌÐò£¬»¹ÐèÒª¸øHDFS´´½¨Ò»¸öÖ÷Ŀ¼
ΪÁËÔËÐгÌÐò£¬Ê×ÏÈÏò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ʹÓã¬ÔËÐÐÏÂÃæµÄÃüÁ
²»³öÒâÍâµÄ»°£¬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µÄÊÔÓöî¶È¡£
¡¡