12月6日权威 DNS 服务中断 1 小时

12 月 6 日 21:37 至 22:39,除 mirrors 外的 LUG 网络服务中断一小时。原因是权威 DNS 服务器挂掉了。原因又是 bind9 陷入死循环,触发 OOM kill。因此带来的不便,我们深表歉意。

由于我测试环境选择不当(用了挂了一台 LUG VPN 的主机),导致问题刚开始的半个小时没有发现问题根源,以为是 ns.ustc.edu.cn 取消了 LUG 域名的解析,于是给 jameszhang 打电话,过了一会儿 jameszhang 回电说是我们的权威 DNS 服务器挂了…… 当时 LUG 会长、DNS 专家 pudh 在校外,正在往回赶,而我手里没有登录 DNS 服务器的 key。最后是 CTO 崔灏救 LUG 于水火之中,把 DNS 服务器的 bind9 服务启动起来了。

QQ图片20141207001954

日志显示 bind9 是这时候开始陷入死循环的:

Dec  6 18:49:28 dns named[21839]: zone ustclug.org/IN/Default: sending notifies (serial 170002)
Dec  6 18:49:33 dns named[21839]: zone ustclug.org/IN/Default: sending notifies (serial 170028)
Dec  6 18:49:38 dns named[21839]: zone ustclug.org/IN/Default: sending notifies (serial 170054)
Dec  6 18:49:43 dns named[21839]: zone ustclug.org/IN/Default: sending notifies (serial 170080)
Dec  6 18:49:48 dns named[21839]: zone ustclug.org/IN/Default: sending notifies (serial 170106)
Dec  6 18:49:53 dns named[21839]: zone ustclug.org/IN/Default: sending notifies (serial 170132)

死循环在接近四小时后,最终撑爆了内存:

Dec  6 21:37:10 dns kernel: [9683698.772789] named invoked oom-killer: gfp_mask=0x201da, order=0, oom_adj=0, oom_score_adj=0
Dec  6 21:37:10 dns kernel: [9683698.772793] named cpuset=/ mems_allowed=0
Dec  6 21:37:10 dns kernel: [9683698.772797] Pid: 21840, comm: named Not tainted 3.2.0-4-amd64 #1 Debian 3.2.60-1+deb7u3
...
Dec  6 21:37:10 dns kernel: [9683698.777831] Out of memory: Kill process 21839 (named) score 917 or sacrifice child
Dec  6 21:37:10 dns kernel: [9683698.777977] Killed process 21839 (named) total-vm:1523060kB, anon-rss:927256kB, file-rss:56kB

这个 OOM 的时间恰好是开始收到报警的时间,就是所有 LUG 域名无法解析的时间。

Blog 支持 curl 库

由于部分 WordPress 插件需要发送 HTTP 请求,且 USTC Blog 为了安全起见禁止了 “URL 作为文件路径打开”,目前只能使用 fsockopen 打开裸的 TCP 连接来发送请求,比较麻烦。CURL 是一个强大的 HTTP 库,目前 USTC Blog 使用的 PHP 编译了 curl 扩展。CURL 库的开发参考资料:http://php.net/manual/en/book.curl.php

顺便说个 tip:在 Chrome 按 F12 进入开发者工具,在 “Network” 选项卡中,右键点击一个 HTTP 请求,就有 “Copy as cURL” 的选项,可以把这个 HTTP 请求复制成一个 curl 命令。妈妈再也不用担心如何仿造 HTTP 请求了!

curl

Blog 修复 JPG 图片无法编辑和缩略问题

问题是由于 USTC blog 使用的 PHP-GD 库存在 bug,无法打开 JPG 格式的文件(但 PNG、GIF 格式均正常)。经调试,没有找到 bug 根源,因此安装了更为强大的 ImageMagick 库,WordPress 会默认使用 ImageMagick 库替代 GD 库。现在 JPG 图片的编辑功能和缩略图生成都恢复正常了。

感谢高三山的 bug 反馈。

Blog 支持 phpMyAdmin

为方便大家修改和备份数据库,USTC blog 支持 phpMyAdmin 了。访问 https://xxx.blog.ustc.edu.cn/phpmyadmin,在如下所示的界面,输入 WordPress 后台的用户名和密码。

Untitled

管理界面:

Untitled

导出数据库界面:

Untitled

该 phpMyAdmin 版本是 USTC Blog 定制版本,请不要随意自己上传 phpMyAdmin 程序,以免出现安全漏洞。