nocas集群部署配置与启动(Windows)
1. 建文件夹
这里我们集群三个nocas服务器。
找一个合适的地方,建一个cluster文件夹
里面将下载的nocas的压缩包,解压出3个。(用这几个端口号命名,注意在2.0版本端口号,相隔100,不要跳1)
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传
2.创建数据库
在conf文件夹下找到mysql-schema.sql文件,在自己的mysql中执行。
注意:执行前,先创建数据库为nacos,并在该数据库中执行。
3. 修改配置文件
修改application.properties文件
修改点:
port:
server.port=8748
数据库:
# spring.sql.init.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=root
db.password.0=root#这里账号密码改为自己的
key:
nacos.core.auth.plugin.nacos.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
注意:这里的key,不一定要为这个,满足条件即可。条件为128Bit好像。(如果你不配置,会报错。那里可以看到)
修改cluster.conf.example
这里配置你要集群的server地址。
注意:这里不要用本地地址,需要用本机的实际ip,不然到时候仍然会去获取实际地址,然后添加在这个文件中。
169.254.3.10:8748
169.254.3.10:8848
169.254.3.10:8950
4. 启动naocs
在bin目录下,找到startup.cmd双击,启动即可。
注意:出现问题,可以在cmd中,进入该目录,命令
startup.cmd
执行,可以看到报错内容。
启动报错常见点:
-
端口占用问题:
分析可能会被占用的端口:
首先就是配置的端口:8848(默认)
在2.0中新增的GRPC的通信方式,新增了两个会被使用的端口号。
这两个端口号有自己的计算方式来得到,不是固定。
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-cSfwwjcO-1681554216875)(D:\截图输出文件夹\image-20230414145852741.png)]
-
key问题。
-
单机,集群模式问题。
5. 配置Nginx
配置
upstream backserver {
server 169.254.33.16:8748 weight=1;
server 169.254.33.16:8848 weight=1;
server 169.254.33.16:8950 weight=1;
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location /{
proxy_pass http://backserver/;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
6. 修改host文件
C:\Windows\System32\drivers\etc\
下的hosts文件。
配置本地域名。
127.0.0.1 www.zhongxu.com
7.测试
www.zhongxu.com/nocas测试能否访问nacos登录页面。
}
## 6. 修改host文件
C:\Windows\System32\drivers\etc\
下的hosts文件。
配置本地域名。
127.0.0.1 www.zhongxu.com
## 7.测试
www.zhongxu.com/nocas测试能否访问nacos登录页面。