In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article is a detailed introduction to "how to configure keepalived dual hot standby nginx". The content is detailed, the steps are clear, and the details are properly handled. I hope this article "how to configure keepalived dual hot standby nginx" can help you solve your doubts. Let's go deeper and learn new knowledge together with the ideas of Xiaobian.
Environmental preparation:
2 centos: 192.168.0.105 and 192.168.0.118, virtual ip(vip) is 192.168.0.119
Configure keepavlived
Install keepalived on 105 and 118 respectively
yum install keepalived
Get ready for the heartbeat.
Keepalived configuration is quite flexible, you can regularly execute the corner command, used for heartbeat check, for example, we visit nginx found nginx inaccessible, turn off keepalived, thus switching to nginx to achieve uninterrupted service support.
vi /etc/keepalived/keepalived.conf
#!/ bin/bashcount=0for (( k=0; k state backup,priority 100 -> priority 90,mcast_src_ip 192.168.0.118 -> mcast_src_ip 192.168.0.105。Everything else remains the same, isn't it simple?
! configuration file for keepalivedvrrp_script chk_nginx { script "/etc/keepalived/check_nginx.sh" interval 2 weight -5}vrrp_instance vi_1 { state backup #modified interface eth0 mcast_src_ip 192.168.0.105 #modified to native ip virtual_router_id 51 priority 90 #number word reduced advert_int 2 authentication { auth_type pass auth_pass 1111 } virtual_ipaddress {192.168.0.119} track_script { chk_nginx }}
Here, the simple configuration of keepalived is completed. Below, start keepalived.
service keepalived start
install Nginx
Check if nginx dependency libraries are complete
rpm -qa zlibrpm -qa zlib-develrpm -qa opensslrpm -qa openssl-develrpm -qa pcrerpm -qa pcre-develrpm -qa gcc
If not, install it.
yum -y install gcc zlib zlib-devel openssl openssl-devel pcre-devel
Download and extract nginx
mkdir nginxsrccd nginxsrc/
wget http://nginx.org/download/nginx-1.13.9.tar.gztar zxvf nginx-1.13.9.tar.gzcd nginx-1.13.9/
./ configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module
The requested URL/usr/local/nginx/sbin/nginx was not found on this server.
make&&make install
After successful execution, the leaving directory will be displayed.
start
/usr/local/nginx/sbin/nginx
check
ps aux|grep nginx
startup
vi /etc/rc.local
add a line
/usr/local/nginx/sbin/nginx
Because port 80 on my machine is occupied by other applications, I modified nginx.conf for 105 and 118 to change port 80 to 81.
vi /usr/local/nginx/conf/nginx.conf
Add an ip to the index.html on 105 and 119 so they can identify which ip is open.
vi /usr/local/nginx/html/index.html
nginx reload configuration
/usr/local/nginx/sbin/nginx -s reload
All right, let's interview
curl 192.168.0.119:81
The html returned is index.html on 118 machines
Now we put 118 nginx stop
/usr/local/nginx/sbin/nginx -s stop
At this time, keepalived heartbeat check on 118. If nginx cannot be accessed, it will turn keepalived off and then turn to the slave node.
Let's go back to 119.
curl 192.168.0.119:81
Restart nginx and keepalived on 118
The URL returned by visiting 119 is index.html on 118.
Read here, this article "keepalived dual hot standby nginx how to configure" article has been introduced, want to master the knowledge points of this article also need to be used by yourself to understand, if you want to know more related content of the article, welcome to pay attention to the industry information channel.
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.