Nacos + Nginx + Keepalived 故障转移

在 5.1、Nacos 集群服务安装说明 文中讲述了Nacos三节点集群的安装部署,本文将继续讲述如何实现Nacos集群的对外高可用。

高可用方案:Nacos + Nginx + Keepalived

服务 作用
Nacos 注册发现、配置中心集群
Nginx 集群负载
Keepalived 故障转移

Nignx 配置

#Nacos2.0以上版本需要代理Grpc端口 8848,9848,9849,7848

stream {
  log_format streamlog '$remote_addr [$time_local] '
                 '$protocol $status $bytes_sent $bytes_received '
                 '$session_time "$upstream_addr" '
                 '"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';

  upstream nacos_9848 {
    server 10.215.185.10:9848;
    server 10.215.185.11:9848;
    server 10.215.185.12:9848;
  }

  upstream nacos_9849 {
    server 10.215.185.10:9849;
    server 10.215.185.11:9849;
    server 10.215.185.12:9849;
  }

  upstream nacos_7848 {
    server 10.215.185.10:7848;
    server 10.215.185.11:7848;
    server 10.215.185.12:7848;
  }

  server {
    listen 9848;
    access_log /data/wwwlogs/nacos_9848.access_nginx.log streamlog;
    #error_log /data/wwwlogs/nacos_9848.error_nginx.log crit;
    proxy_pass nacos_9848;
  }

  server {
    listen 9849;
    access_log /data/wwwlogs/nacos_9849.access_nginx.log streamlog;
    #error_log /data/wwwlogs/nacos_9849.error_nginx.log crit;
    proxy_pass nacos_9849;
  }

  server {
    listen 7848;
    access_log /data/wwwlogs/nacos_7848.access_nginx.log streamlog;
    #error_log /data/wwwlogs/nacos_7848.error_nginx.log crit;
    proxy_pass nacos_7848;
  }
}

http {

  upstream nacos-cluster{
      server 10.215.185.10:8848;
      server 10.215.185.11:8848;
      server 10.215.185.12:8848;
  }

  server{
    listen 8848;
    server_name localhost;
    location /{
      proxy_pass http://nacos-cluster;
    }
  }
}

https://blog.csdn.net/z17806289513/article/details/127239108

https://blog.csdn.net/qq_42838143/article/details/127326251

作者:Jeebiz  创建时间:2023-01-17 12:33
最后编辑:Jeebiz  更新时间:2024-10-03 00:38