In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
I. Topology
II. Keepalived configuration
2.1 Master configuration
! Configuration File for keepalived
Global_defs {
Notification_email {acassen@firewall.locbr/ > acassen@firewall.loc
Br/ > sysadmin@firewall.loc
Notification_email_from Alexandre.Cassen@firewall.loc
Smtp_server 192.168.200.1
Smtp_connect_timeout 30
Router_id NGINX_V1
}
Vrrp_script chk_nginx {
Script "/ usr/local/keepalived/check_nginx.sh"
Interval 2
Weight 2
}
Vrrp_instance VI_1 {
State MASTER
Interface ens37
Virtual_router_id 51
Priority 100
Advert_int 1
Authentication {
Auth_type PASS
Auth_pass wenlf@780419
}
Track_script {
Chk_nginx
}
Virtual_ipaddress {
172.16.10.65 dev ens33
}
Notify_master "/ usr/local/keepalived/clean_arp.sh 172.16.10.65"
}
2.2 standby configuration
! Configuration File for keepalived
Global_defs {
Notification_email {acassen@firewall.locbr/ > acassen@firewall.loc
Br/ > sysadmin@firewall.loc
Notification_email_from Alexandre.Cassen@firewall.loc
Smtp_server 192.168.200.1
Smtp_connect_timeout 30
Router_id NGINX_V1
}
Vrrp_script chk_nginx {
Script "/ usr/local/keepalived/check_nginx.sh"
Interval 2
Weight 2
}
Vrrp_instance VI_1 {
State BACKUP
Interface ens37
Virtual_router_id 51
Priority 99
Advert_int 1
Authentication {
Auth_type PASS
Auth_pass wenlf@780419
}
Track_script {
Chk_nginx
}
Virtual_ipaddress {
172.16.10.65 dev ens33
}
Notify_master "/ usr/local/keepalived/clean_arp.sh 172.16.10.65"
2.3 Monitoring script
-- clean_arp.sh--
#! / bin/sh
VIP=$1
GATEWAY=172.16.10.254
/ sbin/arping-I ens33-c 5-s $VIP $GATEWAY & > / dev/null
-- check_nginx.sh--
#! / bin/sh
If [$(ps-C nginx-- no-header | wc-l)-eq 0]; then
/ etc/rc.d/init.d/nginx start
Fi
Sleep 2
If [$(ps-C nginx-- no-header | wc-l)-eq 0]; then
/ etc/rc.d/init.d/keepalived stop
Fi
III. Nginx configuration
3.1 nginx.conf
User www www
Worker_processes 1
# error_log logs/error.log
# error_log logs/error.log notice
Error_log logs/error.log info
Pid logs/nginx.pid
Worker_rlimit_nofile 65535
Events {
Worker_connections 1024
Use epoll
}
Http {
The default code for include LoadBalance/*.conf;include mime.types;default_type application/octet-stream;# is # charset utf-8;server_names_hash_bucket_size 128; clientholders; headers; 32k; largeclientships; head; buffers; 4 64k; clientmakers; maxilla; bodybones; buffers; 8m; Sendfile on;autoindex on;tcp_nopush on;tcp_nodelay on;keepalive_timeout 120; fastcgists; connectors; timeout; 300; fastcgigs; timeout; 300; fastcgigs; readouts; timeout; 300; fastcgigs buffersizes; buffersizes 64k; fastcgivers buffers 4 64k Fastcgi_busy_buffers_size 128k gzip_comp_level binary_remote_addr binary_remote_addr 10m includes LoadBalance/*.conf;include vhost/*.conf module sets the LoadBalance/*.conf;include vhost/*.conf 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; fastcGzip module
}
3.2 Virtual machine
Server
{
Listen 80
Server_name 172.16.10.65
# index index.html index.htm index.php
Location / {
Proxy_next_upstream http_502 http_504 error timeout invalid_header
Proxy_pass http://LoadBalance;
# proxy_redirect off
Proxy_set_header Host $host
Proxy_set_header X-Forwarded-For $remote_addr
}
Location / NginxStatus {
Stub_status on
Access_log on
Auth_basic "NginxStatus"
# auth_basic_user_file pwd
}
}
3.3 load balancing configuration
Upstream LoadBalance {
Server 192.168.10.70:80 weight=1 max_fails=2 fail_timeout=30s
Server 192.168.10.71:80 weight=1 max_fails=2 fail_timeout=30s
Ip_hash
}
IV. Verification
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.