LVS+NGINX+TOMCAT 集群实施操作记录

合集下载

集群的配置步骤

集群的配置步骤

集群的配置步骤一、搭建集群环境的准备工作在开始配置集群之前,我们需要先进行一些准备工作。

首先,确保所有服务器都已经正确连接到网络,并且能够相互通信。

其次,确保每台服务器上已经安装了操作系统,并且操作系统版本一致。

最后,确保每台服务器上已经安装了必要的软件和工具,例如SSH、Java等。

二、创建集群的主节点1.选择一台服务器作为集群的主节点,将其IP地址记录下来。

2.登录到主节点服务器上,安装并配置集群管理软件,例如Hadoop、Kubernetes等。

3.根据集群管理软件的要求,配置主节点的相关参数,例如集群名称、端口号等。

4.启动集群管理软件,确保主节点能够正常运行。

三、添加集群的工作节点1.选择一台或多台服务器作为集群的工作节点,将其IP地址记录下来。

2.登录到工作节点服务器上,安装并配置集群管理软件,确保与主节点的版本一致。

3.根据集群管理软件的要求,配置工作节点的相关参数,例如主节点的IP地址、端口号等。

4.启动集群管理软件,确保工作节点能够正常连接到主节点。

四、测试集群的连接和通信1.在主节点服务器上,使用集群管理软件提供的命令行工具,测试与工作节点的连接和通信。

例如,可以使用Hadoop的hdfs命令测试与工作节点的文件系统的连接。

2.确保主节点能够正确访问工作节点的资源,并且能够将任务分配给工作节点进行处理。

五、配置集群的资源管理1.根据集群管理软件的要求,配置集群的资源管理策略。

例如,可以设置工作节点的CPU和内存的分配比例,以及任务的调度算法等。

2.确保集群能够合理分配资源,并且能够根据需要动态调整资源的分配。

六、监控和管理集群1.安装并配置集群的监控和管理工具,例如Ganglia、Zabbix等。

2.确保监控和管理工具能够正常运行,并能够及时发现和处理集群中的故障和问题。

3.定期对集群进行巡检和维护,确保集群的稳定和可靠性。

七、优化集群的性能1.根据实际情况,对集群的各项参数进行调优,以提高集群的性能和效率。

网站集群解决方案

网站集群解决方案
5.安全防护策略
(1)网络层防护:部署防火墙,防止非法访问与攻击。
(2)系统层防护:采用安全加固的操作系统,降低系统漏洞风险。
(3)应用层防护:部署Web应用防火墙(WAF),防护SQL注入、跨站脚本攻击等。
(4)定期安全审计:开展安全漏洞扫描、渗透测试等,及时发现并修复安全隐患。
五、实施步骤
1.服务器选型与采购:根据业务需求,选择合适的服务器硬件。
本方案旨在为用户提供一个高效、稳定、安全的网站集群解决方案,满足不断增长的互联网需求。在实施过程中,需遵循相关法律法规,确保合法合规。同时,根据业务发展,不断调整优化方案,提升网站集群的性能与可用性。
(2)后端服务器:选用高计算能力的服务器,部署应用服务器软件,如Tomcat、JBoss等。
(3)数据库服务器:选用高存储容量、高性能的数据库服务器,部署MySQL、Oracle等数据库。
2.负载均衡策略
采用轮询、加权轮询、最小连接数等负载均衡算法,实现用户请求的合理分发。
3.数据同步机制
(1)数据库同步:采用主从复制技术,实现数据库数据的一致性。
网站集群解决方案
第1篇
网站集群解决方案
一、背景与目的
随着互联网技术的飞速发展,单一服务器已无法满足日益增长的网站访问需求。为提高网站访问速度、数据存储能力以及系统稳定性,本项目将采用网站集群解决方案,通过多台服务器协同工作,实现资源的优化配置与高效处理。
二、方案概述
1.网站集群架构:采用分布式部署方式,将网站前端、后端及数据库分别部署在不同的服务器上,实现负载均衡与数据冗余。
7.系统测试:对整个网站集群进行性能测试、安全测试,确保系统稳定可靠。
五、后期维护
1.监控系统:部署监控系统,实时监控服务器性能、网络状况、系统负载等。

