Nacos 配置中心 集群 与负载均衡
集群配置文件
vim /root/cluster/nacos01/conf/cluster.conf
vim /root/cluster/nacos02/conf/cluster.conf
vim /root/cluster/nacos03/conf/cluster.conf
vim /root/cluster/nacos04/conf/cluster.conf
vim /root/cluster/nacos05/conf/cluster.conf
host:
192.168.66.100:8851
192.168.66.100:8852
192.168.66.100:8853
192.168.66.100:8854
192.168.66.100:8855
config:
vim /root/cluster/nacos01/conf/application.properties
mysql:
spring.datasource.platform=mysql
Count of DB:
db.num=1
Connect URL of DB:
db.url.0=jdbc:mysql://192.168.66.100:3306/nacos_config?characterEncoding=utf8&connectTi
meout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&se
rverTimezone=Asia/Shanghai
db.user.0=root
db.password.0=root
启动集群:
sh /root/cluster/nacos01/bin/startup.sh
关闭:
sh /root/cluster/nacos01/bin/shutdown.sh
sh /root/cluster/nacos02/bin/shutdown.sh
JVM 调整:
vim /root/cluster/nacos01/bin/startup.sh
访问地址:
192.168.66.100:8851/nacos/
192.168.66.100:8852
192.168.66.100:8853
192.168.66.100:8854
192.168.66.100:8855
负载均衡:
upstream nacos-servers { server 192.168.66.100:8851; server 192.168.66.100:8852; server 192.168.66.100:8853; server 192.168.66.100:8854; server 192.168.66.100:8855; } server { listen 9999; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { #root html; #index index.html index.htm; proxy_pass http://nacos-servers; }
集群配置文件 vim /root/cluster/nacos01/conf/cluster.conf vim /root/cluster/nacos02/conf/cluster.conf vim /root/cluster/nacos03/conf/cluster.conf vim /root/cluster/nacos04/conf/cluster.conf vim /root/cluster/nacos05/conf/cluster.conf host: 192.168.66.100:8851 192.168.66.100:8852 192.168.66.100:8853 192.168.66.100:8854 192.168.66.100:8855 config: vim /root/cluster/nacos01/conf/application.properties mysql: spring.datasource.platform=mysql ### Count of DB: db.num=1 ### Connect URL of DB: db.url.0=jdbc:mysql://192.168.66.100:3306/nacos_config?characterEncoding=utf8&connectTi meout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&se rverTimezone=Asia/Shanghai db.user.0=root db.password.0=root 启动集群: sh /root/cluster/nacos01/bin/startup.sh 关闭: sh /root/cluster/nacos01/bin/shutdown.sh sh /root/cluster/nacos02/bin/shutdown.sh JVM 调整: vim /root/cluster/nacos01/bin/startup.sh 访问地址: 192.168.66.100:8851/nacos/ 192.168.66.100:8852 192.168.66.100:8853 192.168.66.100:8854 192.168.66.100:8855 日志: tail -f /root/cluster/nacos03/logs/start.out 负载均衡: upstream nacos-servers { server 192.168.66.100:8851; server 192.168.66.100:8852; server 192.168.66.100:8853; server 192.168.66.100:8854; server 192.168.66.100:8855; } server { listen 9999; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { #root html; #index index.html index.htm; proxy_pass http://nacos-servers; } 启动Nginx 加载配置启动 ./nginx -c /usr/nginx/conf/nginx.conf 查看是否启动 ps -ef|grep nginx 通过Nginx访问Nacos http://192.168.127.154:9999/nacos