Installing and using Nacos on Linux operating system is similar to Windows, the following is a detailed step-by-step tutorial. We will use the Standalone mode of Nacos for installation and use. Note that for production environments, cluster mode is recommended for high availability and scalability.
Step 1: Prepare the environment
-
Java Installation: Make sure you have the Java JDK installed (Java 8 or higher is recommended). You can install Java using the package manager that comes with your Linux distribution (such as
apt
oryum
). -
Maven installation (optional): If you plan to build and compile Nacos source code, you can install Maven to build it.
Step 2: Download the Nacos installation package
-
Visit the GitHub repository of Nacos: https://github.com/alibaba/nacos/releases
-
On the Releases page, find and download
nacos-server-$VERSION.zip
, where$VERSION
is the version number of the release.
Step 3: Unzip and configure Nacos
-
Open the terminal, enter the decompressed directory, and
nacos-server-$VERSION.zip
decompress the downloaded file to the directory where you want to install Nacos. -
Enter the unzipped directory and
conf
find the file in the folderapplication.properties
. -
Open the file with a text editor such as
nano
or .vi
application.properties
-
Modify
nacos-server-$VERSION/conf/application.properties
the configuration items in the file, set the database, port and other information (configure according to your needs).
Step 4: Start Nacos
-
In the terminal, enter
bin
the folder under the Nacos decompression directory. -
Run the following command to start Nacos:
sh startup.sh -m standalone
Step 5: Access Nacos console
-
Open your browser and visit http://localhost:8848/nacos.
-
In the login page, the default username and password are both
nacos
.
Step 6: Create namespace and service
-
In the Nacos console, select "Namespace Management", and then click "Create Namespace".
-
In the namespace list, click the namespace you just created, then click Service Management, and then click Create Service.
-
Fill in the service name, cluster name, instance and other information, and then save.
Step 7: Access Nacos service
-
Visit http://localhost:8848/nacos/v1/ns/catalog/serviceList in your browser, and replace it
localhost
with your host name or IP address. -
You will see information about the service you just created.
Step 8: Use Nacos for configuration management (optional)
-
In the Nacos console, select "Configuration Management" and click "New Configuration".
-
Fill in information such as Group, Data ID, configuration format, etc., then fill in the configuration content on the configuration editing page, and save.
-
In your application, use the Nacos client to get the configuration.
Through the above steps, you can successfully install and use Nacos on Linux, and experience its service discovery and configuration management functions. In an actual production environment, you may need more detailed configuration and deployment to meet high availability and scalability requirements.