In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces how to interface with CMDB in Nacos v0.7.0 to achieve tag-based service discovery capabilities, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Summary: Nacos recently released version 0.7.0, which supports docking third-party CMDB to obtain CMDB data, using Selector mechanism to configure the routing type of service, supporting stand-alone mode to use MySQL database, launching Node.js client, and fixing some bug.
Nacos recently released version 0.7.0, which supports interfacing with third-party CMDB to obtain CMDB data, using Selector mechanism to configure the routing type of service, supporting stand-alone mode to use MySQL database, launching Node.js client, and fixing some bug.
Access to the nearest by docking with CMDB
Cdn.nlark.com/lark/0/2018/png/15356/1544702277705-0bbfca60-6629-477c-92bb-1a690e68f9cd.png ">
When services are deployed in multiple data centers or regions, the latency of cross-region service access is often high. The typical network latency between data centers in a city is about 1ms, while the network latency between cities, such as Shanghai to Beijing, is about 30ms. A natural idea at this time is whether service consumers and service providers can have access to the same region.
Nacos defines a SPI interface that contains methods agreed with third-party CMDB. After the user implements the corresponding SPI interface in accordance with the contract, pack the implementation into a jar package and place it in the Nacos installation directory. Restart Nacos to connect the data between Nacos and CMDB.
CMDB plug-in development process
Referring to https://github.com/nacos-group/nacos-examples, an example plugin implementation has been given here.
The specific steps are as follows:
Create a new maven project and introduce the dependency nacos-api:
Com.alibaba.nacos nacos-api 0.7.0
Introduce packaging plug-ins:
Org.apache.maven.plugins maven-assembly-plugin jar-with-dependencies
Define implementation classes, inherit com.alibaba.nacos.api.cmdb.CmdbService, and implement related methods.
Create a new directory under the src/main/resource/ directory: META-INF/services
Create a new file com.alibaba.nacos.api.cmdb.CmdbService in the src/main/resources/META-INF/services directory and write the full name of the implementation class created in step 3 to the file:
After the code self-test is completed, execute the command to package:
Mvn package assembly:single-Dmaven.test.skip=true
Upload the jar package containing dependencies under the target directory to the nacos CMDB plug-in directory:
{nacos.home} / plugins/cmdb
Turn on the load plug-in switch in nacos's application.properties:
Nacos.cmdb.loadDataAtStart=true
Restart nacos Server and load it into your nacos-cmdb plug-in to get your CMDB data.
Configure service routing typ
On the console, edit the service and use the same room priority policy:
After this configuration, all consumers who access the service will implement the same server room priority policy.
Support stand-alone mode to use MySQL database
Before version 0. 7, nacos used embedded database to store data in stand-alone mode, so it was not convenient to observe the basic situation of data storage. Version 0.7 adds the ability to support mysql data sources, specific steps:
Install database, version requirements: 5.6.5+
Initialize mysql database, database initialization file: nacos-mysql.sql
Modify the application.properties file to add support for mysql data source configuration (currently only mysql is supported), and add url, user name and password for mysql data source.
Spring.datasource.platform=mysqldb.num=2db.url.0=jdbc:mysql://11.162.196.16:3306/nacos_devtest?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=truedb.url.1=jdbc:mysql://11.163.152.9:3306/nacos_devtest?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=truedb.user=nacos_devtestdb.password=youdontknow
Then start nacos in stand-alone mode
Sh startup.sh-m standalone
Nacos all the data written to the embedded database is written to mysql.
Support for Node.js client
After the launch of the Java version client, we have been thinking about the multilingual version. In the multilingual research, the voice of Node.js is the highest, and many Node.js developers are looking forward to having a native Node.js client to use.
Now we have launched the first version of the client, completed the common addition, deletion, modification and search functions, thus taking the first step towards multilingualization.
Take nacos-config as an example. Here is a simple access instruction. For more information on how to connect, please see https://github.com/nacos-group/nacos-sdk-nodejs.
Import {NacosConfigClient} from 'nacos'; / / tsconst NacosConfigClient = require (' nacos') .NacosConfigClient / / the following code is the addressing mode const configClient = new NacosConfigClient ({endpoint: 'acm.aliyun.com', / / acm console view namespace:' *', / / acm console view accessKey:'*', / / acm console view secretKey:'*' / / acm console to view requestTimeout: 6000, / / request timeout Default 6s}) / / the following code is the direct connection mode const configClient = new NacosConfigClient ({serverAddr: '127.0.0.1 ip 8848, / / opposite ip and port, other parameters are the same as addressing mode}); / / active pull configuration const content= await configClient.getConfig (' test', 'DEFAULT_GROUP'); console.log (' getConfig =', content) On Nacos v0.7.0 on how to interface with CMDB to achieve tag-based service discovery capabilities to share here, I hope that the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.
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.