I learned the start-up in the stand-alone mode earlier. The deployment of nacos in the production environment must use cluster mode to ensure high availability. For the cluster deployment of official documents, it is recommended to use vip domain name mode, put all service lists under one vip, and then hang them under one domain name.

Three deployment modes

It is officially recommended that there are three ways to deploy a nacos cluster. The differences between the three deployment ways in the access form are as follows:,

http://ip1:port/openAPI direct connection ip mode, which can be used only after the ip is modified when the machine is hung

http://VIP:port/openAPI is used to mount VIP mode, which can be connected directly to VIP. The real ip of server is hung below, which is not readable

http://nacos.com:port/openAPI domain name VIP mode, good readability, easy to change ip, recommended mode

It is officially recommended that at least three or more nodes implement the cluster mode.

Modify start port

The default port used for program startup is 8848. We can modify the port, open application.properties in the conf file, and modify the startup port.

Now, I will demonstrate the use of the single machine pseudo cluster mode, so I will deploy the three instances by modifying the ports: 8848, 8858, and 8868.

Configure cluster profile

In the conf directory of nacos / directory, configure the file cluster.conf. Please configure each line as ip:port. (please configure 3 or more nodes)

# ip:port

Configure MySQL database

It is recommended to use at least the active standby mode or the highly available database for production.

Initialize MySQL database

The source file of SQL statement is Nacos mysql.sql under the directory of distribution/conf /. The corresponding database is initialized locally.

Add database configuration

The configuration file is in application.properties under the conf directory of nacos. Add the following configuration


db.num is the number of database instances. If there are multiple database instances, specify different database links through db.url.0 and db.url.1.

Start server

By default, there is no parameter mode, i.e. cluster mode. The startup command is sh startup.sh

Shut down the server and execute sh shutdown.sh directly

Configure Nginx service

Modify conf/nginx.conf configuration

upstream nacos {

server {
    listen 80;
    server_name test.nacos.com;
    location / {
        proxy_pass http://nacos;

Configure domain name test.nacos.com to bind VIP

Service registration and configuration

Service registration

curl -X PUT '

Service discovery

curl -X GET '

Release configuration

curl -X POST "

Get configuration

curl -X GET ""

Cluster management

After the three nodes are started normally, you can log in to each web interface to view the nodes and health status of the cluster

Scan code pays attention to public number: architecture evolution theory, get first-hand technical information and original articles.

Yue Yue
Published 20 original articles, won praise 3, 10000 visitors+