Я пытаюсь использовать службу ClearDB в своем приложении PHP для Symfony 3, которое размещено в IBM Bluemix. я имею
успешно связал сервис Cleardb с приложением и получил учетные данные, собранные с панели управления Bluemix.
Однако во время загрузки приложения (cf push) возникает ошибка:
Произошло исключение в драйвере:
SQLSTATE[HY000] [1045] Access denied for user 'bf655aa76ba65b'@'ip-10-139-25-93.ec2.internal' (using password:
YES)
[Doctrine\DBAL\Driver\PDOException]
SQLSTATE[HY000] [1045] Access denied for user
'bf655aa76ba65b'@'ip-10-139-25-93.ec2.internal' (using password: YES)
Я связался со службой поддержки ClearDB, и они подтвердили, что моя учетная запись включена и у нее есть все привилегии.
я использую https://github.com/cloudfoundry/php-buildpack
Вот полный журнал ошибок:
2016-06-20T22:58:00.69+0200 [API/0] OUT Updated app with guid 3ddcce14-6aa2-421c-bb8b-1b29b03265be ({"name"=>"qtogo-admin", "memory"=>128, "buildpack"=>"https://github.com/cloudfoundry/php-buildpack", "environment_json"=>"PRIVATE DATA HIDDEN"})
2016-06-20T22:58:40.46+0200 [API/2] OUT Updated app with guid 3ddcce14-6aa2-421c-bb8b-1b29b03265be ({"state"=>"STOPPED"})
2016-06-20T22:58:42.78+0200 [DEA/191] OUT Got staging request for app with id 3ddcce14-6aa2-421c-bb8b-1b29b03265be
2016-06-20T22:58:48.19+0200 [API/1] OUT Updated app with guid 3ddcce14-6aa2-421c-bb8b-1b29b03265be ({"state"=>"STARTED"})
2016-06-20T22:58:49.56+0200 [STG/191] OUT -----> Downloaded app package (43M)
2016-06-20T22:58:50.17+0200 [STG/0] ERR Cloning into '/tmp/buildpacks/php-buildpack'...
2016-06-20T22:58:59.13+0200 [STG/0] OUT Submodule 'compile-extensions' (https://github.com/cloudfoundry/compile-extensions) registered for path 'compile-extensions'
2016-06-20T22:58:59.20+0200 [STG/0] ERR Cloning into 'compile-extensions'...
2016-06-20T22:59:01.18+0200 [STG/0] OUT Submodule path 'compile-extensions': checked out '4a0e48afc46c1d467b7c75a8ae5e6f3a044d3d64'
2016-06-20T22:59:01.51+0200 [STG/0] OUT -------> Buildpack version 4.3.14
2016-06-20T22:59:01.59+0200 [STG/0] OUT Installing HTTPD
2016-06-20T22:59:05.22+0200 [STG/0] OUT Downloaded [https://pivotal-buildpacks.s3.amazonaws.com/concourse-binaries/httpd/httpd-2.4.20-linux-x64.tgz] to [/tmp]
2016-06-20T22:59:05.50+0200 [STG/0] OUT WARNING: A version of PHP has been specified in both `composer.json` and `./bp-config/options.json`.
2016-06-20T22:59:05.50+0200 [STG/0] OUT WARNING: The version defined in `composer.json` will be used.
2016-06-20T22:59:05.50+0200 [STG/0] OUT Installing PHP
2016-06-20T22:59:05.50+0200 [STG/0] OUT PHP 5.5.36
2016-06-20T22:59:30.02+0200 [STG/0] OUT Downloaded [https://pivotal-buildpacks.s3.amazonaws.com/concourse-binaries/php/php-5.5.36-linux-x64-1464282808.tgz] to [/tmp]
2016-06-20T22:59:41.48+0200 [STG/0] OUT Downloaded [https://pivotal-buildpacks.s3.amazonaws.com/concourse-binaries/php/php-5.5.36-linux-x64-1464282808.tgz] to [/tmp]
2016-06-20T22:59:45.01+0200 [STG/0] OUT Downloaded [https://pivotal-buildpacks.s3.amazonaws.com/php/binaries/trusty/composer/1.1.2/composer.phar] to [/tmp]
2016-06-20T22:59:45.01+0200 [STG/0] OUT PROTIP: Include a `composer.lock` file with your application! This will make sure the exact same version of dependencies are used when you deploy to CloudFoundry.
2016-06-20T22:59:45.03+0200 [STG/0] ERR % Total % Received % Xferd Average Speed Time Time Time Current
2016-06-20T22:59:45.04+0200 [STG/0] ERR Dload Upload Total Spent Left Speed
2016-06-20T22:59:45.45+0200 [STG/0] ERR
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
100 283 100 283 0 0 674 0 --:--:-- --:--:-- --:--:-- 675
2016-06-20T22:59:45.68+0200 [STG/0] ERR Loading composer repositories with package information
2016-06-20T22:59:45.82+0200 [STG/0] ERR Updating dependencies
2016-06-20T23:00:26.42+0200 [STG/0] ERR - Installing doctrine/cache (v1.6.0)
2016-06-20T23:00:26.42+0200 [STG/0] ERR Downloading
2016-06-20T23:00:29.32+0200 [STG/0] ERR - Installing doctrine/inflector (v1.1.0)
2016-06-20T23:00:29.32+0200 [STG/0] ERR Downloading
2016-06-20T23:00:31.37+0200 [STG/0] ERR - Installing symfony/polyfill-util (v1.2.0)
2016-06-20T23:00:31.37+0200 [STG/0] ERR Downloading
2016-06-20T23:00:33.46+0200 [STG/0] ERR - Installing paragonie/random_compat (v2.0.2)
2016-06-20T23:00:33.46+0200 [STG/0] ERR Downloading
2016-06-20T23:00:35.52+0200 [STG/0] ERR - Installing symfony/polyfill-php70 (v1.2.0)
2016-06-20T23:00:35.52+0200 [STG/0] ERR Downloading
2016-06-20T23:00:37.45+0200 [STG/0] ERR - Installing symfony/polyfill-php56 (v1.2.0)
2016-06-20T23:00:37.45+0200 [STG/0] ERR Downloading
2016-06-20T23:00:39.55+0200 [STG/0] ERR - Installing symfony/polyfill-mbstring (v1.2.0)
2016-06-20T23:00:39.55+0200 [STG/0] ERR Downloading
2016-06-20T23:00:41.59+0200 [STG/0] ERR - Installing symfony/symfony (v3.1.1)
2016-06-20T23:00:41.59+0200 [STG/0] ERR Downloading
2016-06-20T23:00:47.72+0200 [STG/0] ERR - Installing symfony/polyfill-intl-icu (v1.2.0)
2016-06-20T23:00:47.72+0200 [STG/0] ERR Downloading
2016-06-20T23:00:49.68+0200 [STG/0] ERR - Installing psr/log (1.0.0)
2016-06-20T23:00:49.68+0200 [STG/0] ERR Downloading
2016-06-20T23:00:51.75+0200 [STG/0] ERR - Installing psr/cache (1.0.0)
2016-06-20T23:00:51.75+0200 [STG/0] ERR Downloading
2016-06-20T23:00:53.96+0200 [STG/0] ERR - Installing twig/twig (v1.24.1)
2016-06-20T23:00:53.96+0200 [STG/0] ERR Downloading
2016-06-20T23:00:56.79+0200 [STG/0] ERR - Installing doctrine/lexer (v1.0.1)
2016-06-20T23:00:56.79+0200 [STG/0] ERR Downloading
2016-06-20T23:00:58.75+0200 [STG/0] ERR - Installing doctrine/annotations (v1.2.7)
2016-06-20T23:00:58.75+0200 [STG/0] ERR Downloading
2016-06-20T23:01:00.76+0200 [STG/0] ERR - Installing doctrine/collections (v1.3.0)
2016-06-20T23:01:00.76+0200 [STG/0] ERR Downloading
2016-06-20T23:01:02.94+0200 [STG/0] ERR - Installing doctrine/common (v2.6.1)
2016-06-20T23:01:02.94+0200 [STG/0] ERR Downloading
2016-06-20T23:01:05.41+0200 [STG/0] ERR - Installing doctrine/doctrine-cache-bundle (1.3.0)
2016-06-20T23:01:05.41+0200 [STG/0] ERR Downloading
2016-06-20T23:01:07.63+0200 [STG/0] ERR - Installing jdorn/sql-formatter (v1.2.17)
2016-06-20T23:01:07.63+0200 [STG/0] ERR Downloading
2016-06-20T23:01:09.79+0200 [STG/0] ERR - Installing doctrine/dbal (v2.5.4)
2016-06-20T23:01:09.79+0200 [STG/0] ERR Downloading
2016-06-20T23:01:12.26+0200 [STG/0] ERR - Installing doctrine/doctrine-bundle (1.6.3)
2016-06-20T23:01:12.26+0200 [STG/0] ERR Downloading
2016-06-20T23:01:14.70+0200 [STG/0] ERR - Installing doctrine/instantiator (1.0.5)
2016-06-20T23:01:14.70+0200 [STG/0] ERR Downloading
2016-06-20T23:01:16.77+0200 [STG/0] ERR - Installing doctrine/orm (v2.5.4)
2016-06-20T23:01:16.77+0200 [STG/0] ERR Downloading
2016-06-20T23:01:19.39+0200 [STG/0] ERR - Installing th3mouk/doctrine-table-prefix-bundle (1.0.1)
2016-06-20T23:01:19.39+0200 [STG/0] ERR Downloading
2016-06-20T23:01:21.30+0200 [STG/0] ERR - Installing willdurand/jsonp-callback-validator (v1.1.0)
2016-06-20T23:01:21.30+0200 [STG/0] ERR Downloading
2016-06-20T23:01:23.18+0200 [STG/0] ERR - Installing friendsofsymfony/jsrouting-bundle (1.6.0)
2016-06-20T23:01:23.18+0200 [STG/0] ERR Downloading
2016-06-20T23:01:25.32+0200 [STG/0] ERR - Installing phpoption/phpoption (1.5.0)
2016-06-20T23:01:25.32+0200 [STG/0] ERR Downloading
2016-06-20T23:01:27.22+0200 [STG/0] ERR - Installing phpcollection/phpcollection (0.4.0)
2016-06-20T23:01:27.22+0200 [STG/0] ERR Downloading
2016-06-20T23:01:29.27+0200 [STG/0] ERR - Installing jms/parser-lib (1.0.0)
2016-06-20T23:01:29.27+0200 [STG/0] ERR Downloading
2016-06-20T23:01:31.18+0200 [STG/0] ERR - Installing jms/metadata (1.5.1)
2016-06-20T23:01:31.18+0200 [STG/0] ERR Downloading
2016-06-20T23:01:33.31+0200 [STG/0] ERR - Installing jms/serializer (1.1.0)
2016-06-20T23:01:33.31+0200 [STG/0] ERR Downloading
2016-06-20T23:01:35.89+0200 [STG/0] ERR - Installing jms/serializer-bundle (1.1.0)
2016-06-20T23:01:35.89+0200 [STG/0] ERR Downloading
2016-06-20T23:01:38.22+0200 [STG/0] ERR - Installing kriswallsmith/buzz (v0.15)
2016-06-20T23:01:38.22+0200 [STG/0] ERR Downloading
2016-06-20T23:01:40.36+0200 [STG/0] ERR - Installing richsage/rms-push-notifications-bundle (dev-master 324b294)
2016-06-20T23:01:40.36+0200 [STG/0] ERR Cloning 324b29431ad58a006f53891cb103fad65c23d948
2016-06-20T23:01:44.96+0200 [STG/0] ERR - Installing friendsofsymfony/user-bundle (dev-master d1fccc6)
2016-06-20T23:01:44.96+0200 [STG/0] ERR Cloning d1fccc6335b74beca94525551cacc06b256ed261
2016-06-20T23:01:52.54+0200 [STG/0] ERR - Installing nelmio/cors-bundle (1.4.1)
2016-06-20T23:01:52.54+0200 [STG/0] ERR Downloading
2016-06-20T23:01:54.47+0200 [STG/0] ERR - Installing incenteev/composer-parameter-handler (v2.1.2)
2016-06-20T23:01:54.47+0200 [STG/0] ERR Downloading
2016-06-20T23:01:56.56+0200 [STG/0] ERR - Installing swiftmailer/swiftmailer (v5.4.2)
2016-06-20T23:01:56.56+0200 [STG/0] ERR Downloading
2016-06-20T23:01:59.03+0200 [STG/0] ERR - Installing symfony/swiftmailer-bundle (v2.3.11)
2016-06-20T23:01:59.03+0200 [STG/0] ERR Downloading
2016-06-20T23:02:01.22+0200 [STG/0] ERR - Installing monolog/monolog (1.19.0)
2016-06-20T23:02:01.22+0200 [STG/0] ERR Downloading
2016-06-20T23:02:03.65+0200 [STG/0] ERR - Installing symfony/monolog-bundle (2.11.1)
2016-06-20T23:02:03.65+0200 [STG/0] ERR Downloading
2016-06-20T23:02:05.83+0200 [STG/0] ERR - Installing sensiolabs/security-checker (v3.0.2)
2016-06-20T23:02:05.84+0200 [STG/0] ERR Downloading
2016-06-20T23:02:07.88+0200 [STG/0] ERR - Installing sensio/distribution-bundle (v5.0.6)
2016-06-20T23:02:07.88+0200 [STG/0] ERR Downloading
2016-06-20T23:02:09.95+0200 [STG/0] ERR - Installing sensio/framework-extra-bundle (v3.0.16)
2016-06-20T23:02:09.96+0200 [STG/0] ERR Downloading
2016-06-20T23:02:12.08+0200 [STG/0] ERR - Installing zendframework/zend-eventmanager (3.0.1)
2016-06-20T23:02:12.08+0200 [STG/0] ERR Downloading
2016-06-20T23:02:14.43+0200 [STG/0] ERR - Installing zendframework/zend-code (2.6.3)
2016-06-20T23:02:14.43+0200 [STG/0] ERR Downloading
2016-06-20T23:02:16.67+0200 [STG/0] ERR - Installing ocramius/proxy-manager (1.0.2)
2016-06-20T23:02:19.20+0200 [STG/0] ERR - Installing doctrine/migrations (1.4.1)
2016-06-20T23:02:19.20+0200 [STG/0] ERR Downloading
2016-06-20T23:02:21.39+0200 [STG/0] ERR - Installing doctrine/doctrine-migrations-bundle (1.1.1)
2016-06-20T23:02:21.39+0200 [STG/0] ERR Downloading
2016-06-20T23:02:23.42+0200 [STG/0] ERR - Installing kriswallsmith/assetic (v1.3.2)
2016-06-20T23:02:23.42+0200 [STG/0] ERR Downloading
2016-06-20T23:02:25.60+0200 [STG/0] ERR - Installing symfony/assetic-bundle (v2.8.0)
2016-06-20T23:02:25.60+0200 [STG/0] ERR Downloading
2016-06-20T23:02:27.78+0200 [STG/0] ERR - Installing vich/uploader-bundle (1.1.0)
2016-06-20T23:02:27.78+0200 [STG/0] ERR Downloading
2016-06-20T23:02:29.83+0200 [STG/0] ERR - Installing willdurand/negotiation (1.5.0)
2016-06-20T23:02:29.83+0200 [STG/0] ERR Downloading
2016-06-20T23:02:31.91+0200 [STG/0] ERR - Installing friendsofsymfony/rest-bundle (1.7.7)
2016-06-20T23:02:31.91+0200 [STG/0] ERR Downloading
2016-06-20T23:02:37.32+0200 [STG/0] ERR Writing lock file
2016-06-20T23:02:37.32+0200 [STG/0] ERR Generating autoload files
2016-06-20T23:02:37.36+0200 [STG/0] ERR > Incenteev\ParameterHandler\ScriptHandler::buildParameters
2016-06-20T23:02:37.37+0200 [STG/0] OUT Creating the "app/config/parameters.yml" file
2016-06-20T23:02:37.38+0200 [STG/0] ERR > Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
2016-06-20T23:02:37.91+0200 [STG/0] ERR > Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache
2016-06-20T23:02:39.45+0200 [STG/0] OUT [Doctrine\DBAL\Exception\ConnectionException]
2016-06-20T23:02:39.45+0200 [STG/0] OUT An exception occured in driver: SQLSTATE[HY000] [1045] Access denied for user 'bf655aa76ba65b'@'ip-10-139-25-93.ec2.internal' (using password: YES)
2016-06-20T23:02:39.49+0200 [STG/0] OUT [Doctrine\DBAL\Driver\PDOException]
2016-06-20T23:02:39.49+0200 [STG/0] OUT SQLSTATE[HY000] [1045] Access denied for user 'bf655aa76ba65b'@'ip-10-139-25-93.ec2.internal' (using password: YES)
2016-06-20T23:02:39.51+0200 [STG/0] OUT [PDOException]
2016-06-20T23:02:39.51+0200 [STG/0] OUT SQLSTATE[HY000] [1045] Access denied for user 'bf655aa76ba65b'@'ip-10-139-25-93.ec2.internal' (using password: YES)
2016-06-20T23:02:39.57+0200 [STG/0] ERR Script Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache handling the post-update-cmd event terminated with an exception
2016-06-20T23:02:40.03+0200 [STG/0] ERR [RuntimeException]
2016-06-20T23:02:40.03+0200 [STG/0] ERR An error occurred when executing the "'cache:clear --no-warmup'" command:
2016-06-20T23:02:40.03+0200 [STG/0] ERR [Doctrine\DBAL\Exception\ConnectionException]
2016-06-20T23:02:40.03+0200 [STG/0] ERR An exception occured in driver: SQLSTATE[HY000] [1045] Access denied for user 'bf655aa76ba65b'@'ip-10-139-25-93.ec2.internal' (using password: YES)
2016-06-20T23:02:40.03+0200 [STG/0] ERR [Doctrine\DBAL\Driver\PDOException]
2016-06-20T23:02:40.03+0200 [STG/0] ERR SQLSTATE[HY000] [1045] Access denied for user 'bf655aa76ba65b'@'ip-10-139-25-93.ec2.internal' (using password: YES)
2016-06-20T23:02:40.03+0200 [STG/0] ERR [PDOException]
2016-06-20T23:02:40.03+0200 [STG/0] ERR SQLSTATE[HY000] [1045] Access denied for user 'bf655aa76ba65b'@'ip-10-139-25-93.ec2.internal' (using password: YES)
2016-06-20T23:02:40.03+0200 [STG/0] ERR .
2016-06-20T23:02:40.03+0200 [STG/0] ERR install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--ignore-platform-reqs] [--] [<packages>]...
2016-06-20T23:02:40.74+0200 [STG/0] OUT -----> Composer command failed
2016-06-20T23:02:40.75+0200 [STG/0] ERR Traceback (most recent call last):
2016-06-20T23:02:40.75+0200 [STG/0] ERR File "/tmp/buildpacks/php-buildpack/scripts/compile.py", line 50, in <module>
2016-06-20T23:02:40.75+0200 [STG/0] ERR .from_build_pack('lib/additional_commands')
2016-06-20T23:02:40.75+0200 [STG/0] ERR File "/tmp/buildpacks/php-buildpack/lib/build_pack_utils/builder.py", line 208, in extensions
2016-06-20T23:02:40.75+0200 [STG/0] ERR process_extension(path, ctx, 'compile', process, args=[self])
2016-06-20T23:02:40.75+0200 [STG/0] ERR File "/tmp/buildpacks/php-buildpack/lib/build_pack_utils/utils.py", line 69, in process_extension
2016-06-20T23:02:40.75+0200 [STG/0] ERR success(getattr(extn, to_call)(*args))
2016-06-20T23:02:40.75+0200 [STG/0] ERR File "/tmp/buildpacks/php-buildpack/extensions/composer/extension.py", line 412, in compile
2016-06-20T23:02:40.75+0200 [STG/0] ERR return composer.compile(install)
2016-06-20T23:02:40.75+0200 [STG/0] ERR File "/tmp/buildpacks/php-buildpack/lib/extension_helpers.py", line 154, in compile
2016-06-20T23:02:40.75+0200 [STG/0] ERR self._compile(install)
2016-06-20T23:02:40.75+0200 [STG/0] ERR File "/tmp/buildpacks/php-buildpack/extensions/composer/extension.py", line 179, in _compile
2016-06-20T23:02:40.75+0200 [STG/0] ERR self.run()
2016-06-20T23:02:40.75+0200 [STG/0] ERR File "/tmp/buildpacks/php-buildpack/extensions/composer/extension.py", line 314, in run
2016-06-20T23:02:40.75+0200 [STG/0] ERR *self._ctx['COMPOSER_INSTALL_OPTIONS'])
2016-06-20T23:02:40.75+0200 [STG/0] ERR File "/tmp/buildpacks/php-buildpack/extensions/composer/extension.py", line 358, in run
2016-06-20T23:02:40.75+0200 [STG/0] ERR shell=True)
2016-06-20T23:02:40.75+0200 [STG/0] ERR File "/tmp/buildpacks/php-buildpack/lib/build_pack_utils/runner.py", line 109, in stream_output
2016-06-20T23:02:40.75+0200 [STG/0] ERR raise CalledProcessError(retcode, cmd)
2016-06-20T23:02:40.75+0200 [STG/0] ERR build_pack_utils.runner.CalledProcessError: Command '<open file '<fdopen>', mode 'w' at 0x7f875028b8a0>' returned non-zero exit status 1
2016-06-20T23:02:40.77+0200 [STG/0] OUT Staging failed: Buildpack compilation step failed
2016-06-20T23:02:41.03+0200 [API/1] ERR encountered error: App staging failed in the buildpack compile phase
С большой поддержкой Bluemix я наконец понял это. Вы не можете жестко закодировать свои учетные данные parameters.yml.dist Вместо этого вы должны загрузить его динамически.
Мое решение состоит в том, чтобы создать собственный файл bluemix.php с параметрами, загруженными из переменной vcap, например:
<?php
// load default parameters when working on local environment
if( empty($vcap_services = json_decode($_ENV["VCAP_SERVICES" ]) ) ) {
$container->setParameter('database_host', '127.0.0.1');
// ...
}
// load credentials from cleardb service
else {
$db = $vcap_services->{'cleardb'}[0]->credentials;
$container->setParameter('database_host', $db->hostname);
$container->setParameter('database_port', $db->port);
$container->setParameter('database_name', $db->name);
$container->setParameter('database_user', $db->username);
$container->setParameter('database_password', $db->password);
}
// common parameters
$container->setParameter('mailer_transport', 'smtp');
// ...
затем загрузите ваши ресурсы в config.yml или config_prod.yml, вот так:
imports:
- { resource: bluemix.php }
# ...
Я вижу это в журнале:
Cr[STG/0] OUT Creating the "app/config/parameters.yml" file
Что композитор делает, это использует app/config/parameters.yml.dist
создать новый файл parameters.yml во время обновления композитора. Таким образом, вы хотите зайти в ваш parameters.yml.dist и установить все правильные значения, которые вы планируете использовать (то есть database_password).