2012-06-21 101 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