### Nacos Technical explanation ** When it comes to decentralized systems, I don't want to mention CAP Principles ** #### What is CAP **CAP Principles are also called CAP Theorem , In a decentralized system , Uniformity (Consistency)、 Usability (Availability)、 Fault tolerance of dividing slot (Partition tolerance).CAP Principle means , These three elements can only achieve two points at most at the same time , It's impossible to combine the three .** **CAP Under the principle of Alibaba Naos Simultaneous support AP and CP Pattern , He chooses temporary and permanent based on service registration AP The pattern is still CP Pattern , He's here to support CP The pattern is to my understanding , It should be to configure the central cluster , Because nacos It can be both a registry and a configuration center , Because his configuration center information is stored in nacos Inside , If because of nacos When one of them went down , There is no synchronization configuration information yet , Configuration inconsistency may occur ., The configuration change of the configuration center is that the server has a listener , Configuration changes in the configuration center , Then the server will listen to the configuration change , To make a change ** ** Now I build a simple micro service system , Explain the system ** **( Personal servers , Limited flow , Please cherish )[ Click on the project experience address ](https://ityml.com/index)https://ityml.com/index** ** System architecture diagram :**  ** This mainly completes a front-end page for real-time calculation function , You can understand it as a simple calculator .** * website : front end * Gateway : Service gateway * UserCenter : User services * MqCenter: Information services * AlogirthmCenter: Computing services * ConfigCenter: Configuration center * ServiceDiscovery(Nacos): Service discovery * CPP For C The calculation flow written in language ** The technology stack used in this project includes ,Spring Cloud Alibaba/Spring Boot/Mysql/MQ/Linux etc. ** #### What is Nacos **[ official document ](https://nacos.io/zh-cn/docs/quick-start-spring.html)** **Nacos Provide 「 Registration Center 」、「 Configuration center 」 and 「 Dynamic DNS Service 」 Three functions .** ** It's on it Nacos You can learn about it by yourself , Yes Nacos Do a deep understanding of , The so-called master leads the door , Practice is personal , We need to learn more , Learn more about ** ** It's getting late , There were a lot of people , Talk less , Get down to business first .** ** [Nacos Download address ](https://github.com/alibaba/nacos/releases)** ** Select the corresponding version to decompress ( Be careful Nacos After decompression It's a complete execution package , If you don't use it skillfully , Don't touch the configuration information in it )**  ** After downloading, unzip and enter bin Catalog Execute the command at the terminal ** * MAC `sh startup.sh -m standalone` (standalone Stands for stand-alone mode execution , Later, we will explain how to build and start cluster mode ) * Windows `cmd startup.cmd` ** After starting successfully Default account password nacos/nacos( Initial account password )**  ** After logging in, you can see the Chinese and English switch in the upper right corner , Students who are not good at English You can switch to Chinese **  * Configuration management is mainly used for project configuration , For example, configuration files can be used nacos To manage Because nacos It's not just a service center , It's also a configuration center ( I'll talk about it later ) Our development project configuration generally has the following methods : 1. Hard code -- As a form of class field , Lead to : Dynamic modification is difficult , No persistence 2. Configuration file ( properties、yml Files, etc )-- Lead to : Configuration changes dynamically , You may need to restart the application , Make the configuration work . Of course , You can also add a timed task to your code , Every time 10s Read configuration file contents , Let the latest configuration take effect in the application in time , That way, you won't have to To restart the application “ Heavy ” Operation and maintenance operation of . 3. DB Configuration table -- Lead to : Configuration changes dynamically , It may need to be solved through the exposure management interface . **Nacos Really separate the configuration from the application , Unified management , Elegant solution to dynamic configuration changes 、 Persistence 、 Operation and maintenance costs and other issues . The application itself does not need to add a new management configuration interface , You don't need to implement the persistence of the configuration by yourself , There is no need to introduce “ Scheduled tasks ” In order to reduce operation and maintenance costs .Nacos Provides configuration management functions , Collapse all the logic related to the configuration , And it's easy to use SDK, So that the configuration of the application can be very convenient Nacos It's more than that in management ,Nacos Provide DNS-F function , Can be associated with K8S、Spring Cloud and Dubbo And other open source products to integrate , Realize the registration function of the service .** * Service discovery is used to manage registration to nacos Microservices on , Can achieve services offline and other functions . * The name space is used to distinguish the service environment , When a project needs to be developed , Test , Production and many different configurations , The name space can be used for configuration isolation . * Cluster management I'll talk about it later ** The next chapter will explain how to use Nacos Register a simple micro