当前位置:网站首页>Nacos introduction and console service installation
Nacos introduction and console service installation
2022-07-24 18:47:00 【Charge8】
One 、 What is? Nacos
Official documents : https://nacos.io/zh-cn/docs/what-is-nacos.html
1、Nacos brief introduction
Nacos yes Dynamic Naming and Configuration Service An acronym for .
Nacos Dedicated to helping you discover 、 Configure and manage microservices .Nacos Provides an easy-to-use feature set , Helps you quickly implement dynamic service discovery 、 Service configuration 、 Service metadata and traffic management .
Nacos Helps you build more quickly and easily 、 Deliver and manage microservice platforms . Nacos Is to build in “ service ” Modern application architecture centered ( For example, the microservices paradigm 、 Cloud native paradigm ) Service infrastructure .
Nacos Key features include :
- Service discovery and service health monitoring
- Dynamic configuration services
- dynamic DNS service
- Services and metadata management
Use Nacos Simplify service discovery 、 Configuration Management 、 Solutions for service governance and management , Let the discovery of microservices 、 management 、 share 、 It's easier to combine .
2、Nacos Basic concepts
Nacos Introduced some basic concepts , A systematic understanding of these concepts can help you better understand and use them correctly Nacos product . See official documents for more concepts .
1) Namespace
Used for tenant granularity configuration isolation . Under different namespaces , There can be the same Group or Data ID Configuration of .
Namespace One of the most common scenarios is the separation of configurations between different environments , For example, develop the resources of test environment and production environment ( Such as configuration 、 service ) Isolation etc. .
2) Configure grouping
Nacos A set of configuration sets in , It is one of the dimensions of organization configuration . Through a meaningful string ( Such as Buy or Trade ) Group configuration sets , To distinguish Data ID Same configuration set . When you are in Nacos When you create a configuration on , If the name of the configuration group is not filled in , The name of the configuration group By default DEFAULT_GROUP .
Common scenarios for configuring grouping : Different applications or components use the same configuration type , Such as database_url Configuration and MQ_topic To configure .
3) Service registry
A database that stores service instances and service load balancing policies .
4) Meta information
Nacos data ( Such as configuration and service ) Description information , Such as service version 、 The weight 、 Disaster recovery strategy 、 Load balancing strategy 、 Authentication configuration 、 Various custom tags (label), In terms of scope of action , Meta information divided into service levels 、 Meta information of cluster and instance .
5) The weight
Instance level configuration . The weight is floating point number . The greater the weight , The more traffic is allocated to the instance .
6) health examination
Check the instance mounted under the service in the specified way (Instance) The health of , To confirm the instance (Instance) Whether the service can be provided . According to the inspection results , example (Instance) Will be judged healthy or unhealthy . When a parse request is made to a service , Unhealthy examples (Instance) Will not be returned to the client .
3、Nacos Basic structure and concept
The picture comes from the official :
1) service (Service):
Service refers to one or a group of software functions ( For example, retrieval of specific information or execution of a group of operations ), Its purpose is that different clients can be reused for different purposes ( For example, through cross process network call ).
Nacos Support mainstream service Ecology , such as :Kubernetes Service、gRPC|Dubbo RPC Service perhaps Spring Cloud RESTful Service.
2) Service registry (Service Registry)
Service registry , It is a database of services and their instances and metadata .
The service instance is registered to the service registry at startup , And log off on shutdown . Clients of services and routers query the service registry for available instances of services . The service registry may call the health check of the service instance API To verify that it can handle requests .
3) Service Metadata (Service Metadata)
Service metadata refers to including service endpoints (endpoints)、 Service Tag 、 Service version number 、 Service instance weight 、 Routing rules 、 Security policy and other data describing the service .
4) service provider (Service Provider)
Refers to the application side that provides reusable and callable services .
5) Service consumer (Service Consumer)
It refers to the application party that will initiate a service call .
Two 、Nacos Server build
Nacos Provides a simple and easy to use UI Help you manage the configuration of all services and Applications . There are three ways to build :
- standalone mode - For testing and stand-alone trials .
- Cluster pattern - For the production environment , Ensure high availability .
- Multi cluster mode - For multi data center scenarios .
Official deployment documents : https://nacos.io/zh-cn/docs/deployment.html
The official also provides a sample console Demo(nacos/nacos):http://console.nacos.io/nacos/index.html#/login
Use Docker install Nacos Server, Stand alone mode starts . choice Nacos Version is : v2.1.0
1、mysql New database , And implement SQL Script
stay 0.7 Before the release , In stand-alone mode nacos Use embedded database to store data , It is not convenient to observe the basic situation of data storage .0.7 Support for mysql Data source capabilities ,( Currently only supported MySQL).
official SQL Script :https://github.com/alibaba/nacos/blob/2.1.0/distribution/conf/nacos-mysql.sql
stay MySQL Created in nacos database :nacos_config( The database name can be customized ), Then execute the official SQL Script .
/******************************************/
/* Database full name = nacos_config */
/* The name of the table = config_info */
/******************************************/
CREATE TABLE `config_info` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
`group_id` varchar(255) DEFAULT NULL,
`content` longtext NOT NULL COMMENT 'content',
`md5` varchar(32) DEFAULT NULL COMMENT 'md5',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ' Creation time ',
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ' Modification time ',
`src_user` text COMMENT 'source user',
`src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
`app_name` varchar(128) DEFAULT NULL,
`tenant_id` varchar(128) DEFAULT '' COMMENT ' Tenant fields ',
`c_desc` varchar(256) DEFAULT NULL,
`c_use` varchar(64) DEFAULT NULL,
`effect` varchar(64) DEFAULT NULL,
`type` varchar(64) DEFAULT NULL,
`c_schema` text,
`encrypted_data_key` text NOT NULL COMMENT ' Secret key ',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_configinfo_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info';
/******************************************/
/* Database full name = nacos_config */
/* The name of the table = config_info_aggr */
/******************************************/
CREATE TABLE `config_info_aggr` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
`group_id` varchar(255) NOT NULL COMMENT 'group_id',
`datum_id` varchar(255) NOT NULL COMMENT 'datum_id',
`content` longtext NOT NULL COMMENT ' Content ',
`gmt_modified` datetime NOT NULL COMMENT ' Modification time ',
`app_name` varchar(128) DEFAULT NULL,
`tenant_id` varchar(128) DEFAULT '' COMMENT ' Tenant fields ',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_configinfoaggr_datagrouptenantdatum` (`data_id`,`group_id`,`tenant_id`,`datum_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT=' Add tenant field ';
/******************************************/
/* Database full name = nacos_config */
/* The name of the table = config_info_beta */
/******************************************/
CREATE TABLE `config_info_beta` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
`group_id` varchar(128) NOT NULL COMMENT 'group_id',
`app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
`content` longtext NOT NULL COMMENT 'content',
`beta_ips` varchar(1024) DEFAULT NULL COMMENT 'betaIps',
`md5` varchar(32) DEFAULT NULL COMMENT 'md5',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ' Creation time ',
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ' Modification time ',
`src_user` text COMMENT 'source user',
`src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
`tenant_id` varchar(128) DEFAULT '' COMMENT ' Tenant fields ',
`encrypted_data_key` text NOT NULL COMMENT ' Secret key ',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_configinfobeta_datagrouptenant` (`data_id`,`group_id`,`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_beta';
/******************************************/
/* Database full name = nacos_config */
/* The name of the table = config_info_tag */
/******************************************/
CREATE TABLE `config_info_tag` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
`group_id` varchar(128) NOT NULL COMMENT 'group_id',
`tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id',
`tag_id` varchar(128) NOT NULL COMMENT 'tag_id',
`app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
`content` longtext NOT NULL COMMENT 'content',
`md5` varchar(32) DEFAULT NULL COMMENT 'md5',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ' Creation time ',
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ' Modification time ',
`src_user` text COMMENT 'source user',
`src_ip` varchar(50) DEFAULT NULL COMMENT 'source ip',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_configinfotag_datagrouptenanttag` (`data_id`,`group_id`,`tenant_id`,`tag_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_info_tag';
/******************************************/
/* Database full name = nacos_config */
/* The name of the table = config_tags_relation */
/******************************************/
CREATE TABLE `config_tags_relation` (
`id` bigint(20) NOT NULL COMMENT 'id',
`tag_name` varchar(128) NOT NULL COMMENT 'tag_name',
`tag_type` varchar(64) DEFAULT NULL COMMENT 'tag_type',
`data_id` varchar(255) NOT NULL COMMENT 'data_id',
`group_id` varchar(128) NOT NULL COMMENT 'group_id',
`tenant_id` varchar(128) DEFAULT '' COMMENT 'tenant_id',
`nid` bigint(20) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`nid`),
UNIQUE KEY `uk_configtagrelation_configidtag` (`id`,`tag_name`,`tag_type`),
KEY `idx_tenant_id` (`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='config_tag_relation';
/******************************************/
/* Database full name = nacos_config */
/* The name of the table = group_capacity */
/******************************************/
CREATE TABLE `group_capacity` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT ' Primary key ID',
`group_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Group ID, The empty character indicates the entire cluster ',
`quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT ' The quota ,0 Indicates use default ',
`usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT ' Usage quantity ',
`max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT ' Maximum size of a single configuration , The unit is byte ,0 Indicates use default ',
`max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT ' Maximum number of aggregate sub configurations ,,0 Indicates use default ',
`max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT ' The maximum sub configuration size of a single aggregate data , The unit is byte ,0 Indicates use default ',
`max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT ' Maximum number of change history ',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ' Creation time ',
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ' Modification time ',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_group_id` (`group_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT=' colony 、 various Group Capacity information table ';
/******************************************/
/* Database full name = nacos_config */
/* The name of the table = his_config_info */
/******************************************/
CREATE TABLE `his_config_info` (
`id` bigint(64) unsigned NOT NULL,
`nid` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`data_id` varchar(255) NOT NULL,
`group_id` varchar(128) NOT NULL,
`app_name` varchar(128) DEFAULT NULL COMMENT 'app_name',
`content` longtext NOT NULL,
`md5` varchar(32) DEFAULT NULL,
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
`src_user` text,
`src_ip` varchar(50) DEFAULT NULL,
`op_type` char(10) DEFAULT NULL,
`tenant_id` varchar(128) DEFAULT '' COMMENT ' Tenant fields ',
`encrypted_data_key` text NOT NULL COMMENT ' Secret key ',
PRIMARY KEY (`nid`),
KEY `idx_gmt_create` (`gmt_create`),
KEY `idx_gmt_modified` (`gmt_modified`),
KEY `idx_did` (`data_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT=' Multi tenant transformation ';
/******************************************/
/* Database full name = nacos_config */
/* The name of the table = tenant_capacity */
/******************************************/
CREATE TABLE `tenant_capacity` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT ' Primary key ID',
`tenant_id` varchar(128) NOT NULL DEFAULT '' COMMENT 'Tenant ID',
`quota` int(10) unsigned NOT NULL DEFAULT '0' COMMENT ' The quota ,0 Indicates use default ',
`usage` int(10) unsigned NOT NULL DEFAULT '0' COMMENT ' Usage quantity ',
`max_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT ' Maximum size of a single configuration , The unit is byte ,0 Indicates use default ',
`max_aggr_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT ' Maximum number of aggregate sub configurations ',
`max_aggr_size` int(10) unsigned NOT NULL DEFAULT '0' COMMENT ' The maximum sub configuration size of a single aggregate data , The unit is byte ,0 Indicates use default ',
`max_history_count` int(10) unsigned NOT NULL DEFAULT '0' COMMENT ' Maximum number of change history ',
`gmt_create` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ' Creation time ',
`gmt_modified` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT ' Modification time ',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_tenant_id` (`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT=' Tenant capacity information table ';
CREATE TABLE `tenant_info` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`kp` varchar(128) NOT NULL COMMENT 'kp',
`tenant_id` varchar(128) default '' COMMENT 'tenant_id',
`tenant_name` varchar(128) default '' COMMENT 'tenant_name',
`tenant_desc` varchar(256) DEFAULT NULL COMMENT 'tenant_desc',
`create_source` varchar(32) DEFAULT NULL COMMENT 'create_source',
`gmt_create` bigint(20) NOT NULL COMMENT ' Creation time ',
`gmt_modified` bigint(20) NOT NULL COMMENT ' Modification time ',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_tenant_info_kptenantid` (`kp`,`tenant_id`),
KEY `idx_tenant_id` (`tenant_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='tenant_info';
CREATE TABLE `users` (
`username` varchar(50) NOT NULL PRIMARY KEY,
`password` varchar(500) NOT NULL,
`enabled` boolean NOT NULL
);
CREATE TABLE `roles` (
`username` varchar(50) NOT NULL,
`role` varchar(50) NOT NULL,
UNIQUE INDEX `idx_user_role` (`username` ASC, `role` ASC) USING BTREE
);
CREATE TABLE `permissions` (
`role` varchar(50) NOT NULL,
`resource` varchar(255) NOT NULL,
`action` varchar(8) NOT NULL,
UNIQUE INDEX `uk_role_permission` (`role`,`resource`,`action`) USING BTREE
);
INSERT INTO users (username, password, enabled) VALUES ('nacos', '$2a$10$EuWPZHzz32dJN7jexM34MOeYirDdFAZm2kuWj7VEOJhhZkDrxfvUu', TRUE);
INSERT INTO roles (username, role) VALUES ('nacos', 'ROLE_ADMIN');
2、Docker install nacos-server
2.1 Pull the mirror image
1) Find image
[[email protected] ~]# docker search nacos/nacos-server
2) Pull the mirror image
Pull when there is no local image , Just omit this step .
[[email protected] ~]# docker pull nacos/nacos-server:v2.1.0
3) Create and start the container
[[email protected] ~]# docker run -d --name nacos-server_v2.1.0 -p 192.168.xxx.xxx:8848:8848 -p 192.168.xxx.xxx:9848:9848 --env MODE=standalone nacos/nacos-server:v2.1.0
20344da3754f524422111a36a3550ae279cfb7b3d18e6b1e721f678cad519ba4
- –env MODE=standalone: Stand alone mode starts
Be careful :nacos Add on startup 9848 port , And open the server 9848 port -p9848:9848. If not added , When the application service starts, it will not be connected nacos.
nacos2.0 Compared with the above version 1.X Added gRPC Mode of communication , See nacos Website shows : https://nacos.io/zh-cn/docs/2.0.0-compatibility.html
4) Enter the start good nacos-server service
[[email protected] ~]# docker exec -it 20344da3754f /bin/bash
[[email protected] nacos]# ls
LICENSE NOTICE bin conf data derby.log logs target work
2.2 Modify the data source
Get into nacos Container modification conf/application.properties file .
[[email protected] nacos]# vi conf/application.properties

