nacos简介
学习地址:https://www.bilibili.com/video/BV18E411x7eT?p=96&vd_source=e7f24a421cc55783283e95fe226df2af
官网:https://nacos.io/zh-cn/docs/what-is-nacos.html
github:https://github.com/alibaba/nacos/
配置中心+注册中心
单机版部署
下载:https://github.com/alibaba/nacos/releases
将nacos sql导入mysql
[root@localhost bin]# ll ../conf/ total 88 -rw-r--r-- 1 502 games 1224 Jun 18 2021 1.4.0-ipv6_support-update.sql -rw-r--r-- 1 502 games 9508 Dec 15 16:40 application.properties -rw-r--r-- 1 502 games 9506 Jul 27 2021 application.properties.example -rw-r--r-- 1 502 games 670 Mar 18 2021 cluster.conf.example -rw-r--r-- 1 502 games 31156 Jul 15 2021 nacos-logback.xml -rw-r--r-- 1 502 games 10660 Jun 18 2021 nacos-mysql.sql -rw-r--r-- 1 502 games 8795 Jun 18 2021 schema.sql mysql> create database nacos; mysql> use nacos Database changed mysql> source /data/nacos/conf/nacos-mysql.sql; Query OK, 0 rows affected, 3 warnings (0.01 sec) Query OK, 0 rows affected, 3 warnings (0.01 sec) Query OK, 0 rows affected, 3 warnings (0.00 sec) Query OK, 0 rows affected, 3 warnings (0.01 sec) Query OK, 0 rows affected, 4 warnings (0.01 sec) Query OK, 0 rows affected, 9 warnings (0.01 sec) Query OK, 0 rows affected, 4 warnings (0.01 sec) Query OK, 0 rows affected, 9 warnings (0.00 sec) Query OK, 0 rows affected, 5 warnings (0.01 sec) Query OK, 0 rows affected (0.01 sec) Query OK, 0 rows affected (0.00 sec) Query OK, 0 rows affected (0.01 sec) Query OK, 1 row affected (0.00 sec) Query OK, 1 row affected (0.00 sec) mysql> show tables; +----------------------+ | Tables_in_nacos | +----------------------+ | config_info | | config_info_aggr | | config_info_beta | | config_info_tag | | config_tags_relation | | group_capacity | | his_config_info | | permissions | | roles | | tenant_capacity | | tenant_info | | users | +----------------------+ 12 rows in set (0.00 sec)
修改配置文件,user.0与password.0改为以下
### Connect URL of DB: db.url.0=jdbc:mysql://192.168.20.220:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC db.user=root db.password=mysqlpasswd
单机版启动
bin]# ./startup.sh -m standalone
集群部署
官网文档:https://nacos.io/zh-cn/docs/cluster-mode-quick-start.html
参考文档:https://blog.csdn.net/weixin_38568503/article/details/120591999
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
配置中心
yaml注册到nacos,提供配置,程序动态加载
创建配置
命名规范
测试
三、名称空间分组和dataid的关系
![](https://img2023.cnblogs.com/blog/2170925/202212/2170925-20221217164223917-1243954794.png)
![](https://img2023.cnblogs.com/blog/2170925/202212/2170925-20221217165614718-727337354.png)
nacos之命名空间方案
![](https://img2023.cnblogs.com/blog/2170925/202212/2170925-20221217172403409-1965657417.png)
服务注册中心
nacos界面查看
消费
自动支持负载均衡
使用客户端访问注册的服务,可以看到是轮询访问