当前位置:首页 > 服务端 > nacos 负载策略

nacos 负载策略

1、三台服务器准备

10.199.12.26

10.199.12.32

10.199.12.41

2、版本号,端口和部署目录

端口:8848

部署目录:/data/nacos

版本号:nacos-server-1.4.0.zip

3、三台服务的配置文件

3.1、cluster.conf

#三台机器配置和启动端口

10.199.11.26:8848

10.199.11.32:8848

10.199.11.41:8848

3.2、application.properties

server.servlet.contextPath=/nacos

server.port=8848

nacos.naming.empty-service.auto-clean=true

nacos.naming.empty-service.clean.initial-delay-ms=50000

nacos.naming.empty-service.clean.period-time-ms=30000

management.metrics.export.elastic.enabled=false

management.metrics.export.influx.enabled=false

server.tomcat.accesslog.enabled=true

server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i

server.tomcat.basedir=

nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**

nacos.core.auth.system.type=nacos

nacos.core.auth.enabled=false

nacos.core.auth.default.token.expire.seconds=18000

nacos.core.auth.default.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789

nacos.core.auth.caching.enabled=true

nacos.istio.mcp.server.enabled=false

spring.datasource.platform=mysql

#使用mysql做数据库,用户名和密码  创建一个nacos_config的源,并执行解压后代码包的nacos-mysql.sql数据库文件

db.num=1

db.url.0=jdbc:mysql://10.199.11.18:3306/nacos_config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true

db.user=wd

db.password=wd

4、nacos注册为系统服务

# 三台都一样操作

[root@nacos-1 conf]# vi /etc/systemd/system/nacos.service

[Unit]

Description=nacos

After=network.target

[Service]

Type=forking

# 集群版 见后面 -m standalone 去掉即可

ExecStart=/data/nacos/bin/startup.sh

ExecReload=/data/nacos/bin/shutdown.sh

ExecStop=/data/nacos/bin/shutdown.sh

PrivateTmp=true

[Install]

WantedBy=multi-user.target

5、启动服务

systemctl enable nacos

systemctl start nacos

6、nginx负载均衡配置

# nacos.conf

upstream nacos{

server 10.199.12.26:8848;

server 10.199.12.32:8848;

server 10.199.12.41:8848;

}

server {

listen 8080;

server_name localhost ;

index index.html;

location /{

proxy_pass http://nacos;

}

}

作者:蓝狍
来源链接:https://blog.csdn.net/weixin_31655087/article/details/112894006

版权声明:
1、JavaClub(https://www.javaclub.cn)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。

2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。


本文链接:https://www.javaclub.cn/server/69239.html

标签: Nacos
分享给朋友: