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

导致重启后网络错误



1
1
清风
优秀!
2021-02-11
共1条回复

清风

2021-02-11

这个是因为 kubeblog 应用依赖 mysql 服务,可以在 kubelog 的 pod 里,通过以下配置的地址访问 mysql 的服务

env:

- name: MYSQL_PORT

value: "30306"

- name: MYSQL_SERVER

value: "192.168.99.102"


0
0

Kubernetes 入门到进阶实战,系统性掌握 K8s 生产实践

阿里云最有价值专家亲授,云原生时代必备技能

1502 学习 · 613 问题

查看课程