下载安装包
部署
mkdir /data/nacos
# 上传nacos-server-1.3.0.tar.gz
rz -e
# 解压
tar zxvf nacos-server-1.3.0.tar.gz
mv nacos nacos1
cp -r nacos1 nacos2
cp -r nacos1 nacos3
数据源准备
在目标数据源创建数据库nacos,执行conf/nacos-mysql.sql
初始化nacos管理密码
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>5.4.6</version>
</dependency>
生成加密密码串
String encode = new BCryptPasswordEncoder().encode("your secret");
System.out.println(encode);
数据库添加用户
INSERT INTO users (username, password, enabled) VALUES ('admin', '$2a$10$m8L7LBpkARwRmO3Hmp/hgO.FNxLWUCTJsy91xdlABiUdw92iN.mQW', TRUE);
INSERT INTO roles (username, role) VALUES ('admin', 'ROLE_ADMIN');
配置启动
修改三个包(nacos1,nacos2,nacos3)的配置文件conf/applications.properties
三个端口可以分别配置为8848 8849 8850
server.port=8848
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=root
db.password=yourPassword
修改三个包(nacos1,nacos2,nacos3)的配置文件conf/cluster.conf
,mv conf/cluster.conf.example conf/cluster.conf
127.0.0.1:8848
127.0.0.1:8849
127.0.0.1:8850
启停脚本start.sh
stop.sh
#!/usr/bin/env bash
sh nacos1/bin/startup.sh
sh nacos2/bin/startup.sh
sh nacos3/bin/startup.sh
#!/usr/bin/env bash
sh nacos1/bin/shutdown.sh
sh nacos2/bin/shutdown.sh
sh nacos3/bin/shutdown.sh
chmod +x start.sh stop.sh
./start.sh
## 启动要等待50s左右
访问管理页面
http://127.0.0.1:8848/nacos/index.html
http://127.0.0.1:8849/nacos/index.html
http://127.0.0.1:8850/nacos/index.html