四层负载均衡实践
lb01是我已配置好的七层负载均衡,下面有一些项目知乎,博客
现要加一台四层负载均衡和七层负载均衡
保证七层的负载均衡的高可用性
主机 | 外网IP | 内网IP | 身份 |
lb03 | 10.0.0.6 | 172.16.1.6 | 四层负载均衡 |
lb02 | 10.0.0.4 | 172.16.1.4 | 七层负载均衡 |
lb01 | 10.0.0.5 | 172.16.1.5 | 七层负载均衡 |
[root@lb02 ~]# vim /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[root@lb02 ~]# yum install -y nginx
[root@lb02 ~]# groupadd -g 666 www
[root@lb02 ~]# useradd -u 666 -g 666 www
[root@lb02 ~]# vim /etc/nginx/nginx.conf
user www;
[root@lb02 ~]# systemctl start nginx
[root@lb01 ~]# scp /etc/nginx/conf.d/* 172.16.1.5:/etc/nginx/conf.d/
[root@lb01 ~]# [root@lb01 ~]# scp /etc/nginx/proxy_params 172.16.1.5:/etc/nginx/
[root@lb02 ~]# nginx -t
[root@lb02 ~]# systemctl restart nginx
[root@lb03 ~]# vim /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[root@lb03 ~]# yum install -y nginx
[root@lb03 ~]# vim /etc/nginx/nginx.conf
include /etc/nginx/conf.c/*.conf;
[root@lb03 ~]# mkdir /etc/nginx/conf.c
[root@lb03 ~]# vim /etc/nginx/conf.c/4lb.conf
stream {
log_format proxy '$remote_addr $remote_port - [$time_local] $status $protocol' '"$upstream_addr" "$upstream_bytes_sent" "$upstream_connect_time"' ;
access_log /var/log/nginx/proxy.log proxy;
upstream lbserver {
server 10.0.0.4:80;
server 10.0.0.5:80;
}
server {
listen 80;
proxy_connect_timeout 1s;
proxy_timeout 3s;
proxy_pass lbserver;
}
}
[root@lb03 ~]# nginx -t
[root@lb03 ~]# rm -rf /etc/nginx/conf.d/*
[root@lb03 ~]# systemctl restart nginx
[root@lb03 ~]# tailf /var/log/nginx/proxy.log
本文来自博客园,作者:六月OvO,转载请注明原文链接:https://www.cnblogs.com/chenlifan/p/13610961.html