LVS

IP:

Eth0:192.168.100.115

Eth1:192.168.100.215

Vi 
/etc/init.d./lvs

#!/bin/sh

#

# lvs     
Start lvs

#

# chkconfig: 2345 08 92

# description:  Starts, stops and saves lvs

#

SNS_VIP=192.168.100.215

SNS_RIP1=192.168.100.114

SNS_RIP2=192.168.100.113

. /etc/rc.d/init.d/functions

#logger $0 called with $1

retval=0

start()

{

#set squid vip

/sbin/ipvsadm --set 30 5 60

#/sbin/ifconfig eth0:0 $SNS_VIP broadcast $SNS_VIP netmask
255.255.255.255 broadcast $SNS_VIP up

#/sbin/route add -host $SNS_VIP dev eth0:0

/sbin/ipvsadm -A -t $SNS_VIP:80 -s rr

/sbin/ipvsadm -a -t $SNS_VIP:80 -r $SNS_RIP1 -g

/sbin/ipvsadm -a -t $SNS_VIP:80 -r $SNS_RIP2 -g

touch /var/lock/subsys/ipvsadm > /dev/null 2 >&1

echo "ipvsadm started"

}

stop()

{

/sbin/ipvsadm -C

/sbin/ipvsadm -Z

#ifconfig eth0:0 down

#route del $SNS_VIP

rm -rf /var/lock/subsys/ipvsadm > /dev/null 2 >&1

echo "ipvsadm stoped"

}

status()

{

if [ ! -e /var/lock/subsys/ipvsadm ];then

echo "ipvsadm stoped"

exit 1

else

echo "ipvsadm OK"

fi

}

case "$1" in

start)

start

;;

stop)

stop

;;

status)

status

;;

restart)

stop

start

;;

*)

echo $"Usage: $0 {start|stop|status}"

retval=1

esac

exit $retval

keepalvived

tar xf keepalived-1.2.7.tar.gz

cd keepalived-1.2.7

./configure --prefix=/ --mandir=/usr/local/share/man/
--with-kernel-dir=/usr/src/kernels/2.6.32-279.el6.x86_64

Make

make install

cd /etc/keepalived/

mv keepalived.conf keepalived.conf.default

chkconfig --add keepalived

chkconfig keepalived on

vim /etc/keepalived/keepalived.conf

! Configuration File for keepalived

global_defs {

notification_email {

root@localhost

}

notification_email_from root@localhost

smtp_server 127.0.0.1

smtp_connect_timeout 30

router_id Director1

}

#VRRP(虚拟路由冗余协议)实例配置

vrrp_instance VI_1 {

state MASTER

interface eth0

virtual_router_id 51

priority 150

advert_int 1

authentication {

auth_type PASS

auth_pass 1111

}

virtual_ipaddress {

192.168.122.254/24 eth1

}

}

#LVS配置

virtual_server 192.168.100.215 80 {

delay_loop 3

lb_algo rr

lb_kind DR

nat_mask 255.255.255.0

#
persistence_timeout 50

protocol TCP

real_server
192.168.100.113 80 {

weight 1

TCP_CHECK {

connect_port 80

connect_timeout 10

nb_get_retry 3

delay_before_retry 3

}

}

real_server 192.168.100.114 80 {

weight 1

TCP_CHECK {

connect_port 80

connect_timeout 10

nb_get_retry 3

delay_before_retry 3

}

}

}

}

LVS-realserver

Ip 192.168.100.113

Ip 192.168.100.114

Vi  /etc/init.d/rsup

#!/bin/bash

VIP=192.168.100.215

ifconfig lo:0 $VIP broadcast $VIP netmask
255.255.255.255 up

#route add –host $VIP dev lo:0

echo "1"
>/proc/sys/net/ipv4/conf/lo/arp_ignore

echo "2"
>/proc/sys/net/ipv4/conf/lo/arp_announce

echo "1"
>/proc/sys/net/ipv4/conf/all/arp_ignore

echo "2"
>/proc/sys/net/ipv4/conf/all/arp_announce

#sysctl –p

Nginx

Ip 192.168.100.122(nfs)

Ip 192.168.100.113

Ip 192.168.100.114

#安装zlib