Then exit the container , And restart the container .
[[email protected] ~]# docker restart 20344da3754f
## Check the container startup log
[[email protected] ~]# docker logs 20344da3754f
2.3 visit Nacos In the console
visit Nocas The management side of , Browser input :http://192.168.xxx.xxx:8848/nacos .
The default username and password is :nocas/nocas

Here we are ,Nacos Server installation is complete .
– Stay Hungry , stay foolish .
边栏推荐
猜你喜欢

Ionic4 learning notes 4 -- add a tab page

Data analysis of network security competition of national vocational college skills competition digital forensics-a

Make C #

QT—动画框架

轻松学Pytorch-迁移学习实现表面缺陷检查

Is the validity period of the root certificate as long as the server SSL certificate?

MySQL - bufferpool related information

04 distributed resource management system yarn

OPENGL学习(二)OPENGL渲染管线

Escape character in JS?
随机推荐
深度学习中Dropout原理解析
Ionic4 learning notes 4 -- add a tab page
【历史上的今天】7 月 24 日:Caldera 诉微软案;AMD 宣布收购 ATI;谷歌推出 Chromecast
Namespace: cluster environment sharing and isolation
QT - animation frame
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag
Generate publickey with der format public key and report an error
理解corners_align,两种看待像素的视角
Show or hide password plaintext + password box verification information
Crazy God redis notes 11
6. How to add an array in Es5?
3. Variable declaration promotion?
Nacos简介和控制台服务安装
1. Typeof view variable type?
Analysis of several possible causes of 0xc0000005 memory violation
Mysqlworkbench performance analysis tool -- Performance dashboard
SATA protocol OOB essay
Attack and defense world novice zone PWN
2. JS variable type conversion, automatic conversion, manual conversion, what is the difference between parseint(), parsefloat(), number()?
vim相关介绍