首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >kubernetes上的Mariadb读取通信数据包时出错

kubernetes上的Mariadb读取通信数据包时出错
EN

Stack Overflow用户
提问于 2020-12-03 17:12:08
回答 1查看 619关注 0票数 0

我尝试在我的k8s集群上部署一个具有mariadb数据库的应用程序。这是我使用的部署:

代码语言:javascript
复制
apiVersion: v1
kind: Service
metadata:
  name: app-back
  labels:
    app: app-back
  namespace: dev
spec:
  type: ClusterIP
  ports:
    - port: 8080
      name: app-back
  selector:
    app: app-back
---
apiVersion: v1
kind: Service
metadata:
  name: app-db
  labels:
    app: app-db
  namespace: dev
spec:
  type: ClusterIP
  clusterIP: None
  ports:
    - port: 3306
      name: app-db
  selector:
    app: app-db
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: mysql
  labels:
    app: mysql
data:
  60-server.cnf: |
    [mysqld]
    bind-address = 0.0.0.0
    skip-name-resolve
    connect_timeout = 600
    net_read_timeout = 600
    net_write_timeout = 600
    max_allowed_packet = 256M
    default-time-zone = +00:00
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app-db
  namespace: dev
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: app-db
  template:
    metadata:
      labels:
        app: app-db
    spec:
      containers:
        - name: app-db
          image: mariadb:10.5.8
          env:
            - name: MYSQL_DATABASE
              value: app
            - name: MYSQL_USER
              value: app
            - name: MYSQL_PASSWORD
              value: app
            - name: MYSQL_RANDOM_ROOT_PASSWORD
              value: "true"
          ports:
            - containerPort: 3306
              name: app-db
          resources:
            requests:
              memory: "200Mi"
              cpu: "100m"
            limits:
              memory: "400Mi"
              cpu: "200m"
          volumeMounts:
            - name: config-volume
              mountPath: /etc/mysql/conf.d
      volumes:
        - name: config-volume
          configMap:
            name: mysql
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: app-back
  namespace: dev
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: app-back
  template:
    metadata:
      labels:
        app: app-back
    spec:
      containers:
        - name: app-back
          image: private-repository/app/app-back:latest
          env:
            - name: spring.profiles.active
              value: dev
            - name: DB_HOST
              value: app-db
            - name: DB_PORT
              value: "3306"
            - name: DB_NAME
              value: app
            - name: DB_USER
              value: app
            - name: DB_PASSWORD
              value: app
          ports:
            - containerPort: 8080
              name: app-back
          resources:
            requests:
              memory: "200Mi"
              cpu: "100m"
            limits:
              memory: "200Mi"
              cpu: "400m"
      imagePullSecrets:
        - name: docker-private-credentials

当我运行此命令时,mariadb容器记录以下警告:

代码语言:javascript
复制
2020-12-03  8:23:41 28 [Warning] Aborted connection 28 to db: 'app' user: 'app' host: 'xxx.xxx.xxx.xxx' (Got an error reading communication packets)
2020-12-03  8:23:41 25 [Warning] Aborted connection 25 to db: 'app' user: 'app' host: 'xxx.xxx.xxx.xxx' (Got an error reading communication packets)
2020-12-03  8:23:41 31 [Warning] Aborted connection 31 to db: 'app' user: 'app' host: 'xxx.xxx.xxx.xxx' (Got an error reading communication packets)
2020-12-03  8:23:41 29 [Warning] Aborted connection 29 to db: 'app' user: 'app' host: 'xxx.xxx.xxx.xxx' (Got an error reading communication packets)
...

我的应用程序在尝试连接到数据库时卡住了。该应用程序是使用以下dockerfile构建的Sprinbboot应用程序:

代码语言:javascript
复制
FROM maven:3-adoptopenjdk-8 AS builder
WORKDIR /usr/src/mymaven/
COPY . .
RUN mvn clean package -e -s settings.xml -DskipTests

FROM tomcat:9-jdk8-adoptopenjdk-hotspot
ENV spring.profiles.active=dev
ENV DB_HOST=localhost
ENV DB_PORT=3306
ENV DB_NAME=app
ENV DB_USER=app
ENV DB_PASSWORD=app

COPY --from=builder /usr/src/mymaven/target/app.war /usr/local/tomcat/webapps/

有什么想法吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-12-04 06:02:01

好了,我找到解决方案了。这不是mariadb的错误。这是由于apache在内存较低的容器内运行时会中断连接。将内存限制设置为1500 to解决了此问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65122890

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档