alibaba / nacos

an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.
https://nacos.io
Apache License 2.0
30.12k stars 12.81k forks source link

使用springboot启动nacos的源码,在nacos的服务详情页面点击服务的“下线”功能报错 #10283

Closed ZYHdolphin closed 1 year ago

ZYHdolphin commented 1 year ago

Describe the bug 使用springboot启动nacos的源码,在nacos的服务详情页面点击服务的“下线”功能报错: caused: errCode: 500, errMsg: do metadata operation failed ;caused: java.lang.IllegalArgumentException: No corresponding Raft Group found : naming_instance_metadata;caused: No corresponding Raft Group found : naming_instance_metadata;

我使用startup.sh的方式就不会出现这个问题,使用源码启动的nacos就会,网上的解决方案大部分都是删除nacos下面的data文件,但是源码启动的话就没有这些文件,所以不知道从何入手。

Expected behavior 我希望能够正常使用上线下线功能

Actually behavior 实际报错

使用的源码版本是nacos 2.1.1

youshang520i commented 1 year ago

The error message "No corresponding Raft Group found : naming_instance_metadata" suggests that Nacos is unable to find the Raft Group associated with the metadata for the service instance you are trying to offline.

There could be several reasons for this issue, including:

The metadata for the service instance is not available in the Raft Group due to a synchronization issue or a failure in the Nacos cluster.

The service instance is not registered with Nacos or has already been offline.

To troubleshoot this issue, you can try the following steps:

Check if the service instance is registered with Nacos and its metadata is available in the Raft Group. You can use the Nacos console or API to verify this.

Check if there are any synchronization issues or failures in the Nacos cluster. You can check the Nacos logs for any error messages or warnings related to synchronization or Raft Group.

Try restarting the Nacos cluster and see if the issue persists.

If none of the above steps work, you can try raising the issue on the Nacos GitHub repository or forum, providing details of the error message and steps to reproduce the issue.

youshang520i commented 1 year ago

To check if a service instance is registered with Nacos and its metadata is available in the Raft Group, you can use the Nacos console or API.

Using the Nacos Console: Open the Nacos Console in your web browser. Click on the "Services" tab in the top navigation bar. Find the service instance you want to check and click on its name. In the service details page, click on the "Instances" tab to see the list of instances registered for that service. Check if the instance you are looking for is present in the list and its metadata is correct. Using the Nacos API: Send a GET request to the Nacos API to retrieve the details of the service instance. The API endpoint is /nacos/v1/ns/instance. Provide the necessary query parameters such as serviceName and ip, or clusterName if applicable. Check the response to see if the instance is registered and its metadata is correct. For example, if you want to check the metadata for an instance of the "example-service" registered at IP address "192.168.1.100" in the default cluster, you can use the following API endpoint:

GET http://localhost:8848/nacos/v1/ns/instance?serviceName=example-service&ip=192.168.1.100

If the instance is registered and its metadata is available in the Raft Group, you should see a JSON response with details of the instance including its metadata. If the instance is not registered, or its metadata is not available, the response will be empty or contain an error message.

KomachiSion commented 1 year ago

I can't reproduce your problem, How do you start source code?

ZYHdolphin commented 1 year ago

I can't reproduce your problem, How do you start source code?

微信截图_20230410123746

2

Download the latest source code and modify application.properties: spring.sql.init. platform=mysql db.num=1 db.url.0=jdbc:mysql://127.0.0.1:3307/arh_config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC nacos.core.auth.plugin.nacos.token.secret.key=xxxxxxxx Then start nacos directly

KomachiSion commented 1 year ago

The error info has hint you, the cluster no raft leader. You should check and fix your cluster deploy problem, make the jraft status ready.

Serverdowno commented 1 year ago

錯誤信息提示你,集群沒有 raft leader。您應該檢查並修復您的集群部署問題,使 jraft 狀態準備就緒。

我也遇到了这个问题,web页面上面查看集群状态都是在线,我操作线下也是这个报错信息,我查阅资料说是Nacos 采用 raft 算法来计算 Leader,并且会记录前一次启动的集群地址,所以当我们自己的服务器 IP 改变时(这里特指自己学习时,在本地启动的同学,因为有时候我们的网络环境会变的 … WIFI,所以 IP 地址也经常变化),会导致 raft 记录的集群地址失效,导致选 Leader 出现问题,只要删除 Nacos 根目录下 data 文件夹下的 protocol 文件夹即可,但是,删除后,停止容器,启动后,还是一样的报错。 截屏2023-04-19 18 17 05

KomachiSion commented 1 year ago

你俩下线不是同一个下线。。。。 他是应用服务实例下线。 你是下线nacos节点。

KomachiSion commented 1 year ago

錯誤信息提示你,集群沒有 raft leader。您應該檢查並修復您的集群部署問題,使 jraft 狀態準備就緒。

我也遇到了这个问题,web页面上面查看集群状态都是在线,我操作线下也是这个报错信息,我查阅资料说是Nacos 采用 raft 算法来计算 Leader,并且会记录前一次启动的集群地址,所以当我们自己的服务器 IP 改变时(这里特指自己学习时,在本地启动的同学,因为有时候我们的网络环境会变的 … WIFI,所以 IP 地址也经常变化),会导致 raft 记录的集群地址失效,导致选 Leader 出现问题,只要删除 Nacos 根目录下 data 文件夹下的 protocol 文件夹即可,但是,删除后,停止容器,启动后,还是一样的报错。 截屏2023-04-19 18 17 05

自学一下raft协议,raft member的数据是需要持久化记录的, 如果ip老变动, 超过了半数, 那肯定选不出leader,因为旧member已经访问不通了。

Serverdowno commented 1 year ago

你俩下线不是同一个下线。。。。 他是应用服务实例下线。 你是下线nacos节点。

是的,我就是截了一个那个图,是应用服务下线,我集群ip是固定的不会变化,查看日志是有错误,选举去链接了7848端口失败了,请问7848端口是什么?我没有开启这个端口。

Serverdowno commented 1 year ago

你玩下線不是同一條下線。。。。他是應用服務實例下線。你是下線nacos節點。

是的,我就是截了一個那個圖,是應用服務下線,我群ip是固定的不會變的,查看日誌是有錯,選擇去鏈接了7848端口失職7,請4害?我沒有打開這個端口。

以解决,7848是检查端口,需要开启。

ZYHdolphin commented 1 year ago

The error info has hint you, the cluster no raft leader. You should check and fix your cluster deploy problem, make the jraft status ready.

Error message: 微信截图_20230423162509 tips:Not using a cluster

breastcover commented 8 months ago

怎么解决啊大哥们