Linux企业运维-nginx源码安装、七层负载均衡、并发优化、平华升级

Nginx (engine x) 是一个高性能的HTTP反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务。Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru站点(俄文:Рамблер)开发的,第一个公开版本0.1.0发布于2004年10月4日。

       其将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、简单的配置文件和低系统资源的消耗而闻名

         Nginx是一款轻量级Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,在BSD-like 协议下发行。其特点是占有内存少,并发能力强,事实上nginx的并发能力在同类型的网页服务器中表现较好,中国大陆使用nginx网站用户有:百度、京东新浪网易腾讯淘宝

在企业中,我们需要给一些架构中的软件定制功能,需采用源码编译安装软件

源码编译安装三部曲:configure---make---make install

源码安装nginx 七层调度软件开源软件

源码编译 使用./configure --help查看各模块使用情况 --prefix(安装路径) 

用--with-http_ssi_module方式关闭不需要的模块 

用--with-http_stub_status_module 监控nginx状态模块

nginx安装依赖gcc(c语言编译器)、pcre-devel (pcre开发包)openssl-devel(软件库)

 configure生成makefile makefile指导后续的make编译 编译完成后make install将编译出来的二进制程序安装到系统环境中(指定的路径)

 objs/里边是生成的二进制文件   conf/生成的配置目录

sbin/里边是objs/目录里边编译好的二进制程序

ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
全局使用nginx命令

出现这个界面即为安装成功

nginx七层负载均衡 反向代理

官方下载脚本

 worker_cpu_affinity 01 10; 一个cpu绑定一个进程 一个核心负责一个进程的工作

 

 

 

 

上边调用负载均衡器westos   下边调用proxy_pass模块 实现反向代理 所有访问域名80端口的请求全部交由proxy_pass递交负载均衡器

客户端真机添加地址解析

[root@server2 ~]# systemctl start httpd 

[root@server3 html]# systemctl start httpd 

nginx健康检测

[root@server3 html]# systemctl stop httpd 

[root@server2 ~]# systemctl stop httpd 

[root@server1 conf]# vim /etc/httpd/conf/httpd.conf 

由于apache和ngnix不能同时开启

将server1作为备用服务器,配置文件修改,端口改为8080,对nginx配置文件修改

 [root@server1 conf]# vim nginx.conf 

[root@server2 ~]# systemctl start httpd 

[root@server3 html]# systemctl start httpd 

[root@server1 conf]# vim nginx.conf [root@server1 conf]# vim nginx.conf 

sticky的客户名称更改

编译:

--add-module 用来添加第三方模块 支持动态解析

make 

[root@server1 conf]# cd
[root@server1 ~]# cd nginx-1.20.1/
[root@server1 nginx-1.20.1]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  Makefile  man  objs  README  src
[root@server1 nginx-1.20.1]# cd objs/
[root@server1 objs]# ll nginx
-rwxr-xr-x 1 root root 6138632 Dec  9 14:39 nginx
[root@server1 objs]# du -h nginx
5.9M    nginx
[root@server1 ~]# cd nginx-1.20.1/
[root@server1 nginx-1.20.1]# make clean 将刚才编译的删掉
rm -rf Makefile objs 

nginx平滑升级

升级nginx系统且不需要关闭服务 升级1.19到1.20版本不需要关闭服务直接就可以进行升级

[root@server1 conf]# vim nginx.conf

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值