Nacos local configuration and startup steps and NoDataSourceset problem solving

The premise of the article is that mysql has been installed on the local machine, and the mysql and Java environment variables have been configured.

First find a package on the network nacos-server. Official website download portal

https://github.com/alibaba/nacos/releases

Here's what to do if you have a .gz file instead of a zip file. If you have downloaded a zip file, you can ignore this step:

After decompression, it is a .gz file. You can use the Windows PowerShell tool that comes with Windows to use Linux commands to decompress it. I can directly search for it on the win10 system.

After opening the above tools, use the cd command to enter the folder where the nacos.gz file belongs, and use the tar -zxvf command to decompress the file. After decompression, you can see a folder named nacos in the same location.

The following are the general steps:

 

 The folder directory is as shown in the figure above, where the bin directory allows us to start and stop the switch of the nacos service, and the config folder is the folder for the database information we want to configure.

First configure the database

The configuration of database information is divided into 2 steps:

The first step is to execute the data script in nacos-mysql.sql in the database, that is, create a new database dedicated to nacos in the local mysql database. Here to emphasize:

1) The nacos version I use is version 2.0.4, and the corresponding mysql version is preferably version 5.7, up to mysql8. If the version gap is too large, an error will be reported when the startup is executed.

The second step is to configure the application.properties file in the config directory, and fill in the database information just executed

The user name and password can be filled in according to your own situation, but here are the points to be emphasized: 

2) The name of the mysql database should be consistent with the database information configured in the application.properties file, that is, the name nacos-config above . Otherwise, No DataSource set will be reported  , which is a very troublesome and common error. If you encounter this problem, you can check whether the name of the database behind the port is consistent with the name in your own library .

Then configure the startup items

Here is how to start the startup.cmd file in the bin directory. Since what I am talking about here is the local startup of the machine, that is, the stand-alone startup, the mode should be changed to standalone. The default cluster is the cluster startup. We will not change it . won't start up.

When you start after the change, you can pay attention to whether the change here is successful:

 After everything is saved, double-click startup.cmd to start our nacos:

 As shown in the figure above, the startup is successful.

The most common error in the startup process is NoDataSourceset error, which means that the database is not set. The solution is also described above. As long as the name of the nacos database defined by yourself is consistent with the name in the configuration file, there is no problem. If not, here are two Ideas:

1) Connect to the database locally to check whether the account password is correct, or whether the database is currently available. Sometimes too many connections to the database will cause nacos connection failure.

2) Increase the connection time, increase here, it may be affected by database performance problems, please be patient.

Finally, you can log in to our background management  through http://localhost:8848/nacos/index.html#/login , and the account password is also nacos.

At this point, the local nacos has been realized from scratch, but I should add that the nacos version I used at the beginning is 2.0.4, and mysql is 5.7. I don’t know if it is a version problem or the nacos.server package is not found correctly. Using the built-in data source can start normally, but after introducing the local mysql as the data source, it can’t survive and report an error of no database set. I changed nacos to 2.1 The .1 version can start normally, so the 2.0.4 version of nacos may have some problems.

First record here, if you have any questions, please point them out.

Guess you like

Origin blog.csdn.net/httpmc2018/article/details/128790786