Nacos是在SpringCloudAlibaba架構(gòu)中起到注冊中心和配置中心的作用恨统。
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/
單節(jié)點(diǎn)啟動Nacos
單節(jié)點(diǎn)啟動Nacos,可以不配置Mysql三妈,它內(nèi)存集成了數(shù)據(jù)庫畜埋,直接啟動即可
// change the $version to your actual path
cd distribution/target/nacos-server-$version/nacos/bin
sh startup.sh -m standalone
控制臺默認(rèn)賬密: nacos/nacos
集群啟動Nacos
集群啟動,需要保證數(shù)據(jù)一致性畴蒲,所以不能使用內(nèi)嵌數(shù)據(jù)庫悠鞍,需要指定統(tǒng)一的Mysql
1.Mysql創(chuàng)建user
mysql -uroot -p123
use mysql;
create user 'nacos'@'localhost' identified by 'nacos';
grant all privileges on nacos.* to "nacos"@'localhost'
2.執(zhí)行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.復(fù)制三份target目錄,修改application.properties
server.port=8848
server.port=8838
server.port=8828
5.復(fù)制三份target目錄模燥,修改cluster.conf
192.168.31.230:8828
192.168.31.230:8838
192.168.31.230:8848