2012-06-21 98 views
0

我創建了一個Web角色來使用Web Plaform Installer安裝PHP(順利運行沒有問題),並且我使用Eclipse創建了一個工作者角色來安裝MySql。 Eclipse會創建Mysql_WorkerRole.dll(其他人)。以下是我的.csdef文件在Windows Azure上安裝MySql(使用Eclipse)

<WebRole enableNativeCodeExecution="true" name="PhpMySqlWA_phpWebRole"> 
<Startup> 
    <Task commandLine="install-php.cmd" executionContext="elevated" taskType="background" /> 
</Startup> 
<Sites> 
    <Site name="MyPHPSite" physicalDirectory=".\PhpMySqlWA_phpWebRole"> 
    <Bindings> 
     <Binding name="HttpEndpoint" endpointName="HttpIn" /> 
    </Bindings> 
    </Site> 
</Sites> 
<Imports/> 
<Endpoints> 
    <InputEndpoint name="HttpIn" port="80" protocol="http"/> 
</Endpoints> 
<ConfigurationSettings> 
    <Setting name="StorageAccountName"/> 
    <Setting name="StorageAccountKey"/> 
    <Setting name="SqlAzureHost"/> 
    <Setting name="SqlAzureUserName"/> 
    <Setting name="SqlAzurePassword"/> 
    <Setting name="SqlAzureDatabase"/> 
    <Setting name="UseDataStorage"/> 
    <Setting name="UseDevelopmentStorage"/> 
    <Setting name="UseCloudStorage"/> 
    <Setting name="UseSqlAzure"/> 
    <Setting name="LogLevel"/> 
    <Setting name="ScheduledTransferPeriodInSeconds"/> 
    <Setting name="WindowsAzureStorageConnectionString"/> 
    <Setting name="XDrives"/> 
    <Setting name="XDrivesLocalCache"/> 
</ConfigurationSettings> 
</WebRole> 
<WorkerRole enableNativeCodeExecution="true" name="PhpMySqlWA_MysqlWorkerRole" vmsize="Medium"> 
<Imports> 
    <Import moduleName="RemoteAccess" /> 
    <Import moduleName="RemoteForwarder" /> 
</Imports> 
<LocalResources> 
    <LocalStorage cleanOnRoleRecycle="false" name="MySQL" sizeInMB="260"/> 
    <LocalStorage cleanOnRoleRecycle="false" name="MySQLDatastore" sizeInMB="60"/> 
</LocalResources> 
<ConfigurationSettings> 
    <Setting name="InitFile"/> 
    <Setting name="LogLevel"/> 
    <Setting name="ScheduledTransferPeriodInSeconds"/> 
    <Setting name="WindowsAzureStorageConnectionString"/> 
</ConfigurationSettings> 
<Endpoints> 
    <InternalEndpoint name="MySQL" protocol="tcp"/> 
</Endpoints> 
</WorkerRole> 

當我執行

cspack ServiceDefinition.csdef /generateConfigurationFile:ServiceConfiguration.cscfg /role:PhpMySqlWA_MysqlWorkerRole;PhpMySqlWA_MysqlWorkerRole;Mysql_WorkerRole.dll /role:PhpMySqlWA_phpWebRole;PhpMySqlWA_phpWebRole /copyonly 
and 
csrun ServiceDefinition.csx ServiceConfiguration.cscfg /launchbrowser 

兩個Web角色和輔助角色是綠色計算仿真,下面是我看到的輔助角色

