Take Service-center as an example, reference to ServiceCenter Quick Start
Requirements, Golang version 1.11+
# Get Service-center Syncer source code from github $ git clone https://github.com/apache/servicecomb-service-center.git $GOPATH/src/github.com/apache/servicecomb-service-center $cd $GOPATH/src/github.com/apache/servicecomb-service-center # Set "go mod" compile env $ GO111MODULE=on go mod download $ GO111MODULE=on go mod vendor # Build it $ cd syncer $ go build
sc-addr
Service center address, which is the service registry address. Cluster mode is supported, and multiple addresses are separated by commas.
bind-addr
P2P address of Syncer for communication with other Syner members in P2P networks by Gossip.
rpc-addr
Address of Syncer for data transmission, used to synchronize microservices data between Syncers.
join-addr
The address of any member of the P2P network, to enable itself join the specified P2P network, ignore this parameter when starting the first syncer on a P2P network.
mode
Runtime mode of Syncer, specify ‘cluster’ for cluster mode which enables each Syncer to have three instance, default to ‘single’ mode.
cluster-name
Name of the Syncer cluster when mode is set to be ‘cluster’.
cluster-port
The port that the Syner cluster members communicate with when mode is set to be “cluster”.
node
Member name of Syncer cluster when mode is set to be “cluster”.
Incremental Synchronization:
Default synchronization mode.
Full Synchronization:
A full synchronization is automatically triggered when each syncer starts to join, or it can be triggered manually by calling the interface after an exception occurs in the incremental synchronization.
$ curl http://localhost:30300/v1/syncer/full-synchronization
Suppose there are 2 Service centers, each of them with a Service-center cluster for microservices discovery and registry, as following,
Servicecenter | Local address |
---|---|
http://10.0.0.10:30100 | 10.0.0.10 |
http://10.0.0.11:30100 | 10.0.0.11 |
Start Service-center Syncer to enable communication between 2 service centers
$ ./syncer daemon --sc-addr http://10.0.0.10:30100 --bind-addr 10.0.0.10:30190 --rpc-addr 10.0.0.10:30191
$ ./syncer daemon --sc-addr http://10.0.0.11:30100 --bind-addr 10.0.0.11:30190 --rpc-addr 10.0.0.11:30191 --join-addr 10.0.0.10:30191
Start 2 Syncer clusters on there host to synchronize microservice data between the 2 service centers
$ ./syncer daemon --sc-addr http://10.0.0.10:30100 --bind-addr 10.0.0.10:30190 --rpc-addr 10.0.0.10:30191 --mode cluster --node syncer011 --cluster-port 30201 --join-addr 10.0.0.10:30190 $ ./syncer daemon --sc-addr http://10.0.0.10:30100 --bind-addr 10.0.0.10:30290 --rpc-addr 10.0.0.10:30291 --mode cluster --node syncer012 --cluster-port 30202 --join-addr 10.0.0.10:30190 $ ./syncer daemon --sc-addr http://10.0.0.10:30100 --bind-addr 10.0.0.10:30390 --rpc-addr 10.0.0.10:30391 --mode cluster --node syncer013 --cluster-port 30203 --join-addr 10.0.0.10:30190
$ ./syncer daemon --sc-addr http://10.0.0.11:30100 --bind-addr 10.0.0.11:30190 --rpc-addr 10.0.0.11:30191 --mode cluster --node syncer021 --cluster-port 30201 --join-addr 10.0.0.10:30190 $ ./syncer daemon --sc-addr http://10.0.0.11:30100 --bind-addr 10.0.0.11:30290 --rpc-addr 10.0.0.11:30291 --mode cluster --node syncer022 --cluster-port 30202 --join-addr 10.0.0.10:30190 $ ./syncer daemon --sc-addr http://10.0.0.11:30100 --bind-addr 10.0.0.11:30390 --rpc-addr 10.0.0.11:30391 --mode cluster --node syncer023 --cluster-port 30203 --join-addr 10.0.0.10:30190
Verification
30 seconds after registering a microservice to one of the Service-centers, the information about it can be get from the other one.
Syncer is in developing progress, reference to TODO to get more developing features. Supported features are listed as follows,