In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Configure keepalivedHa Cluster
1) Experimental environment:
Server system: CentOS7.3
Service: nginx,keepalived
Client system: Windows 10centOS7.3
2) initialization operation: Master/Backup, operation of Tong Yan
# install keepalived software
[root@shiyan7 ~] # yum install keepalived
# install Nginx (need to configure EPEL source)
[root@shiyan7 ~] # yum install Nginx
# turn off and clear the firewall
[root@shiyan7 ~] # systemctl disable firewall.d
[root@shiyan7 ~] # systemctl stop firewall.d
[root@shiyan7] # iptables-F
# add host resolution
[root@shiyan7 ~] # vim / etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
:: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6
172.18.17.34 shiyan.fore
172.18.17.31 shiyan.one
# disable Selinux (restart after configuration)
[root@shiyan7 ~] # vim / etc/selinux/config
Selinux=disabled
III) Master configuration
Nginx configuration
[root@shiyan7 ~] # mkdir / app/nginx/html
[root@shiyan7 ~] # echo "Sorry Server-1" > / app/nginx/html/index.html
[root@shiyan7 ~] # cp / etc/nginx/nginx.conf {, .bak}
[root@shiyan7 ~] # vim / etc/nginx/nginx.conf
Server {
Listen 80 default_server
Listen [::]: 80 default_server
Server_name _
Root / app/nginx/html
# Loadconfiguration files for the default server block.
Include/etc/nginx/default.d/*.conf
Location / {
}
Error_page404 / 404.html
Location = / 40x.html {
}
Error_page500 502 503 504 / 50x.html
Location = / 50x.html {
}
}
[root@shiyan7 ~] # systemctl start nginx
Test Nginx using a browser
KeepAlived configuration
[root@shiyan7 ~] # cp / etc/keepalived/keepalived.conf {, .bak}
[root@shiyan7 ~] # vim / etc/keepalived/keepalived.conf
Global_defs {
Notification_email {
Acassen@firewall.loc
Failover@firewall.loc
Sysadmin@firewall.loc
}
Notification_email_from Alexandre.Cassen@firewall.loc
Smtp_server192.168.200.1
Smtp_connect_timeout 30
Router_id node1
}
Vrrp_instance Ha_1 {
State BACKUP
Interface ens33
Virtual_router_id 51
Priority 100
Advert_int 1
Authentication {
Auth_type PASS
Auth_pass 1111
}
Virtual_ipaddress {
172.18.17.30/16 dev ens33
}
}
IV) Backup configuration
Nginx configuration
[root@shiyan7 ~] # mkdir / app/nginx/html
[root@shiyan7 ~] # echo "Sorry Server-2" > / app/nginx/html/index.html
[root@shiyan7 ~] # cp / etc/nginx/nginx.conf {, .bak}
[root@shiyan7 ~] # vim / etc/nginx/nginx.conf
Server {
Listen 80 default_server
Listen [::]: 80 default_server
Server_name _
Root / app/nginx/html
# Loadconfiguration files for the default server block.
Include/etc/nginx/default.d/*.conf
Location / {
}
Error_page404 / 404.html
Location = / 40x.html {
}
Error_page500 502 503 504 / 50x.html
Location = / 50x.html {
}
}
[root@shiyan7 ~] # systemctl start nginx
Test Nginx using a browser
KeepAlived configuration
[root@shiyan7 ~] # cp / etc/keepalived/keepalived.conf {, .bak}
[root@shiyan7 ~] # vim / etc/keepalived/keepalived.conf
Global_defs {
Notification_email {
Acassen@firewall.loc
Failover@firewall.loc
Sysadmin@firewall.loc
}
Notification_email_from Alexandre.Cassen@firewall.loc
Smtp_server192.168.200.1
Smtp_connect_timeout 30
Router_id node2
}
Vrrp_instance Ha_1 {
State BACKUP
Interface ens33
Virtual_router_id 51
Priority 99
Advert_int 1
Authentication {
Auth_type PASS
Auth_pass 1111
}
Virtual_ipaddress {
172.18.17.30/16 dev ens33
}
}
V) testing:
1) start the keepalived service of the master server and view the VIP/IP
Master
[root@shiyan7 ~] # systemctl start keepalived
[root@shiyan7 ~] # ip a l
Backup
[root@shiyan7 ~] # systemctl start keepalived
[root@shiyan7 ~] # ip a l
Test Nginx on the Master environment
2) close Master to test Backup
Master
[root@shiyan7 ~] # systemctl stop keepalived
[root@shiyan7 ~] # ip a l
Backup
[root@shiyan7 ~] # ip a l
Test Nginx on the Backup environment
3) enable Master
Master
[root@shiyan7 ~] # systemctl start keepalived
Root@shiyan7 ~] # ip a l
Backup
[root@shiyan7 ~] # ip a l
Test Nginx on the Master environment
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.