biyexp 发表于 2012-10-26 22:46:12

军哥,新服务器安装lnmp,遇到cpu占用高问题

新服务器安装了lnmp0.9,和以前的旧服务器对比起来好像负载不降反高(旧服务器是很久前康盛的人给做的环境)。由于小弟不是很熟悉,向您请教了!
DiscuzX2论坛,使用top命令查看,偶尔有几个php-cgi进程跳到90%以上,甚至到100%,几秒后又掉下去。我应该如何解决,如果需要更详细的数据,比如配置文件请说,我会继续提供。
刚刚接触linux,太多问题都要学习:'(

top - 22:22:01 up 4 days,5:47,1 user,load average: 0.77, 1.15, 1.67
Tasks: 794 total,   5 running, 789 sleeping,   0 stopped,   0 zombie
Cpu(s):8.0%us,0.4%sy,0.0%ni, 91.5%id,0.0%wa,0.0%hi,0.1%si,0.0%st
Mem:32829560k total, 13631460k used, 19198100k free,   640232k buffers
Swap: 16482296k total,      0k used, 16482296k free,6729368k cached
PID   USER      PRNIVIRT   RESSHR S %CPU %MEM    TIME+COMMAND                                                      
22711 www       20   0228m23m 4448 S 30.50.1   0:08.92 php-cgi      <---个别进程有时候会跳到90-100%                                                   
22585 www       20   0226m23m 4488 S8.20.1   0:08.22 php-cgi               ,几秒后恢复                                             
22797 www       20   0228m24m 4636 S6.90.1   0:08.09 php-cgi                                                         
22605 www       20   0229m24m 4520 S6.60.1   0:09.21 php-cgi                                                         
22836 www       20   0234m29m 4776 S6.60.1   0:07.89 php-cgi                                                         
22882 www       20   0224m19m 4312 S6.60.1   0:07.51 php-cgi                                                         
22762 www       20   0228m23m 4484 S5.90.1   0:07.51 php-cgi                                                         
22837 www       20   0221m18m 4428 S5.90.1   0:07.59 php-cgi                                                         
22567 www       20   0226m24m 4664 S5.60.1   0:07.76 php-cgi                                                         
22628 www       20   0229m24m 4524 S5.20.1   0:09.12 php-cgi                                                         
22761 www       20   0221m17m 4512 S4.90.1   0:08.33 php-cgi                                                         
22631 www       20   0225m20m 4644 S3.90.1   0:07.94 php-cgi                                                         
22890 www       20   0221m19m 4372 S3.90.1   0:07.21 php-cgi                                                         
22921 www       20   0225m20m 4520 S3.90.1   0:06.56 php-cgi                                                         
22715 www       20   0227m23m 4660 S3.60.1   0:08.11 php-cgi                                                         


24个核心的CPU也是工作的少,闲置的多,白天有6、7个CPU核心都是60%。然后其他的都不足10%

top - 22:43:45 up 4 days,6:08,1 user,load average: 1.20, 1.12, 1.20
Tasks: 800 total,   2 running, 798 sleeping,   0 stopped,   0 zombie
Cpu0: 17.3%us,1.0%sy,0.0%ni, 81.7%id,0.0%wa,0.0%hi,0.0%si,0.0%st       <---------白天有时候会到60%以上
Cpu1:8.3%us,0.0%sy,0.0%ni, 91.7%id,0.0%wa,0.0%hi,0.0%si,0.0%st
Cpu2:5.3%us,0.3%sy,0.0%ni, 94.4%id,0.0%wa,0.0%hi,0.0%si,0.0%st
Cpu3:0.7%us,0.0%sy,0.0%ni, 99.3%id,0.0%wa,0.0%hi,0.0%si,0.0%st
Cpu4:0.7%us,0.0%sy,0.0%ni, 99.3%id,0.0%wa,0.0%hi,0.0%si,0.0%st
Cpu5:0.0%us,0.0%sy,0.0%ni,100.0%id,0.0%wa,0.0%hi,0.0%si,0.0%st
Cpu6:0.0%us,0.0%sy,0.0%ni,100.0%id,0.0%wa,0.0%hi,0.0%si,0.0%st
Cpu7:0.0%us,0.0%sy,0.0%ni,100.0%id,0.0%wa,0.0%hi,0.0%si,0.0%st
Cpu8:0.0%us,0.0%sy,0.0%ni,100.0%id,0.0%wa,0.0%hi,0.0%si,0.0%st
Cpu9:0.7%us,0.0%sy,0.0%ni, 99.3%id,0.0%wa,0.0%hi,0.0%si,0.0%st
Cpu10 :0.0%us,0.0%sy,0.0%ni,100.0%id,0.0%wa,0.0%hi,0.0%si,0.0%st
Cpu11 :0.0%us,0.0%sy,0.0%ni,100.0%id,0.0%wa,0.0%hi,0.0%si,0.0%st
Cpu12 :0.0%us,0.0%sy,0.0%ni,100.0%id,0.0%wa,0.0%hi,0.0%si,0.0%st
Cpu13 : 25.4%us,0.7%sy,0.0%ni, 73.9%id,0.0%wa,0.0%hi,0.0%si,0.0%st
Cpu14 :1.0%us,0.0%sy,0.0%ni, 98.7%id,0.0%wa,0.0%hi,0.3%si,0.0%st
Cpu15 : 14.5%us,1.0%sy,0.0%ni, 84.2%id,0.0%wa,0.0%hi,0.3%si,0.0%st
Cpu16 : 21.3%us,0.7%sy,0.0%ni, 78.1%id,0.0%wa,0.0%hi,0.0%si,0.0%st
Cpu17 :0.7%us,0.3%sy,0.0%ni, 99.0%id,0.0%wa,0.0%hi,0.0%si,0.0%st
Cpu18 :0.3%us,0.3%sy,0.0%ni, 99.3%id,0.0%wa,0.0%hi,0.0%si,0.0%st
Cpu19 : 14.6%us,0.7%sy,0.0%ni, 84.8%id,0.0%wa,0.0%hi,0.0%si,0.0%st
Cpu20 :0.7%us,0.7%sy,0.0%ni, 98.4%id,0.0%wa,0.0%hi,0.3%si,0.0%st
Cpu21 :0.0%us,0.0%sy,0.0%ni,100.0%id,0.0%wa,0.0%hi,0.0%si,0.0%st      <---------好多这样闲置的
Cpu22 :0.0%us,0.0%sy,0.0%ni,100.0%id,0.0%wa,0.0%hi,0.0%si,0.0%st      <---------好多这样闲置的
Cpu23 :0.0%us,0.0%sy,0.0%ni,100.0%id,0.0%wa,0.0%hi,0.0%si,0.0%st      <---------好多这样闲置的

