Squid反向代理加速缓存+负载均衡实验架构

实验环境:
公司有两台web服务器,运行同一套网站,读取同一台mysql数据库。
两台web服务器的主机名如下:
test1.com 192.168.1.119
test2.com 192.168.1.120
squid服务器ip:192.168.1.123

DNS: 192.168.9.254

Squid反向代理加速缓存+负载均衡实验架构

实验思路:DNS将www.fb.com解析给squid服务器,squid轮询web主机返回其中一台作应答,并提供缓冲加速的服务!

注意:在次试验中,针对https的部分有点问题,需要负载均衡设备做一些设置!另外,两台web服务器部分网站目录的同步问题,已解决可以才从NFS挂载目录的方式来实现!

一、基础配置

A、更新

1、更换更新源(服务器位于国内做此操作)

sed -i "s/mirror.CentOS.org/centos/mirrors.centos.91.com/g" /etc/yum.repos.d/CentOS-Base.repo

sed -i "s/^mirrorlist/#mirrorlist/g" /etc/yum.repos.d/CentOS-Base.repo

sed -i "s/^#baseurl/baseurl/g" /etc/yum.repos.d/CentOS-Base.repo

2、更新

yum clean all

yum -y update

[sepatator]

B、优化

1、增加以下内容到/etc/sysctl.conf末尾

kernel.core_uses_pid = 1

net.ipv4.ip_forward = 1

net.ipv4.conf.lo.arp_ignore = 1

net.ipv4.conf.lo.arp_announce = 2

net.ipv4.conf.all.arp_ignore = 1

net.ipv4.conf.all.arp_announce = 2

net.ipv4.tcp_tw_reuse = 1

net.ipv4.tcp_tw_recycle = 1

net.ipv4.tcp_fin_timeout = 30

net.ipv4.tcp_keepalive_time = 300

net.ipv4.tcp_window_scaling = 0

net.ipv4.tcp_sack = 0

net.ipv4.tcp_timestamps = 0

net.ipv4.tcp_syncookies = 1

net.ipv4.icmp_echo_ignore_broadcasts = 1

net.ipv4.icmp_ignore_bogus_error_responses = 1

net.ipv4.conf.all.log_martians = 1

net.ipv4.tcp_max_syn_backlog = 4096

net.ipv4.tcp_max_tw_buckets = 1440000

net.ipv4.ip_local_port_range = 1024 65536

net.core.rmem_max = 16777216

net.core.wmem_max = 16777216

net.ipv4.tcp_rmem = 4096 87380 16777216

net.ipv4.tcp_wmem = 4096 65536 16777216

net.ipv4.tcp_keepalive_intvl = 15

net.ipv4.tcp_retries2 = 5

fs.file-max = 655360

net.core.somaxconn = 4096

执行:

sysctl -p

使之生效

2、加大可允许打开的文件句柄数

echo "* soft nofile 65536" >>/etc/security/limits.conf

echo "* hard nofile 65536" >>/etc/security/limits.conf

3、时间校对

yum -y install ntp

service ntpd restart

service ntpd stop

echo "#time update" >> /etc/crontab

echo "0 23 * * * root /usr/sbin/ntpdate time.windows.com" >> /etc/crontab

C、硬盘分区挂载

查看硬盘

fdisk -l

根据实际物理机器是否硬raid及硬盘数量做不同的raid及分区情况

因为这里是做cache,不建议使用软raid

相关推荐