Install nacos under windows and set it to start automatically

1. Download nacos

Nacos official website document introduction: https://nacos.io/zh-cn/docs/what-is-nacos.html

Download address: https://github.com/alibaba/nacos/releases/tag/1.4.0
insert image description here

2. After downloading and decompressing, configure nacos to start in stand-alone mode

Tip : Nacos defaults to cluster mode after decompression, here we need to set it to stand-alone mode. It is convenient for local development and use. (In the production environment, you still have to use the cluster mode to ensure the high availability of nacos services)

The decompression directory of nacos in this article is D:\tools\ You can change it yourself if necessary

  1. Enter the nacos\bin directory.
  2. Right-click to edit the startup.cmd file
  3. Find set MODE="cluster" and change cluster to standalone
  4. Save and exit

3. Configure the db mode of nacos

Tips:
The data of nacos is stored in memory by default, and the data will be deleted after the machine is restarted. All suggestions are saved in database. This article uses the mysql database mode.

Open the application.properties file. Find the location as shown below. Perform the following operations ( note : the data mode must have a nacos database, and the sql file is also under the conf directory. Create a naocs database, import the nacos-mysql.sql file into the database and execute it )

insert image description here
Release the comment in the red box. Copy the following configuration into the configuration file.

spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://172.16.2.41:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user.0=root
db.password.0=*******

After the configuration is complete, save and exit.

4. Start the test

 1. 进入nacos\bin目录 双击startup.cmd文件。出现下图信息说明启动成功。

insert image description here

5. Configure windows to start automatically

Tip: Close the cmd window in the above steps first. Close naocs.

设置windows开机自启需要使用到WinSW.NET4.exe工具
[下载地址:](https://github.com/winsw/winsw/releases/tag/v2.11.0)

insert image description here
Rename WinSW.NET4.exe to nacos-service.exe and put it in the bin directory of naocs. And create a configuration file nacos-service.xml in this directory

insert image description here

<service>
  <!-- 唯一服务ID-->
  <id>nacos</id>
  <!-- 显示服务的名称 -->
  <name>Nacos Service</name>
  <!-- 服务描述 -->
  <description>Nacos服务</description>
  <!-- 日志路径 注意这里的路径改为你的nacos路径-->
  <logpath>D:\tools\nacos\bin\logs\</logpath>
  <!-- 日志模式 -->
  <logmode>roll</logmode>
  <!-- 可执行文件的命令 注意这里的路径改为你的nacos路径-->
  <executable>D:\tools\nacos\bin\startup.cmd</executable>
  <!-- 停止可执行文件的命令 注意这里的路径改为你的nacos路径-->
  <stopexecutable>D:\tools\nacos\bin\shutdown.cmd</stopexecutable>
</service>

The above code is the configuration code of nacos-service.xml. Note that the above paths need to fill in their own specific paths.

Save after configuration. Enter cmd in the current file and press Enter.

insert image description here
Enter nacos-service.exe install and the following figure will appear and indicate success. Uninstall command: nacos-service.exe uninstall

insert image description here
Finally, click the start icon (the win icon in the lower left corner), hold down win+x, and double-click the program in the red box.

insert image description here
Enter net start nacos and the following message appears, indicating that the startup is successful. Pause command: net start nacos

insert image description here

6. Verify whether to join the windwos service and start automatically

Right-click the computer icon and click Manage, and click to view as shown in the figure below. Click on the keyboard on the right and enter n to quickly view n development services.

insert image description here

Right-click nacos.Service and click Properties to perform the following configurations. When naocs fails to start, it will automatically restart.

insert image description here

Open the browser and enter localhost:8848/nacos, the login page as shown below will appear and the installation is successful. Default account nacos password nacos

insert image description here

Reference blog: https://www.cnblogs.com/bayu/articles/15766965.html

Guess you like

Origin blog.csdn.net/GBK_8/article/details/123631533