Nginx 服务器性能Bug和性能优化方案(真实经历)

一、遇到的问题

1、问题:本应该是3个ffmpeg ,但是怎么会有5个ffmpeg出现?

2、Lua脚本问题,一直写入日志,导致有大量的日志,这里的错误日志是直接写进nginx的error.log 日志文件的

(1)日志文件

total 1.8G
-rw-r--r-- 1 root root  11M May  9 21:47 access.log
-rw-r--r-- 1 root root 3.1K May  9 21:46 error.log
-rw-r--r-- 1 root root 705M May  9 21:44 live_access.log
-rw-r--r-- 1 root root 1.1G May  9 21:44 nginx_error.log

2017/05/09 21:43:05 时间段详细记录:

2017/05/09 21:43:05 [notice] 154005#0: *2276339 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2276301 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2255428 "\.m3u8" matches "/live/C
2017/05/09 21:43:05 [notice] 154005#0: *2255382 "\.m3u8" matches "/live/C
2017/05/09 21:43:05 [notice] 154005#0: *2276989 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2276946 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2255373 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2277509 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2255426 "\.m3u8" matches "/live/C
2017/05/09 21:43:05 [notice] 154005#0: *2276852 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2276850 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2276811 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2276416 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2276558 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2276495 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2255454 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2280641 "\.m3u8" matches "/live/C
2017/05/09 21:43:05 [notice] 154005#0: *2255417 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2255401 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2257856 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2255428 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2255372 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2255426 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2255396 "\.m3u8" matches "/live/C
2017/05/09 21:43:05 [notice] 154005#0: *2276402 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2254567 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2255436 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2255387 "\.m3u8" matches "/live/C
2017/05/09 21:43:05 [notice] 154005#0: *2276423 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2255460 "\.m3u8" matches "/live/C
2017/05/09 21:43:05 [notice] 154005#0: *2255443 "\.m3u8" matches "/live/C
2017/05/09 21:43:05 [notice] 154005#0: *2277380 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2276203 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2276375 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2255467 "\.m3u8" matches "/live/C
2017/05/09 21:43:05 [notice] 154005#0: *2255404 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2255485 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2276709 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2255473 "\.m3u8" matches "/live/C
2017/05/09 21:43:05 [notice] 154005#0: *2255419 "\.m3u8" matches "/live/C
2017/05/09 21:43:05 [notice] 154005#0: *2255443 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2255456 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2255480 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2255460 "\.m3u8" does not match "
2017/05/09 21:43:05 [notice] 154005#0: *2255467 "\.m3u8" does not match "

2017/05/09 21:36:43 时间段详细记录,太恐怖了,1s写入日志多大240条,难怪nginx的负载飙到54%

2017/05/09 21:36:42 [notice] 143984#0: *2210297 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2106253 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2186550 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2186550 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2204373 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2178827 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2178827 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2174075 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2192938 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2184738 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2178702 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2178827 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2164479 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2164479 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2207950 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2207950 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2206807 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2206807 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2147325 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2147325 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2146090 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2146090 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2202243 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2202243 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2159677 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2181228 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2181228 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2199544 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2129089 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2147325 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2164479 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2144525 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2144525 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2202243 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2128282 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2146090 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2209153 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2209153 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2151087 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2151087 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2087849 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2087849 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2180084 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2194164 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2149424 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2149424 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2132295 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2086470 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2195833 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2195833 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2165986 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2210503 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2210503 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2209153 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2196487 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2196487 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2165986 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2174122 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2184751 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2136083 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2136083 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2175850 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2188260 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2169324 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2160157 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2160157 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2203464 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2203464 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2181228 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2148600 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2204612 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2204612 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2149424 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2186550 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2180900 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2180900 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2149681 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2149681 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2152412 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2197834 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2197834 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2211485 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2211485 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2199276 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2199276 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2136083 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2144525 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2138501 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2138501 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2203464 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2147376 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2147376 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2204612 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2171804 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2171804 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2187796 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2187796 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2160157 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2159339 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2210355 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2175294 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2204800 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2204800 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2191351 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2191351 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2134758 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2205738 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2205738 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2200117 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2200117 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2204001 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2204001 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2142361 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2142361 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2171804 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2202345 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2197156 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2197156 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2196879 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2196879 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2151087 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2193240 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2204977 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2193240 [lua] hls
2017/05/09 21:36:43 [error] 143984#0: *2204977 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2189719 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2189719 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2141027 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2141027 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2165986 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2165986 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2122514 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2190219 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2190219 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2147376 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2098802 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2098802 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2156137 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2156137 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2142361 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2211167 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2205291 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2205291 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2192529 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2192529 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2097916 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2201800 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2201800 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2193020 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2193020 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2141139 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2136709 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2136709 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2159600 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2159600 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2156137 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2210052 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2210053 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2211168 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2211162 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2149892 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2159845 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2194944 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2194944 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2196511 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2206411 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2206411 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2211541 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2159261 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2211541 [lua] hls
2017/05/09 21:36:43 [error] 143984#0: *2159261 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2152418 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2152418 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2194275 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2209256 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2209256 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2208837 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2208837 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2185994 "\.m3u8"
2017/05/09 21:36:43 [info] 143984#0: *2210187 client pre
2017/05/09 21:36:43 [notice] 143984#0: *2136709 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2199994 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2199994 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2197135 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2197135 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2189288 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2189288 [lua] hls
2017/05/09 21:36:43 [info] 143984#0: *2208514 client 183
2017/05/09 21:36:43 [info] 143984#0: *2209467 client 183
2017/05/09 21:36:43 [notice] 143984#0: *2204658 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2204658 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2159261 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2201943 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2201943 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2181340 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2197116 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2159600 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2162239 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2162239 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2188389 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2188389 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2203649 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2203649 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2209256 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2133678 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2189211 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2133678 [lua] hls
2017/05/09 21:36:43 [error] 143984#0: *2189211 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2208950 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2208950 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2204405 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2204405 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2165986 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2200375 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2200375 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2168351 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2184419 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2184419 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2183669 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2183669 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2134644 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2162239 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2142432 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2142432 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2162247 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2162247 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2211574 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2197450 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2197450 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2180184 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2203913 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2203913 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2152418 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2202370 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2202370 [lua] hls
2017/05/09 21:36:43 [notice] 143984#0: *2142432 "\.m3u8"
2017/05/09 21:36:43 [notice] 143984#0: *2206880 "\.m3u8"
2017/05/09 21:36:43 [error] 143984#0: *2206880 [lua] hls
2017/05/09 21:36:44 [notice] 143984#0: *2200453 "\.m3u8"

 

