您好,欢迎光临本网站![请登录][注册会员]  
文件名称: Nginx+tomcat 企业级JSP项目部署.pdf
  所属分类: Web服务器
  开发工具:
  文件大小: 1mb
  下载次数: 0
  上传时间: 2019-08-30
  提 供 者: qq_40******
 详细说明:Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务。 Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,在BSD-like 协议下发行。其特点是占有内存少,并发能力强,事实上nginx的并发能力确实在同类型的网页服务器中表现较好,中国大陆使用nginx网站用户有:百度、京东、新浪、网易、腾讯、淘宝等。 该文档详细讲述了nginx在企业线上环境的优化部署,更好的提工了安全性以及处理能力。实验环境: 主机 P地址 软件包 192168200100(V|P) Nginx 192168.200101 nginx+keepalived Nginx 192.168.200.102 nginx+keepalived Tomcat 192.168.200103 jdkttomcat+ sLSaleSystem Tomcat 2 192168.200.104 jdk+tomcat+SLSaleSystem MYSQL 192.168.200.105 mysql 、 Nginx调度器构建 源代码编译安装 ngInx rootnginx1I# useradd -M-S/sbin/nologin nginx [rootnginx"# yum-y install pcre-devel zlib-devel openssl-devel [rootnginx1"]* tar xf nginx-162. targz-C/usr/src/ frootnginx"]# cd /usr/src/nginx-162/ [rootnginx1 nginx-1.6. 2]# configure--prefix=/usr/local/ nginx--user=nginx--group=nginx with-file-aio--with-http_flv_module--with-httpstubstatus_module--with-http_sslmodule -with-httpgzipstatic_module--with-http_realipmodule&&make&&makeinstall [rootnginx ]# In-s/usr/local/nginx/sbin/*/usr/local/sbin/ 2、配置 nginx. conf配置文件 [rootnginx cd /usr/local/nginx/conf [rootnginx conf]# cp nginx conff bak) [rootnginx conf]# vim nginx. conf PI gInx ngIn worker_ processes 2; error_ log logs/error log pid logs/nginx pid; events use epoll; worker connections 10240 /20 httpi include mime types; default type application/octet-stream; log_ format main 'Sremote_addr -Sremote user [stime_local]"srequest" 'sStatussbodybytessent"shttp_referEr" Httpuseragent"shttpxforwardedfor server tokens off. access_ Jog logs/access log main; add header x-Server hostname server names hash bucket size 128 server name in redirect off; sendfile tcp nopush tcp nodelay on; keepalive_timeout 60; client header buffer size 32k: large client header buffers 4 128k; client_ max body size 512m open_ file cache max=65535 inactive=20s open file cache valid 30s open file cache min uses 1; gzIp on; gzip static on; gziphttpversion1.1; gzip_ comp_level 2: gzip min length 1024 gzip vary on; gzip types text/plain text/javascript application/x- javascript text/css text/xml licata nl application/xml fastcgi connect timeout 300 fastcgi send timeout 300 fastcgi read timeout 300 cgi buffer size 512k fastcgi buffers 6 512k; fastcgi busy buffers size 512k; fastcgi temp file write size 512k fastcgi intercept errors on; /20 lient body buffer size 128k; proxy__ timeout 600 proxy send timeout 600 proxy_read_timeout 600 proxy buffer size 32k; proxy buffers 4 32k; proxy_ busy_ buffers size 54k; proxy temp file write size 2m; proxy_ ignore client_ abort on; proxy_cache_ path /usr/local/nginx/cache_temp levels=2: 2 keys_ zone=cache_ temp: 128m inactive=30m max size=2g proxy_ cache valid 200 302 10m include /usr/local/nginx/conf/conf. d/*. conf [rootnginx1"I# mkdir /usr/local/nginx/conf/conf. d [rootnginx1"I# vim /usr/local/nginx/conf/conf. d/server. conf server listen 80: servernamewww.crushlinux.com192.168.200.101: dex index. html index. htm index jsp root/usr/local/nginx/html; access log /usr/local/nginx/logs/ tomcat. crushlinux com_ access log main cation index jsp; proxy_set_ header HOST Shost proxy_ set_ header X-Real-lP Sremote_add roxy_ set header Client-lP Sremote addr: proxy_set_ header X-For Proxy_add_ x_ forwarded_ for; proxypasshttp://tomcatservers location". *\.gif ipg lipeg bmp swf png)s( expires 30d location". *l(s css)s i expires ih [rootnginx1"I# vim /usr/local/nginx/ conf/conf. d/pool. conf upstream tomcat servers ip hash. 5/20 server 192.168.200.103: 8080 weight=l max fails=3 fail timeout=105: server 192. 168.200. 104: 8080 weight=1 max fails=3 fail timeout=105 rootnginx1]# ulimit-n 65535 3、启动ngnx服务 rootnginx1"I# nginx-t nginx: the configuration file/usr/local/nginx/conf/nginx. conf syntax is ok nginx: configuration file /usr/local/nginx/ conf/nginx. conf test is successful [rootnginx1 I# nginx 二、 keepalived服务构建 方法一,源码包安装 若源码包安装,需先安装依赖包: [rootnginx 1"# yum-y popt-devel kernel-devel openssl-devel 编译安装步骤: rootnginx 1 keepalived-2 122#.configure--prefix=/--with-kernel- dir=/usr/src/kernels/2.6.32-431 el6x86_64/&& make & make install 方法二,yum安装 [rootnginx1]# yum -y install keepalived [rootnginx1"]# chkconfig keepalived --add [rootnginx chkconfig keepalived on rootnginx1 chkconfig keepalived --list keepalived 0:关闭1:关闭2启用3:启用4:启用5:启用6:关闭 修改 keeplived主配置文件 [rootnginx"]# cd/etc/keepalived/ [rootnginx1 keepalived]# cp-p keepalived. conf keepalived. conf. bak rootnginx1 keepalived]# vim keepalived. conf Configuration File for keepalived global- defs i 6/20 notification _ email t crushlinux163.com notificationemailfromcrushlinux163.com smtp server 127.0.0.1 smtp connect timeout 30 router id nginx 1 vrrp_ script nginx script/opt/chk nginx. sh weight -10 vrrp_ instance VI_1 i state MASTER interface etho virtual router id 51 priority 100 advert int 1 authentication i auth type PASS auth pass 1111 track script t ngInx virtual_ ipaddress t 192.168200.100 vrrp instance VI_2( tate BACKUP interface etho virtual router id 52 priority 99 nopreemp ∥/非抢占模式 advert int 1 authentication i auth type pAss auth pass 1111 /20 track script ngInx virtual ipaddress i 192168200.200 [rootnginx1 I# vim /opt chk nginx.sh #U /bin/bash check nginx server status NGINX="/usr/local/nginx/sbin/nginx nginxpid=S(ps-C nginx --no-header wc - if Snginxpid -eq 0 1 then SNGINX sleep 3 nginxpid=S(ps-C nginx--no-header wc-l) if Snginxpid-eq 0 ] then /etc/init. d/keepalived stop echo"Keepalived stopped please check your Nginx! "ltee-a/var/log/ messages [rootnginx1"J# chmod +x/opt/chk_nginx. sh rootnginx1"#/etc/init. d/keepalived start 三、 ngInx2的配置 ngInx2主机的配置过程与 ngInx1完全相同,需要修改部分配置: [rootnginx"J# vim /usr/local/nginx/conf/ conf. d/server. conf server listen 80 servernamewww.crushlinux.com192.168.200.102 index index. html index. htm index jsp; root /usr/local/nginx/html access log /usr/local/nginx/logs/tomcat. crushlinux com_ access log main; location " * jsps i xsp; proxy set header HOST Shost proxy_set_ header X-Real-IP Sremote_addr proxy set header Client-IP Sremote addr: proxy_ set_ header X-For Proxy _add_x forwarded_for 8/20 proxy_passhttp://tomcatservers location".gif ipg lipeg bmp swf i pngs expires 30d location".\is csss i expires 1h [rootnginx"I# cat/etc/keepalived/keepalived. conf I Configuration File for keepalived global defs i notification email t crushlinux163. cam notificationemailfromcrushlinux163.com smtp server 127.0.0.1 smtp_ connect_ timeout 30 router id nginx 2 vrrp script nginx t script /opt/chk nginx, sh interval 2 weight-10 vrp_ instanceⅥ_1{ state BACKUP interface etho virtual router id 51 priority 99 advert int 1 authentication auth type PAss auth_ pass 1111 track script i ngInx virtual_ ipaddress i 192.168200.100 9/20 vrrp_ instance VI-2 state MASTER interface etho virtual router id 52 priority 100 preempt avert int 1 authentication i auth type PAss auth pass 1111 track script t ngInx irtual ipaddress t 192.168200.200 rootnginx"I# scp 192.. 101: / opt/chk _ nginx.sh/opt root192. 168.200101s password chk nginx.sh 100%356 04KB/s00:00 [rootnginx keepalived]#/etc/init. d/keepalived start 正在启动 keepalived: [确定] 高可用测试 [rootnginx1 "# ip addr show etho 2: ethO: mtu 1500 disc pfifo fast state uP qlen 1000 link/ether 00: 0c: 29: 8d: d 2: do brd ff: ff: ff: ff: ff: ff inet192168200.101/24brd192168200.255sc。 pe global eth0 inet 192.. 100/32 scope global ethO inet fe80: 20c: 29ff: fe&d: d2d0/64 scope link valid Ift forever preferred_ Ift forever [rootnginx1#/etc/init. d/keepalived stop 停止 keepalived: [确定] 10/20
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 输入关键字,在本站1000多万海量源码库中尽情搜索: