mysql 重启后 pod 无法连接,直接连mysql可以
来源:11-2 编写博客应用的Service和Deployment文件

慕尼黑2773818
2021-02-11
[root@node1 ~]# kubectl logs kubeblog-57f67c5ff9-8gvjl -f |grep fail
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
org.springframework.jdbc.support.MetaDataAccessException: Could not get Connection for extracting meta-data; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Caused by: org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure
2021-02-11 03:55:00.373 WARN 1 — [ main] o.h.e.j.e.i.JdbcEnvironmentInitiator : HHH000342: Could not obtain connection to query metadata : Communications link failure
2021-02-11 03:55:00.456 WARN 1 — [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
2021-02-11 03:55:00.579 ERROR 1 — [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘entityManagerFactory’ defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment]
2回答
-
慕尼黑2773818
提问者
2021-02-11
收到,谢了
node节点 少了这个
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
导致重启后网络错误
112021-02-11 -
清风
2021-02-11
这个是因为 kubeblog 应用依赖 mysql 服务,可以在 kubelog 的 pod 里,通过以下配置的地址访问 mysql 的服务
env:
- name: MYSQL_PORT
value: "30306"
- name: MYSQL_SERVER
value: "192.168.99.102"
00
相似问题