我已將 Symfony 演示應用程式配置從 SQLite 更改為 MySQL。在本地它對我來說很好,但如果我嘗試在 Google App Engine 標準環境中部署它,它就不起作用。
如果資料庫在 Google Cloud SQL 中,我不清楚應該如何放置連接字串。目前該專案的.env
檔案有這個:
DATABASE_URL="mysql://dbname=THEDATABASENAME;unix_socket=PROJECTNAME:ZONE:INSTANCENAME"
我不確定它是否正確,或者是否缺少某些內容,或者我是否需要在 Symfony 或 Google Cloud Console 中配置其他內容。
當我部署并瀏覽到該站點時,我遇到了錯誤 500。
錯誤日志顯示:
2022-11-02 14:41:00 default[20221102t151407] "GET / HTTP/1.1" 302
2022-11-02 14:41:01 default[20221102t151407] nginx: [warn] the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /tmp/google-config/nginx.conf:3
2022-11-02 14:41:03 default[20221102t151407] "GET /es HTTP/1.1" 200
2022-11-02 14:41:03 default[20221102t151407] "GET /build/app.c5bd2611.js HTTP/1.1" 200
2022-11-02 14:41:03 default[20221102t151407] "GET /build/runtime.725dd7e0.js HTTP/1.1" 200
2022-11-02 14:41:03 default[20221102t151407] "GET /build/755.5a8586e9.js HTTP/1.1" 200
2022-11-02 14:41:03 default[20221102t151407] "GET /build/95.1ed6b32f.js HTTP/1.1" 200
2022-11-02 14:41:03 default[20221102t151407] "GET /build/app.17316efd.css HTTP/1.1" 200
2022-11-02 14:41:03 default[20221102t151407] "GET /build/fonts/fa-solid-900.1551f4f6.woff2 HTTP/1.1" 200
2022-11-02 14:41:03 default[20221102t151407] "GET /build/fonts/fa-regular-400.7a333762.woff2 HTTP/1.1" 200
2022-11-02 14:41:03 default[20221102t151407] "GET /build/95.22c66ae4.css HTTP/1.1" 200
2022-11-02 14:41:03 default[20221102t151407] "GET /build/823.168b723b.js HTTP/1.1" 200
2022-11-02 14:41:03 default[20221102t151407] "GET /build/31.46aa6824.js HTTP/1.1" 200
2022-11-02 14:41:03 default[20221102t151407] "GET /build/fonts/lato-bold.21b3848a.woff2 HTTP/1.1" 200
2022-11-02 14:41:03 default[20221102t151407] "GET /build/fonts/lato-normal.75614cfc.woff2 HTTP/1.1" 200
2022-11-02 14:41:08 default[20221102t151407] "GET /es/blog/ HTTP/1.1" 500
2022-11-02 14:41:09 default[20221102t151407] [02-Nov-2022 14:41:09] WARNING: [pool app] child 20 said into stderr: "{"message":"Matched route \"blog_index\".","context":{"route":"blog_index","route_parameters":{"_route":"blog_index","page":"1","_format":"html","_controller":"App\\Controller\\BlogController::index","_locale":"es"},"request_uri":"https://testMYPROJECT.uc.r.appspot.com/es/blog/","method":"GET"},"level":200,"level_name":"INFO","channel":"request","datetime":"2022-11-02T14:41:08.499913 00:00","extra":{}}"
2022-11-02 14:41:09 default[20221102t151407] [02-Nov-2022 14:41:09] WARNING: [pool app] child 20 said into stderr: "{"message":"Checking for authenticator support.","context":{"firewall_name":"main","authenticators":1},"level":100,"level_name":"DEBUG","channel":"security","datetime":"2022-11-02T14:41:08.500353 00:00","extra":{}}"
2022-11-02 14:41:09 default[20221102t151407] [02-Nov-2022 14:41:09] WARNING: [pool app] child 20 said into stderr: "{"message":"Checking support on authenticator.","context":{"firewall_name":"main","authenticator":"Symfony\\Component\\Security\\Http\\Authenticator\\FormLoginAuthenticator"},"level":100,"level_name":"DEBUG","channel":"security","datetime":"2022-11-02T14:41:08.500361 00:00","extra":{}}"
2022-11-02 14:41:09 default[20221102t151407] [02-Nov-2022 14:41:09] WARNING: [pool app] child 20 said into stderr: "{"message":"Authenticator does not support the request.","context":{"firewall_name":"main","authenticator":"Symfony\\Component\\Security\\Http\\Authenticator\\FormLoginAuthenticator"},"level":100,"level_name":"DEBUG","channel":"security","datetime":"2022-11-02T14:41:08.500367 00:00","extra":{}}"
2022-11-02 14:41:09 default[20221102t151407] [02-Nov-2022 14:41:09] WARNING: [pool app] child 20 said into stderr: "{"message":"Failed to save key \"App\Controller\BlogController\" of type array: fopen(/workspace/var/cache/prod/pools/system/qGYD7CGfrN/d7b0f5b96ec8): Failed to open stream: Read-only file system","context":{"key":"App\Controller\BlogController","exception":{"class":"ErrorException","message":"fopen(/workspace/var/cache/prod/pools/system/qGYD7CGfrN/d7b0f5b96ec8): Failed to open stream: Read-only file system","code":0,"file":"/workspace/vendor/symfony/cache/Traits/FilesystemCommonTrait.php:99"},"cache-adapter":"Symfony\\Component\\Cache\\Adapter\\PhpFilesAdapter"},"level":300,"level_name":"WARNING","channel":"cache","datetime":"2022-11-02T14:41:08.528050 00:00","extra":{}}"
2022-11-02 14:41:09 default[20221102t151407] [02-Nov-2022 14:41:09] WARNING: [pool app] child 20 said into stderr: "{"message":"Failed to save key \"ea12799f***********\" of type Doctrine\\ORM\\Query\\ParserResult: fopen(/workspace/var/cache/prod/pools/system/16ctGUzn1Q/774b86986a15): Failed to open stream: No such file or directory","context":{"key":"ea12799f**********","exception":{"class":"ErrorException","message":"fopen(/workspace/var/cache/prod/pools/system/16ctGU**********): Failed to open stream: No such file or directory","code":0,"file":"/workspace/vendor/symfony/cache/Traits/FilesystemCommonTrait.php:99"},"cache-adapter":"Symfony\\Component\\Cache\\Adapter\\PhpFilesAdapter"},"level":300,"level_name":"WARNING","channel":"cache","datetime":"2022-11-02T14:41:09.092063 00:00","extra":{}}"
2022-11-02 14:41:09 default[20221102t151407] [02-Nov-2022 14:41:09] WARNING: [pool app] child 20 said into stderr: "{"message":"Uncaught PHP Exception Doctrine\\DBAL\\Exception\\ConnectionException: \"An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection refused\" at /workspace/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php line 101","context":{"exception":{"class":"Doctrine\\DBAL\\Exception\\ConnectionException","message":"An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection refused","code":2002,"file":"/workspace/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php:101","previous":{"class":"Doctrine\\DBAL\\Driver\\PDO\\Exception","message":"SQLSTATE[HY000] [2002] Connection refused","code":2002,"file":"/workspace/vendor/doctrine/dbal/src/Driver/PDO/Exception.php:28","previous":{"class":"PDOException","message":"SQLSTATE[HY000] [2002] Connection refused","code":2002,"file":"/workspace/vendor/doctrine/dbal/src/Driver/PDO/MySQL/Driver.php:28"}}}},"level":500,"level_name":"CRITICAL","chann"
2022-11-02 14:41:09 default[20221102t151407] [02-Nov-2022 14:41:09] WARNING: [pool app] child 20 said into stderr: "el":"request","datetime":"2022-11-02T14:41:09.173672 00:00","extra":{}}"
2022-11-02 14:41:09 default[20221102t151407] [02-Nov-2022 14:41:09] WARNING: [pool app] child 20 said into stderr: "{"message":"Failed to save key \"Symfony\Component\HttpKernel\Controller\ErrorController\" of type array: fopen(/workspace/var/cache/prod/pools/system/qGYD7CGfrN/d7b0f5b96ec8): Failed to open stream: Read-only file system","context":{"key":"Symfony\Component\HttpKernel\Controller\ErrorController","exception":{"class":"ErrorException","message":"fopen(/workspace/var/cache/prod/pools/system/qGYD7CGfrN/d7b0f5b96ec8): Failed to open stream: Read-only file system","code":0,"file":"/workspace/vendor/symfony/cache/Traits/FilesystemCommonTrait.php:99"},"cache-adapter":"Symfony\\Component\\Cache\\Adapter\\PhpFilesAdapter"},"level":300,"level_name":"WARNING","channel":"cache","datetime":"2022-11-02T14:41:09.191792 00:00","extra":{}}"
2022-11-02 14:41:09 default[20221102t151407] [02-Nov-2022 14:41:09] WARNING: [pool app] child 20 said into stderr: "{"message":"Failed to save key \"Symfony\Component\HttpKernel\Controller\ErrorController#__invoke\" of type array: fopen(/workspace/var/cache/prod/pools/system/qGYD7CGfrN/d7b0f5b96ec8): Failed to open stream: Read-only file system","context":{"key":"Symfony\Component\HttpKernel\Controller\ErrorController#__invoke","exception":{"class":"ErrorException","message":"fopen(/workspace/var/cache/prod/pools/system/qGYD7CGfrN/d7b0f5b96ec8): Failed to open stream: Read-only file system","code":0,"file":"/workspace/vendor/symfony/cache/Traits/FilesystemCommonTrait.php:99"},"cache-adapter":"Symfony\\Component\\Cache\\Adapter\\PhpFilesAdapter"},"level":300,"level_name":"WARNING","channel":"cache","datetime":"2022-11-02T14:41:09.192185 00:00","extra":{}}"
2022-11-02 14:41:09 default[20221102t151407] [02-Nov-2022 14:41:09] WARNING: [pool app] child 20 said into stderr: "{"message":"Failed to save key \"Symfony\Bundle\FrameworkBundle\Controller\TemplateController\" of type array: fopen(/workspace/var/cache/prod/pools/system/qGYD7CGfrN/d7b0f5b96ec8): Failed to open stream: Read-only file system","context":{"key":"Symfony\Bundle\FrameworkBundle\Controller\TemplateController","exception":{"class":"ErrorException","message":"fopen(/workspace/var/cache/prod/pools/system/qGYD7CGfrN/d7b0f5b96ec8): Failed to open stream: Read-only file system","code":0,"file":"/workspace/vendor/symfony/cache/Traits/FilesystemCommonTrait.php:99"},"cache-adapter":"Symfony\\Component\\Cache\\Adapter\\PhpFilesAdapter"},"level":300,"level_name":"WARNING","channel":"cache","datetime":"2022-11-02T14:41:09.700565 00:00","extra":{}}"
2022-11-02 14:41:09 default[20221102t151407] [02-Nov-2022 14:41:09] WARNING: [pool app] child 20 said into stderr: "{"message":"Failed to save key \"Symfony\Bundle\FrameworkBundle\Controller\TemplateController#templateAction\" of type array: fopen(/workspace/var/cache/prod/pools/system/qGYD7CGfrN/d7b0f5b96ec8): Failed to open stream: Read-only file system","context":{"key":"Symfony\Bundle\FrameworkBundle\Controller\TemplateController#templateAction","exception":{"class":"ErrorException","message":"fopen(/workspace/var/cache/prod/pools/system/qGYD7CGfrN/d7b0f5b96ec8): Failed to open stream: Read-only file system","code":0,"file":"/workspace/vendor/symfony/cache/Traits/FilesystemCommonTrait.php:99"},"cache-adapter":"Symfony\\Component\\Cache\\Adapter\\PhpFilesAdapter"},"level":300,"level_name":"WARNING","channel":"cache","datetime":"2022-11-02T14:41:09.701047 00:00","extra":{}}"
2022-11-02 14:41:09 default[20221102t151407] "GET /build/fonts/fa-brands-400.d878b0a6.woff2 HTTP/1.1" 200
2022-11-02 14:41:09 default[20221102t151407] "GET /build/css/app.4aa95248.css HTTP/1.1" 404
uj5u.com熱心網友回復:
用于連接到 Cloud SQL的Google App Engine (Standard) 檔案指出:
正確配置后,您可以將服務連接到在環境檔案系統上訪問的 Cloud SQL 實體的 Unix 域套接字,路徑如下:/cloudsql/INSTANCE_CONNECTION_NAME
您unix_socket
上面的值應該是:
/cloudsql/project:region:instance-id
而不僅僅是
project:region:instance-id
另請注意,它應該是區域,而不是區域,即,northamerica-northeast1
而不是northamerica-northeast1-a
。如有疑問,您可以驗證連接名稱:
- 在目標 SQL 實體的控制臺的概覽頁面上
- 通過運行
gcloud sql instances describe INSTANCE_NAME
最后,您可能還需要驗證:
- 您的 App Engine 服務的服務帳戶
Cloud SQL Client
在托管 SQL 實體的專案和托管 App Engine 服務的專案中具有角色 sqladmin.googleapis.com
在托管 SQL 實體的專案和托管 App Engine 服務的專案上都啟用了 Cloud SQL Admin API ( )
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/529117.html
標籤:Google Cloud Collective 交响乐谷歌应用引擎谷歌云 sql
上一篇:調整flex容器中的影像大小