[fabric] Role Instance: deployment17(63).PhpMySqlWA.PhpMySqlWA_MysqlWorkerRole.0 
[fabric] Role state Started 
[runtime] Role entrypoint . CALLING OnStart() 
[WaWorkerHost.exe] RoleEntryPoint.OnStart() 
[runtime] Role entrypoint . COMPLETED OnStart() 
[runtime] Role entrypoint . CALLING Run() 
Information: Mysql_WorkerRole entry point called 
Information: Copying folder mysql to C:/Users/ksaleh.CORP/AppData/Local/dftmp/Resources/d3fdb9aa- 67b5-4dad-9c50-0d5116ded0bc/directory/MySQL/ 
Information: Copying folder mysql\data to  C:/Users/ksaleh.CORP/AppData/Local/dftmp/Resources/d3fdb9aa-67b5-4dad-9c50-0d5116ded0bc/directory/MySQLDatastore/ 
Information: MySQLIP=127.255.0.0 
Information: MySQLPort=20001 
Information: Copy C:/Users/ksaleh.CORP/AppData/Local/dftmp/Resources/d3fdb9aa-67b5-4dad-9c50- 0d5116ded0bc/directory/MySQL/my.ini 
Information: Starting mysqld C:/Users/ksaleh.CORP/AppData/Local/dftmp/Resources/d3fdb9aa-67b5-4dad-9c50-0d5116ded0bc/directory/MySQL/bin/mysqld.exe 
Information: Arguments --init-file=C:\\Users\\ksaleh.CORP\\AppData\\Local\\dftmp\\Resources\\d3fdb9aa-67b5-4dad-9c50-0d5116ded0bc\\directory\\MySQL\\ 
Information: enter looping 
Information: Working 

我改變我connectDB.php使用127.255.0.0:20001作爲主機(如上),但它會產生「錯誤連接到數據庫!」。我檢查我的機器的事件查看器,發現錯誤:

C:/Users/myuser/AppData/Local/dftmp/Resources/d3fdb9aa-67b5-4dad-9c50-0d5116ded0bc/directory/MySQL/bin/mysqld.exe: unknown option '--skip-locking' 

和它說mysqlid.exe關閉完成

是否我真的mysql安裝localy(計算仿真器),如果是,爲什麼服務已停止? 爲什麼我不能連接數據庫?我如何檢查一切正常? 感謝您的建議。

+0

我不確定你是否仍然想使用Windows Azure Web/Worker角色,但如果你將使用Windows Azure WebSite並配置MySQL對於基於PHP的網站,您可以在幾個小時內完成整個工作。(我現在正在研究你的問題,並會在稍後添加更多信息) – AvkashChauhan

+0

我想使用Web/Worker角色的原因是我聽說和讀過Windows Azure上的虛擬機有時會被回收,並且我們必須照顧我們通過啓動腳本自動安裝Java/PHP/Mysql。我也讀過關於WA網站和觀看視頻。我覺得我很困惑,錯過了一些東西。 – user217648

回答

0

根據您的意見和使用Java/PHP/MySQL的要求,我可以建議最好的選擇是使用Windows Azure虛擬機,而不是使用Windows Azure工作者角色。

由於您不需要自動執行安裝腳本,因此Windows Azure虛擬機將比工作角色更適合您的項目,並且您可以管理和縮放它們相同的工作人員角色。你的配置是如下:

  1. 擁有的Windows Azure虛擬機(Linux或Windows)來配置你的PHP/Java實例
  2. 擁有的Windows Azure虛擬機(Linux或Windows)來配置你的MySQL實例

您可以通過RDP將虛擬機上的應用程序安裝/配置到Windows VM中的實例,並且可以使用Linux使用Putty來安裝/配置您的應用程序。這些虛擬機是持久的,所以所有的安裝都會持續下去,並且你不需要在這方面自動化任何事情。

如果您只需要更多資源,請向您的Web實例添加更多實例。我不確定如何照顧帶有多個實例的MySQL,這是您未來需要考慮的事情(包括Worker Role和Azure VM)。

這裏是起點使用的Windows Azure虛擬機與Java: https://www.windowsazure.com/en-us/develop/java/tutorials/tomcat-on-a-virtual-machine/

最後,如果我不得不在Java/PHP運行/ MySQL的項目,我寧願的Windows Azure虛擬機和(如果可能的話更換MySQL與SQL Azure,所以我不需要擔心數據庫的可伸縮性,但MySQL也是最好的選擇)

+0

好的,謝謝。如果我按照你的描述使用虛擬機。回收虛擬機時發生了什麼?我是否需要再次安裝和配置應用程序? – user217648

+0

不,Windows Azure虛擬機持續存在,因此您可以安裝任何內容而不用擔心丟失數據。在這裏瞭解更多信息:http://msdn.microsoft.com/en-us/library/windowsazure/jj156003 – AvkashChauhan

+0

我閱讀了您發送的文章,但仍不清楚100%是否適合med,誰將負責更新Windows Azure Virutal機器?如果我使用Windows Azure虛擬機,是否需要像所有其他主機公司一樣照顧它的更新?那麼與其他主機公司有什麼不同? – user217648