




免费预览已结束,剩余3页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Nginx+keepalived+tomcat实现tomcat高可用性负载均衡试验环境: CentOS5.4、pcre-8.12、nginx-upstream-jvm-route-0.1、nginx-1.0.10、apache-tomcat-7.0.23 、keepalived-1.1.17.tar.gz、jdk-7u2-linux-x64.tar.gz主nginx服务器地址:00 辅nginx服务器地址:01 tomcat1: 02 tomcat2: 03VIP: 88拓扑如下:1.分别在00和01上面安装nginxtar zxf pcre-8.12.tar.gz cd pcre-8.12 ./configure make;make install下载下面的插件安装,否则nginx无法识别tomcat中jvmRoute,从而无法达到session复制的效果。wget /LinuxSoft/nginx-upstream-jvm-route-0.1.tar.gz tar xzf nginx-upstream-jvm-route-0.1.tar.gz tar xzf nginx-1.0.10.tar.gz cd nginx-1.0.10 patch -p0 ./nginx_upstream_jvm_route/jvm_route.patch ./configure -prefix=/usr/local/nginx -with-http_stub_status_module -with-pcre=/root/pcre-8.12 -add-module=./nginx_upstream_jvm_route/ #-with-pcre=指向的是pcre的源码包 make;make install2.配置nginxvim /usr/local/nginx/conf/nginx.confuser www www;worker_processes 4;error_log /home/wwwlogs/nginx_error.log crit;pid /usr/local/nginx/logs/nginx.pid;#Specifies the value for maximum file descriptors that can be opened by this process.worker_rlimit_nofile 51200;events use epoll; worker_connections 51200; http upstream backend server 02:8080 srun_id=tomcat1; server 03:8080 srun_id=tomcat2; jvm_route $cookie_JSESSIONID|sessionid reverse; include mime.types;default_type application/octet-stream;server_names_hash_bucket_size 128;client_header_buffer_size 32k;large_client_header_buffers 4 32k;client_max_body_size 50m;sendfile on;tcp_nopush on;keepalive_timeout 60;tcp_nodelay on;fastcgi_connect_timeout 300;fastcgi_send_timeout 300;fastcgi_read_timeout 300;fastcgi_buffer_size 64k;fastcgi_buffers 4 64k;fastcgi_busy_buffers_size 128k;fastcgi_temp_file_write_size 256k;gzip on;gzip_min_length 1k;gzip_buffers 4 16k;charset UTF-8gzip_http_version 1.0;gzip_comp_level 2;gzip_types text/plain application/x-javascript text/css application/xml;gzip_vary on;#limit_zone crawler $binary_remote_addr 10m;server listen 80; server_name ; index index.jsp index.htm index.html; root /home/wwwroot/;location / proxy_pass http:/backend; proxy_redirect off; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $http_host; location .*.(gif|jpg|jpeg|png|bmp|swf)$ expires 30d; location .*.(js|css)?$ expires 1h; location /Nginxstatus stub_status on; access_log off; 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 /home/wwwlogs/access.log access; include vhost/*.conf; 3. 分别在两台nginx服务器上安装keepalivedtar zxvf keepalived-1.1.17.tar.gzcd keepalived-1.1.17./configure -prefix=/usr/local/keepalivedmake & make installcp /usr/local/keepalived/sbin/keepalived /usr/sbin/cp /usr/local/keepalived/etc/sysconfig/keepalived /etc/sysconfig/cp /usr/local/keepalived/etc/rc.d/init.d/keepalived /etc/init.d/mkdir /etc/keepalivedcd /etc/keepalived/主keepalived配置vim keepalived.confvrrp_script chk_http_port script /opt/nginx_pid.sh interval 2 weight 2vrrp_instance VI_1 state MASTER interface eth0 virtual_router_id 51 mcast_src_ip 00 priority 150 authentication auth_type PASS auth_pass track_script chk_http_port virtual_ipaddress 88 辅keepalived 配置vrrp_script chk_http_port script /opt/nginx_pid.sh interval 2 weight 2vrrp_instance VI_1 state BACKUP interface eth0 virtual_router_id 51 mcast_src_ip 01 priority 100 authentication auth_type PASS auth_pass track_script chk_http_port virtual_ipaddress 88 启动keepalived,检查虚拟IP是否邦定,在主keepalivedrootxenvps0 # /etc/init.d/keepalived start启动 keepalived: 确定rootxenvps0 # ip a1: lo: mtu 16436 qdisc noqueue link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet /8 scope host lo2: eth0: mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:16:36:68:a4:fc brd ff:ff:ff:ff:ff:ff inet 00/24 brd 55 scope global eth0inet 88/32 scope global eth0在eth0上面我们已经看到虚拟IP88已经邦定成功4.安装tomcat 1)安装tomcat_1 tar zxvf apache-tomcat-7.0.23.tar.gz mv apache-tomcat-7.0.23 /usr/local/tomcat 2)安装tomcat_2,步骤同1)5.分别在tomcat服务器安装jdktar zxvf jdk-7u2-linux-x64.tar.gzmv jdk1.7.0_02 /usr/local/jdk1.7.0_02cat /etc/profile EOFexport JAVA_HOME=/usr/local/jdk1.7.0_02export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$HOMR/binEOF;source /etc/profile /使环境变量立即生效5.tomcat集群配置 tomcat1配置: 修改conf/server.xml配置文件 在添加下面这句:tomcat2配置: 修改conf/server.xml配置文件 在添加下面这句:6.sess
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年上半年江苏徐州市九州职业技术学院招聘考前自测高频考点模拟试题附答案详解(黄金题型)
- 2025年齐齐哈尔工程学院博士人才招聘50人考前自测高频考点模拟试题及答案详解(考点梳理)
- 涂装改造入门知识培训课件
- 2025湖南邵阳市洞口县黄桥镇中心卫生院面向社会公开招聘编外合同制影像(医师)技师考前自测高频考点模拟试题参考答案详解
- 2025湖北武汉市通城县事业单位高层次和急需紧缺人才引进48人考前自测高频考点模拟试题(含答案详解)
- 涂料培训知识课件
- 涂料助剂专业知识培训课件
- 安全培训背景相关照片课件
- 2025年甘肃省嘉峪关开放大学招聘公益性岗位人员模拟试卷及完整答案详解一套
- 2025内蒙古第七批高层次人才需求目录(2025年4月29日发布)考前自测高频考点模拟试题(含答案详解)
- 2025年中级制图员《理论知识》考试真题(含新版解析)
- 广东省2025年度初级注册安全工程师职业资格考试金属非金属矿山安全复习题及答案
- 小学教师网络信息安全管理规范
- 惊恐障碍课件
- 视频监控巡查管理办法
- 银行招聘考试题目及答案
- 房地产渠道销售代理合同范本
- 十二经络课件
- Starter Unit 3 Welcome 单元测试(含答案)人教版(2024)七年级英语上册
- 糖尿病患者抗感染管理要点
- 2023年中国出版集团有限公司招聘笔试题库及答案解析
评论
0/150
提交评论