learning target
This article can quickly help you build the nacos service. For readers, you can click the corresponding link to download, and gently copy and paste the corresponding startup command to quickly run the nacos service
version selection
You can find an introduction to the functions supported by each version in the release notes and blog of Nacos . The currently recommended stable version is 2.0.3.
Prepare environment
Nacos relies on the Java environment to run. If you are building and running Nacos from the code, you also need to configure the Maven environment for this, please ensure that it is installed and used in the following version environment:
64 bit OS, supports Linux/Unix/Mac/Windows, Linux/Unix/Mac is recommended.
64 bit JDK 1.8+; download & configure.
Maven 3.2.x+; download & configure.
Download source code or installation package
You can obtain Nacos through source code and release package.
- Download the source code from Github
git clone https://github.com/alibaba/nacos.git
cd nacos/
mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U
ls -al distribution/target/
// change the $version to your actual path
cd distribution/target/nacos-server-$version/nacos/bin
- How to download the compressed package after compiling
You can download the nacos-server-$version.zip package from the latest stable version. As shown in the picture:
unzip nacos-server-$version.zip 或者 tar -xvf nacos-server-$version.tar.gz
cd nacos/bin
start server
Linux/Unix/Mac
startup command (standalone represents stand-alone mode operation, non-cluster mode):
sh startup.sh -m standalone
If you are using the ubuntu system, or if you run the script and report an error message [[The symbol cannot be found, you can try to run it as follows:
bash startup.sh -m standalone
Windows
startup command (standalone represents stand-alone mode operation, non-cluster mode):
startup.cmd -m standalone
Or, modify the script and change it to "standalone" as shown in the figure, so that double-clicking under Windows can run in stand-alone mode
Service Registration & Discovery and Configuration Management
- service registration
curl -X POST 'http://127.0.0.1:8848/nacos/v1/ns/instance?serviceName=nacos.naming.serviceName&ip=20.18.7.10&port=8080'
- service discovery
curl -X GET 'http://127.0.0.1:8848/nacos/v1/ns/instance/list?serviceName=nacos.naming.serviceName'
- publish configuration
curl -X POST "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&group=test&content=HelloWorld"
- get configuration
curl -X GET "http://127.0.0.1:8848/nacos/v1/cs/configs?dataId=nacos.cfg.dataId&group=test"
shutdown server
Linux/Unix/Mac
sh shutdown.sh
Windows
shutdown.cmd
Or double-click shutdown.cmd to run the file.