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 
                
            

相关内容

热门资讯

透视透明挂!微扑克辅助插件挂,... 透视透明挂!微扑克辅助插件挂,(微扑克wpk)原来有挂,新2025版(有挂教程)1、微扑克辅助插件挂...
黑科技辅助挂!aa poker... 黑科技辅助挂!aa poker透明挂德州辅助工具,(AAPOKer)其实真的是有挂,我来教教你(有挂...
wepoke辅助软件靠谱吗(w... wepoke辅助软件靠谱吗(wepOkE)wepoke里面有ai吗(黑科技)微扑克教程(原来是真的有...
黑科技辅助挂挂!wepoke透... 黑科技辅助挂挂!wepoke透明黑科技,wepower插件,可靠教程(原先真的有挂)准备好在wepo...
黑科技软件!wepoke有透视... 黑科技软件!wepoke有透视挂吗,(wepoKE)真是是真的有挂,德州教程(有挂详情);1.wep...
黑科技辅助挂!wPk透视辅助,... 黑科技辅助挂!wPk透视辅助,wPK透视有猫腻,黑科技教程(有挂透视)1、不需要AI权限,帮助你快速...
aapoker辅助器是真的吗(... aapoker辅助器是真的吗(aapoKer)aapoker插件(辅助挂)解密教程(总是有挂)暗藏猫...
黑科技辅助挂挂!wpk真的有外... 《黑科技辅助挂挂!wpk真的有外挂,wpk长期盈利打法教学,揭秘教程(从来有挂)》 wpk真的有外挂...
透视app!wpk外挂第一视角... 透视app!wpk外挂第一视角,(wpK)本来存在有挂,线上教程(有挂脚本)1、玩家可以在wpk外挂...
黑科技辅助挂!(Wepoke)... 黑科技辅助挂!(Wepoke)一贯存在有挂,(wepower)好像存在有挂,科技教程(有挂透视)1、...