nginx详细配置

nginx详细配置

nginx详细配置Nginx内容概览1、nginx简介(1)介绍 nginx的应⽤场景和具体可以做什么事情(2)介绍什么是反向代理(3)介绍什么是负载均衡(4)介绍什么是动静分离2、nginx安装(1)介绍 nginx在 linux系统中如何进⾏安装3、nginx常⽤的命令和配置⽂件(1)介绍 nginx启动、关闭、重新加载命令(2)介绍 nginx的配置⽂件4、nginx配置实例-反向代理5、nginx配置实例-负载均衡6、nginx配置实例-动静分离7、nginx原理与优化参数配置8、搭建 nginx⾼可⽤集群(1)搭建 nginx⾼可⽤集群(主从模式)(2)搭建 nginx⾼可⽤集群(双主模式)第 1 章 Nginx 简介1.1 Nginx 概述Nginx ("engine x") 是⼀个⾼性能的 HTTP 和反向代理服务器,特点是占有内存少,并发能⼒强,事实上 nginx的并发能⼒确实在同类型的⽹页服务器中表现较好,中国⼤陆使⽤ nginx⽹站⽤户有:百度、京东、新浪、⽹易、腾讯、淘宝等1.2 Nginx 作为 web 服务器Nginx 可以作为静态页⾯的 web 服务器,同时还⽀持 CGI 协议的动态语⾔,⽐如 perl、php等。

但是不⽀持 java。

Java程序只能通过与tomcat配合完成。

Nginx专为性能优化⽽开发,性能是其最重要的考量,实现上⾮常注重效率,能经受⾼负载的考验,有报告表明能⽀持⾼达50,000个并发连接数。

1.3 正向代理Nginx 不仅可以做反向代理,实现负载均衡。

还能⽤作正向代理来进⾏上⽹等功能。

正向代理:如果把局域⽹外的 Internet 想象成⼀个巨⼤的资源库,则局域⽹中的客户端要访问Internet,则需要通过代理服务器来访问,这种代理服务就称为正向代理。

1.4 反向代理反向代理,其实客户端对代理是⽆感知的,因为客户端不需要任何配置就可以访问,我们只需要将请求发送到反向代理服务器,由反向代理服务器去选择⽬标服务器获取数据后,在返回给客户端,此时反向代理服务器和⽬标服务器对外就是⼀个服务器,暴露的是代理服务器地址,隐藏了真实服务器 IP地址。

Nginx+tomcat集群并实现session共享(广播机制、redis两种方式)

Nginx+tomcat集群并实现session共享(广播机制、redis两种方式)

Nginx+tomcat集群并实现session共享(广播机制、redis 两种方式)本帖最后由小蜀哥哥于 2017-9-5 12:51 编辑简介:随着互联网的飞速发展,互联网的用户也飞速增加。

随之而来就是如何解决大量用户访问导致高并发的问题,倘若用单机版的tomcat在理想状态下能够承受的并发访问量大概为150到200左右,为了解决高并发就需要引入负载均衡技术。

负载均衡就是一个web服务器解决不了的问题可以通过多个web服务器来平均分担压力来解决,并将发过来的请求被平均分配到多个后台web服务器来处理,这样压力就被分解开来。

如:将同一个系统部署到多台tomcat服务器,每个tomcat服务器都可以独立提供服务——tomcat集群,并且通过负载均衡技术反向代理tomcat集群,这样既可提供系统的访问压力。

负载均衡技术有两种方式实现:(1) 硬件负载均衡——如F5 (2)软件负载均衡——如Nginx、Apache等,但是硬件负载均衡的成本比较大,所以一般都采用软件负载均衡。

而很多大型网站如京东、淘宝都采用Nginx负载均衡解决高并发问题,所有我们这里也采用Nginx实现负载均衡,反向代理tomcat集群。

