Nacos是在SpringCloudAlibaba架构中起到注册中心和配置中心的作用。
Nacos官方文档:https://nacos.io/zh-cn/index.html
从 Github 上下载源码方式
git clone https://github.com/alibaba/nacos.git
cd nacos/
mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U
ls -al distribution/target/
单节点启动Nacos
单节点启动Nacos,可以不配置Mysql,它内存集成了数据库,直接启动即可
// change the $version to your actual path
cd distribution/target/nacos-server-$version/nacos/bin
sh startup.sh -m standalone
控制台默认账密: nacos/nacos
集群启动Nacos
集群启动,需要保证数据一致性,所以不能使用内嵌数据库,需要指定统一的Mysql
1.Mysql创建user
mysql -uroot -p123
use mysql;
create user 'nacos'@'localhost' identified by 'nacos';
grant all privileges on nacos.* to "nacos"@'localhost'
2.执行Mysql初始化文件/nacos/distribution/conf/nacos-mysql.sql
3.Nacos配置文件/nacos/distriution/conf/application.properties
#*************** Config Module Related Configurations ***************#
### If use MySQL as datasource:
spring.datasource.platform=mysql
### Count of DB:
db.num=1
### Connect URL of DB:
db.url.0=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user.0=nacos
db.password.0=nacos
4.Maven打包
mvn -Prelease-nacos -Dmaven.test.skip=true clean install -U
5.复制三份target目录,修改application.properties
server.port=8848
server.port=8838
server.port=8828
5.复制三份target目录,修改cluster.conf
192.168.31.230:8828
192.168.31.230:8838
192.168.31.230:8848