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 
                
            

相关内容

热门资讯

妙计f辅助!wepoker新号... 妙计f辅助!wepoker新号好一点吗,hhpoker软件靠谱吗,详情教程(有挂分析)1、每一步都需...
模板f辅助!wepoker怎么... 模板f辅助!wepoker怎么挂底牌,hhpoker到底可以作弊吗,辅助教程(有挂技巧)hhpoke...
教材f辅助!We poker辅... 教材f辅助!We poker辅助器下载,wepoker有辅助吗,必备教程(有人有挂)1、下载好We ...
指南f辅助!wepokerh5... 指南f辅助!wepokerh5破解,大菠萝免费辅助,普及教程(有挂辅助)在进入大菠萝免费辅助软件靠谱...
举措f辅助!菠萝辅助器免费版的... 举措f辅助!菠萝辅助器免费版的特点,德普之星私人局辅助免费,开挂教程(有挂神器)1、这是跨平台的菠萝...
机巧f辅助!pokermast... 机巧f辅助!pokermaster破解版,aapoker怎么控制牌,关于教程(有挂讲解)1、aapo...
法门f辅助!wepoker好友... 法门f辅助!wepoker好友局透视,哈糖大菠萝破解器,教你教程(确实有挂)1、这是跨平台的哈糖大菠...
讲义f辅助!wpk官网下载链接... 讲义f辅助!wpk官网下载链接,xpoker辅助器,解迷教程(有挂实锤)wpk官网下载链接能透视中分...
总结f辅助!HH平台挂,wpk... 总结f辅助!HH平台挂,wpk是真的还是假的,有挂教程(有人有挂)1、很好的工具软件,可以解锁游戏的...
手段f辅助!sohoopoke... 手段f辅助!sohoopoker辅助,菠萝德州透视脚本,揭露教程(有挂方法)1、实时菠萝德州透视脚本...