一.Nginx+tomcat广播机制实现session共享1. 环境准备2. Nginx安装与启动(1) 解压Nginx压缩包(2) 双击nginx.exe启动Nginx,在浏览器输入http://localhost展示如下页面即表示安装成功3. Tomcat集群(1) 解压apache-tomcat-7.0.69.zip成两个tomcat1、tomcat2(2) 修改tomcat1的配置文件conf/server.xml1). 修改server的port端口为180052). 修改Connector的port端口为180803). 修改<Connector port="18009"protocol="AJP/1.3" redirectPort="8443" />4). 修改Engine添加jvmRoute="tomcat"5). 在<Engine>下添加如下配置文件[XML] 纯文本查看 复制代码01 02 03 04 05 06 07 08 09 10 1<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster" channelSendOptions="8"><ManagerclassName="org.apache.catalina.ha.session.DeltaManager"expireSessionsOnShutdown="false"notifyListenersOnReplication="true"/><ChannelclassName="org.apache.catalina.tribes.group.GroupChannel"> <MembershipclassName="org.apache.catalina.tribes.membership.McastService" address="228.0.0.4" port="45564" frequency="500" dropTime="3000"/><ReceiverclassName="org.apache.catalina.tribes.transport.nio.NioReceiver" address="localhost" port="14000" autoBind="100" selectorTimeout="5000" maxThreads="6"/> <SenderclassName="org.apache.catalina.tribes.transport.ReplicationTransmitt er"><Transport1 12 13 14 15 16 17 18 19 className="org.apache.catalina.tribes.transport.nio.PooledParallelSe nder"/></Sender><InterceptorclassName="org.apache.catalina.tribes.group.interceptors.TcpFailureD etector"/><InterceptorclassName="org.apache.catalina.tribes.group.interceptors.MessageDisp atch15Interceptor"/></Channel><ValveclassName="org.apache.catalina.ha.tcp.ReplicationValve" filter=""/> <ValveclassName="org.apache.catalina.ha.session.JvmRouteBinderValve"/> <ClusterListenerclassName="org.apache.catalina.ha.session.JvmRouteSessionIDBinderLis tener"/><ClusterListenerclassName="org.apache.catalina.ha.session.ClusterSessionListener"/> </Cluster>(3) tomcat2操作同上,修改位置参照tomcat1,修改tomcat2的配置文件conf/server.xml1). 修改server 的port 端口为28005同tomcat1修改server 的port 端口2). 修改Connector 的port 端口为28080同tomcat1修改Connector 的port3). 修改<Connector port="28009"protocol="AJP/1.3" redirectPort="8443" />同tomcat1修改操作4). 修改Engine 添加jvmRoute="tomcat"同tomcat1该操作5). 在<Engine>下添加如下配置文件同tomcat1的该操作(4) 修改Nginx 安装目录下conf/nginx.conf 文件4. 创建Web项目并测试广播机制的session共享(1) 创建一个Web项目,名称为TestJQ(2) 编辑index.jsp的内容如下(3) 在WEB-INF下的web.xml中加入<distributable/>(4) 将该web项目分部复制到tomcat1和tomcat2的webapps 目录下(5) 分别修改tomcat1和tomcat2下web项目的index.jsp内容如下(6) 启动tomcat1和tomcat2(7) 在Nginx安装目录下,进入cmd命令模式执行如下命令(8) 测试,在浏览器输入http://localhost/TestJQ。

LVS

LVS

