架构总览与分层设计
入口与负载均衡高可用
http {
upstream backend {
server 10.0.1.11:80 max_fails=3 fail_timeout=30s;
server 10.0.1.12:80 max_fails=3 fail_timeout=30s;
server 10.0.1.13:80 backup;
keepalive 32;
}
server {
listen 80;
location / {
proxy_pass http://backend;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_next_upstream on;
proxy_next_upstream_tries 3;
proxy_next_upstream_timeout 5s;
}
}
}
数据库高可用与读写分离
[mysqld]
server-id=1
log-bin=mysql-bin
binlog_format=ROW
[mysqld]
server-id=2
relay-log=mysql-relay-bin
CHANGE MASTER TO
MASTER_HOST='master_ip',
MASTER_USER='repl',
MASTER_PASSWORD='pwd',
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=154;
START SLAVE;
Web 层与共享存储
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
监控、自动化与演练