配置JDK(1.8以上)
略
配置MVN(3.2以上)
略
配置nacos
修改nacos/conf/cluster.conf
以192.168.40.180/181/182为例
#2024-08-30T13:53:00.618
192.168.40.180:8848
192.168.40.181:8848
192.168.40.182:8848
修改nacos/conf/
server.servlet.contextPath=/nacos
server.port=8848
spring.datasource.platform=mysql
### Count of DB:
db.num=1
### Connect URL of DB:
db.url.0=jdbc:mysql://192.168.40.199/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC # 数据源
db.user.0=dbuser1 # 数据库连接账户密码
db.password.0=NSD2021@tedu.cn # 数据库连接账户密码
注:nacos 2.2?开始默认关闭身份校验,需按照文档修改,修改完毕后无需重启,登陆控制台需要初始化密码,初始化完后后登陆验证,需要重启其余节点的nacos以同步信息。
配置nginx
安装略
编译添加stream代理模块
./configure --prefix=/app/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_ssl_module --with-http_realip_module --with-stream
make && make install
nacos rpc协议默认为 9848 9849 http协议为8848
修改nginx.conf如下:
[root@apollo-180 nginx]# grep -v "#" conf/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
stream {
upstream name-tcp-180-9848 {
server 192.168.40.180:9848 weight=1;
}
server {
listen 9744;
proxy_pass name-tcp-180-9848;
}
upstream name-tcp-181-9848 {
server 192.168.40.181:9848 weight=1;
}
server {
listen 9746;
proxy_pass name-tcp-181-9848;
}
upstream name-tcp-182-9848 {
server 192.168.40.182:9848 weight=1;
}
server {
listen 9748;
proxy_pass name-tcp-182-9848;
}
upstream name-tcp-180-9849 {
server 192.168.40.182:9849 weight=1;
}
server {
listen 9745;
proxy_pass name-tcp-180-9849;
}
upstream name-tcp-181-9849 {
server 192.168.40.182:9849 weight=1;
}
server {
listen 9747;
proxy_pass name-tcp-181-9849;
}
upstream name-tcp-182-9849 {
server 192.168.40.182:9849 weight=1;
}
server {
listen 9749;
proxy_pass name-tcp-182-9849;
}
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream nacos-cluster {
server 192.168.40.180:8848 weight=1;
server 192.168.40.181:8848 weight=1;
server 192.168.40.182:8848 weight=1;
}
server {
listen 8888;
server_name localhost;
location / {
proxy_pass http://nacos-cluster/;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
浏览器访问nginx:8848控制台代理至nacos集群