群集概念的出现
• 人口大爆炸,男的比女的多3700万,都去 上网。于是服务器吃不消了,有人提出了 群集、云------概念。
解决之道
• Html语法URL重定向
– Location – 返回代码
• 早前的DNS的多个A记录 • 负载均衡产品
– F5硬件 – GSLB服务端应用负载均衡 从程序解决
– 通过IP隧道实现虚拟服务器的方法VS/TUN (Virtual Server via IP Tunneling) – 通过直接路由实现虚拟服务器的方法VS/DR(Virtual Server via Direct Routing),
• VS/DR可以极大地提高系统的伸缩性。 • VS/NAT、VS/TUN和技术是LVS集群中实现的三种IP负载均衡技术。
开源解决之道
• 节约采购硬件成本、减少开发难度 • 基于开源应用软件的Modules解决之路
– apache mod_geoip mod_proxy_balancer mod_proxy_ajp – nginx GEO Module – tomcat sessions
• 1998年5月创立LVS
– 成为了Linux内核的一部分 效率高 – 真实运行的Web proxy集群系统
网站集群架构设版主 kns0124wh(百湖) 2009年6月20日 西安
• • • • •
清楚为什么会出现LVS LVS能够做到的 LVS实现方式 LVS需要High Availability LVS的应用延伸
互联网的发展
互联网用户
大型机
• Unix诞生于1969年 • 1987商业化的互联网诞生 • 1990年互联网的膨胀在继续
LVS Piranha

Nginx+Tomcat+Redis实现负载均衡、资源分离、session共享

Nginx+Tomcat+Redis实现负载均衡、资源分离、session共享

Nginx+Tomcat+Redis实现负载均衡、资源分离、session共享CentOS安装Nginx/CentosServer/www/2013/0910/1593.htmlCentOS安装Tomcat/zhuying_linux/article/details/6583096CentOS安装Redis/zhuhongbao/archive/2013/06/04/3117997.html多个Tomcat负载均衡实例:可在服务器上复制出多个Tomcat分别修改Tomcat的http访问端口(默认为8080端口)Shutdown端口(默认为8005端口)JVM启动端口(默认为8009端口)1、Nginx实现多Tomcat负载均衡Tomcat服务192.168.1.177:8001192.168.1.177:8002192.168.1.177:8003Nginx配置upstream mytomcats {server 192.168.1.177:8001;server 192.168.1.177:8002;server 192.168.1.177:8003;}server {listen 80;server_name ;location ~* \.(jpg|gif|png|swf|flv|wma|wmv|asf|mp3|mmf|zip|rar)$ { root /web/www/html/;}location / {proxy_pass http://mytomcats;proxy_redirect off;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;client_max_body_size 10m;client_body_buffer_size 128k;proxy_connect_timeout 90;proxy_send_timeout 90;proxy_read_timeout 90;proxy_buffer_size 4k;proxy_buffers 4 32k;proxy_busy_buffers_size 64k;proxy_temp_file_write_size 64k;}}upstream指定负载均衡组,指定其Tomcat成员location ~* \.(jpg|gif|……实现了静态资源分离。

Linux平台Apache高可用双机集群Tomcat负载均衡集群配置手册

Linux平台Apache高可用双机集群Tomcat负载均衡集群配置手册

Linux平台Apache双机高可用集群+ Tomcat负载均衡集群配置手册在这个配置手册中,使用的操作系统和软件清单如下:操作系统:RedHat Enterprise Linux AS4 U4 64bit(安装时最好选择完全安装)软件:jdk-1_5_0_15-linux-amd64.binTomcat5.5.26httpd-2.0.63.tar.gzjakarta-tomcat-connectors-jk2-src-current.tar.gzipvsadm-1.24.tar.gzlibnet.tar.gzheartbeat-2.1.3-3.el4.centos.x86_64.rpmheartbeat-pils-2.1.3-3.el4.centos.x86_64.rpmheartbeat-stonith-2.1.3-3.el4.centos.x86_64.rpm因为是linux操作系统,所以在安装软件时请使用对应自己操作系统内核的软件,这是整个集群成功的第一步。

本配置手册中的软件都是对应RedHat Enterprise Linux AS4 U4 64bit 这个版本的软件。

jdk-1_5_0_15-linux-amd64.binJAVA环境包使用的是64位1.5版Tomcat版本为公司指定的5.5版本Apache为2.0.63版jakarta-tomcat-connectors-jk2-src-current.tar.gz是连接Apache和Tomcat的连接插件,具体可以去Tomcat网站上查找下载ipvsadm-1.24.tar.gzlibnet.tar.gz这两个是用于2台Apache服务器虚拟一个IP地址使用heartbeat-2.1.3-3.el4.centos.x86_64.rpmheartbeat-pils-2.1.3-3.el4.centos.x86_64.rpmheartbeat-stonith-2.1.3-3.el4.centos.x86_64.rpm这3个软件是用于2台Apache服务器之间的心跳检测结构图Apache1以以以以以Tomcat1Tomcat2Apache22台Tomcat服务器使用Tomcat软件可以自己做集群,2台Apache服务器需要其他的软件实现虚拟服务器功能,工作站访问虚拟IP地址访问2台Apache服务器,再通过Apache服务器访问Tomcat服务器第3 页总13 页1.安装JAVA环境包1)输入命令:./ jdk-1_5_0_15-linux-amd64.bin执行完毕后,会在当前目录下生成一个JDK-1.5.0_15的文件夹2)在 /usr/local/下新建一个名字为JAVA文件夹,将个JDK-1.5.0_15的文件夹拷入到该文件夹下3)设置环境变量。

