ZooKeeper Registry Center
ZooKeeper serves as a critical registry center implementation within the Seata component.
This document is based on Seata 1.1.0, demonstrating how to register Seata with ZooKeeper using a file as the configuration center.
It is recommended to use ZooKeeper version 3.4.13 or above. The following example uses ZooKeeper version 3.4.14.
Prerequisites
Before registering Seata with ZooKeeper, ensure that the ZooKeeper service is running. If you are unfamiliar with basic ZooKeeper usage, you can refer to the ZooKeeper official documentation.
Quick Start
Integrating Seata with ZooKeeper involves simple steps, roughly categorized as "Adding Maven Dependencies" and "Configuring the Registry Center."
Server-side Registry Center Configuration
Download Seata 1.1.0 release and extract the files.
Modify the corresponding configuration in /conf/registry.conf
. For other configuration options, refer to the Seata configuration reference.
registry {
type = "zk"
zk {
# Cluster name registered on ZooKeeper, default is "default"
cluster = "default"
serverAddr = "127.0.0.1:2181"
sessionTimeout = 6000
connectTimeout = 2000
}
}
Execute /bin/seata-server.bat
(Windows) or /bin/seata-server.sh
(Unix) to start Seata. The service will run on the local port 8091. Open the ZooKeeper command-line client and enter ls /registry/zk/default
, check if the node address is listed, indicating successful registration (as shown below).
[zk: localhost:2181(CONNECTED) 1] ls /registry/zk/default
[127.0.0.1:8091]
Client-side Configuration
If you are using the io.seata:seata-spring-boot-starter
dependency, you need to add the following ZooKeeper configuration in the application.yml file. For additional configurations, please refer to the configuration reference
:
seata:
registry:
type: zk
zk:
server-addr: 127.0.0.1:2181
session-timeout: 6000
connect-timeout: 2000
username:
password:
Alternatively, if you are using the io.seata:seata-all
dependency, add the ZooKeeper configuration in the registry.conf file. For additional configurations, please refer to the configuration reference:
zk {
serverAddr = "127.0.0.1:2181"
session.timeout = 6000
connect.timeout = 2000
username = ""
password = ""
}
After configuring the client, start the application and wait for a moment, the Seata service will be operational soon.