In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly shows you "what are the Nacos cluster deployment models", which is easy to understand and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "what are the Nacos cluster deployment models?"
Preface
Nacos supports two deployment modes: stand-alone mode and cluster mode.
Directly connected mode
The directly connected pattern is the simplest and easiest to understand in deployment.
After adopting the directly connected mode, the typical development scenarios are configured as follows:
Nacos-client configuration
Properties properties = new Properties (); properties.setProperty (PropertyKeyConst.SERVER_ADDR, "192.168.0.1 purl 8848192.168.0.2 purl 8848192.168.0.3 purl 8848"); NamingService namingService = NacosFactory.createNamingService (properties)
Note that the literal amount of PropertyKeyConst.SERVER_ADDR here is: serverAddr
Dubbo configuration
Dubbo.registry.address=192.168.0.1:8848192.168.0.2:8848192.168.0.3:8848dubbo.registry.protocol=nacos
If one day, the IP of Nacos changes, such as capacity expansion, machine replacement, cluster migration and other scenarios, all applications need to be modified, this way is not flexible. So it is not the recommended mode of production.
Mode analysis
High availability. The expansion and expansion of the cluster itself must change the business code in order to be aware. If a node failure occurs, it requires emergency offline, emergency capacity expansion and other scenarios. It is not realistic for the business to modify the code and does not meet the principle of high availability.
Scalability. Same as above, the scalability is not good.
The structure is simple and the cost of user understanding is low.
No additional components are introduced, and there is no operation and maintenance cost of the new components.
VIP mode
VIP (Virtual IP) mode can well solve the problem of application batch modification caused by the change of IP in directly connected mode. What is VIP?
Real Server: the back-end server node that processes the actual request.
Director Server: refers to the load balancer node that receives client requests and forwards them to RS.
The IP address used by VIP:Virtual IP,DS to communicate with the client, as the destination IP address of the client request.
The IP address that IP,DS uses to communicate with the internal RS.
RIP:Real IP, the IP address of the backend server.
CIP:Client IP, the IP address of the client.
Instead of using [load balance mode], I use [VIP mode] when I introduce it here, mainly to keep consistent with the official Nacos documents. In fact, the name VIP is quite popular within Ali, so it is also habitually taken out when opening up Nacos.
VIP helps Nacos Client block the back-end RIP, and VIP rarely changes compared to RIP. Take the expansion scenario as an example, you only need to make VIP aware of it, and Nacos Client only needs to pay attention to VIP to avoid code changes caused by capacity expansion.
As long as it is a component with load balancing capability, you can implement VIP mode, such as open source Nginx and load balancer SLB.
After adopting VIP mode, the code does not need to be aware of RIP. A typical development scenario is configured as follows:
Nacos-client configuration
Properties properties = new Properties (); properties.setProperty (PropertyKeyConst.SERVER_ADDR, "{VIP}: 8848"); NamingService namingService = NacosFactory.createNamingService (properties)
Dubbo configuration
Dubbo.registry.address= {VIP}: 8848dubbo.registry.protocol=nacos
Domain name configuration
Both VIP mode and direct connection mode are not readable, so in actual production, a domain name is often mounted to VIP.
Two VIP can be mounted on the back of the domain name for high availability. Routing to the same rs; and the existence of the domain name also makes the replacement of the VIP more flexible. When there is a problem with one of them, the DNS resolution of the domain name will only be routed to another normal VIP, leaving enough room for smooth replacement.
Tips: a domain name can be bound to multiple A records, and one A record corresponds to an IPv4 type VIP,DNS domain name server. There will be a load balancing policy and health check mechanism for multiple A records.
The final production of the high-availability architecture of the VIP model results in:
In a typical development scenario, you only need to replace VIP with a domain name.
Nacos-client configuration
Properties properties = new Properties (); properties.setProperty (PropertyKeyConst.SERVER_ADDR, "mse-abc123-nacos.mse.aliyuncs.com:8848"); NamingService namingService = NacosFactory.createNamingService (properties)
Dubbo configuration
Dubbo.registry.address=mse-abc123-nacos.mse.aliyuncs.com:8848dubbo.registry.protocol=nacos
Mode analysis
High availability. The DNS domain name server is responsible for the availability of the domain name, and the availability guarantee is high. VIP needs to be supported by highly available balancer components, and traffic is forwarded by load balancer, which requires high availability for the implementation of VIP.
Scalability. When scaling up horizontally, you only need to let VIP perceive it, and it has good scalability.
Rely on the domain name resolution system and load balancing system, production and deployment, need the support of supporting facilities.
Address server mode
Address server introduction
When it comes to address server, you may feel unfamiliar with this word, because the concept of address server is mainly popular in Ali, and it is also the most widely used addressing mode of Ali middleware. But in the open source world, few people will mention it, but for the Nacos deployment model, the address server model is another recommended deployment method for production availability in addition to the VIP model.
What is the address server? As the name implies, it is used to address the server, send a request and return a list of addresses. Although the real address server used inside Ali is a little more complex, the simple interaction logic shown below covers almost 90% of the content of the address server.
It is not difficult to implement a simple version of the address server. It is recommended to use Nginx to build a static file server to manage addresses. Of course, you can use Java!
@ Controllerpublic class AddressServerController {@ RequestMapping ("/ nacos/serverlist") public ResponseEntity serverlist () {return ResponseEntity.ok (). Header ("Content-Type", "text/plain"). Body ("192.168.0.1 8848\ r\ n" + "192.168.0.2 8848\ r\ n" + "192.168.0.3 purl 8848\ r\ n");}}
The address server can be used to decouple the cluster address and client configuration, and solve the problem that the cluster node can not be dynamically perceived in the directly connected mode. The client connects in direct connection mode according to the list returned by the address server, and after the client starts, it starts a timer to poll for aware AddressServer changes, and then updates the address list in a timely manner.
And the address server suggests configuring the domain name to increase readability. So the final deployment interaction architecture looks like this:
Friends who are familiar with RPC should be able to make a good analogy between the VIP mode and the address server mode:
VIP mode is a server load balancing technology similar to DNS.
Address server is a client load balancing technology similar to service discovery mechanism.
The source code of nacos-client is specially adapted to the address server mode. We only need to configure the endpoint of addressServer.
Nacos-client configuration
Properties properties = new Properties (); properties.setProperty (PropertyKeyConst.ENDPOINT, "{addressServerDomain}"); properties.setProperty (PropertyKeyConst.ENDPOINT_PORT, "8080"); NamingService namingService = NacosFactory.createNamingService (properties)
Note that the literal amount of PropertyKeyConst.ENDPOINT here is: endpoint, which is configured with the address of the address server.
Dubbo configuration
Dubbo.registry.address=0.0.0.0?endpoint=127.0.0.1&endpointPort=8080dubbo.registry.protocol=nacos
The url of dubbo.registry.address can be entered arbitrarily, because when both serverAddr and endpoint exist at the same time, the address is selected first from the address server by default.
At this point, you only need to configure the real Nacos Server IP to the address server.
Dubbo passes the value through to Nacos to create a Nacos-Client through the kv attribute of url. When Dubbo + Nacos uses the address server mode, it is recommended that the Dubbo version > = 2.7.4 precinct nacosyl client version > = 1.0.1
Mode analysis
High availability. The availability of the domain name needs to be taken care of by the DNS domain name server, and the availability guarantee is high; the address server has a single responsibility and high availability; Client is directly connected to the Nacos Server node at run time, and the availability is guaranteed by nacos-sdk.
Scalability. When scaling up horizontally, you only need to make the address server aware of it, and it has good scalability.
Rely on the domain name resolution system and address server, production and deployment, need the support of supporting facilities.
Deployment model comparison
Nacos, an open source product, well supports the address server model, so when large, medium and small companies build their own Nacos, they can choose the address server mode to build a highly available Nacos cluster. The address server component is relatively simple to maintain, and the Web server built by Nginx,Java can easily implement an address server. After using the address server, there is still a direct connection between nacos-client and nacos-server, so it can operate well under a flat network.
VIP mode is also recommended for self-built scenarios, but the operation and maintenance cost is still higher than the address server, which can be evaluated according to your company's operation and maintenance system. After being forwarded by VIP, it has both advantages and disadvantages. The disadvantages are obvious, the network has one more hop, which is unnecessary for a flat network such as the intranet environment, and the advantages are also obvious. Large companies often have a complex environment, there is network isolation between data centers, and applications and middleware may be deployed in different network environments. With the help of VIP, the network can be well connected, and security groups, ACL and other characteristics can be well realized based on VIP, which is more in line with the requirements of enterprises.
Of course, it is also possible to combine address server and VIP, which can fully combine the advantages of the two:
The practice of MSE Nacos
The above scenarios mainly introduce the specific deployment schemes of the three modes, and how to achieve high availability in self-built Nacos scenarios. Finally, we will introduce how the environment MSE is deployed.
MSE (Micro Services engine) provides the full hosting capability of the Nacos registry. In addition to the high availability, scalability, and ease of use mentioned above, the following factors should also be considered:
Open source acceptance. Avoid bringing too much understanding cost to users, and try to be open source, so that the acceptance of users will be high.
Network isolation. MSE provides BaaS-based capabilities. Nacos Server is deployed in the cloud product VPC and is isolated from the user VPC, so the network isolation problem needs to be solved.
network security. MSE Nacos is an exclusive mode, and tenant isolation on the network is the most basic requirement. In addition, enterprise users will put forward security group / ACL control requirements to MSE Nacos, which need to be considered.
To sum up, MSE Nacos finally adopts the VIP mode of domain name + SLB.
MSE Nacos provides two domain names, of which the public network domain name can be used as an access point for local development testing, or for scenarios such as self-built environment and hybrid cloud, and the private network domain name can be used as an access point for production environment. The public network domain name has a bandwidth limit, which needs to be selected according to the scenario when the cluster is created, while the private network domain name has no bandwidth limit. Please add IP access whitelist for public network domain name.
These are all the contents of the article "what are the Nacos cluster deployment models?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.