当前位置:   article > 正文

配置压力测试环境_压测服务器配置

压测服务器配置

压力测试环境跟测试环境基本一样,不过部署到新的服务器
首先选一台服务器部署eureka,在把项目发布到eureka上
选择另外一台服务器部署nginx,实现前后端分离

(eureka路径如下:/opt/cbd/cloud/cbd-cloud-eureka/)

1.部署nginx环境

wget http://nginx.org/download/nginx-1.18.0.tar.gz
tar -zxvf nginx-1.18.0.tar.gz
cd nginx-1.18.0
设置安装目录为/usr/local/nginx
./configure --prefix=/usr/local/nginx
make
make install
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

2.configure配置

你需要的configure不一定一样,目前我的项目需要

./configure 
--with-http_stub_status_module
 --with-http_ssl_module 
 --with-pcre=/opt/files/pcre-8.43 
 --with-http_realip_module
 --prefix=/opt/nginx 
 --sbin-path=/usr/bin/nginx
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

3.查看nginx版本

/usr/local/nginx/sbin/nginx -V

	[root@svc-app-t30 sbin]# /usr/local/nginx/sbin/nginx -V
	nginx version: nginx/1.18.0
	built by gcc 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
	built with OpenSSL 1.0.2k-fips  26 Jan 2017
	TLS SNI support enabled
	configure arguments: --with-http_stub_status_module --with-http_ssl_module --with-pcre=/opt/files/pcre-8.43 --with-http_realip_module
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

4.nginx重新安装

如果改过2.之后可以将安装包中的nginx文件复制到启动路径中
cp /usr/local/src/nginx-1.18.0/objs/nginx /usr/local/nginx/sbin/nginx
重新启动
cd /usr/local/nginx/sbin
./nginx -s reload

5.eureka相关配置

将eureka上的项目 配置到nginx.conf
在这里插入图片描述

6.nginx.conf配置

nginx.conf 怎么配置?

一般如下,具体百度

server {
        	listen       8888;
        	server_name  scljh.csair.com;
	        charset utf-8;
       		 add_header Access-Control-Allow-Origin *;
	        add_header Access-Control-Allow-Headers Origin,X-Requested-Width,Content-Type,Accept;

       		 location / {
            		rewrite ^(.*)$   https://scptest.csair.com/frame/home permanent;
		}
	}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

7.nginx启动是否成功

查看日志,started成功,说明nginx.conf没问题
在这里插入图片描述

8.https不生效http生效

此时在nginx服务器,curl https://…我重定向的网址,也是反向代理网址,打不开

有问题发现:

问题一:nginx https不生效,http生效

方法一:以为443 ssl有问题,看了眼证书是有的,没解决

在这里插入图片描述
用到 添加链接描述

方法二:查看liunx是否打开了8888和443和80等端口

查看端口号指令
netstat -ntlp
http://t.zoukankan.com/l0zh-p-13739747.html
参考链接
[https://huaweicloud.csdn.net/6356408cd3efff3090b5c3fb.html?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Eactivity-1-115514334-blog-127805893.pc_relevant_landingrelevant&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7EBlogCommendFromBaidu%7Eactivity-1-115514334-blog-127805893.pc_relevant_landingrelevant&utm_relevant_index=1]

此时端口全都打开了。

方法三:查看防火墙

参考链接 [https://blog.csdn.net/ccboy2009/article/details/25748251/]

问题二:nginx启动后,只有master进程,没有worker

说明nginx的配置有问题,需要改./configure 将配置补全
参考链接 nginx1.18默认配置启动无80端口进程
ginx启动后,只有master进程,没有worker
我缺的是pcre ,所以把配置补全
pcre安装过程

9.配置成功,https还是不生效

端口号打开了,443 ssl配置了 ,nginx还是https不生效,http生效
这时要配置nginx所在服务器的hosts,hosts在/etc目录
hosts需要加上:

ip  域名 服务器名
10.79.145.121 scptest.csair.com xs-test01
10.79.145.122 scptest.csair.com xs-test02
  • 1
  • 2
  • 3

本地电脑的ip也需要在hosts加上
在这里插入图片描述
在这里插入图片描述
成功,可以打开https://***.###.com/frame/home

10.总结

正向代理即是客户端代理, 代理客户端, 服务端不知道实际发起请求的客户端.
反向代理即是服务端代理, 代理服务端, 客户端不知道实际提供服务的服务端

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Guff_9hys/article/detail/833872
推荐阅读
相关标签
  

闽ICP备14008679号