[ 本帖最后由 biyexp 于 2012-10-26 23:01 编辑 ]

biyexp 发表于 2012-10-26 23:11:03

提供nginx.conf配置文件
----------
userwww www;

worker_processes 8;          #我只开了8个,网上说开多了没用,但是我机器有24个核心。。。

error_log/home/wwwlogs/nginx_error.logcrit;

pid      /usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.

worker_rlimit_nofile 65535;

events
        {
                use epoll;
                worker_connections 65535;
            multi_accept on;
        }

http
        {
                include       mime.types;
                default_typeapplication/octet-stream;
                server_names_hash_bucket_size 128;
                client_header_buffer_size 32k;
                large_client_header_buffers 4 32k;
                client_max_body_size 8m;

                sendfile on;
                tcp_nopush   on;
                tcp_nodelay on;

                keepalive_timeout 15;
            client_header_timeout 300;
            client_body_timeout   300;
            send_timeout          300;

                fastcgi_connect_timeout 300;
                fastcgi_send_timeout 300;
                fastcgi_read_timeout 300;
            fastcgi_buffer_size 64k;
            fastcgi_buffers 4 64k;
            fastcgi_busy_buffers_size 128k;
            fastcgi_temp_file_write_size 256k;

                gzip on;
                gzip_min_length1K;
                gzip_buffers   4 32k;
                gzip_http_version 1.1;
                gzip_comp_level 2;
                gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
                gzip_vary on;

                #limit_zonecrawler$binary_remote_addr10m;

server
        {
                include rewrite.conf;


                listen80;
                server_namestatus.bbs.test.cn;

                location / {
                stub_status on;
                access_log   off;
                   }


        }       

                error_page 404 = http://bbs.test.cn/404/404.htm;

                include vhost/*.conf;

}

-----------

biyexp 发表于 2012-10-26 23:17:07

php.ini
配置只是修改了 附件大小2M。其他是lnmp安装包的默认

----------------------------------------------------
php-fpm.conf
修改了以下
<value name="max_children">300</value>
<value name="rlimit_files">65535</value>
<value name="max_requests">1024</value>
--------------------------------------------------

上传php-fpm.log,里面有警告
大概内容是,详细请见附件
Oct 26 17:09:48.088599 fpm_stdio_child_said(), line 167: child 8351 (pool default) said into stderr: "Not a JPEG file: starts with 0x47 0x49"
Oct 26 17:10:13.322397 fpm_stdio_child_said(), line 167: child 8565 (pool default) said into stderr: "Not a JPEG file: starts with 0x47 0x49"
Oct 26 19:10:32.068687 fpm_got_signal(), line 48: received SIGCHLD
Oct 26 19:10:32.068863 fpm_children_bury(), line 215: child 8350 (pool default) exited with code 0 after 9094.498469 seconds from start
Oct 26 19:10:32.070088 fpm_children_make(), line 352: child 16161 (pool default) started

[ 本帖最后由 biyexp 于 2012-10-26 23:22 编辑 ]

biyexp 发表于 2012-10-28 09:38:02

我这贴要石沉大海了。
页: [1]
查看完整版本: 军哥,新服务器安装lnmp,遇到cpu占用高问题