Nginx 学习 记录

Nginx 学习 记录

1

Nginx是开源软件,用户可以访问 http://nginx.org/
作为生产环境,通常建议用户使用稳定版本。
http://nginx.org/

http://nginx.org/download/nginx-1.20.1.tar.gz
在这里插入图片描述

Nginx学习之十四-GDB调试Nginx初试
https://blog.youkuaiyun.com/xiajun07061225/article/details/9383883

<深入剖析nginx.pdf> 高群凯

配置单进程非daemon方式启动
daemon off;
master_process off;

在这里插入图片描述

调试

VSCODE单步跟踪NGINX(虚拟机中搭建NGINX)源码
https://www.freesion.com/article/20061383885/

非root不能gdb attach的限制
在nginx源代码中有大量的任务被加到红黑树中,或者通过注册回调函数来实现,通过阅读源码很难发现和跟踪执行流程。但是通过调试nginx代码可以很清晰的跟踪nginx执行的流程,可以很直观的发现一次http请求响应完整处理生命周期。

https://www.cnblogs.com/hugb/articles/6271278.html
使用GDB调试nginx

Nginx学习之十四-GDB调试Nginx初试
https://blog.youkuaiyun.com/xiajun07061225/article/details/9383883

nginx debug 调试及GDB调试设置
https://blog.youkuaiyun.com/sjin_1314/article/details/80872218

gdb打断点并调试

使用l(list)命令查看main 函数,这个main函数是在src/core/nginx.c里面,是nginx的入口函数

(gdb) l #列出源文件,只列出10行,请使用l- 和 l 或者l +行号 或者 l +函数名 进行定位

(gdb) break 215 #在哪行打断点

(gdb) r #run,从main函数开始运行程序

C++服务器开发精髓 张远龙 著
学习了黄建宏老师的《Redis设计与实现》之后,对redis的部分实现有了一个简明的认识

https://github.com/y123456yz/middleware_development_learning
https://xie.infoq.cn/article/2ee961483c66a146709e7e861

gdb -q -tui
1
ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0,
                   "epoll timer: %M", timer);

#define ngx_log_error(level, log, ...)                                        \
    if ((log)->log_level >= level) ngx_log_error_core(level, log, __VA_ARGS__)

ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err,
    const char *fmt, ...)
    

1

云原生系列之使用prometheus监控nginx
https://blog.youkuaiyun.com/m0_58523831/article/details/129435949

使用nginx-module-vts监控各虚拟主机的流量
https://cloud.tencent.com/developer/article/1632509

由于yum安装的nginx,默认是没有nginx-module-vts模块的。需要下载对应的nginx源码,进行重新编译才行。

为了快速演示,dockerhub已经有镜像了,包括nginx和nginx-module-vts模块

nginx-module-vts: Nginx virtual host traffic status module,nginx的监控模块,能够提供json、html、prometheus格式的数据产出。
nginx-vts-exporter: Simple server that scrapes Nginx vts stats and exports them via HTTP for Prometheus consumption。主要用于收集nginx的监控数据,并给Prometheus提供监控接口,默认端口号9913。

Nginx日志实时分析利器(Ngxtop)
nginx -V
–with-http_stub_status_module

Nginx性能统计模块http_stub_status_module使用
https://zhuanlan.zhihu.com/p/63159825

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值