Nginx+Tomcat配置

Nginx+Tomcat配置

Nginx+Tomcat配置为什么使用Nginx?Apache∙经典的Web服务器∙除了慢没有别的缺点了∙Apache2对fcgi支持并不好∙非常好用的proxy和proxy_ajp(很多人用它作为tomcat的前端)∙不支持epoll(这年头,epoll几乎是性能的必备)Nginx∙速度快,占用资源少∙杀手级的proxy和rewrite∙非常不错的静态文件能力∙最适合作为整个网站的前端服务(将php、svn等不同请求发送往后端apache)∙其他功能马马虎虎代理服务器,也是一个 IMAP/POP3/SMTP代理服务器。

已经因为它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而被人们广泛使用了。

大多数人选择它主要考虑到的是它的高并发和负载均衡。

安装Nginx1. tar zxvf nginx0.8.36.tar.gz2、编译安装nginxcd nginx-0.7.44./configure --with-http_stub_status_module --with-http_ssl_module --prefix=/usr/local/nginx执行后,可能会提示 ./configure: error: the HTTP rewrite module requires the PCRE library.这个错误,是缺少pcre 包,可用yum install pcre pcre-devlel来解决3、make && make install4、nginx安装成功后的安装目录为/usr/local/nginx5.编辑配置文件nginx.conf#user www www;worker_processes 8; #启动进程数,可根据机器核数来修改error_log /usr/local/nginx/logs/nginx_error.log crit; #全局错误日志及PID文件pid /usr/local/nginx/nginx.pid;worker_rlimit_nofile 65535;events{use epoll;worker_connections 65535; #工作模式及连接数上限}http #设定http服务器,利用它的反向代理功能提供负载均衡支持{include mime.types;default_type application/octet-stream;log_format main '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main; #定义的日志格式和存放路径#General Optionsserver_names_hash_bucket_size 128;client_header_buffer_size 32k;large_client_header_buffers 4 32k;client_body_buffer_size 8m; #256kserver_tokens off;ignore_invalid_headers on;recursive_error_pages on;server_name_in_redirect off;sendfile on;#timeoutskeepalive_timeout 60;#client_body_timeout 3m;#client_header_timeout 3m;#send_timeout 3m;#TCP Optionstcp_nopush on;tcp_nodelay on;#size limitsclient_max_body_size 50m;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 {ip_hash;server x.x.x.x:8080 max_fails=0 weight=1;server x.x.x.x:8080 max_fails=0 weight=1; #8080为tomcat端口 }server {listen 80 default;rewrite ^(.*) / permanent;#charset koi8-r;#access_log logs/host.access.log main;#error_page 404 /404.html;# redirect server error pages to the static page /50x.html #error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}}server{listen 80;server_name ;index index.php index.html index.htm;root /http;access_log /data/logs/.log combined;error_log /data/logs/error_test.xxx.log;#expireslocation ~ .*\.(gif|jpg|jpeg|png|bmp|swf)${expires 30d;}location ~ .*\.(js|css)?${expires 24h;}location /nginxstatus {stub_status on;access_log off;}# location ~ .*\.jsp?$location /{proxy_pass http://npduxiu;proxy_redirect off;# proxy_set_header X-Real-IP $remote_addr;proxy_set_header Host $http_host;proxy_set_header X-Forwarded-For$proxy_add_x_forwarded_for;proxy_set_header Connection Close;proxy_set_header X-Forwarded-For $remote_addr; error_page 404 /404.html;error_page 500 502 503 504 /50x.html;# location = /50x.html {# root html;# }}}}6、修改/usr/local/nginx/conf/nginx.conf配置文件后,用命令/usr/local/nginx/sbin/nginx -t 检查配置文件是否正确:7、启动nginx的命令/usr/local/nginx/sbin/nginx8、停止nginx的命令/usr/local/nginx/sbin/nginx -s stop9、在不停止Nginx服务的情况下加载Nginx配置kill -HUP `cat /usr/local/nginx/nginx.pid`10.nginx网站开启后(已启用stub_stauts),可用/nginxstatus查看nginx状态active connections -- 对后端发起的活动连接数server accepts handled requests -- nginx 总共处理的连接, 成功创建了几次握手总共处理了多少个请求reading -- nginx 读取到客户端的Header信息数writing -- nginx 返回给客户端的Header信息数waiting -- 开启 keep-alive 的情况下,这个值等于 active - (reading + writing)安装Tomcat下面开始Tomcat的安装了,那就更简单了,网上文档也是一大把Tomcat安装一、jdk的安装安装的jdk为:jdk-6u21-linux-x64.bin1.sh jdk-6u17-linux-x64-rpm.bin2.安装程序在问您是否愿意遵守刚才看过的许可协议。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

