在Google App Engine上部署的配置数据库不起作用 [英] Metabase deployed on Google App Engine doesn't work

查看:82
本文介绍了在Google App Engine上部署的配置数据库不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Gcloud中部署Metabase后,GAE应用网址显示错误页面.

After deploying Metabase in Gcloud, GAE app url shows error page.

我按照此链接上的所有说明进行操作

I followed all the instructions on this link https://www.cloudbooklet.com/install-metabase-on-google-cloud-with-docker-app-engine/ to deploy metabase on GAE.

我已经尝试了mysql和Postgres db,但是结果始终是错误页面

I have tried with both mysql and Postgres db but the result is always an error page

这是我的App.yaml代码.

Here is my App.yaml code.

env: flex

manual_scaling:
   instances: 1

env_variables:
   MB_JETTY_PORT: 8080
   MB_DB_TYPE: postgres
   MB_DB_DBNAME: metabase
   MB_DB_PORT: 5432
   MB_DB_USER: root
   MB_DB_PASS: password
   MB_DB_HOST: 127.0.0.1

beta_settings:
   cloud_sql_instances: <sql_instance>=tcp:5432

这是我的dockerfile

Here is my dockerfile

FROM gcr.io/google-appengine/openjdk

EXPOSE 8080

ENV PORT 8080
ENV MB_PORT 8080
ENV MB_JETTY_PORT 8080
ENV MB_DB_PORT 5432
ENV METABASE_SQL_INSTANCE <sql_instance>=tcp:5432
ENV JAVA_OPTS "-XX:+IgnoreUnrecognizedVMOptions -Dfile.encoding=UTF-8 --add-opens=java.base/java.net=ALL-UNNAMED --add-modules=java.xml.bind"

ADD https://dl.google.com/cloudsql/cloud_sql_proxy.linux.amd64 ./cloud_sql_proxy
ADD http://downloads.metabase.com/v0.33.2/metabase.jar /metabase.jar

RUN chmod +x ./cloud_sql_proxy

CMD ./cloud_sql_proxy -instances=$METABASE_SQL_INSTANCE=tcp:$MB_DB_PORT & java -jar ./metabase.jar

以下是我在控制台日志上看到的错误

Following is the error I get on console log

INFO metabase.driver :: Registered abstract driver :sql  ?

App Engine URL上的错误消息也显示以下内容,

Also the error message on App engine URL says the following,

Error: Server Error
The server encountered a temporary error and could not complete your request.
Please try again in 30 seconds.

我尝试了所有可能找到的选项,请为我提供可行的解决方案.

I tried all options I could find, please help me with a working solution.

推荐答案

首先,请按照

First, start by following the instructions on the Connecting from App Engine page. Make sure that the SQL Admin API is enabled, and that the service account being used has the Cloud SQL Connect IAM role.

第二,您不需要在docker容器中运行代理.当您在app.yml中指定它时,它允许您在 172.17.0.1:<PORT> 上对其进行访问.(尽管如果您使用的是容器,我强烈建议您改为尝试 Cloud Run ).

Second, you don't need to run the proxy in the docker container. When you specify it in the app.yml, it allows you to access it on 172.17.0.1:<PORT>. (Although if you are using a container, I would highly suggest you try Cloud Run instead).

最后,根据此在配置数据库的说明中,您需要向容器提供环境变量,以指定要使用的数据库.这些环境变量全部采用 MB_DB _ * 格式.

Finally, according to this Metabase setup instructions, you need to provide the environment variables to the container to specify what database you want it to use. These env vars are all in format MB_DB_*.

这是没有代理的dockerfile的样子:

Here is what a dockerfile without the proxy might look like:

FROM gcr.io/google-appengine/openjdk


ENV MB_JETTY_PORT 8080

ENV MB_DB_TYPE postgres
ENV MB_DB_HOST 172.17.0.1
ENV MB_DB_PORT 5432
ENV MB_DB_USER <your-username>
ENV MB_DB_PASS <your-password>
ENV MB_DB_DBNAME <your-database>

ENV JAVA_OPTS "-XX:+IgnoreUnrecognizedVMOptions -Dfile.encoding=UTF-8 --add-opens=java.base/java.net=ALL-UNNAMED --add-modules=java.xml.bind"

ENTRYPOINT java -jar ./metabase.jar

要获得奖励积分,您可以考虑使用一次性容器( gcr.io/distroless/java:11 )作为基础(尤其是如果您切换到Cloud Run).

For bonus points, you might consider using the distroless container (gcr.io/distroless/java:11) as a base instead (especially if you switch to Cloud Run).

这篇关于在Google App Engine上部署的配置数据库不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