ensky's

  • Me
  • Archive
  • feeds

Posts match “ cloud ” tag:

about 10 years ago

PHP on Windows Azure - Installation

前言

DataMining這門課第一次作業要建立FP Tree來分析Frequent Itemset,有分三部分:

  1. 單機版
  2. Map Reduce on Window Azure版本
  3. 第二版本改善效能(bonus) 由於筆者最擅長的語言是PHP,就打算用PHP撰寫之。

安裝

  1. 先照著這篇文章來安裝 PHP + Windows Azure SDK + SQL Server Express
  2. 再照著這篇文章來安裝 Windows Azure SDK for PHP 以及學習如何測試開發

試跑

上一步驟做完應該已經會產生package了,現在要來跑跑看,請參考這篇文章來用用看phpinfo();

安裝 Q & A

你可能會遇到一些神奇的問題

  • PHP 安裝失敗

很妙的是Microsoft Web Platform Installer他並不會自己幫你裝好IIS,你要去控制台->程式與功能->開啟或關閉windows功能把它設定成至少這樣才能開始安裝PHP

  • 404 Not Found

根據筆者的經驗,Microsoft Web Platform Installer安裝的php版本會是壞掉的(很妙,啊?),檢測方法是去C:\Program Files\PHP\v5.3\下點開php.exe和php-cgi.exe看會不會炸掉,
如果OK就可以,不行的話你可能要去PHP for Windows官網找5.3 Thread safe zip
請自行備份舊檔案,解壓縮新檔案到同一個資料夾,再把舊的php.ini複製進去新folder。

然後呢,你可能會繼續404 Not Found,此時很有可能是IIS並沒有自動幫你設定好FastCGI & enable PHP。

請進入控制台->系統管理工具->IIS管理員->FastCGI設定然後這樣設定



然後回到IIS管理員進去PHP管理區啟動PHP

之後看看行不行,不行就google看看囉,或看這裡搜尋404,至少我是這樣解決的。

Reference

  • http://azurephp.interoperabilitybridges.com/articles/setup-the-windows-azure-development-environment-automatically-with-the-microsoft-web-platform-installer
  • http://azurephp.interoperabilitybridges.com/articles/setup-the-windows-azure-sdk-for-php
  • http://azurephp.interoperabilitybridges.com/articles/build-and-deploy-a-windows-azure-php-application
  • 用worker: http://blogs.msdn.com/b/silverlining/archive/2011/10/04/support-for-worker-roles-in-the-windows-azure-sdk-for-php.aspx
  • 用table, blob, queue: http://azurephp.interoperabilitybridges.com/tagsearchresults/?tag=Storage
  • 好多教學: http://azurephp.interoperabilitybridges.com/tutorials
  • 微軟教學: http://msdn.microsoft.com/zh-tw/library/windowsazure/hh696549v=VS.103).aspx(
  • Note
  • cloud
  • php
  • Azure
  • April 21, 2012 06:10
  • Permalink
  • Comments
 
about 10 years ago

Running python on hadoop using dumbo

All in one link

其實官方wiki寫的很清楚了,
直接到那邊就可以看到如何安裝、如何測試等等。不過我這邊還是記錄一下我的步驟,以及我遇到的困難及解法。

Overview

既然是要做map-reduce,所以先來份code。

這份code裡面就是基本的word count,

function version

def mapper(key, value):
    for word in value.split():
        yield word, 1

def reducer(key, values):
    yield key, sum(values)

if __name__ == "__main__":
    import dumbo
    dumbo.run(mapper, reducer)

可以看到mapper function負責map, reducer function負責reduce,是透過dumbo.run來註冊。

class version

你也可以用class來做mapper和reduce的動作,就可以定義__init__在initilize的時候執行一次就好,減少一些overhead。

class Mapper:
    def __init__(self):
        file = open("excludes.txt", "r")
        self.excludes = set(line.strip() for line in file)
        file.close()
    def __call__(self, key, value):
        for word in value.split():
            if not word in self.excludes:
                yield word, 1

def reducer(key, values):
    yield key, sum(values)

if __name__ == "__main__":
    import dumbo
    dumbo.run(Mapper, reducer, reducer)

可以看到__init__是constructor,一開始會被執行一次;__call__是真正執行的function。

Installation

https://github.com/klbostee/dumbo/wiki/Building-and-installing

Note

若你打算使用國網中心的hadoop,直接看到virtual Python environment的解法即可。

Running

dumbo允許你單機進行測試,單基測完沒問題可以放到hadoop上測試,減少開發時間。

詳細說明
https://github.com/klbostee/dumbo/wiki/Running-programs

Notes

有關Running這邊實在吃了不少苦頭,於是把一些常見問題放在這裡以資各位參考。

  • 共同
    • 每次都要刪除舊檔案很麻煩 -> 參數加上 -overwrite yes
    • 出現Memory error -> 記憶體不足,因為預設的記憶體限制很小,參數加上 -memlimit 1073741824
  • Hadoop only
    • Output出現亂碼 -> 參數加上 -outputformat text
    • 只用到兩個mapper, 一個reducer -> 預設參數是這樣,要設定參數: -nummaptasks [a number]
  • Note
  • cloud
  • May 19, 2012 23:47
  • Permalink
  • Comments
 

Copyright © 2013 ensky . Powered by Logdown.
Based on work at subtlepatterns.com.