The following diagram illustrates a typical Dubbo microservice deployment architecture using Nacos and Zookeeper as the registration center.
Please refer to the following documentation for how to install Nacos locally.
We will continue to use the project in Quick Start as an example to demonstrate the detailed steps for application packaging and deployment.
Clone the sample project locally:
$ git clone -b main --depth 1 https://github.com/apache/dubbo-samples
Switch to the sample directory:
$ cd dubbo-samples/11-quickstart
Here are two packaging and deployment modes:
Local packaging process:
$ mvn clean package
Start the Dubbo process:
$ java -jar ./quickstart-service/target/quickstart-service-0.0.1-SNAPSHOT.jar
application.yml
file is correctly pointing to the desired registration center.$ docker build -f ./Dockerfile -t quickstart
$ docker run quickstart -p port1:port2
# Some port or connection details to the registration center need to be clarified
In a Docker container environment, special attention is needed for the addresses used for network communication between different containers. Therefore, you may need to set the address that the Dubbo process listens to or registers with the registration center. Please refer to the following link for more information.
See dubbo sets host through environment variables
Some deployment scenarios require dynamically specifying the service registration address, such as specifying the host machine IP to enable external communication in the Docker bridge network mode. Dubbo provides two pairs of system properties for the startup phase to set the external communication IP and port addresses.
The above four configuration items are optional. If not configured, dubbo will automatically obtain IP and port. Please flexibly choose configurations based on specific deployment scenarios. Dubbo supports multiple protocols, and if an application exposes multiple different protocol services at the same time and needs to specify IP or port for each service separately, please prefix the above properties with the protocol prefix. For example:
PORT_TO_REGISTRY or IP_TO_REGISTRY will not be used as the default PORT_TO_BIND or IP_TO_BIND, but the reverse is true. For example:
PORT_TO_REGISTRY=20881
and IP_TO_REGISTRY=30.5.97.6
does not affect PORT_TO_BIND
and IP_TO_BIND
.PORT_TO_BIND=20881
and IP_TO_BIND=30.5.97.6
, then by default PORT_TO_REGISTRY=20881
and IP_TO_REGISTRY=30.5.97.6
.Install and run dubbo-control-plane to check the local service deployment status:
Download the installation package
$ curl -L https://raw.githubusercontent.com/apache/dubbo-kubernetes/master/release/downloadDubbo.sh | sh -
$ cd dubbo-$version/bin
Run the following command to start the dubbo-control-plane process
$ ./dubbo-cp run
conf/dubbo-cp.yml
to ensure it points to your desired registration center.Visit http://xxx
to view service deployment details.
In the case of using a traditional registration center, we need to control the timing of when instances are published to the registration center and when instances are removed from the registration center to achieve a graceful online and offline:
prestop
to ensure that instance registration information is first removed from the registration center, and then enter the process of destruction.Before going offline, it is recommended to call the following http port to remove the instance from the registration center first, then attempt to stop the process.
$ curl http://offline
$ sleep 10
$ kill dubbo-pid