This is the 15th day of my participation in the November Gwen Challenge. Check out the event details: The last Gwen Challenge 2021
Review the
We have covered how to install and deploy the Nacos service in the previous article, and you can successfully enter the interface shown below.
As shown in the figure, we can view the service in the service list, also can configure a management, publishing, and other functions related to permissions.
The current version of Nacos is sufficiently stable for use in enterprise systems.
Found the problem
Nacos can be used as a configuration hub, and its graphical interface is significantly more user-friendly than the SpringCloud Config component.
The SpringCloud Config component persists configuration files to git servers, github, or GitLab, so how does Nacos persist these configurations?
Nacos does not enable persistence by default and requires manual configuration.
The persistence of Nacos is carried out through the MySQL database, so the initialization SQL needs to be executed first to build the database and tables.
How do I configure persistence for Nacos
To configure the persistence of Nacos, we first create the corresponding database and data table, which requires an initialization SQL.
Again, you need to find out which file the persistent switch is in.
Initialize the SQL
Nacos provides the initial SQL, which is in the installation file: Nacos /conf/nacos-mysql.sql.
If you open this file, you can see that Nacos persistence requires database and table information.
Just do it.
How do I enable persistence of Nacos
Again in nacos/conf/, you need to manipulate the application.properties file and add the relevant data source information to this file.
The data source information here is the database information we just created.
Spring. The datasource. Platform = mysql db. Num = 1 db. Url. 0 = JDBC: mysql: / / 127.0.0.1:3306 / mynacos db. User = root db. The password = 123456Copy the code
conclusion
This is all about persistent configuration of Nacos. I hope you can have a certain foundation in daily use.