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

docs: add namingserver.md #908

Merged
merged 4 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
Title: Seata Namingserver Registration Center
Keywords: [ Seata, Namingserver ]
Description: Namingserver registration center.
---


# Namingserver Registration Center
Namingserver is the native registration center of Seata.

## Preparations
You can choose to run the naming server in the compiler or after packaging it.

### Running the naming server in the compiler
Go to the namingserver directory, set the port number for the naming server in resources/application.yml, and start the naming server.

### Running the naming server after packaging
Execute the packaging command:
```shell
mvn clean install -U -Prelease-seata-namingserver
```
Set the naming server port number in the `conf/application.yml` file located in the `\\distribution\\target\\apache-seata-2.2.0-SNAPSHOT-incubating-bin\\seata-namingserver` directory.
For macOS or Linux, run:

```shell
bin\\seata-namingserver.sh
```
For Windows, run:

```shell
bin\\seata-namingserver.bat
```
## Getting Started Quickly
The process to use the naming server as Seata's registration center is very simple and involves configuring both the client and server sides.

### Client-side Configuration for the Registration Center
Add the corresponding registration center in the application.yml:

```yaml
seata:
registry:
type: seata
seata:
server-addr: 127.0.0.1:8081 ## IP + port of the naming server configured in the first step. Use commas to separate multiple naming server nodes.
namespace: public ## Namespace
heartbeat-period: 5000 ## Heartbeat interval
```
### Server-side Configuration for the Registration Center
Add the following configuration to `conf/application.yaml`, with the rest of the configuration referring to configuration options:

```yaml
seata:
registry:
type: seata
seata:
server-addr: 127.0.0.1:8081 ## IP + port of the naming server configured in the first step. Use commas to separate multiple naming server nodes.
cluster: default ## Cluster name
namespace: public ## Namespace
heartbeat-period: 5000 ## Heartbeat interval
```
Create a Mapping Between the Client's Transaction Group and the Seata Cluster
Send an HTTP request to one naming server node to create a transaction group-to-cluster mapping (the naming server node will automatically synchronize with other nodes):

```shell
http://127.0.0.1:8081/naming/v1/changeGroup?clusterName=cluster2&namespace=public&unitName&vGroup=my_test_tx_group
```
(In this, namespace is the namespace configured on the client side, vGroup is the transaction group configured on the client side, and clusterName is the cluster name on the server side that needs to be mapped.)

Afterward, once Seata-Server is started and the client configuration is complete, you can begin to experience Seata services.

Tips: Ensure that both the client and server are registered under the same namespace; otherwise, the service won't be found.
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
---
title: Seata Namingserver 注册中心
keywords: [ Seata, Namingserver ]
description: namingserver 注册中心。
---

# Namingserver 注册中心

Namingserver 是 Seata 原生的注册中心.

## 预备工作
可以选择在编译器中运行namingserver或者打包后运行namingserver
### 编译器运行namingserver

进入`namingsever`目录,在`resources/application.yml`下设置namingserver启动的端口号,启动namingserver

### 打包运行namingserver

执行`mvn clean install -U -Prelease-seata-namingserver`打包命令
```shell
`mvn clean install -U -Prelease-seata-namingserver`
```
在`\distribution\target\apache-seata-2.2.0-SNAPSHOT-incubating-bin\seata-namingserver`目录下的`conf/application.yml`中配置namingserver启动的端口号,
funky-eyes marked this conversation as resolved.
Show resolved Hide resolved
mac或linux运行
``` shell
bin\seata-namingserver.sh
```
windows环境运行
``` shell
bin\seata-namingserver.bat
```

## 快速上手

Seata 使用 namingserver 作为注册中心的操作步骤非常简单,分为在client端的配置以及在server端的配置

### Client端配置注册中心

在 [**application.yml**](https://github.com/apache/incubator-seata/blob/2.x/script/client/spring/application.yml)
中加入对应的注册中心。

```yaml
seata:
registry:
type: seata
seata:
server-addr: 127.0.0.1:8081 ##第一步配置的namingserver的ip+端口,若有多个namingserver节点则用逗号分割
namespace: public ##命名空间
heartbeat-period: 5000 ##心跳时间
```

### Server端配置注册中心

在 `conf/application.yaml`加入以下配置,
其余配置参考 [configuration options](https://github.com/apache/incubator-seata/blob/2.x/server/src/main/resources/application.example.yml):

```yaml
seata:
registry:
type: seata
seata:
server-addr: 127.0.0.1:8081 ##第一步配置的namingserver的ip+端口,若有多个namingserver节点则用逗号分割
cluster: default ##集群名称
namespace: public ##命名空间
heartbeat-period: 5000 ##心跳时间
```

### 创建client端的事务分组->seata集群的映射关系
向一个namingserver节点发起创建事务分组映射关系的http请求(namingserver节点会自动同步给其它节点)
```shell
http://127.0.0.1:8081/naming/v1/changeGroup?clusterName=cluster2&namespace=public&unitName&vGroup=my_test_tx_group
ggbocoder marked this conversation as resolved.
Show resolved Hide resolved
```
(其中namespace是client端配置的命名空间,vGroup是client端配置的事务分组,clusterName是需要映射到的server端的集群名称)

随后,启动 Seata-Server 后,Client 配置完成后启动应用就可以正式体验 Seata 服务。

Tips:请确保client与server的注册处于同一个namespace,不然会找不到服务。
1 change: 1 addition & 0 deletions versioned_docs/version-v2.2/user/registry/namingserver.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Placeholder. DO NOT DELETE.
3 changes: 2 additions & 1 deletion versioned_sidebars/version-v2.2-sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
"user/registry/eureka",
"user/registry/etcd3",
"user/registry/consul",
"user/registry/zookeeper"
"user/registry/zookeeper",
"user/registry/namingserver"
]
},
"user/api",
Expand Down
Loading