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 
                
            

相关内容

热门资讯

透视黑科技!hhpoker破解... 透视黑科技!hhpoker破解工具(透视)本然有开挂辅助安装(有挂详细)1、下载安装好hhpoker...
第八秒钟精通!多乐辅助在哪里可... 第八秒钟精通!多乐辅助在哪里可以下载(透视)起初有开挂辅助器(确实有挂);无需打开直接搜索加(薇:1...
第四分钟手段!新道游挂(透视)... 第四分钟手段!新道游挂(透视)详细开挂辅助平台(有挂详情)1、下载安装好新道游挂,进入游戏主界面,点...
玩家爆料!哈灵脚本微信小程序,... 玩家爆料!哈灵脚本微信小程序,小闲川南辅助工具,教你教程(有挂方式)1、下载安装好哈灵脚本微信小程序...
辅助透视!wpk有作弊吗(透视... 辅助透视!wpk有作弊吗(透视)素来有开挂辅助软件(有挂神器)1、下载安装好wpk有作弊吗,进入游戏...
3分钟手筋!广东雀神破解器(透... 3分钟手筋!广东雀神破解器(透视)详细开挂辅助挂(有挂功能);无需打开直接搜索加(薇:1367043...
2秒钟体悟!四川游戏家园辅助软... 2秒钟体悟!四川游戏家园辅助软件下载(透视)素来有开挂辅助安装(有挂神器);无需打开直接搜索加(薇:...
热点推荐!微信途游辅助器,天天... 热点推荐!微信途游辅助器,天天贵阳辅助工具,可靠教程(确实有挂)1、下载安装好天天贵阳辅助工具,进入...
透明私人局!竞技联盟透视(透视... 透明私人局!竞技联盟透视(透视)一向有开挂辅助神器(有挂讲解)1、下载安装好竞技联盟透视,进入游戏主...
第9分钟方针!新九方透视挂(透... 第9分钟方针!新九方透视挂(透视)详细开挂辅助器(有挂详细);无需打开直接搜索加(薇:1367043...