Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Application failed to connect to Nacos server: "nacos-headless.default.svc.cluster.local:8848" #482

Open
liulong1234q opened this issue Feb 12, 2025 · 0 comments

Comments

@liulong1234q
Copy link

以下是我的nacos部署yaml

apiVersion: apps/v1
kind: StatefulSet
metadata:
name: nacos
spec:
podManagementPolicy: Parallel
serviceName: nacos-headless
replicas: 3
selector:
matchLabels:
app: nacos
template:
metadata:
labels:
app: nacos
spec:
containers:
- name: nacos
image: harbor:20443/project1/nacos:2.1.2
imagePullPolicy: Always
ports:
- containerPort: 8848
name: client
- containerPort: 9848
name: client-rpc
- containerPort: 9849
name: raft-rpc
env:
- name: LANG
value: "C.UTF-8"
- name: NACOS_REPLICAS
value: "3"
- name: NACOS_AUTH_ENABLE
value: "false"
- name: nacos.core.auth.server.identity.key
value: serverIdentity
- name: nacos.core.auth.server.identity.value
value: security
- name: NACOS_AUTH_TOKEN
value: "SecretKey012345678901234567890123456789012345678901234567890123456789"
- name: MYSQL_SERVICE_HOST
value: "172.168.63.121"
- name: MYSQL_SERVICE_DB_NAME
value: "nacos"
- name: MYSQL_SERVICE_PORT
value: "33060"
- name: MYSQL_SERVICE_USER
value: "develop"
- name: MYSQL_SERVICE_PASSWORD
value: "Dev#XXX"
- name: SPRING_DATASOURCE_PLATFORM
value: "mysql"
- name: NACOS_SERVER_PORT
value: "8848"
- name: NACOS_APPLICATION_PORT
value: "8848"
- name: PREFER_HOST_MODE
value: "hostname"
- name: NACOS_SERVERS
value: "nacos-0.nacos-headless.default.svc.cluster.local:8848 nacos-1.nacos-headless.default.svc.cluster.local:8848 nacos-2.nacos-headless.default.svc.clus
ter.local:8848"
- name: JVM_XMS
value: "4g"
- name: JVM_XMX
value: "4g"
- name: JVM_XMN
value: "1536m"
- name: JVM_MS
value: "256m"
- name: JVM_MMS
value: "512m"
resources:
requests:
memory: "2Gi"
cpu: "500m"
limits:
memory: "6Gi"
cpu: "2"
livenessProbe:
httpGet:
path: /nacos/actuator/health
port: 8848
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3
readinessProbe:
httpGet:
path: /nacos/actuator/health
port: 8848
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 3

apiVersion: v1
kind: Service
metadata:
name: nacos-headless
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
selector:
app: nacos

apiVersion: v1
kind: Service
metadata:
name: nacos-nodeport
labels:
app: nacos-nodeport
spec:
ipFamilyPolicy: PreferDualStack
ipFamilies:
- IPv6
- IPv4
type: NodePort
ports:
- port: 8848
targetPort: 8848
nodePort: 30088
name: server
selector:
app: nacos
publishNotReadyAddresses: true

java 报错如下:


APPLICATION FAILED TO START


Description:

Application failed to connect to Nacos server: "nacos-headless.default.svc.cluster.local:8848"

Action:

Please check your Nacos server config

2025-02-12 18:00:27.577 ERROR 1 --- [ main] isReporter :


APPLICATION FAILED TO START


Description:

Application failed to connect to Nacos server: "nacos-headless.default.svc.cluster.local:8848"

Action:

Please check your Nacos server config

程序配置文件

nacos:
namespace: 3047ea0c-fc3f-482d-b818-82ec1c10306c
username: nacos
password: nacos

spring:
cloud:
nacos:
config:
server-addr: nacos-headless.default.svc.cluster.local:8848
file-extension: yml
shared-configs:

  • data-id: xspn-common.yml
    refresh: true
    namespace: ${nacos.namespace}
    username: ${nacos.username}
    password: ${nacos.password}
    discovery:
    server-addr: nacos-headless.default.svc.cluster.local:8848
    namespace: ${nacos.namespace}
    username: ${nacos.username}
    password: ${nacos.password}
    #logstash配置
    logstashServer: 172.168.27.90:9250

那个大佬帮忙看看如何解决

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant