nginx搭建负载均衡

Nginx+Tomcat搭建高性能负载均衡集群 一、       工具   nginx-1.8.0   apache-tomcat-6.0.33 二、    目标   实现高性能负载均衡的Tomcat集群:      三、    步骤   1、首先下载Nginx,要下载稳定版:      2、然后解压两个Tomcat,分别命名为apache-tomcat-6.0.33- 阅读详情

实验:

window PC一台【LNS:192.168.1.111】

两台Centos OS虚拟机:

H1(192.168.186.141)

H2:192.168.186.148)


实验环境搭建

1在H1,H2分别部署web项目,具体步骤参考:在Linux上,通过Tomcat部署Web应用

2在LNS上安装nginx(之所以在window上部署nginx,主要是公司多为Windows服务器,通过此练练手)

  1.1下载nginx-1.8.0.zip并解压,我将解压文件命名文demo

  2.2 测试nginx环境

  a)管理员身份打开CMD,进入DOS窗口

   b)进入nginx的目录

c)检测配置命令

nginx -t


d)启动命令:

start nginx
查看启动情况


在浏览器中输入localhost出现如下界面,运行成功,
 

e)修改配置文件,需要重启,命令:

nginx -s reload
f)退出

nginx -s stop
或者

nginx -s quit
查看进程关闭情况




3.负载均衡设置

3.1添加域名

在C:\Windows\System32\drivers\etc中添加:

192.168.1.111 www.cqs.com
3.2修改nginx的conf/nginx.conf配置文件

a)在http{}里面,server上面添加如下脚本:

upstream www.cqs.com {
	server 192.168.186.141:8080;
	server 192.168.186.148:8080;
}

c)在server{}里面的server_name,编码及location /{}修改为:

listen       80;
server_name  www.cqs.com;##访问域名
charset UTF-8;###设置编码

access_log  logs/host.access.log ;   
		
location / {
	proxy_pass        http://www.cqs.com;
	proxy_set_header   Host             $host;
	proxy_set_header   X-Real-IP        $remote_addr;
	proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
}
配置文件部分截图


配置好后重启 nginx

3.3测试:在H1,和H2两台虚拟机的终端中分别输入

tcpdump tcp port 8080 and host 192.168.186.141
tcpdump tcp port 8080 and host 192.168.186.148

在浏览器中输入项目资源http://www.cqs.com/demo2/,请求数次,查看HTTP请求头:


查看IP包的去向


192.168.186.1指的就是LNS(192.168.1.111),因为我虚拟机就是开在LNS电脑上的


PS:现在也没有找到更好的检测HTTP请求详细路径工具,只好用此办法了。

实验简单粗糙,但基本实现了最简单的负载均衡了。

Windows下Nginx发布DEM地形瓦片数据全流程(含Cesium调用避坑指南) 本文详细介绍了在Windows环境下使用Nginx发布DEM地形瓦片数据的完整流程,并提供了Cesium前端调用的详细配置与避坑指南。重点讲解了Nginx的核心配置、跨域问题解决以及CesiumTerrainProvider的关键参数设置,帮助开发者快速搭建本地地形服务,实现高效的三维地形可视化。 阅读详情

相关推荐

Anthropic发布10款金融AI智能体模板深度解析:重构华尔街工作范式

摘要:2026年5月,Anthropic发布10款金融AI智能体模板,标志着AI从辅助工具升级为"虚拟同事"。这些智能体深度集成到Word、Excel等办公软件中,覆盖投行、商行、资管三大场景的核心工作流,预计可提升效率35-85%。技术架构基于Claude3.5Sonnet模型,具备200K上下文窗口和95%+的财务图表解析准确率,并与彭博等金融数据源直连。发布引发传统金融数据服务商股价下跌,摩根大通等机构则视其为成本优化工具。落地需分四阶段推进,关键在于数据治理和复合型人才培养。未来

yyq916的博客 634

L2TP协议笔记1---L2TP概念及协议流程分析

这个协议是早前做防火墙测试工作时主要负责测试的协议,虽然只做了几个月,但感觉如果把当时的一些学习笔记和经验整理好放在网络中,不仅可以使自己的协议理解得到巩固,也让自己有机会在和别人交流中互相学习。 当初学习时,看的资料大部分都是先简介协议然后直接就开始抽象的介绍各种报文格式、报文每个字段的作用,光是大量报文名称看着头就很大了,所以在这里先介...

weixin_34301132的博客 1798

Multisim 14.0元件库下载权威指南:官方与社区资源

详解Multisim元件库下载的官方途径与可靠社区资源,帮助用户快速获取Multisim 14.0所需元件模型,提升电路仿真效率。

weixin_32925455的博客 747

IEEE Transactions模板中参考文献作者缩写、期刊名缩写

本文章记录如何在IEEE Transactions的模板中,解决参考文献的作者缩写、期刊名字缩写的问题。

weixin_43981621的博客 1万+

TDDFT计算软件Octopus学习笔记(二):基态计算(Si)

本文以硅为例,来进行基态计算。

陈啸的博客 7305

Nginx搭建负载均衡

负载均衡是将用户请求分发到多台服务器的一种技术,确保多个服务器共同承担负载,从而提升应用的可用性与响应速度。通过负载均衡,系统能够在某台服务器出现故障时,自动将流量转发至其他健康的服务器,避免单点故障带来的影响。使用Nginx搭建负载均衡能够有效提升系统的可用性和扩展性。通过合理的配置和优化,Nginx不仅可以分担流量,还能确保高效响应。负载均衡在现代Web架构中至关重要,帮助企业应对高并发请求,提升用户体验。

学习,分享一直在路上 5401

5分钟搞定PettingZoo多智能体环境搭建:从安装到运行第一个Demo

本文详细介绍了如何在5分钟内完成PettingZoo多智能体环境的搭建,从安装到运行第一个Demo。通过精准的版本控制和常见问题解决方案,帮助开发者快速上手多智能体强化学习(MARL)环境配置,并提供了实战案例和性能优化技巧。

backprop5master的博客 221

Nginx + Tomcat 负载均衡搭建

通过,将用户请求到多个 Tomcat 应用服务器,实现流量分摊、避免单点故障。:默认方式,按顺序分配请求。:根据服务器性能分配权重。IP_Hash:同一客户端IP固定访问某台Tomcat,解决Session共享问题。Nginx 自动检测后端Tomcat状态,故障节点自动剔除。静态资源(如图片/CSS)由Nginx直接处理,动态请求转发至Tomcat,提升整体性能。单台Tomcat并发能力有限(默认线程数约150-200),高并发场景下易崩溃。

2401_84202965的博客 1385

保姆级教程:用ncnn把自训练的YOLOv8模型塞进Android App(附完整代码)

本文提供了一份详细的保姆级教程,指导开发者如何将自训练的YOLOv8模型通过ncnn框架部署到Android应用中。教程涵盖环境配置、模型训练与转换、Android工程集成及性能优化等全流程,并附完整代码实现,帮助开发者快速掌握移动端AI模型部署技术。

weixin_42659194的博客 255

本地部署AI应用:基于Google Gemini的banana-prompt快速上手指南

AI应用开发的核心在于将大模型能力集成到实际场景中,其原理是通过API调用将用户输入转化为模型可理解的指令,再由模型生成响应。这一技术价值在于降低AI应用开发门槛,实现数据本地化处理与隐私保护。在工程实践中,开发者常面临环境配置复杂、API集成繁琐等挑战。本文聚焦于使用banana-prompt工具包,通过TypeScript技术栈和npm包管理,快速在Windows本地部署基于Google Gemini API的AI应用。该方案特别适用于ai-prompts提示词工程和content-creation内容

weixin_27188815的博客 314

Nginx环境搭建、负载均衡测试

