nginx&tomcat with keepalived for configing cluster
2016-01-20 22:30
429 查看
rpm -ql keepalived
rpm --ivh keepalived
mkdir -p /var/temp/nginx
#nginx source install
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi
make install
single nginx
××××××××××××××××××××××pc-133&pc-134××××××××tomcat cluster××××××××××××××
edit nginx.conf
upstream tomcate_server {
server 192.168.190.133 weight=20;
server 192.168.190.134 weight=10;
}
server {
location / {
proxy_pass http://tomcate_server;
...
...
}
..
}
****************config keepalived********************
global_defs {
# notification_email { #
# acassen@firewall.loc
# failover@firewall.loc
# sysadmin@firewall.loc
# }
# notification_email_from Alexandre.Cassen@firewall.loc
# smtp_server 192.168.200.1
# smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_script check_nginx_status {
script "/etc/keepalived/check_nginx_status.sh"
interval 2
weight 2
}
vrrp_instance VI_1 {
state MASTER #master
interface eth0
virtual_router_id 51 #
advert_int 1 #
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.190.138 #
# 192.168.200.17 #
# 192.168.200.18 #
}
}
×××××××××××××××××××keepalived back up×××××××
global_defs {
# notification_email { #
# acassen@firewall.loc
# failover@firewall.loc
# sysadmin@firewall.loc
# }
# notification_email_from Alexandre.Cassen@firewall.loc
# smtp_server 192.168.200.1
# smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 99 #prio
advert_int 1 #
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.190.138 # virtual IP
# 192.168.200.17 # banding IP
# 192.168.200.18 # banding IP
}
}
**********************keepalived script********
#!/bin/bash
nginxVal=`ps -C nginx--no-header |wc -l`
if [ $nginxVal -eq 0 ];then
servicekeepalived stop
fi
#other command
ip show addr eth0
service keepalived status/start/stop.restart
./sbin/nginx -s quit
rpm --ivh keepalived
mkdir -p /var/temp/nginx
#nginx source install
./configure \
--prefix=/usr/local/nginx \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/temp/nginx/client \
--http-proxy-temp-path=/var/temp/nginx/proxy \
--http-fastcgi-temp-path=/var/temp/nginx/fastcgi \
--http-uwsgi-temp-path=/var/temp/nginx/uwsgi \
--http-scgi-temp-path=/var/temp/nginx/scgi
make install
single nginx
××××××××××××××××××××××pc-133&pc-134××××××××tomcat cluster××××××××××××××
edit nginx.conf
upstream tomcate_server {
server 192.168.190.133 weight=20;
server 192.168.190.134 weight=10;
}
server {
location / {
proxy_pass http://tomcate_server;
...
...
}
..
}
****************config keepalived********************
global_defs {
# notification_email { #
# acassen@firewall.loc
# failover@firewall.loc
# sysadmin@firewall.loc
# }
# notification_email_from Alexandre.Cassen@firewall.loc
# smtp_server 192.168.200.1
# smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_script check_nginx_status {
script "/etc/keepalived/check_nginx_status.sh"
interval 2
weight 2
}
vrrp_instance VI_1 {
state MASTER #master
interface eth0
virtual_router_id 51 #
advert_int 1 #
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.190.138 #
# 192.168.200.17 #
# 192.168.200.18 #
}
}
×××××××××××××××××××keepalived back up×××××××
global_defs {
# notification_email { #
# acassen@firewall.loc
# failover@firewall.loc
# sysadmin@firewall.loc
# }
# notification_email_from Alexandre.Cassen@firewall.loc
# smtp_server 192.168.200.1
# smtp_connect_timeout 30
router_id LVS_DEVEL
}
vrrp_instance VI_1 {
state BACKUP
interface eth0
virtual_router_id 51
priority 99 #prio
advert_int 1 #
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.190.138 # virtual IP
# 192.168.200.17 # banding IP
# 192.168.200.18 # banding IP
}
}
**********************keepalived script********
#!/bin/bash
nginxVal=`ps -C nginx--no-header |wc -l`
if [ $nginxVal -eq 0 ];then
servicekeepalived stop
fi
#other command
ip show addr eth0
service keepalived status/start/stop.restart
./sbin/nginx -s quit
相关文章推荐
- CentOs中JDK与tomcat配置
- Tomcat项目部署方式--利用tomcat发布网站
- Tomcat 多端口,多虚拟主机配置方法
- 1.Tomcat软件使用的常见问题
- 【Mac os x 下配置Intellij IDEA + Tomcat 出现权限问题的解决办法】
- Nginx+Tomcat负载均衡配置
- iOS 自动化打包测试(使用jenkins、Tomcat、JDK实现)
- Tomcat7.0.54 进行日志分割
- 卸载绿色版tomcat
- moo 3 (2) Tomcat 目录结构及Web应用程序的目录结构
- IDEA 学习(二):Intellij IDEA 创建Web项目并在Tomcat中部署运行IDEA
- 解析Tomcat内部结构和请求过程
- moon 4 面向Web开发人员Tomcat 安装及学习
- moo 3 (1) Tomcat 系统架构与设计模式,设计模式讲解
- moo 2 Tomcat 系统架构与设计模式,第 1 部分: 工作原理
- 阿里云服务器连接以及centos 搭建 web java环境(linux java部署 tomcat部署)
- 从零开始写一个Tomcat(壹)
- Tomcat工作原理
- CentOS-6.6安装配置Tomcat-7
- IDEA利用JPDA远程调试运行在tomcat中的程序