0

我使用 Web Plaform Installer 创建了一个 Web 角色来安装 PHP(运行良好,没有问题),我使用 Eclipse 创建了一个 Worker 角色来安装 MySql。Eclipse 创建 Mysql_WorkerRole.dll(以及其他)。以下是我的 .csdef 文件

<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

Compute Emulator 中的 web 角色和 worker 角色都是绿色的,以下是我看到的 worker 角色

[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(计算模拟器),如果是,为什么服务停止了?为什么我无法连接数据库?我如何检查一切正常?谢谢你的建议。

4

1 回答 1

0

根据您的意见和您对使用 Java/PHP/MySQL 的要求,我建议最好的选择是使用 Windows Azure 虚拟机,而不是使用 Windows Azure Worker Role。

Windows Azure 虚拟机将比您的项目的 Worker 角色更具优势,因为您不需要自动化安装脚本,并且您可以管理和扩展它们相同的 Worker 角色。您的配置如下:

  1. 拥有一个 Windows Azure VM(Linux 或 Windows)来配置您的 PHP/Java 实例
  2. 拥有一个 Windows Azure VM(Linux 或 Windows)来配置您的 MySQL 实例

您可以通过 RDP 将虚拟机上的应用程序安装/配置到 Windows VM 中的实例,在 Linux 上,您可以使用 Putty 安装/配置您的应用程序。这些虚拟机是耐用的,因此所有安装都将持续存在,您不需要在这方面自动化任何事情。

当您只需要更多资源时,将更多实例添加到您的 Web 实例。我不确定如何处理具有多个实例的 MySQL,这是您未来需要考虑的事情(同时使用 Worker Role 和 Azure VM)。

以下是使用带有 Java 的 Windows Azure VM 的起点: https ://www.windowsazure.com/en-us/develop/java/tutorials/tomcat-on-a-virtual-machine/

最后,如果我必须从事 Java/PHP/MySQL 项目,我更喜欢 Windows Azure 虚拟机和(如果可能的话,用 SQL Azure 替换 MySQL,所以我不需要担心数据库的可扩展性,但 MySQL 也是最佳选择)

于 2012-06-21T20:35:02.997 回答