nginx報錯”could not build the server_names_hash”


今天在給nginx添加幾十個域名后,重啟nginx的時候,報錯”[emerg]: could not build the server_names_hash, you should increase either server_names_hash_max_size: 512 or server_names_hash_bucket_size: 128″

在nginx.conf配置文件的http{}把server_names_hash_bucket_size 128改為server_names_hash_bucket_size 512,按32的倍數往上加,再重啟問題解決。

[root@localhost vhost]# /usr/local/nginx/sbin/nginx -t    [emerg]: could not build the server_names_hash, you should increase either server_names_hash_max_size: 512 or server_names_hash_bucket_size: 128 configuration file /usr/local/nginx/conf/nginx.conf test failed

[root@localhost vhost]# /usr/local/nginx/sbin/nginx -t    the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok configuration file /usr/local/nginx/conf/nginx.conf test is successful

最后查了下資料:

保存服務器名字的hash表是由指令 server_names_hash_max_size 和 server_names_hash_bucket_size所控制的。參數hash bucket size總是等於hash表的大小,並且是一路處理器緩存大小的倍數。在減少了在內存中的存取次數后,使在處理器中加速查找hash表鍵值成為可能。如果 hash bucket size等於一路處理器緩存的大小,那么在查找鍵的時候,最壞的情況下在內存中查找的次數為2。第一次是確定存儲單元的地址,第二次是在存儲單元中查找鍵值。因此,如果Nginx給出需要增大 hash max size 或 hash bucket size的提示,那么首要的是增大前一個參數的大小.


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM