负载均衡(二)

匿名 (未验证) 提交于 2019-12-02 23:55:01

Nginx+keepalive 搭建负载均衡

准备两台服务器

NginXkeepalived:

yum -y install gcc pcre-devel zlib-devel openssl-devel

yum -y install popt-devel

wget http://nginx.org/download/nginx-1.2.4.tar.gz

wget http://www.keepalived.org/software/keepalived-1.2.7.tar.gz

NginX

keepalive

tar zxvf keepalived-1.2.7.tar.gz

cd keepalived-1.2.7

3

NginX

NginX,/usr/local/nginx/conf/nginx.confhttphttpserverserverlocationhttpupstream,serverlocationproxypasshttp

http {

}

IPurl

/

keepalived

keepalived/etc/keepalived/keepalived.conf

Master:

! Configuration File for keepalived

global_defs {

}

vrrp_instance VI_1 {

}

Backup:

! Configuration File for keepalived

global_defs {

}

vrrp_instance VI_1 {

}

keepalived: /etc/init.d/keepalived start

IPip addr

keepalived: /etc/init.d/keepalived stop IP

keepalivedIP

keepalivedNginX

keepalivedVIPkeepalivedVIPNginX

keepalivedNginXNginXkeepalived

NginX

NginXNginXurl

NginX3

nmapnginxnginxnmap:

#!/bin/bash

# check nginx server status

NGINX=/usr/local/nginx/sbin/nginx

PORT=8080

nmap localhost -p $PORT | grep "$PORT/tcp open"

#echo $?

if [ $? -ne 0 ];then

fi

/opt/chk_nginx.shkeepalived.conf

主keepalived

vrrp_script chk_http_port {

}

track_script {

}

例子:

! Configuration File for keepalived

global_defs {

}

vrrp_script chk_http_port {

}

vrrp_instance VI_1 {

}

keepalivednginx , /etc/init.d/keepalivedstartnginx:

start() {

}

来源: https://www.cnblogs.com/ddcom/p/11380735.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!