Abstract: Nacos has recently released version 0.7.0, which supports connecting with third-party CMDB to obtain CMDB data, using Selector mechanism to configure the routing type of service, supporting MySQL database in standalone mode, launching node.js client, and fixing some bugs.
Nacos recently released version 0.7.0, which supports connecting to third-party CMDB to obtain CMDB data, using Selector mechanism to configure the routing type of the service, supporting MySQL database in standalone mode, launching node.js client, and fixing some bugs.
-> “Ariba Middleware” wechat official account will send “Nacos” in the background to learn more information about the project.
Connect to the CMDB for the nearest access
When the service is deployed in multiple rooms or regions, the service access latency across regions is high. The typical network latency between rooms in a city is about 1ms, while the network latency between rooms in a city is about 30ms, for example, from Shanghai to Beijing. A natural thought at this point was to enable service consumers and service providers to access the same territory.
Nacos defines an SPI interface that contains methods contracted with third-party CMDB. After the corresponding SPI interface is implemented according to the convention, the user will put the implementation into JAR package in the Nacos installation directory, and restart Nacos to make the data between Nacos and CMDB open.
CMDB plug-in development process
Reference github.com/nacos-group… A sample plugin implementation is given here. The specific steps are as follows:
-
Create a Maven project and introduce dependencies on nacos-API:
< the dependency > < groupId > com. Alibaba. Nacos < / groupId > < artifactId > nacos - API < / artifactId > < version > 0.7.0 < / version > </dependency>Copy the code
-
Introducing packaged plug-ins:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <configuration> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> </plugin>Copy the code
-
Define the implementation class, inheritance com. Alibaba. Nacos. API. CMDB. CmdbService, and implement relevant methods.
-
Create a new directory: meta-INF /services under SRC /main/resource/
-
In SRC/main/resources/meta-inf/services directory file new com. Alibaba. Nacos. API. CMDB. CmdbService, and in the file will be created in step 3 the implementation class name written to the file:
-
After the code is self-tested, execute the command to package:
mvn package assembly:single -Dmaven.test.skip=trueCopy the code
-
Upload the jar package containing the dependencies from the target directory to the nacos CMDB plugin directory:
{nacos.home}/plugins/cmdbCopy the code
-
In nacOS application. Properties, turn on the plug-in loading switch:
nacos.cmdb.loadDataAtStart=trueCopy the code
- Restart the nacOS Server and load the NACOS-CMDB plug-in you implement to get your CMDB data.
Configure the service route type
On the console, edit the service using the same room priority policy:
After this configuration, all consumers accessing the service implement the same room priority policy.
MySQL database can be used in single-machine mode
Prior to version 0.7, NACOS used an embedded database for data storage in stand-alone mode, making it difficult to observe the basic situation of data storage. Support for mysql data sources was added in version 0.7.
The database version must be 5.6.5+
Initialize the mysql database with the database initialization file nacos-mysql.sql
Modify the application.properties file, add support for mysql data source configuration (currently only mysql), add mysql data source URL, user name, and password.
Spring. The datasource. Platform = mysql db. Num = 2 db. 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=true
db.user=nacos_devtest
db.password=youdontknowCopy the code
Nacos is then started in single-machine mode
sh startup.sh -m standaloneCopy the code
Nacos writes all the data to the embedded database to mysql
Node.js client is supported
After the release of the Java version client, we have been thinking about the multi-language version. In the multi-language research, Node.js is the most popular, and many Node.js developers are looking forward to having the native Node.js client available. Now we have launched the first version of the client, complete the common add, delete, change and check functions, with this, the first step towards multi-language.
Take nacos-config as an example. The following is a simple access instruction. For details, see github.com/nacos-group…
import {NacosConfigClient} from 'nacos'; // ts
const NacosConfigClient = require('nacos').NacosConfigClient; // the following code is addressing mode const configClient = new NacosConfigClient({endpoint:'acm.aliyun.com'// ACM console View namespace:'* * * * * * * * * * * * * * *'// Acm console to view accessKey:'* * * * * * * * * * * * * * *'// Acm console to view secretKey:'* * * * * * * * * * * * * * *', // acm console check requestTimeout: 6000, // requestTimeout, default 6s}); // Const configClient = new NacosConfigClient({serverAddr:'127.0.0.1:8848', // peer IP and port, other parameters with addressing mode}); Const Content = await configClient.getConfig('test'.'DEFAULT_GROUP');
console.log('getConfig = ',content);Copy the code
The thriving Nacos community
DISS is cheap, show me your hand more important than teasing is helping the community develop Nacos
- Follow and join the Nacos community as a user
Nacos community is thriving. As of the date of publication, Nacos has 5 wechat groups in just a few months, 4 of which are full, 1 QQ group and 1 Dingdinggroup. The number of community concerned about Nacos has nearly 3000 people, exchanging technology and experience with “Dao (basis) friends” in the Nacos group. Recruiting friends, grabbing red envelopes… It’s a joy.
To join the Nacos wechat community, you can scan the wechat QR code of __ “Chao Ge” __ below and ask __ “Chao Ge” __ to help you join the “Nacos community wechat Communication Group”.
- Join the Nacos community as a code contributor
It is natural to develop from Nacos users to contributors, and the Nacos development team is indeed growing, from only 4 code contributors at the beginning to 24 at present, with other team members of __ Alibaba, such as @Xiaogao et al., and the @Zhangbo@Zhou Jian team of __ Huya Live __, Nacos-docker-k8s contributor @Zhang Long__, the main contributor of the front end of the leme __@ Wang Yanmin __, the founder of Spring Cloud Chinese community __@ Xu Jin and others have joined in, we believe that the power of the nacOS community will be more and more powerful in the future.
The community is also planning to add a team introduction page on Nacos website nacos. IO at the appropriate time to officially announce everyone, welcome to join the Nacos community and contribute to the community. In Apache parlance, __ “community over code”! __
Rookie moment – “What is Nacos?”
Don’t know what Nacos is yet? It doesn’t matter, on Github star with the program ape brothers say hello!!
Nacos is a new open source project launched by Alibaba in July. The main vision of Nacos is to help users better build, deliver and manage their micro-service platforms in the cloud native era by providing easy-to-use infrastructure for dynamic service discovery, service configuration management, service sharing and management.
The Github project address is here
More information on open source projects related to Nacos
- Nacos
- Dubbo Registry Nacos
- Nacos DNS-F
- Nacos Docker
- Nacos Spring Project
- Nacos Spring Boot
- Spring Cloud Alibaba
- Dubbo
- Sentinel
- Spring Cloud
- Nepxion Discovery
- Spring Cloud Gateway Nacos