nginx--tcp负载均衡-redis负载均衡

安装redis

wget https://download.redis.io/releases/redis-6.0.6.tar.gz
tar -zxvf redis-6.0.6.tar.gz 
cd redis-6.0.6
make
cd src/
redis-server
ss -ntl

修改文件

vim /root/redis-4.0.14/redis.conf
修改为bind 0.0.0.0

配置nginx

}
stream { 
    upstream mysql_server {
      server 192.168.33.171:3306 max_fails=3 fail_timeout=30s; 
      server 192.168.33.149:6379 max_fails=3 fail_timeout=30s;
 }
    server {
      listen 192.168.33.180:6379;
      proxy_connect_timeout 30s;
      proxy_timeout 300s;
      proxy_pass mysql_server;}
    server {
      listen 192.168.33.180:3306;
      proxy_connect_timeout 30s;
      proxy_timeout 300s;
      proxy_pass mysql_server;
 }
}

访问

上一篇:0507华为od二面


下一篇:如何在Gin框架中使用Websocket?