[Original] Nacos updated from 2.0.4 to 2.1.0

foreword

I searched for a long time on the official website of Nacos but couldn’t find a way to upgrade the 2.X version to the new version. I asked in the Nacos DingTalk official group for a long time and no one responded. Other programmers said that they can export the configuration file of the old version and then import it to The new version is installed in Nacos, but I feel that this method is not good. First, all Nacos needs to be reinstalled and configured, and secondly, this method is not elegant enough. In the end I simply decided to do my own research.

Step on the pit

I found that directly replacing the nacos-server.jar in the target is not possible, and an error will be reported:

solution

First of all, go to the comparison tool, download the nacos in the project operating environment, and compare it with the new version 2.1.0 nacos, and find that the difference is very small

Regardless of the difference in application.properties, the difference is only that MySQL is configured, the default is not configured, and the other auth configuration is just a different location. In fact, the uncommented content is the same.

The biggest difference lies in the SQL statement. The SQL of the new version of nacos has three tables with one more field, which is why an error will be reported if the jar package is directly replaced.

Among them, three tables (config_info, config_info_beta, his_config_info) have added the encrypted_data_key field.

So the upgrade method is also very simple, just add the encrypted_data_key field to these three tables.

ALTER TABLE nacos.config_info ADD encrypted_data_key TEXT NOT NULL;

Then just replace nacos/target/nacos-server.jar , replace the 2.1.0 nacos-server.jar package with the original one, and then restart nacos.

About Embedded Derby Database

If you used the embedded database Derby of nacos before, it is recommended to export all the original configuration files, the first option

Then stop the original nacos, start the new version of nacos and import these configuration files into the new nacos, which is the most primitive way, although not elegant, but it can solve the problem, I personally do not recommend using the embedded Derby database

 

Notice

Since Nacos has an update operation, it is recommended to restart all the application modules it manages to prevent the abnormal acquisition of configuration files due to the interruption of Nacos

Guess you like

Origin blog.csdn.net/DCTANT/article/details/125145835