tar xzvf zlib-1.2.3.tar.gz

cd zlib-1.2.3

./configure

make && make install

#安装pcre

tar zxvf pcre-7.9.tar.gz

cd pcre-7.9

./configure --prefix=/usr/local/pcre

make && make install

wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz

tar -zxvf
nginx_mod_h264_streaming-2.2.7.tar.gz

unzip
nginx_upstream_check_module-master.zip

mv
./nginx_upstream_check_module-master /root/health

tar -xvf nginx-1.4.1.tar.gz  -C /usr/src/

useradd nginx

cd /usr/src/nginx-1.4.1

patch
-p1 < /root/health/check_1.2.6+.patch

./configure --user=nginx
--group=nginx --with-http_stub_status_module --with-http_ssl_module  --with-http_gzip_static_module --with-http_flv_module  --add-module=../nginx_mod_h264_streaming-2.2.7
 --with-pcre=/software/pcre-7.9 --with-zlib=/software/zlib-1.2.3
--prefix=/usr/local/nginx --add-module=/root/health

make
&& make install

/usr/local/nginx/sbin/nginx

开机自动启动

vi /etc/init.d/nginx

#!/bin/bash

#

#
nginx - this script starts and stops the nginx daemin

#

#
chkconfig:   - 85 15

#
description:  Nginx is an HTTP(S) server,
HTTP(S) reverse \

#               proxy and
IMAP/POP3 proxy server

#
processname: nginx

#
config:     
/usr/local/nginx/conf/nginx.conf

#
pidfile:    
/usr/local/nginx/logs/nginx.pid

#
Source function library.

.
/etc/rc.d/init.d/functions

#
Source networking configuration.

.
/etc/sysconfig/network

#
Check that networking is up.

[
"$NETWORKING" = "no" ] && exit 0

nginx="/usr/local/nginx/sbin/nginx"

prog=$(basename $nginx)

NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"

lockfile=/var/lock/subsys/nginx

start() {

[ -x $nginx ] || exit 5

[ -f $NGINX_CONF_FILE ] || exit 6

echo -n $"Starting $prog: "

daemon $nginx -c $NGINX_CONF_FILE

retval=$?

echo

[ $retval -eq 0 ] && touch $lockfile

return $retval

}

stop()
{

echo
-n $"Stopping $prog: "

killproc $prog -QUIT

retval=$?

echo

[
$retval -eq 0 ] && rm -f $lockfile

return $retval

}

restart()
{

configtest || return $?

stop

start

}

reload()
{

configtest || return $?

echo
-n $"Reloading $prog: "

killproc $nginx -HUP

RETVAL=$?

echo

}

force_reload() {

restart

}

configtest() {

$nginx
-t -c $NGINX_CONF_FILE

}

rh_status() {

status $prog

}

rh_status_q() {

rh_status >/dev/null 2>&1

}

case "$1" in

start)

rh_status_q && exit 0

$1

;;

stop)

rh_status_q || exit 0

$1

;;

restart|configtest)

$1

;;

reload)

rh_status_q || exit 7

$1

;;

force-reload)

force_reload

;;

status)

rh_status

;;

condrestart|try-restart)

rh_status_q || exit 0

;;

*)