系统环境: win10,IDEA2020,JDK81.ngxin下载Nginx官网下载: http://nginx.org/en/download.html Nginx有三种版本,分别是Mainline version(开发版)、Stable version(稳定版)、Legacy versions(早期版本)。一般选用稳定版本。 Linux使用时选用中间的版本下载然后通过Xftp或Filezilla工具上传到Linux服务器上即可。也可以从浏览器上复制下载文件的URL地址后在服务器中使用wget命令进行下

weixin_45732391的博客 1417

知识图谱构建中的数据清洗:AI原生应用高质量图谱的前提

数据清洗是知识图谱构建的核心前置环节,直接决定AI原生应用(如智能问答、个性化推荐、决策支持系统)的图谱质量与应用效能。本文以第一性原理为起点,系统解析数据清洗的理论框架、技术架构与工程实践,覆盖从多源异构数据的噪声检测到高质量知识三元组(实体-关系-实体)生成的全流程。通过层次化概念映射(专家→中级→入门)、数学形式化建模及工业级案例分析,揭示数据清洗在解决实体歧义、关系冲突、结构不一致等关键问题中的技术逻辑,并展望基于大模型的智能清洗范式演化。Completeness(完整性)

移动开发前沿的博客 404

10分钟快速搭建Nginx负载均衡环境

负载均衡通过智能地分发请求到不同的服务器,确保每台服务器的负载相对平衡,从而提高整体性能和可靠性。通过客户端的IP地址的哈希值分配给特定的服务器,如果下一次请求的IP哈希值与之前一样,那么依然会请求到之前的服务器。Nginx采用事件驱动的非阻塞方式处理请求,主要利用了操作系统提供的多路复用机制,通过异步非阻塞的方式处理大量并发请求,减少了线程切换和资源消耗,提高了并发处理能力和系统的稳定性。将上述访问运行在两个不同的服务器上,默认的轮询会每个服务器都请求一次,除非有一台掉线,否则nginx会均分请求。

关注微信公众号【开源Linux】,后台回复『10T』,领取10T学习资源大放送,涵盖Linux、虚拟化、容器、云计算、网络、Python、Go等书籍和视频 117

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

搭建Keepalived+Nginx负载均衡及实验

如果您使用承载多个应用程序服务器的服务器,则此功能很有用。当然是找一台新的机器,替代现有的机器,然后做新的环境部署,端口映射,域名解析等等一系列的工作,再将服务重新启动;Keepalived的作用是检测服务器的状态,如果有一台web服务器宕机,或工作出现故障,Keepalived将检测到,并将有故障的服务器从系统中剔除,同时使用其他服务器代替该服务器的工作,当服务器工作正常后Keepalived自动将服务器加入到服务器群中,这些工作全部自动完成,不需要人工干涉,需要人工做的只是修复故障的服务器。

qq_24442273的博客 1474

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

搭建Keepalived+Nginx负载均衡

搭建Keepalived+Nginx负载均衡

weixin_43326918的博客 1269

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Nginx搭建负载均衡详细操作

蚂蚁面试比较重视基础,所以Java那些基本功一定要扎实。蚂蚁的工作环境还是挺赞的,因为我面的是稳定性保障部门,还有许多单独的小组,什么三年1班,很有青春的感觉。面试官基本水平都比较高,基本都P7以上,除了基础还问了不少架构设计方面的问题,收获还是挺大的。经历这次面试我还通过一些渠道发现了需要大厂真实面试主要有:蚂蚁金服、拼多多、阿里云、百度、唯品会、携程、丰巢科技、乐信、软通动力、OPPO、银盛支付、中国平安等初,中级,高级Java面试题集合,附带超详细答案,希望能帮助到大家。

2401_83915450的博客 435
上一篇: 在Linux上,通过Tomcat部署Web应用
下一篇: Centos6.5安装RVM
lixwcqs
博客等级 码龄16年 23粉丝 72原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值