我创建了一个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(计算仿真器),如果是,为什么服务已停止? 为什么我不能连接数据库?我如何检查一切正常? 感谢您的建议。
我不确定你是否仍然想使用Windows Azure Web/Worker角色,但如果你将使用Windows Azure WebSite并配置MySQL对于基于PHP的网站,您可以在几个小时内完成整个工作。(我现在正在研究你的问题,并会在稍后添加更多信息) – AvkashChauhan
我想使用Web/Worker角色的原因是我听说和读过Windows Azure上的虚拟机有时会被回收,并且我们必须照顾我们通过启动脚本自动安装Java/PHP/Mysql。我也读过关于WA网站和观看视频。我觉得我很困惑,错过了一些东西。 – user217648