需先安装jdk1.8环境
1.解压包(3台执行)
tar -xzvf nacos-server-2.0.3.tar.gz -C /data
mv /data/nacos-server-2.0.3 /data/nacos
2.创建nacos库(1台执行)
CREATE DATABASE nacos;
CREATE USER 'nacos'@'%' IDENTIFIED BY '1qaz!QAZ.';
GRANT ALL PRIVILEGES ON nacos.* TO 'nacos'@'%';
flush privileges;
3.执行数据库脚本(1台执行)
4.修改nacos配置文件(3台执行)
vim /data/nacos/conf/application.properties
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://mysql数据库地址:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user.0=naocos
db.password.0=1qaz!QAZ.
db.pool.config.connectionTimeout=30000
db.pool.config.validationTimeout=10000
db.pool.config.maximumPoolSize=20
db.pool.config.minimumIdle=2
5.修改集群文件(3台执行)
cp /data/nacos/conf/cluster.conf.example /data/nacos/conf/cluster.conf
vim /data/nacos/conf/cluster.conf
192.168.1.101:8848
192.168.1.101:8848
192.168.1.101:8848
6.启动nacos(3台执行)
bash /data/nacos/bin/startup.sh
7.访问地址
http://nacos_ip:8848/nacos/index.html
默认用户密码
nacos/nacos
8.关闭双写(2.0版本以上)
curl -X PUT 'localhost:8848/nacos/v1/ns/operator/switches?entry=doubleWriteEnabled&value=false'
报错:
(1)数据库没链接成功
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'communicationController' defined in URL [jar:file:/data/nacos/target/ami-app1105-nacos.jar!/BOOT-INF/lib/nacos-config-2.0.3.jar!/com/alibaba/nacos/config/server/controller/CommunicationController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'externalDumpService': Invocation of init method failed; nested exception is ErrCode:500, ErrMsg:Nacos Server did not start because dumpservice bean construction failure : No DataSource set
(2)之前的进程没杀掉,地址冲突
Caused by: io.grpc.netty.shaded.io.netty.channel.unix.Errors$NativeIoException: bind(..) failed: Address already in use