JDBC驱动程序异常问题出现在keycloak服务中



我正在尝试配置我的keycloak-18运行在helm-chart与外部mysql数据库-8版本。

这是我的舵图文件

的值。yaml文件

image:
repository: quay.io/keycloak/keycloak
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "18.0.0"
args: ["start-dev"
,"--log-console-color=true"
,"--db=mysql"
,"--db-username=****"
,"--db-password=*****"
,"--db-url=jdbc:mysql://194.148.0.57/keycloakblockchain"
]

部署文件

- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
args: {{ .Values.args }}

误差

2022-05-05 02:43:50,762 ERROR [org.keycloak.quarkus.runtime.cli.ExecutionExceptionHandler] (main) ERROR: No suitable driver found for jdbc:mysql://194.148.0.57/keycloakblockchain
2022-05-05 02:43:38,765 WARN  [org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator] (JPA Startup Thread: keycloak-default) HHH000342: Could not obtain connection to query metadata: java.sql.SQLException: No suitable driver found for jdbc:mysql://194.148.0.57/keycloakblockchain
at org.h2.jdbcx.JdbcDataSource.getJdbcConnection(JdbcDataSource.java:191)
at org.h2.jdbcx.JdbcDataSource.getXAConnection(JdbcDataSource.java:352)
at io.agroal.pool.ConnectionFactory.createConnection(ConnectionFactory.java:216)
at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:513)
at io.agroal.pool.ConnectionPool$CreateConnectionTask.call(ConnectionPool.java:494)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at io.agroal.pool.util.PriorityScheduledExecutor.beforeExecute(PriorityScheduledExecutor.java:75)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1126)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)```

Tryremovejdbc:然后使用mysql:/而不是

"--db-url=mysql://194.148.0.57/keycloakblockchain"

我也有同样的问题。我花了一些时间才注意到,在构建生产映像时,我在"KC_DB=mysql"中有一个错字。

如果你从这里使用Dockerfile: https://www.keycloak.org/server/containers

你应该只需要改变KC_DB环境变量为mysql。

Docker文件:

FROM quay.io/keycloak/keycloak:18.0.2 as builder
ENV KC_HEALTH_ENABLED=true
ENV KC_METRICS_ENABLED=true
ENV KC_PROXY=edge
ENV KC_DB=mariadb
ENV KC_DB_URL_PROPERTIES=characterEncoding=UTF-8
ENV KC_TRANSACTION_XA_ENABLED=false
ENV KC_CACHE_CONFIG_FILE=cache-ispn-jdbc-ping.xml
COPY cache-ispn-jdbc-ping.xml /opt/keycloak/conf/cache-ispn-jdbc-ping.xml
RUN curl -sL https://github.com/aerogear/keycloak-metrics-spi/releases/download/2.5.3/keycloak-metrics-spi-2.5.3.jar -o /opt/keycloak/providers/keycloak-metrics-spi-2.5.3.jar
RUN /opt/keycloak/bin/kc.sh build
FROM quay.io/keycloak/keycloak:latest
COPY --from=builder /opt/keycloak/ /opt/keycloak/
WORKDIR /opt/keycloak
ENTRYPOINT ["/opt/keycloak/bin/kc.sh", "start"]

我docker-compose。yml(我曾经在本地测试):

[...]
keycloak:
build:
context: ./keycloak
dockerfile: Dockerfile
container_name: 'keycloak'
restart: 'no'
labels:
- 'traefik.enable=true'
- 'traefik.http.services.keycloak.loadbalancer.server.port=8080'
- 'traefik.http.routers.keycloak.entrypoints=http'
- 'traefik.http.routers.keycloak.rule=Host(`sso.localhost`) || Host(`sso.${HOSTNAME}`)'
- 'traefik.http.routers.keycloak.service=keycloak@docker'
environment:
KC_EXTERNAL_IP: 172.21.2.2
KC_EXTERNAL_PORT: 9600
KC_DB_URL_HOST: db-keycloak
KC_DB_URL_PORT: 3306
KC_DB_URL_DATABASE: db
KC_DB_USERNAME: user
KC_DB_PASSWORD: pass
KC_PROXY: edge
KC_HOSTNAME_STRICT: false
KEYCLOAK_ADMIN: root
KEYCLOAK_ADMIN_PASSWORD: root
networks:
internal:
ipv4_address: 172.21.2.2
expose:
- '8080'
- '9600'
ports:
- '82:8080'
depends_on:
- db-keycloak
[...]

相关内容

  • 没有找到相关文章

最新更新