陕西自助建站做网站,网页编辑模式快捷键,宁波seo服务快速推广,原创文学网站建设基础描述
一个更易于构建云原生应用的动态服务发现、配置管理和服务管理平台Nacos 致力于帮助您发现、配置和管理微服务。Nacos 提供了一组简单易用的特性集#xff0c;帮助您快速实现动态服务发现、服务配置、服务元数据及流量管理。Nacos 帮助您更敏捷和容易地构建、交付和…基础描述
一个更易于构建云原生应用的动态服务发现、配置管理和服务管理平台Nacos 致力于帮助您发现、配置和管理微服务。Nacos 提供了一组简单易用的特性集帮助您快速实现动态服务发现、服务配置、服务元数据及流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。 Nacos 是构建以“服务”为中心的现代应用架构 (例如微服务范式、云原生范式) 的服务基础设施。官网https://nacos.io/开源地址https://github.com/alibaba/nacos企业版本https://nacos.io/cloud/
集群部署 环境准备
3个或3个以上Nacos节点才能构成集群64 bit OS Linux/Unix/Mac推荐使用Linux系统64 bit JDK 1.8 【推荐脚本安装】 三个节点 11.0.1.150 11.0.1.151 11.0.1.152 wget -O jdk1.8-install.sh https://files.rundreams.net/sh/run-sh/jdk/jdk1.8-install.sh sh jdk1.8-install.shMaven 3.2.x 【推荐脚本安装】
wget -O mvn-install.sh https://files.rundreams.net/sh/run-sh/mvn/mvn-install.sh sh mvn-install.sh安装包
安装包下载
wget https://files.rundreams.net/software/nacos-server-2.3.0.tar.gz解压
tar -zxf nacos-server-2.3.0.tar.gz在nacos的解压目录nacos/的conf目录下有配置文件cluster.conf每行配置成ip
配置cluster.conf
mv cluster.conf.example cluster.conf11.0.1.150:8848 11.0.1.151:8848 11.0.1.152:8848 确定数据源Mysql
Mysql8.0 docker 安装脚本
wget -O docker-mysql-8.0.sh https://files.rundreams.net/sh/run-sh/docker/docker-mysql-8.0.sh sh docker-mysql-8.0.sh执行下面的SQL文件
/** Copyright 1999-2018 Alibaba Group Holding Ltd.** Licensed under the Apache License, Version 2.0 (the License);* you may not use this file except in compliance with the License.* You may obtain a copy of the License at** http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an AS IS BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*//******************************************/
/* 表名称 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(128) DEFAULT NULL COMMENT group_id,content longtext NOT NULL COMMENT content,md5 varchar(32) DEFAULT NULL COMMENT md5,gmt_create datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 创建时间,gmt_modified datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 修改时间,src_user text COMMENT source user,src_ip varchar(50) DEFAULT NULL COMMENT source ip,app_name varchar(128) DEFAULT NULL COMMENT app_name,tenant_id varchar(128) DEFAULT COMMENT 租户字段,c_desc varchar(256) DEFAULT NULL COMMENT configuration description,c_use varchar(64) DEFAULT NULL COMMENT configuration usage,effect varchar(64) DEFAULT NULL COMMENT 配置生效的描述,type varchar(64) DEFAULT NULL COMMENT 配置的类型,c_schema text COMMENT 配置的模式,encrypted_data_key text NOT NULL COMMENT 密钥,PRIMARY KEY (id),UNIQUE KEY uk_configinfo_datagrouptenant (data_id,group_id,tenant_id)
) ENGINEInnoDB DEFAULT CHARSETutf8 COLLATEutf8_bin COMMENTconfig_info;/******************************************/
/* 表名称 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(128) NOT NULL COMMENT group_id,datum_id varchar(255) NOT NULL COMMENT datum_id,content longtext NOT NULL COMMENT 内容,gmt_modified datetime NOT NULL COMMENT 修改时间,app_name varchar(128) DEFAULT NULL COMMENT app_name,tenant_id varchar(128) DEFAULT COMMENT 租户字段,PRIMARY KEY (id),UNIQUE KEY uk_configinfoaggr_datagrouptenantdatum (data_id,group_id,tenant_id,datum_id)
) ENGINEInnoDB DEFAULT CHARSETutf8 COLLATEutf8_bin COMMENT增加租户字段;/******************************************/
/* 表名称 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 创建时间,gmt_modified datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 修改时间,src_user text COMMENT source user,src_ip varchar(50) DEFAULT NULL COMMENT source ip,tenant_id varchar(128) DEFAULT COMMENT 租户字段,encrypted_data_key text NOT NULL COMMENT 密钥,PRIMARY KEY (id),UNIQUE KEY uk_configinfobeta_datagrouptenant (data_id,group_id,tenant_id)
) ENGINEInnoDB DEFAULT CHARSETutf8 COLLATEutf8_bin COMMENTconfig_info_beta;/******************************************/
/* 表名称 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 创建时间,gmt_modified datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 修改时间,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)
) ENGINEInnoDB DEFAULT CHARSETutf8 COLLATEutf8_bin COMMENTconfig_info_tag;/******************************************/
/* 表名称 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 COMMENT nid, 自增长标识,PRIMARY KEY (nid),UNIQUE KEY uk_configtagrelation_configidtag (id,tag_name,tag_type),KEY idx_tenant_id (tenant_id)
) ENGINEInnoDB DEFAULT CHARSETutf8 COLLATEutf8_bin COMMENTconfig_tag_relation;/******************************************/
/* 表名称 group_capacity */
/******************************************/
CREATE TABLE group_capacity (id bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 主键ID,group_id varchar(128) NOT NULL DEFAULT COMMENT Group ID空字符表示整个集群,quota int(10) unsigned NOT NULL DEFAULT 0 COMMENT 配额0表示使用默认值,usage int(10) unsigned NOT NULL DEFAULT 0 COMMENT 使用量,max_size int(10) unsigned NOT NULL DEFAULT 0 COMMENT 单个配置大小上限单位为字节0表示使用默认值,max_aggr_count int(10) unsigned NOT NULL DEFAULT 0 COMMENT 聚合子配置最大个数0表示使用默认值,max_aggr_size int(10) unsigned NOT NULL DEFAULT 0 COMMENT 单个聚合数据的子配置大小上限单位为字节0表示使用默认值,max_history_count int(10) unsigned NOT NULL DEFAULT 0 COMMENT 最大变更历史数量,gmt_create datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 创建时间,gmt_modified datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 修改时间,PRIMARY KEY (id),UNIQUE KEY uk_group_id (group_id)
) ENGINEInnoDB DEFAULT CHARSETutf8 COLLATEutf8_bin COMMENT集群、各Group容量信息表;/******************************************/
/* 表名称 his_config_info */
/******************************************/
CREATE TABLE his_config_info (id bigint(20) unsigned NOT NULL COMMENT id,nid bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT nid, 自增标识,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,md5 varchar(32) DEFAULT NULL COMMENT md5,gmt_create datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 创建时间,gmt_modified datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 修改时间,src_user text COMMENT source user,src_ip varchar(50) DEFAULT NULL COMMENT source ip,op_type char(10) DEFAULT NULL COMMENT operation type,tenant_id varchar(128) DEFAULT COMMENT 租户字段,encrypted_data_key text NOT NULL COMMENT 密钥,PRIMARY KEY (nid),KEY idx_gmt_create (gmt_create),KEY idx_gmt_modified (gmt_modified),KEY idx_did (data_id)
) ENGINEInnoDB DEFAULT CHARSETutf8 COLLATEutf8_bin COMMENT多租户改造;/******************************************/
/* 表名称 tenant_capacity */
/******************************************/
CREATE TABLE tenant_capacity (id bigint(20) unsigned NOT NULL AUTO_INCREMENT COMMENT 主键ID,tenant_id varchar(128) NOT NULL DEFAULT COMMENT Tenant ID,quota int(10) unsigned NOT NULL DEFAULT 0 COMMENT 配额0表示使用默认值,usage int(10) unsigned NOT NULL DEFAULT 0 COMMENT 使用量,max_size int(10) unsigned NOT NULL DEFAULT 0 COMMENT 单个配置大小上限单位为字节0表示使用默认值,max_aggr_count int(10) unsigned NOT NULL DEFAULT 0 COMMENT 聚合子配置最大个数,max_aggr_size int(10) unsigned NOT NULL DEFAULT 0 COMMENT 单个聚合数据的子配置大小上限单位为字节0表示使用默认值,max_history_count int(10) unsigned NOT NULL DEFAULT 0 COMMENT 最大变更历史数量,gmt_create datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 创建时间,gmt_modified datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 修改时间,PRIMARY KEY (id),UNIQUE KEY uk_tenant_id (tenant_id)
) ENGINEInnoDB DEFAULT CHARSETutf8 COLLATEutf8_bin COMMENT租户容量信息表;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 创建时间,gmt_modified bigint(20) NOT NULL COMMENT 修改时间,PRIMARY KEY (id),UNIQUE KEY uk_tenant_info_kptenantid (kp,tenant_id),KEY idx_tenant_id (tenant_id)
) ENGINEInnoDB DEFAULT CHARSETutf8 COLLATEutf8_bin COMMENTtenant_info;CREATE TABLE users (username varchar(50) NOT NULL PRIMARY KEY COMMENT username,password varchar(500) NOT NULL COMMENT password,enabled boolean NOT NULL COMMENT enabled
);CREATE TABLE roles (username varchar(50) NOT NULL COMMENT username,role varchar(50) NOT NULL COMMENT role,UNIQUE INDEX idx_user_role (username ASC, role ASC) USING BTREE
);CREATE TABLE permissions (role varchar(50) NOT NULL COMMENT role,resource varchar(255) NOT NULL COMMENT resource,action varchar(8) NOT NULL COMMENT action,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);修改 application.properties
替换为 application.properties 一下内容修改为自己的数据库等参数 #*************** Spring Boot Related Configurations ***************#
### Default web context path:
server.servlet.contextPath/nacos
### Include message field
server.error.include-messageALWAYS
### Default web server port:
server.port8848#*************** Network Related Configurations ***************#
### If prefer hostname over ip for Nacos server addresses in cluster.conf:
# nacos.inetutils.prefer-hostname-over-ipfalse
spring.datasource.platformmysql### Count of DB:
db.num1### Connect URL of DB:
db.url.0jdbc:mysql://11.0.1.141:3306/nacos2.3.0?characterEncodingutf8connectTimeout1000socketTimeout3000autoReconnecttrueuseUnicodetrueuseSSLfalseserverTimezoneUTC
db.user.0root
db.password.012345678### Connection pool configuration: hikariCP
db.pool.config.connectionTimeout30000
db.pool.config.validationTimeout10000
db.pool.config.maximumPoolSize20
db.pool.config.minimumIdle2### the maximum retry times for push
nacos.config.push.maxRetryTime50#***********Metrics for tomcat **************************#
server.tomcat.mbeanregistry.enabledtrue#***********Expose prometheus and health **************************#
#management.endpoints.web.exposure.includeprometheus,health### Metrics for elastic search
management.metrics.export.elastic.enabledfalse
#management.metrics.export.elastic.hosthttp://localhost:9200### Metrics for influx
management.metrics.export.influx.enabledfalse
#management.metrics.export.influx.dbspringboot
#management.metrics.export.influx.urihttp://localhost:8086
#management.metrics.export.influx.auto-create-dbtrue
#management.metrics.export.influx.consistencyone
#management.metrics.export.influx.compressedtrue#*************** Access Log Related Configurations ***************#
### If turn on the access log:
server.tomcat.accesslog.enabledtrue### file name pattern, one file per hour
server.tomcat.accesslog.rotatetrue
server.tomcat.accesslog.file-date-format.yyyy-MM-dd-HH
### The access log pattern:
server.tomcat.accesslog.pattern%h %l %u %t %r %s %b %D %{User-Agent}i %{Request-Source}i### The directory of access log:
server.tomcat.basedirfile:.#*************** Access Control Related Configurations ***************#
### If enable spring security, this option is deprecated in 1.2.0:
#spring.security.enabledfalse### The ignore urls of auth
nacos.security.ignore.urls/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**### The auth system to use, currently only nacos and ldap is supported:
nacos.core.auth.system.typenacos### If turn on auth system:
nacos.core.auth.enabledtrue### Turn on/off caching of auth information. By turning on this switch, the update of auth information would have a 15 seconds delay.
nacos.core.auth.caching.enabledtrue### Since 1.4.1, Turn on/off white auth for user-agent: nacos-server, only for upgrade from old version.
nacos.core.auth.enable.userAgentAuthWhitefalse### Since 1.4.1, worked when nacos.core.auth.enabledtrue and nacos.core.auth.enable.userAgentAuthWhitefalse.
### The two properties is the white list for auth and used by identity the request from other server.
nacos.core.auth.server.identity.keynacos
nacos.core.auth.server.identity.valuenacos123### worked when nacos.core.auth.system.typenacos
### The token expiration in seconds:
nacos.core.auth.plugin.nacos.token.cache.enablefalse
nacos.core.auth.plugin.nacos.token.expire.seconds18000
### The default token (Base64 String): QlM8iR9AHxhzZ7ptqd6IX8AzHcuSo12a
nacos.core.auth.plugin.nacos.token.secret.keyUWxNOGlSOUFIeGh6WjdwdHFkNklYOEF6SGN1U28xMmE#*************** Istio Related Configurations ***************#
### If turn on the MCP server:
nacos.istio.mcp.server.enabledfalse
集群配置
三台机器分别替换 cluster.conf application.properties 文件三台机器保持一致
启动
在bin目录执行 sh startup.sh三台机器分别执行启动日志
控制台使用
随机器访问一台机器进行访问http://11.0.1.150:8848/nacos默认账户名密码nacos nacos 集群列表
总结
nacos做为注册服务中心 一定不开外网内部通过跳板机进行访问持久化存储 Mysql 要保证高可用文章中没深度设计访问nacos控制台不单独访问某一台机器通过nginx配置代理至其中一台常用问题说明https://nacos.io/docs/latest/guide/user/faq/