scene
What is Nacos
Nacos is dedicated to helping you discover, configure, and manage microservices. Nacos provides a set of easy-to-use feature sets to help you quickly realize dynamic service delivery
Service configuration, service metadata and flow management.
Nacos helps you build, deliver, and manage microservice platforms more quickly and easily. Nacos is to build a modern application architecture centered on "service" (for example)
Such as micro service paradigm and cloud native paradigm).
Nacos panorama
Blog:
https://blog.csdn.net/badao_liumang_qizhi
Official account
Domineering procedural ape
Get programming related e-books, tutorial push and free download.
realization
Nacos official documents:
https://nacos.io/zh-cn/docs/quick-start.html
Nacos download address:
https://github.com/alibaba/nacos/releases
Select the specified stable version to download. This is Windows, so select the zip package to download
When the download is completed, extract it to a directory on the disk
Nacos persistence
To prevent data loss after Nacos downtime or restart, Nacos supports unified persistence of data to Mysql database (when Nacos persistence to Mysql is not configured,
By default, Nacos has built-in an embedded database derby, which saves some data to the built-in database (multiple built-in databases will appear for multiple Nacos).
Connect to the Mysql database for Nacos persistence and create a new database nacos_config
Why is it called nacos_config? This is because the extracted database is in the nacos-mysql.sql file in the conf directory of Nacos
The default database name is nacos_config
After creating a new database, execute the above nacos-mysql.sql file in the database to initialize the database.
Then go back to the application.properties in the conf directory under the Nacos decompression directory
Remove the comments from the above code to open persistent Mysql, and change the url, user name and password of the connected database to your own.
### If use MySQL as datasource: spring.datasource.platform=mysql ### Count of DB: db.num= 1 ### Connect URL of DB: db.url. 0= jdbc: mysql:/ /127.0.0.1:3306/nacos_config?characterEncoding=utf8&connectTimeout= 1000&socketTimeout= 3000&autoReconnect= true&useUnicode= true&useSSL= false&serverTimezone=UTC db.user=root db.password= 123456
Start Nacos
Then go back to the bin directory after extracting the directory above
The startup.cmd and shtudown.cmd here are the startup and shutdown commands under Windows, but an error will be reported if you double-click them directly.
This is because Nacos does not configure the cluster mode, but uses the stand-alone mode, so edit startup.cmd,
Change the MODE to standalone
The default MODE value is "cluster"
Therefore, when following the logic below, we will follow the logic of cluster mode
if %MODE% == "standalone" ( echo "nacos is starting with standalone" set "NACOS_OPTS=-Dnacos.standalone=true" set "NACOS_JVM_OPTS=-Xms512m -Xmx512m -Xmn256m" ) rem if nacos startup mode is cluster if %MODE% == "cluster" ( echo "nacos is starting with cluster" if %EMBEDDED_STORAGE% == "embedded" ( set "NACOS_OPTS=-DembeddedStorage=true" ) set "NACOS_JVM_OPTS=-server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=%BASE_DIR%\logs\java_heapdump.hprof -XX:-UseLargePages" )
After editing, double-click startup.cmd
Then open the browser to access
The default user name and password are all nacos
After successful login