IP:Eth0:192.168.100.115Eth1:192.168.100.215Vi /etc/init.d./lvs#!/bin/sh## lvs Start lvs## chkconfig: 2345 08 92# description: Starts, stops and saves lvs#SNS_VIP=192.168.100.215SNS_RIP1=192.168.100.114SNS_RIP2=192.168.100.113. /etc/rc.d/init.d/functions#logger $0 called with $1retval=0start(){#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 -gtouch /var/lock/subsys/ipvsadm > /dev/null 2 >&1echo "ipvsadm started"}stop(){/sbin/ipvsadm -C/sbin/ipvsadm -Z#ifconfig eth0:0 down#route del $SNS_VIPrm -rf /var/lock/subsys/ipvsadm > /dev/null 2 >&1echo "ipvsadm stoped"}status(){if [ ! -e /var/lock/subsys/ipvsadm ];thenecho "ipvsadm stoped"exit 1elseecho "ipvsadm OK"fi}case "$1" instart)start;;stop)stop;;status)status;;restart)stopstart;;*)echo $"Usage: $0 {start|stop|status}"retval=1esacexit $retvalkeepalvivedtar xf keepalived-1.2.7.tar.gzcd keepalived-1.2.7./configure --prefix=/ --mandir=/usr/local/share/man/ --with-kernel-dir=/usr/src/kernels/2.6.32-279.el6.x86_64Makemake installcd /etc/keepalived/mv keepalived.conf keepalived.conf.default chkconfig --add keepalivedchkconfig keepalived onvim /etc/keepalived/keepalived.conf! Configuration File for keepalivedglobal_defs {notification_email {root@localhost}notification_email_from root@localhost smtp_server 127.0.0.1smtp_connect_timeout 30router_id Director1}#VRRP(虚拟路由冗余协议)实例配置vrrp_instance VI_1 {state MASTERinterface eth0virtual_router_id 51priority 150advert_int 1authentication {auth_type PASSauth_pass 1111}virtual_ipaddress {192.168.122.254/24 eth1}}#LVS配置virtual_server 192.168.100.215 80 {delay_loop 3lb_algo rrlb_kind DRnat_mask 255.255.255.0# persistence_timeout 50protocol TCPreal_server 192.168.100.113 80 {weight 1TCP_CHECK {connect_port 80connect_timeout 10nb_get_retry 3delay_before_retry 3}}real_server 192.168.100.114 80 {weight 1TCP_CHECK {connect_port 80connect_timeout 10nb_get_retry 3delay_before_retry 3}}}}LVS-realserverIp 192.168.100.113Ip 192.168.100.114Vi /etc/init.d/rsup#!/bin/bashVIP=192.168.100.215ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up #route add –host $VIP dev lo:0echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignoreecho "2" >/proc/sys/net/ipv4/conf/lo/arp_announceecho "1" >/proc/sys/net/ipv4/conf/all/arp_ignoreecho "2" >/proc/sys/net/ipv4/conf/all/arp_announce#sysctl –pIp 192.168.100.122(nfs)Ip 192.168.100.113Ip 192.168.100.114#安装zlibtar xzvf zlib-1.2.3.tar.gzcd zlib-1.2.3./configuremake && make install#安装pcretar zxvf pcre-7.9.tar.gzcd pcre-7.9./configure --prefix=/usr/local/pcremake && make installwget /download/nginx_mod_h264_streaming-2.2.7.tar.gztar -zxvf nginx_mod_h264_streaming-2.2.7.tar.gzunzip nginx_upstream_check_module-master.zipmv ./nginx_upstream_check_module-master /root/healthtar -xvf nginx-1.4.1.tar.gz -C /usr/src/useradd nginxcd /usr/src/nginx-1.4.1patch -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=/softw are/pcre-7.9 --with-zlib=/software/zlib-1.2.3 --prefix=/usr/local/nginx --add-module=/root/healthmake && 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 0nginx="/usr/local/nginx/sbin/nginx"prog=$(basename $nginx)NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"lockfile=/var/lock/subsys/nginxstart() {[ -x $nginx ] || exit 5[ -f $NGINX_CONF_FILE ] || exit 6echo -n $"Starting $prog: "daemon $nginx -c $NGINX_CONF_FILEretval=$?echo[ $retval -eq 0 ] && touch $lockfilereturn $retval}stop() {echo -n $"Stopping $prog: "killproc $prog -QUITretval=$?echo[ $retval -eq 0 ] && rm -f $lockfilereturn $retval}restart() {configtest || return $?stopstart}reload() {configtest || return $?echo -n $"Reloading $prog: "killproc $nginx -HUPRETVAL=$?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" instart)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 2esac############################################################################## 改权限chmod 755 /etc/init.d/nginxchkconfig nginx onchkconfig --list nginxnginx 0:off 1:off 2:on 3:on 4:on 5:on 6:offservice nginx startservice nginx stopservice nginx restartservice nginx reload/etc/init.d/nginx start/etc/init.d/nginx stop/etc/init.d/nginx restart/etc/init.d/nginx reloadNginx 配置文件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:2keys_zone=TEST:10minactive=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:2keys_zone=TEST:10minactive=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/i18nLANG="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 65535vi /etc/pam.d/loginsession required /lib/security/pam_limits.songinx 日志按天分割vi nginx_log.sh#!/bin/bashlogs_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").logkill -USR1 `cat ${pid_path}`chmod 755 nginx_log.shcrontab –e0 0 * * * bash /usr/local/nginx/nginx_log.shTomcat memcachetar xf libevent-1.4.11-stable.tar.gzcd libevent-1.4.11-stable./configuremakemake installcd ../tar xf memcached-1.4.5.tar.gzcd memcached-1.4.5./configuremakemake install/usr/local/bin/memcached -d -m 10 -u root -l 192.168.1.113 -p 11211 -c 1024 -P /tmp/memcached.pidMemcache+tomcat 共享session后续计划尚未配置。

相关文档
最新文档