Skip to content
新趋势、新开源、新实践|云栖大会 AI 原生应用架构专场邀您参会Know more

Cluster Deployment Guide

Cluster deployment instructions

Document optimizing…

This quick start manual assists you in rapidly downloading, installing, and using Nacos in a production-ready clustered mode on your computer.

Cluster Deployment Architecture

Open-source recommendations include placing all service lists under a VIP and associating it with a domain name.

  • <http://ip1:port/openAPI>: Direct IP mode requires IP modification when a machine fails.
  • <http://SLB:port/openAPI>: SLB (intranet) mounting mode is not to be exposed to the public network due to security risks.
  • <http://nacos.com:port/openAPI>: Domain + SLB (intranet) mode is recommended for its readability and easy IP swapping.

deployDnsVipMode.jpg

PortOffset from Main PortDescription
88480Primary port used by clients, console, and OpenAPI for HTTP requests.
98481000gRPC client request to server port, for client-initiated connections and requests.
98491001Server-to-server gRPC request port for service synchronization, etc.
7848-1000Jraft request to server port, for handling Raft-related requests among servers.

When using VIP/nginx, configure TCP forwarding instead of http2 to prevent connection termination by nginx. Ports 9849 and 7848 are for inter-service communication; do not expose them to external networks or clients.

1. Prerequisite Environment Preparation

Ensure the following are installed and used:

2. Obtain Source Code or Installation Package

Nacos can be obtained through two methods.

Download Source Code from GitHub

Terminal window
unzip nacos-source.zip
cd nacos/
mvn -Prelease-nacos clean install -U
cd nacos/distribution/target/nacos-server-1.3.0/nacos/bin

Download Compiled Package

Download from the latest stable version nacos-server-$version.zip or nacos-server-$version.tar.gz.

Terminal window
unzip nacos-server-$version.zip or tar -xvf nacos-server-$version.tar.gz
cd nacos/bin

3. Configure Cluster Configuration Files

Under the conf directory in the extracted nacos/, edit cluster.conf with each line as ip:port (minimum 3 nodes).

# ip:port
200.8.9.16:8848
200.8.9.17:8848
200.8.9.18:8848

3.1 Enable Default Authentication Plugin (Optional)

Modify application.properties in the conf directory.

Set:

nacos.core.auth.enabled=true
nacos.core.auth.system.type=nacos
nacos.core.auth.plugin.nacos.token.secret.key=${custom, ensure consistency across all nodes}
nacos.core.auth.server.identity.key=${custom, ensure consistency across all nodes}
nacos.core.auth.server.identity.value=${custom, ensure consistency across all nodes}

For more details, refer to Authentication.

Note: The default values SecretKey012345678901234567890123456789012345678901234567890123456789 and VGhpc0lzTXlDdXN0b21TZWNyZXRLZXkwMTIzNDU2Nzg= are public defaults, suitable for temporary testing. Replace with custom values for actual use.

4. Determine Data Source

Use Built-in Data Source

No configuration required.

Use External Data Source

Recommended for production in at least master-slave mode or with a highly available database.

Initialize MySQL Database

SQL script source

application.properties Configuration

application.properties file

5. Start Server

Linux/Unix/Mac

Standalone Mode

Terminal window
sh startup.sh -m standalone

Cluster Mode

Built-in Data Source

Terminal window
sh startup.sh -p embedded

External Data Source

Terminal window
sh startup.sh

6. Service Registration & Discovery and Configuration Management

Service Registration

Terminal window
curl -X POST 'http://127.0.0.1:8848/nacos/v1/ns/instance?serviceName=nacos.naming.serviceName&ip=20.18.7.10&port=8080'

If the default authentication plugin is enabled, include credentials in the Header.

Service Discovery

Terminal window
curl -X GET 'http://127.0.0.1:8848/nacos/v1/ns/instance/list?serviceName=nacos.naming.serviceName'

If the default authentication plugin is enabled, include credentials in the Header.

Publish Configuration

Terminal window
curl -X POST "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&group=test&content=helloWorld"

If the default authentication plugin is enabled, include credentials in the Header.

Retrieve Configuration

Terminal window
curl -X GET "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&group=test