(2)Lua脚本日志写入:

if ( tonumber(res) == 0 or tonumber(res) == 1 ) then          -- 不是签名验证,则直接返回
   ngx.log(ngx.ERR, "error : 不是签名验证,则直接返回::res=== ",res)  
    return
end

解决办法:立即关闭该日志的写入,重启nginx服务器 reload

【1】日志切割工具下载:http://soft.laozuo.org/tools/Knife4File.zip

【2】log日志查看工具:http://www.uvviewsoft.com/logviewer/files/LogViewerPro.zip

 

3、他们摄像头推流,直播结束后ffmpeg 进程一直在

4、是否针对播流权限认真是否取消掉?

答:暂时先取消掉

6、流状态列表查看(必须的联系他们的人员怎么处理),没有推流但是nginx服务状态一直存在

 解决方案:

修改nginx rtmp配置参数,添加这个参数:drop_idle_publisher 10s;

drop_idle_publisher
语法:drop_idle_publisher timeout
上下文:rtmp, server, application
描述:终止指定时间内闲置(没有音频/视频数据)的发布连接。默认为 off。注意这个仅仅对于发布模式的连接起作用(发送 publish 命令之后)。
 
二、性能优化技巧
1、设置worker_connections:10240

官方解释如下,个人认为是每一个worker进程能并发处理(发起)的最大连接数(包含所有连接数)。不能超过最大文件打开数:在linux终端中输入ulimit -a进行查看

www@ubuntu5:$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 126277
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 126277
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

 参考:linux ulimit命令调优系统参数

 2、编译安装过程优化
 

找到源码的这个文件 /nginx-1.10.3/auto/cc/gcc

# debug
CFLAGS="$CFLAGS -g"

不修改代码大小7.3M:

tinywan@tinywan:~/nginx-1.10.3/auto/cc$ ls -lh /usr/local/nginx/sbin/nginx 
-rwxr-xr-x 1 root root 7.3M 3月  31 09:29 /usr/local/nginx/sbin/nginx

修改后的文件大小759K

tinywan@tinywan:~/nginx-1.10.3$ ls -lh /usr/local/nginx/sbin/nginx 
-rwxr-xr-x 1 root root 759K 5月  10 14:35 /usr/local/nginx/sbin/nginx

 

查看CPU类型

tinywan@tinywan:~/nginx-1.10.3$ cat /proc/cpuinfo | grep "model name"
model name    : Intel(R) Core(TM) i3-4160 CPU @ 3.60GHz

 

 
 
 Nginx日志分割及自动删除超过30天日志
#!/bin/bash
# 分割nginx access日志脚本
 
time=`date +%Y%m%d`
logs_path="/usr/local/nginx/logs/"
pid_path="/usr/local/nginx/logs/nginx.pid"
 
#日志分割,按天创建文件夹
cd $logs_path
website=`ls $logs_path/access_* | xargs -n 1 | cut -f 2 -d "_"`
for i in $website
do
  mkdir -p $logs_path/backup/$time/
  mv $logs_path/access_$i $logs_path/backup/$time/$i
done
#向nginx主进程发信号重新打开日志
kill -USR1 `cat ${pid_path}`
 
#每月1日删除所有超过30天日志。
if [ "`date +%d`" = "01" ]; then
  all_list=`ls $logs_path/backup | xargs -n 1`
  for del in $all_list
  do
    let results=$time-$del
    if [ $results -gt 30 ]; then
      rm -rf $logs_path/backup/$del
    fi
  done
fi

注: /usr/local/nginx/logs/下的日志格式为access_domain1.log。

加入计划任务,每天大概0时分割日志:

 
 
 
 
 
 

 

posted @ 2017-05-10 09:07  Tinywan  阅读(3590)  评论(0编辑  收藏  举报