nginx,keepalived高可用部署

2021-08-30 13:50:01 字數 2165 閱讀 7375

環境

172.16.91.218  主

172.16.91.219

安裝包版本

nginx-1.14.0.tar.gz

keepalived-2.0.7.tar.gz

把 nginx,keepalived 壓縮包 上傳到 /usr/local/src/

兩個機器 都 安裝 nginx

安裝 依賴 包

yum install -y gcc-c++

yum install -y pcre pcre-devel

yum install -y zlib zlib-devel

yum install -y openssl openssl-devel

把 nginx 解壓 放到 /usr/local/ 並重命名為 nginx

./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/nginx.conf

編譯 安裝

cd  /usr/local/nginx/

make && make install

基本 命令使用

nginx  啟動

nginx  -s  stop  關閉 nginx

nginx  -s  start  啟動nginx

兩台機器都要安裝 keepalived

安裝 所需要 的依賴包

yum install -y gcc;

yum install -y openssl-devel;

yum install -y libnl;

yum install -y libnl-devel;

yum install -y libnfnetlink-devel;

解壓,並 放到 /usr/local /, 並 重新命名為 keepalived

./configure --prefix=/usr/local/keepalived/ --sysconf /etc

4cd   /usr/local/keepalived/

make && make install

ln -s sbin/keepalived /sbin/

cd keepalived

cp etc/init.d/keepalived /etc/init.d/

chkconfig --add keepalived

chkconfig keepalived on

service keepalived start

主 伺服器   keepalived  的 keepalived 配置

! configuration file for keepalived

global_defs

vrrp_script chk_nginx_service

vrrp_instance vi_1

virtual_ipaddress

track_script

}virtual_server 172.16.91.100 80    }}

}從 伺服器  keepalived  的 keepalived 配置

! configuration file for keepalived

global_defs

vrrp_script chk_nginx_service

vrrp_instance vi_1

virtual_ipaddress

track_script  

}virtual_server 172.16.91.100 80 }}

}觸發的指令碼

#! /bin/sh

a=`ps -c nginx --no-header | wc -l`

if [ $a -eq 0 ]

then

echo 'nginx server is died'

service keepalived stop

fi~    

keepalived  配置檔案 講解

global_defs

vrrp_instance vi_1

virtual_ipaddress

}virtual_server 192.168.11.100 80 }}

nginx keepalived學習目錄

keepalived權威指南 深入理解nginx nginx模組開發與架構解析第二版 nginx開發從入門到精通 keepalived工作原理和配置說明 1 nginx安裝和介紹 2 nginx的啟動和停止 3 nginx程序模型 4 nginx處理請求過程 5 nginx配置一 6 nginx配置...

Nginx Keepalived 負載均衡

喜歡搞nginx,這兩天研究了一下nginx的負載配置 nginx平台搭建 nginx mysql php fpm搭建高效能nginx平台 單nginx負載均衡 nginx 負載均衡 配置全過程 熟悉上面的配置之後,今天我再來搞nginx keepalived 的配置,具體拓撲如下 一 安裝keep...

nginx keepalived雙機熱備

採用nginx實現反向 配置集群,實現軟f5的功能。nginx.conf的配置如下 server 192.168.2.134 8082 upstream socologin server access log home soco share nginx logs access.log access ...