k8s nacos2.0.3 连接 mysql8.0 提示No Datasource set问题
创始人
2025-01-09 10:36:28
0

主要因为是连接数据库字符串未指定时区问题

将 mysql-service-db-param 参数追加 serverTimezone=UTC 即可连接成功。

k8s集群yaml文件

apiVersion: v1 data:   mysql_root_password: MTIzNDU2 kind: Secret metadata:   name: mysql-password   namespace: test  ---  apiVersion: v1 data:   jvm-xmn: 128m   jvm-xms: 256m   jvm-xmx: 256m   mode: cluster   mysql-database-num: "1"   mysql-service-db-name: nacos_config   mysql-service-db-param: characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&serverTimezone=UTC   mysql-service-host: 172.17.19.17   mysql-service-port: "30121"   mysql-service-user: root   nacos-servers: nacos-0.nacos-headless.test.svc.cluster.local:8848 nacos-1.nacos-headless.test.svc.cluster.local:8848 nacos-2.nacos-headless.test.svc.cluster.local:8848   spring-datasource-platform: mysql kind: ConfigMap metadata:   name: nacos-deploy-config   namespace: test  --- kind: Service apiVersion: v1 metadata:   name: nacos-external-lb   namespace: test   labels:     app: nacos-external-lb spec:   ports:     - name: server       protocol: TCP       port: 8848       targetPort: 8848       nodePort: 31180     - name: client-rpc       protocol: TCP       port: 9848       targetPort: 9848       nodePort: 30182     - name: raft-rpc       protocol: TCP       port: 9849       targetPort: 9849       nodePort: 31626     - name: old-raft-rpc       protocol: TCP       port: 7848       targetPort: 7848       nodePort: 32724   selector:     app: nacos   type: NodePort   sessionAffinity: None   externalTrafficPolicy: Cluster  --- apiVersion: v1 kind: Service metadata:   name: nacos-headless   namespace: test   labels:     app: nacos-headless spec:   type: ClusterIP   clusterIP: None   ports:     - port: 8848       name: server       targetPort: 8848     - port: 9848       name: client-rpc       targetPort: 9848     - port: 9849       name: raft-rpc       targetPort: 9849     ## 兼容1.4.x版本的选举端口     - port: 7848       name: old-raft-rpc       targetPort: 7848   selector:     app: nacos --- apiVersion: apps/v1 kind: StatefulSet metadata:   name: nacos   namespace: test spec:   selector:     matchLabels:       app: nacos   serviceName: nacos-headless   replicas: 3   template:     metadata:       labels:         app: nacos       annotations:         pod.alpha.kubernetes.io/initialized: "true"     spec: #      affinity: #        podAntiAffinity: #          requiredDuringSchedulingIgnoredDuringExecution: #            - labelSelector: #                matchExpressions: #                  - key: "app" #                    operator: In #                    values: #                      - nacos #              topologyKey: "kubernetes.io/hostname"       containers:         - name: nacos           image: 172.17.19.17:8082/library/nacos/nacos-server:2.0.3           ports:             - containerPort: 8848               name: nacos             - containerPort: 9848               name: client-rpc             - containerPort: 9849               name: raft-rpc             - containerPort: 7848               name: old-raft-rpc           env:             - name: JVM_XMN               valueFrom:                 configMapKeyRef:                   key: jvm-xmn                   name: nacos-deploy-config             - name: JVM_XMS               valueFrom:                 configMapKeyRef:                   key: jvm-xms                   name: nacos-deploy-config             - name: JVM_XMX               valueFrom:                 configMapKeyRef:                   key: jvm-xmx                   name: nacos-deploy-config             - name: NACOS_REPLICAS               value: "3"             - name: MYSQL_DATABASE_NUM               valueFrom:                 configMapKeyRef:                   key: mysql-database-num                   name: nacos-deploy-config             - name: MYSQL_SERVICE_DB_NAME               valueFrom:                 configMapKeyRef:                   key: mysql-service-db-name                   name: nacos-deploy-config             - name: MYSQL_SERVICE_DB_PARAM               valueFrom:                 configMapKeyRef:                   key: mysql-service-db-param                   name: nacos-deploy-config             - name: MYSQL_SERVICE_HOST               valueFrom:                 configMapKeyRef:                   key: mysql-service-host                   name: nacos-deploy-config             - name: MYSQL_SERVICE_PASSWORD               valueFrom:                 secretKeyRef:                   key: mysql_root_password                   name: mysql-password             - name: MYSQL_SERVICE_PORT               valueFrom:                 configMapKeyRef:                   key: mysql-service-port                   name: nacos-deploy-config             - name: MYSQL_SERVICE_USER               valueFrom:                 configMapKeyRef:                   key: mysql-service-user                   name: nacos-deploy-config             - name: NACOS_SERVER_PORT               value: "8848"             - name: NACOS_APPLICATION_PORT               value: "8848"             - name: PREFER_HOST_MODE               value: "hostname"             - name: NACOS_SERVERS               valueFrom:                 configMapKeyRef:                   key: nacos-servers                   name: nacos-deploy-config             - name: SPRING_DATASOURCE_PLATFORM               valueFrom:                 configMapKeyRef:                   key: spring-datasource-platform                   name: nacos-deploy-config 
                
            

相关内容

热门资讯

wepower辅助器(透视)w... wepower辅助器(透视)wepoke线上(详细辅助2025版教程)一贯存在有挂(大神智能ai)1...
wepoke辅助有挂(透视)w... wepoke辅助有挂(透视)wepoke ai代打辅助(详细辅助必备教程)一直是有挂(攻略有辅助挂)...
wepoke辅助插件(透视)w... wepoke辅助插件(透视)wepoke透明挂件(详细辅助力荐教程)一直真的有挂(玩家透视挂);1、...
wepoke辅助挂(透视)we... wepoke辅助挂(透视)wepoke系统(详细辅助高科技教程)一直是有挂(了解透明挂)1、下载好w...
wepoke插件(透视)德州w... wepoke插件(透视)德州wepower透视辅助(详细辅助透牌教程)总是有挂(详细辅助技巧)1、下...
wepokeai代打(透视)w... wepokeai代打(透视)wepoke软件俱乐部(详细辅助技巧教程)本来有挂(玩家辅助有挂)1、进...
wepower有外 挂(透视)... wepower有外 挂(透视)wopoker外挂(详细辅助实用技巧)果然有挂(攻略有外 挂)1、we...
wepoke辅助德之星(透视)... wepoke辅助德之星(透视)wopoker透明挂(详细辅助揭秘攻略)总是真的是有挂(教你辅助器)1...
wepokeai机器人(透视)... wepokeai机器人(透视)wepoke辅助是真的(详细辅助必备教程)原来真的有挂(教你ai代打)...
WePoKe透明挂(透视)we... WePoKe透明挂(透视)wepower有外挂(详细辅助靠谱教程)好像存在有挂(黑科技辅助插件)小薇...