echo $"Usage: $0
{start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"

exit 2

esac

##############################################################################

改权限

chmod 755
/etc/init.d/nginx

chkconfig nginx on

chkconfig --list nginx

nginx           0:off   1:off  
2:on    3:on    4:on   
5:on    6:off

service nginx
start

service nginx
stop

service nginx
restart

service nginx
reload

/etc/init.d/nginx
start

/etc/init.d/nginx
stop

/etc/init.d/nginx
restart

/etc/init.d/nginx
reload

Nginx 配置文件

vi /usr/local/nginx/conf/nginx.conf

#user  nginx nginx;

worker_processes
12;

error_log  /usr/local/nginx/logs/error.log  crit;

pid        /usr/local/nginx/logs/nginx.pid;

worker_rlimit_nofile
65535;

events

{

use epoll;

worker_connections 204800;

}

http

{

include      
mime.types;

default_type 
application/octet-stream;

charset 
utf-8;

server_names_hash_bucket_size 128;

client_header_buffer_size 2k;

large_client_header_buffers 4 4k;

client_max_body_size 8m;

sendfile on;

tcp_nopush    
on;

keepalive_timeout 60;

fastcgi_cache_path
/usr/local/nginx/fastcgi_temp levels=1:2

keys_zone=TEST:10m

inactive=5m;

fastcgi_connect_timeout 300;

fastcgi_send_timeout 300;

fastcgi_read_timeout 300;

fastcgi_buffer_size 1638;

fastcgi_buffers 16 16k;

fastcgi_busy_buffers_size 16k;

fastcgi_temp_file_write_size 16k;

fastcgi_cache TEST;

fastcgi_cache_valid 200 302 1h;

fastcgi_cache_valid 301 1d;

fastcgi_cache_valid any 1m;

fastcgi_cache_min_uses 1;

fastcgi_cache_use_stale error timeout
invalid_header http_500;

open_file_cache max=204800 inactive=20s;

open_file_cache_min_uses 1;

open_file_cache_valid 30s;

tcp_nodelay on;

gzip on;

gzip_min_length  1k;

gzip_buffers     4 16k;

gzip_http_version 1.0;

gzip_comp_level 2;

gzip_types       text/plain application/x-javascript
text/css application/xml;

gzip_vary on;

upstream
nginx_server {

ip_hash;

server 192.168.100.122:80;

}

upstream
web_server {

ip_hash;

server 192.168.100.131:9001;

server 192.168.100.132:9001;

server 192.168.100.133:9001;

server 192.168.100.134:9001;

check interval=3000 rise=2 fall=5
timeout=1000;

}

upstream
napi_server {

ip_hash;

server 192.168.100.131:9002;

server 192.168.100.132:9002;

server 192.168.100.133:9002;

server 192.168.100.134:9002;

server 192.168.100.131:9003;

server 192.168.100.132:9003;

server 192.168.100.133:9003;

server 192.168.100.134:9003;

server 192.168.100.131:9004;

server 192.168.100.132:9004;

server 192.168.100.133:9004;

server 192.168.100.134:9004;

check interval=3000 rise=2 fall=5
timeout=1000;

}

upstream
oapi_server {

ip_hash;

server 192.168.100.131:9005;

server 192.168.100.132:9005;

server 192.168.100.133:9005;

server 192.168.100.134:9005;

server 192.168.100.131:9006;

server 192.168.100.132:9006;

server 192.168.100.133:9006;

server 192.168.100.134:9006;

check interval=3000 rise=2 fall=5
timeout=1000;

}

server {

listen       80;

server_name  localhost;

location ~
.*\.(gif|jpg|jpeg|png|bmp|swf|html|mp3|wma|wmv)$

{

root /usr/wodm/;

proxy_pass http://nginx_server;

}

location ~ .*\.(js|css)?$

{

expires      1h;

}

location /NginxStatus

{

stub_status                 on;

access_log                  on;

auth_basic                  "NginxStatus";

#auth_basic_user_file       conf/htpasswd;

}

location /nstatus {

check_status;

access_log off;

}

error_page  
500 502 503 504  /50x.html;

location = /50x.html {

root   html;

}

}

log_format  access 
'$remote_addr - $remote_user [$time_local] "$request" '

'$status $body_bytes_sent
"$http_referer" '       '"$http_user_agent"
$http_x_forwarded_for';

access_log  /usr/local/nginx/logs/access.log access;

include
/usr/local/nginx/conf/vhost/*.conf;

}

Nginx(nfs)

Nginx.conf

#user  nginx nginx;

worker_processes
16;

#worker_cpu_affinity
00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000;

error_log
/usr/local/nginx/logs/error.log  crit;

pid        /usr/local/nginx/logs/nginx.pid;

worker_rlimit_nofile
204800;

events

{

use epoll;

worker_connections 204800;

}

http

{

include      
mime.types;

default_type 
application/octet-stream;

charset 
utf-8;

server_names_hash_bucket_size 128;

client_header_buffer_size 2k;

large_client_header_buffers 4 4k;

client_max_body_size 8m;

sendfile on;

tcp_nopush    
on;

keepalive_timeout 60;

fastcgi_cache_path
/usr/local/nginx/fastcgi_cache levels=1:2

keys_zone=TEST:10m

inactive=5m;

fastcgi_connect_timeout 300;

fastcgi_send_timeout 300;

fastcgi_read_timeout 300;

fastcgi_buffer_size 1638;

fastcgi_buffers 16 16k;

fastcgi_busy_buffers_size 16k;

fastcgi_temp_file_write_size 16k;

fastcgi_cache TEST;

fastcgi_cache_valid 200 302 1h;

fastcgi_cache_valid 301 1d;

fastcgi_cache_valid any 1m;

fastcgi_cache_min_uses 1;

fastcgi_cache_use_stale error timeout
invalid_header http_500;

open_file_cache max=204800 inactive=20s;

open_file_cache_min_uses 1;

open_file_cache_valid 30s;

tcp_nodelay on;

gzip on;

gzip_min_length  1k;

gzip_buffers     4 16k;

gzip_http_version 1.0;

gzip_comp_level 2;

gzip_types       text/plain application/x-javascript
text/css application/xml;

gzip_vary on;

server

{

listen      
80;

server_name 
localhost;

index index.php index.htm;

root 
/usr/wodm/;

location /status

{

stub_status on;

}

location ~
.*\.(gif|jpg|jpeg|png|bmp|swf|html|mp3|wma|wmv)$

{

expires      30d;

}

}

log_format  access 
'$remote_addr - $remote_user [$time_local] "$request" '

'$status $body_bytes_sent
"$http_referer" '      
'"$http_user_agent" $http_x_forwarded_for';

access_log  /usr/local/nginx/logs/access.log access;

标准字符集

vi
/etc/sysconfig/i18n

LANG="zh_CN.UTF-8"
SYSFONT="latarcyrheb-sun16"
SUPPORTED="zh_CN.UTF-8:zh_CN:zh"

LANG="zh_CN.GB18030"

SUPPORTED="zh_CN.GB18030:zh_CN:zh:en_US.UTF-8:en_US:en"

打开文件数

vi /etc/security/limits.conf

* soft nofile 65535

* hard nofile 65535

vi /etc/pam.d/login

session required /lib/security/pam_limits.so

nginx  日志按天分割

vi  nginx_log.sh

#!/bin/bash

logs_path="/usr/local/nginx/logs/"

pid_path="/usr/local/nginx/nginx.pid"

mv ${logs_path}access.log ${logs_path}access_$(date -d
"yesterday" +"%Y%m%d").log

kill -USR1 `cat ${pid_path}`

chmod 755 nginx_log.sh

crontab –e

0 0 * * *  bash
/usr/local/nginx/nginx_log.sh

Tomcat  memcache

tar xf libevent-1.4.11-stable.tar.gz

cd libevent-1.4.11-stable

./configure

make

make install

cd ../

tar xf memcached-1.4.5.tar.gz

cd memcached-1.4.5

./configure

make

make install

/usr/local/bin/memcached -d -m 10 -u root -l 192.168.1.113 -p
11211 -c 1024 -P /tmp/memcached.pid

Memcache+tomcat 共享session

后续计划尚未配置

LVS+NGINX+TOMCAT_集群实施操作记录.docx的更多相关文章

  1. LVS+Heartbeat 高可用集群方案操作记录

    之前分别介绍了LVS基础知识和Heartbeat基础知识, 今天这里简单说下LVS+Heartbeat实现高可用web集群方案的操作说明. Heartbeat 项目是 Linux-HA 工程的一个组成 ...

  2. Haproxy+Heartbeat 高可用集群方案操作记录

    之前详细介绍了haproxy的基础知识点, 下面记录下Haproxy+Heartbeat高可用web集群方案实现过程, 以加深理解. 架构草图如下: 1) 基本环境准备 (centos6.9系统) 1 ...

  3. 运维利器-ClusterShell集群管理操作记录

    在运维实战中,如果有若干台数据库服务器,想对这些服务器进行同等动作,比如查看它们当前的即时负载情况,查看它们的主机名,分发文件等等,这个时候该怎么办?一个个登陆服务器去操作,太傻帽了!写个shell去 ...

  4. 高性能Linux服务器 第11章 构建高可用的LVS负载均衡集群

    高性能Linux服务器 第11章 构建高可用的LVS负载均衡集群 libnet软件包<-依赖-heartbeat(包含ldirectord插件(需要perl-MailTools的rpm包)) l ...

  5. kafka 基础知识梳理及集群环境部署记录

    一.kafka基础介绍 Kafka是最初由Linkedin公司开发,是一个分布式.支持分区的(partition).多副本的(replica),基于zookeeper协调的分布式消息系统,它的最大的特 ...

  6. Linux Cluster 基础之LVS调度算法与集群类型

    Linux Cluster 基础之LVS调度算法与集群类型 作者:尹正杰  版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.LB Cluster 1>.什么是LB LB 集群是 load ...

  7. kubeadm安装kubernetes 1.13.1集群完整部署记录

    k8s是什么 Kubernetes简称为k8s,它是 Google 开源的容器集群管理系统.在 Docker 技术的基础上,为容器化的应用提供部署运行.资源调度.服务发现和动态伸缩等一系列完整功能,提 ...

  8. Linux+.NetCore+Nginx搭建集群

    本篇和大家分享的是Linux+NetCore+Nginx搭建负载集群,对于netcore2.0发布后,我一直在看官网的文档并学习,关注有哪些新增的东西,我,一个从1.0到2.0的跟随者这里只总结一句话 ...

  9. 实现基于LVS负载均衡集群的电商网站架构

    背景 上一期我们搭建了小米网站,随着业务的发展,网站的访问量越来越大,网站访问量已经从原来的1000QPS,变为3000QPS,网站已经不堪重负,响应缓慢,面对此场景,单纯靠单台LNMP的架构已经无法 ...

随机推荐

  1. MapReduce 图解流程超详细解答(1)-【map阶段】

    转自:http://www.open-open.com/lib/view/open1453097241308.html 在MapReduce中,一个YARN  应用被称作一个job, MapReduc ...

  2. 摄像头驱动OV7725学习笔记连载(二):0V7725 SCCB时序的实现之寄存器配置

    上一篇博客主要介绍了OV7725的电气特性以及SCCB接口的时序和输出一帧图像的时序图以及数据的拼接.输出一帧图像与输出时钟PCLK有关. 上图是OV7725实现的整体框架,有点丑.FPGA描述SCC ...

  3. C++ 结构体和枚举

    共同体 共同体(union) 是一种数据格式, 它能够存储不同的数据类型, 但只能同时存储其中的一种类型.也就是说, 结构可以同时存储int.long 和 double, 共同体只能存储int.lon ...

  4. 第三百三十七节,web爬虫讲解2—PhantomJS虚拟浏览器+selenium模块操作PhantomJS

    第三百三十七节,web爬虫讲解2—PhantomJS虚拟浏览器+selenium模块操作PhantomJS PhantomJS虚拟浏览器 phantomjs 是一个基于js的webkit内核无头浏览器 ...

  5. 安卓横竖屏切换时activity的生命周期

    关于Activity横竖屏切换的声明周期变化: 1.新建一个Activity并把各个生命周期打印出来 2.运行Activity,得到如下信息 onCreate-->onStart-->on ...

  6. JUnit4参数化测试实例

    在JUnit中,可以同时使用@RunWith 和 @parameter 注解来为单元测试传递参数. 注意: 在Eclipse中因为版本问题,可能无法使用@parameters(name = " ...

  7. c#中的对象生命周期

    无论是指类型的变量或是类类型的变量,其存储单元都是在栈中分配的,唯一不同的是类类型的变量实际上存储的是该类对象的指针,相当于vc6中的CType*,只是在.net平台的语言中将指针的概念屏蔽掉了.我们 ...

  8. Lambda动态排序

    private static IList<T> IListOrderBy<T>(IList<T> list, string propertyName) where ...

  9. jQuery table td可编辑

    参考链接: http://www.freejs.net/ http://www.freejs.net/article_biaodan_34.html http://www.freejs.net/sea ...

  10. 成都传智播客java就业班(14.04.01班)就业快报(Java程序猿薪资一目了然)

    这是成都传智播客Java就业班的就业情况,很多其它详情请见成都传智播客官网:http://cd.itcast.cn?140812ls 姓名 入职公司 入职薪资(¥) 方同学 安**软件成都有限公司(J ...