九色91_成人精品一区二区三区中文字幕_国产精品久久久久一区二区三区_欧美精品久久_国产精品99久久久久久久vr_www.国产视频

Hello! 歡迎來到小浪云!


centos誤刪nginx.conf文件恢復方式


avatar
小浪云 2024-07-07 191


當你不小心誤刪或者錯誤操作導致nginx.conf文件丟失,而且nginx處于在運行的狀態,在這種情況下我們就可以在內存中獲取配置文件。

1.獲取nginx進程pid

ps -ef | grep nginx

你會得到如下輸出,找到master的pid

root     19812     1  0 5月10 ?       00:00:00 nginx: master process /usr/sbin/nginx

nginx    19813 19812  0 5月10 ?       00:00:26 nginx: worker process

nginx    19814 19812  0 5月10 ?       00:00:33 nginx: worker process

nginx    19815 19812  0 5月10 ?       00:01:15 nginx: worker process

nginx    19816 19812  0 5月10 ?       00:00:55 nginx: worker process

nginx    19817 19812  0 5月10 ?       00:00:04 nginx: cache manager process

root     26171 12446  0 12:56 pts/0    00:00:00 grep –color=auto nginx

如上所示,nginx的主要進程pid為19812

2.查找內存映射

安裝gdb工具

yum install gdb -y

接下來我們需要檢查進程正在使用哪些內存映射

cat /proc/19812/maps | grep heap

[root@loghub-server tmp]# cat /proc/19812/maps | grep heap

55e0e6760000-55e0e69c2000 rw-p 00000000 00:00 0                          [heap]

可以看到有2處地方,我們只需要關注heap部分。內存位于55e0e6760000-55e0e69c2000之間。

3.轉儲

然后需要轉儲

gdb -p 19812

你會得到一個(gdb)提示。現在在這個提示下使用我們之前記下的地址,地址前需要加0x

(gdb) dump memory /tmp/nginx-memory 0x55e0e6760000 0x55e0e69c2000

4.從轉儲中獲取字符串數據

strings  /tmp/nginx-memory > /tmp/nginx-memory.str

5.查找 nginx 配置

現在有了內存轉儲。大多數配置都會有http {一行,現在可以測試下/tmp/nginx-memory.str

grep -A 20 “http {” /tmp/nginx-memory.str

[root@loghub-server tmp]# grep -A 50 “http {” /tmp/nginx-memory.str 

http {

    log_format  main  ‘$remote_addr – $remote_user [$time_local] “$request” ‘

                      ‘$status $body_bytes_sent “$http_referer” ‘

                      ‘”$http_user_agent” “$http_x_forwarded_for“‘;

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;

    tcp_nopush          on;

    tcp_nodelay         on;

    keepalive_timeout   65;

    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;

    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d Directory.

    # See http://www.landui.com/en/docs/ngx_core_module.html#include

    # for more information.

    include /etc/nginx/conf.d/*.conf;

    #proxy_temp_path  /etc/nginx/temp_dir;

    #proxy_cache_path /var/cache/nginx/cache levels=1:2 keys_zone=imgcache:100m inactive=1d max_size=1g;

    #proxy_cache_path /etc/nginx/cache_dir levels=1:2 keys_zone=imgcache:500m max_size=1g inactive=1d use_temp_path=off;

    proxy_cache_path /etc/nginx/conf.d/cache levels=1:2 keys_zone=my_zone:100m inactive=3600s max_size=1g;

復制出來修改下格式就可以了。

相關閱讀

主站蜘蛛池模板: 亚洲精品麻豆 | 蜜桃av鲁一鲁一鲁一鲁 | 久久久国产精品入口麻豆 | 久色视频在线观看 | 国产免费一区二区三区 | 九九九精品视频 | 视频一区在线 | 日韩三极 | 日韩成人高清在线 | 97日日碰人人模人人澡分享吧 | 成人av一区 | 免费在线观看成年人视频 | 日韩高清三区 | 自拍视频一区二区三区 | 国产高清视频在线观看 | 欧美一区二区大片 | 国产激情在线 | 少妇黄色| 成人欧美一区二区三区白人 | 国产高清在线精品 | 一片毛片 | 深夜福利亚洲 | ww 255hh 在线观看 | 亚洲精品一区二区三区在线 | 91在线看片 | 国产一区二区电影 | 亚洲精品视频导航 | av毛片 | 日韩在线小视频 | www.一区二区三区.com | 超碰91在线 | 国内精品久久久久久久影视简单 | 欧洲在线视频 | 日韩一二区在线 | 欧美99 | 欧美成年人视频在线观看 | 秋霞a级毛片在线看 | 91精产国品一二三区 | 亚洲视频精品在线 | 97成人免费| 欧美精品一区二区三区视频 |