Fading Coder

One Final Commit for the Last Sprint

Home > Notes > Content

Installation and Configuration of Nacos on Windows

Notes May 14 1

Downloading and Extracting Nacos

To set up Nacos, navigate to the official Nacos website or the release page on GitHub. Select the specific version tag you require and download the distribution package compatible with your operating system (Windows). Once downloaded, extract the archive to a local directory.

Database Configuration

By default, Nacos uses an embedded Derby database for storage. For production environments or persistent storage, it is recommended to configure MySQL. Follow these steps to set up the external database:

  1. Create a new MySQL database named nacos_config.
  2. Locate the SQL initialization script within the extracted directory at conf/nacos-mysql.sql. Execute this script against your newly created database to generate the required tables.
  3. Open the configuration file conf/application.properties. You need to modify the data source settings to point to your MySQL instance.

Replace the default storage configuration with the following properties, adjusting the JDBC URL, username, and password to match your environment:

#*************** Config Module Related Configurations ***************#

# Switch datasource to MySQL
spring.datasource.platform=mysql

# Number of database instances
db.num=1

# JDBC connection parameters
db.url.0=jdbc:mysql://127.0.0.1:3306/nacos_config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&serverTimezone=UTC
db.user.0=nacos_user
db.password.0=your_secure_password

Configuring Startup Mode

The default startup script for Windows (bin/startup.cmd) is configured to run Nacos in cluster mode. Cluster mode requires a complex network setup and is not suitable for a local single-machine installation. To run Nacos locally, you must switch it to standalone mode.

Open bin/startup.cmd in a text editor and look for the section defining the MODE variable. Change the value from "cluster" to "standalone":

set MODE="standalone"

Launching the Service

Navigate to the bin directory in your command prompt or terminal and execute the startup script:

startup.cmd

Alternatively, you can simply double-click the startup.cmd file in File Explorer.

Accessing the Console

Once the service has started successful, open your web browser and navigate to the following URL:

http://127.0.0.1:8848/nacos

You will be redirected to the login page. The default credentials are:

  • Username: nacos
  • Password: nacos

After logging in, you will gain access to the Nacos console where you can manage configurations and service discovery.

Troubleshooting Common Issues

1. Startup Crash or "heapdump" Path Error

If the application crashes immediately upon launching or you encounter an error message similar to "The filename, directory name, or volume label syntax is incorrect" involving \logs\java_heapdump.hprof, check your file path.

Cause: The installation path contains non-ASCII characters or spaces (e.g., a folder named "软件" or "Program Files").

Resolution: Move the Nacos folder to a directory path that contains only standard English characters and no spaces (e.g., C:\nacos\).

2. "Unable to start embedded Tomcat"

If the service fails to start citing an embedded Tomcat error, verify the startup mode configuration.

Cause: The startup.cmd is still attempting to launch in cluster mode, but the necessary cluster configuration files (like cluster.conf) or network topology are not set up for a single local node.

Resolution: Ensure you have modified bin/startup.cmd to set set MODE="standalone" as described in the configuration section.

Tags: nacoswindows

Related Articles

Designing Alertmanager Templates for Prometheus Notifications

How to craft Alertmanager templates to format alert messages, improving clarity and presentation. Alertmanager uses Go’s text/template engine with additional helper functions. Alerting rules referenc...

Deploying a Maven Web Application to Tomcat 9 Using the Tomcat Manager

Tomcat 9 does not provide a dedicated Maven plugin. The Tomcat Manager interface, however, is backward-compatible, so the Tomcat 7 Maven Plugin can be used to deploy to Tomcat 9. This guide shows two...

Skipping Errors in MySQL Asynchronous Replication

When a replica halts because the SQL thread encounters an error, you can resume replication by skipping the problematic event(s). Two common approaches are available. Methods to Skip Errors 1) Skip a...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.