幾個月來,我的 2GB RAM VPS Linode 伺服器經常出現隨機崩潰的情況。有人說服我改用自我管理託管,出於某種原因,我認為儘管沒有該領域的經驗,但我可以處理它。我將提供盡可能多的信息來幫助:
有問題的網站是一個 Wordpress/Woocommerce 網站,它確實有很多插件,所以我知道這並不理想,但它們大多是必需的。並髮用戶數通常約為 10 個,實際上不會超過 20 個。我設定了CDN 和w3cache。該網站 99% 的時間都運作順利,沒有任何問題。我甚至使用 loadimpact.com 運行了負載測試,伺服器處理得很好。
以下是最近崩潰的一些日誌,也許有人可以找到一些線索:
錯誤日誌
[Fri Jun 19 03:06:07 2015] [error] server reached MaxClients setting, consider raising the MaxClients setting
MySQL日誌
150619 03:06:09 mysqld_safe Number of processes running now: 0
150619 03:06:12 mysqld_safe mysqld restarted
150619 3:06:15 [Warning] Using unique option prefix key_buffer instead of key_buffer_size is deprecated and will be removed in a future release. Please use the full name instead.
150619 3:06:15 [Note] Plugin 'FEDERATED' is disabled.
150619 3:06:15 InnoDB: The InnoDB memory heap is disabled
150619 3:06:15 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150619 3:06:15 InnoDB: Compressed tables use zlib 1.2.3
150619 3:06:15 InnoDB: Using Linux native AIO
150619 3:06:16 InnoDB: Initializing buffer pool, size = 320.0M
150619 3:06:16 InnoDB: Completed initialization of buffer pool
150619 3:06:17 InnoDB: highest supported file format is Barracuda.
InnoDB: The log sequence number in ibdata files does not match
InnoDB: the log sequence number in the ib_logfiles!
150619 3:06:17 InnoDB: Database was not shut down normally!
InnoDB: Starting crash recovery.
系統日誌訊息
Jun 19 03:06:07 panel kernel: php invoked oom-killer: gfp_mask=0x201da, order=0, oom_score_adj=0
Jun 19 03:06:07 panel kernel: php cpuset=/ mems_allowed=0
Jun 19 03:06:07 panel kernel: CPU: 1 PID: 24844 Comm: php Not tainted 4.0.5-x86_64-linode58 #1
Jun 19 03:06:07 panel kernel: 0000000000000000 ffff880055fac740 ffffffff8193b626 ffff880055fac100
Jun 19 03:06:07 panel kernel: ffffffff819360a4 0100000000000400 ffff88007fc17000 0000000000000020
Jun 19 03:06:07 panel kernel: ffff88007fc17000 0000000000000000 0000000000000000 0000000000000000
Jun 19 03:06:07 panel kernel: Call Trace:
Jun 19 03:06:07 panel kernel: [<ffffffff8193b626>] ? dump_stack+0x40/0x50
Jun 19 03:06:07 panel kernel: [<ffffffff819360a4>] ? dump_header.isra.10+0x78/0x1e3
Jun 19 03:06:07 panel kernel: [<ffffffff81941bb6>] ? _raw_spin_unlock_irqrestore+0x2e/0x3f
Jun 19 03:06:07 panel kernel: [<ffffffff81172f4a>] ? oom_kill_process+0xbe/0x380
Jun 19 03:06:07 panel kernel: [<ffffffff810dc57d>] ? has_ns_capability_noaudit+0x13/0x1b
Jun 19 03:06:07 panel kernel: [<ffffffff8117369a>] ? __out_of_memory+0x43d/0x47d
Jun 19 03:06:07 panel kernel: [<ffffffff8117381b>] ? out_of_memory+0x52/0x67
Jun 19 03:06:07 panel kernel: [<ffffffff811777e5>] ? __alloc_pages_nodemask+0x708/0x846
Jun 19 03:06:07 panel kernel: [<ffffffff811a4a7d>] ? alloc_pages_current+0xb2/0xcf
Jun 19 03:06:07 panel kernel: [<ffffffff8117205d>] ? filemap_fault+0x26f/0x394
Jun 19 03:06:07 panel kernel: [<ffffffff8118f78d>] ? __do_fault+0x3f/0x79
Jun 19 03:06:07 panel kernel: [<ffffffff81193009>] ? handle_mm_fault+0x370/0xd80
Jun 19 03:06:07 panel kernel: [<ffffffff811426a1>] ? __audit_syscall_exit+0x208/0x224
Jun 19 03:06:07 panel kernel: [<ffffffff8104219d>] ? __do_page_fault+0x321/0x37b
Jun 19 03:06:07 panel kernel: [<ffffffff81943f08>] ? page_fault+0x28/0x30
Jun 19 03:06:07 panel kernel: Mem-Info:
Jun 19 03:06:07 panel kernel: Node 0 DMA per-cpu:
Jun 19 03:06:07 panel kernel: CPU 0: hi: 0, btch: 1 usd: 0
Jun 19 03:06:07 panel kernel: CPU 1: hi: 0, btch: 1 usd: 0
Jun 19 03:06:07 panel kernel: Node 0 DMA32 per-cpu:
Jun 19 03:06:07 panel kernel: CPU 0: hi: 186, btch: 31 usd: 3
Jun 19 03:06:07 panel kernel: CPU 1: hi: 186, btch: 31 usd: 0
Jun 19 03:06:07 panel kernel: active_anon:348396 inactive_anon:116687 isolated_anon:32
Jun 19 03:06:07 panel kernel: active_file:351 inactive_file:528 isolated_file:0
Jun 19 03:06:07 panel kernel: unevictable:0 dirty:0 writeback:6 unstable:0
Jun 19 03:06:07 panel kernel: free:3411 slab_reclaimable:8339 slab_unreclaimable:5537
Jun 19 03:06:07 panel kernel: mapped:169339 shmem:168953 pagetables:8887 bounce:0
Jun 19 03:06:07 panel kernel: free_cma:0
Jun 19 03:06:07 panel kernel: Node 0 DMA free:7928kB min:44kB low:52kB high:64kB active_anon:2880kB inactive_anon:3140kB active_file:0kB inactive_file:28kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:15996kB managed:15912kB mlocked:0kB dirty:0kB writeback:0kB mapped:2676kB shmem:2664kB slab_reclaimable:44kB slab_unreclaimable:164kB kernel_stack:0kB pagetables:132kB unstable:0kB bounce:0kB free_cma:0kB writeback_tmp:0kB pages_scanned:20 all_unreclaimable? no
Jun 19 03:06:07 panel kernel: lowmem_reserve[]: 0 1972 1972 1972
Jun 19 03:06:07 panel kernel: Node 0 DMA32 free:5736kB min:5656kB low:7068kB high:8484kB active_anon:1390704kB inactive_anon:463608kB active_file:1488kB inactive_file:1892kB unevictable:0kB isolated(anon):128kB isolated(file):0kB present:2080768kB managed:2023584kB mlocked:0kB dirty:0kB writeback:24kB mapped:675052kB shmem:673148kB slab_reclaimable:33312kB slab_unreclaimable:21984kB kernel_stack:4304kB pagetables:35416kB unstable:0kB bounce:0kB free_cma:0kB writeback_tmp:0kB pages_scanned:0 all_unreclaimable? no
Jun 19 03:06:07 panel kernel: lowmem_reserve[]: 0 0 0 0
Jun 19 03:06:07 panel kernel: Node 0 DMA: 4*4kB (UM) 5*8kB (U) 8*16kB (UM) 4*32kB (UM) 3*64kB (UE) 10*128kB (EM) 6*256kB (UEM) 1*512kB (U) 0*1024kB 0*2048kB 1*4096kB (R) = 7928kB
Jun 19 03:06:07 panel kernel: Node 0 DMA32: 97*4kB (UEMR) 10*8kB (MR) 0*16kB 0*32kB 1*64kB (R) 1*128kB (R) 0*256kB 0*512kB 1*1024kB (R) 0*2048kB 1*4096kB (R) = 5780kB
Jun 19 03:06:07 panel kernel: 174507 total pagecache pages
Jun 19 03:06:07 panel kernel: 4598 pages in swap cache
Jun 19 03:06:07 panel kernel: Swap cache stats: add 1673544, delete 1668946, find 6783627/7234079
Jun 19 03:06:07 panel kernel: Free swap = 0kB
Jun 19 03:06:07 panel kernel: Total swap = 262140kB
Jun 19 03:06:07 panel kernel: 524191 pages RAM
Jun 19 03:06:07 panel kernel: 0 pages HighMem/MovableOnly
Jun 19 03:06:07 panel kernel: 14317 pages reserved
Jun 19 03:06:07 panel kernel: [ pid ] uid tgid total_vm rss nr_ptes nr_pmds swapents oom_score_adj name
Jun 19 03:06:07 panel kernel: [ 1541] 0 1541 2710 0 9 2 127 -1000 udevd
Jun 19 03:06:07 panel kernel: [ 2129] 0 2129 2295 34 8 2 90 0 dhclient
Jun 19 03:06:07 panel kernel: [ 2175] 0 2175 6402 0 12 2 75 -1000 auditd
Jun 19 03:06:07 panel kernel: [ 2238] 0 2238 60749 0 21 3 214 0 rsyslogd
Jun 19 03:06:07 panel kernel: [ 2264] 25 2264 57836 0 44 2 4143 0 named
Jun 19 03:06:07 panel kernel: [ 2295] 81 2295 5373 0 14 2 63 0 dbus-daemon
Jun 19 03:06:07 panel kernel: [ 2350] 495 2350 80168 0 26 5 86 0 memcached
Jun 19 03:06:07 panel kernel: [ 2368] 0 2368 16569 11 34 2 166 -1000 sshd
Jun 19 03:06:07 panel kernel: [ 2662] 0 2662 4943 23 19 5 54 0 dovecot
Jun 19 03:06:07 panel kernel: [ 2665] 498 2665 10600 0 41 6 144 0 pop3-login
Jun 19 03:06:07 panel kernel: [ 2666] 498 2666 10639 0 41 6 153 0 imap-login
Jun 19 03:06:07 panel kernel: [ 2667] 97 2667 3369 0 18 5 49 0 anvil
Jun 19 03:06:07 panel kernel: [ 2668] 0 2668 3402 0 18 5 78 0 log
Jun 19 03:06:07 panel kernel: [ 2671] 498 2671 10636 18 41 6 120 0 pop3-login
Jun 19 03:06:07 panel kernel: [ 2672] 0 2672 4145 0 19 5 282 0 config
Jun 19 03:06:07 panel kernel: [ 2673] 498 2673 10635 0 42 6 145 0 imap-login
Jun 19 03:06:07 panel kernel: [ 2683] 47 2683 18053 15 49 7 136 0 exim
Jun 19 03:06:07 panel kernel: [ 2807] 0 2807 43014 217 108 6 12952 0 /usr/local/cpan
Jun 19 03:06:07 panel kernel: [ 2895] 0 2895 43249 4306 97 6 9070 0 spamd child
Jun 19 03:06:07 panel kernel: [ 2952] 501 2952 4042 0 14 4 33 0 newrelic-daemon
Jun 19 03:06:07 panel kernel: [ 2953] 0 2953 28675 0 16 2 52 0 abrtd
Jun 19 03:06:07 panel kernel: [ 2954] 501 2954 60989 123 29 4 544 0 newrelic-daemon
Jun 19 03:06:07 panel kernel: [ 2970] 0 2970 28181 0 23 4 65 0 abrt-dump-oops
Jun 19 03:06:07 panel kernel: [ 2981] 0 2981 34674 9 23 2 160 0 pure-ftpd
Jun 19 03:06:07 panel kernel: [ 2983] 0 2983 34047 7 27 2 114 0 pure-authd
Jun 19 03:06:07 panel kernel: [ 2995] 0 2995 29217 8 16 2 148 0 crond
Jun 19 03:06:07 panel kernel: [ 3009] 0 3009 5291 11 14 2 34 0 atd
Jun 19 03:06:07 panel kernel: [ 3521] 0 3521 35818 389 90 6 6493 0 cpsrvd (SSL) -
Jun 19 03:06:07 panel kernel: [ 3760] 0 3760 10172 158 34 4 1275 0 queueprocd - wa
Jun 19 03:06:07 panel kernel: [ 3832] 0 3832 28548 0 66 5 4769 0 dnsadmin - serv
Jun 19 03:06:07 panel kernel: [ 3858] 0 3858 21764 452 54 5 3245 0 tailwatchd
Jun 19 03:06:07 panel kernel: [ 3934] 0 3934 29015 2 65 5 5416 0 cpdavd - accept
Jun 19 03:06:07 panel kernel: [ 3964] 0 3964 7951 11 27 4 1315 0 cpanellogd - sl
Jun 19 03:06:07 panel kernel: [ 4002] 0 4002 1035 1 9 4 19 0 agetty
Jun 19 03:06:07 panel kernel: [ 4004] 0 4004 1031 0 9 4 17 0 mingetty
Jun 19 03:06:07 panel kernel: [ 4006] 0 4006 1031 0 9 4 18 0 mingetty
Jun 19 03:06:07 panel kernel: [ 4008] 0 4008 1031 0 9 4 18 0 mingetty
Jun 19 03:06:07 panel kernel: [ 4011] 0 4011 2709 0 9 2 128 -1000 udevd
Jun 19 03:06:07 panel kernel: [ 4012] 0 4012 2709 0 9 2 128 -1000 udevd
Jun 19 03:06:07 panel kernel: [ 4013] 0 4013 1031 0 9 4 18 0 mingetty
Jun 19 03:06:07 panel kernel: [ 4015] 0 4015 1031 0 9 4 18 0 mingetty
Jun 19 03:06:07 panel kernel: [ 4017] 0 4017 1031 0 8 4 17 0 mingetty
Jun 19 03:06:07 panel kernel: [16053] 0 16053 18080 444 59 5 138 0 httpd
Jun 19 03:06:07 panel kernel: [19702] 0 19702 2883 1 15 4 71 0 mysqld_safe
Jun 19 03:06:07 panel kernel: [19964] 497 19964 393396 49834 210 7 17743 0 mysqld
Jun 19 03:06:07 panel kernel: [22735] 0 22735 3368 26 17 5 0 0 ssl-params
Jun 19 03:06:07 panel kernel: [24373] 0 24373 20166 2064 63 5 9 0 leechprotect
Jun 19 03:06:07 panel kernel: [24374] 99 24374 18247 625 48 5 129 0 httpd
Jun 19 03:06:07 panel kernel: [24375] 99 24375 18259 641 48 5 127 0 httpd
Jun 19 03:06:07 panel kernel: [24378] 99 24378 18283 650 48 5 129 0 httpd
Jun 19 03:06:07 panel kernel: [24379] 99 24379 18207 582 48 5 131 0 httpd
Jun 19 03:06:07 panel kernel: [24380] 99 24380 18294 651 48 5 129 0 httpd
Jun 19 03:06:07 panel kernel: [24383] 99 24383 18251 632 48 5 129 0 httpd
Jun 19 03:06:07 panel kernel: [24388] 99 24388 18275 651 48 5 129 0 httpd
Jun 19 03:06:07 panel kernel: [24395] 99 24395 18232 610 48 5 129 0 httpd
Jun 19 03:06:07 panel kernel: [24438] 0 24438 4252 51 12 2 0 0 anacron
Jun 19 03:06:07 panel kernel: [24457] 99 24457 18249 629 48 5 129 0 httpd
Jun 19 03:06:07 panel kernel: [24460] 99 24460 18243 622 48 5 129 0 httpd
Jun 19 03:06:07 panel kernel: [24559] 99 24559 18234 611 48 5 129 0 httpd
Jun 19 03:06:07 panel kernel: [24688] 99 24688 18283 646 48 5 131 0 httpd
Jun 19 03:06:07 panel kernel: [24757] 97 24757 7930 113 30 5 0 0 auth
Jun 19 03:06:07 panel kernel: [24838] 507 24838 84744 21633 134 6 0 0 php
Jun 19 03:06:07 panel kernel: [24840] 507 24840 83776 20878 133 6 0 0 php
Jun 19 03:06:07 panel kernel: [24841] 507 24841 82483 18820 128 7 0 0 php
Jun 19 03:06:07 panel kernel: [24844] 507 24844 82937 20101 130 7 0 0 php
Jun 19 03:06:07 panel kernel: [24845] 507 24845 82227 18788 129 7 0 0 php
Jun 19 03:06:07 panel kernel: [24846] 507 24846 82291 19040 129 6 0 0 php
Jun 19 03:06:07 panel kernel: [24847] 507 24847 82887 19792 131 7 0 0 php
Jun 19 03:06:07 panel kernel: [24848] 507 24848 82934 20094 130 7 0 0 php
Jun 19 03:06:07 panel kernel: [24850] 507 24850 82894 19887 130 6 0 0 php
Jun 19 03:06:07 panel kernel: [24852] 507 24852 82548 19709 129 6 0 0 php
Jun 19 03:06:07 panel kernel: [24859] 507 24859 82803 19724 131 6 0 0 php
Jun 19 03:06:07 panel kernel: [24862] 99 24862 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24866] 507 24866 81465 17804 126 6 0 0 php
Jun 19 03:06:07 panel kernel: [24875] 99 24875 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24876] 99 24876 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24877] 507 24877 79415 14127 121 6 0 0 php
Jun 19 03:06:07 panel kernel: [24878] 507 24878 79221 13720 118 7 0 0 php
Jun 19 03:06:07 panel kernel: [24885] 99 24885 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24886] 99 24886 18182 523 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24887] 99 24887 18182 523 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24888] 99 24888 18182 523 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24892] 507 24892 77328 9824 111 6 0 0 php
Jun 19 03:06:07 panel kernel: [24898] 99 24898 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24899] 99 24899 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24900] 99 24900 18182 513 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24901] 99 24901 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24902] 99 24902 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24903] 99 24903 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24904] 99 24904 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24905] 99 24905 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24906] 507 24906 75260 6007 103 6 0 0 php
Jun 19 03:06:07 panel kernel: [24907] 507 24907 61544 14697 114 6 0 0 php
Jun 19 03:06:07 panel kernel: [24908] 507 24908 75724 6894 105 6 0 0 php
Jun 19 03:06:07 panel kernel: [24909] 507 24909 74348 5097 101 6 0 0 php
Jun 19 03:06:07 panel kernel: [24910] 507 24910 75746 6708 104 7 0 0 php
Jun 19 03:06:07 panel kernel: [24911] 507 24911 75746 6630 104 6 0 0 php
Jun 19 03:06:07 panel kernel: [24912] 507 24912 75746 6705 104 6 0 0 php
Jun 19 03:06:07 panel kernel: [24913] 507 24913 76743 8656 108 6 0 0 php
Jun 19 03:06:07 panel kernel: [24922] 507 24922 73138 3847 99 7 0 0 php
Jun 19 03:06:07 panel kernel: [24923] 507 24923 72900 3513 96 6 0 0 php
Jun 19 03:06:07 panel kernel: [24925] 507 24925 72704 3279 98 6 0 0 php
Jun 19 03:06:07 panel kernel: [24926] 507 24926 72856 3395 98 6 0 0 php
Jun 19 03:06:07 panel kernel: [24927] 99 24927 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24928] 99 24928 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24929] 99 24929 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24930] 99 24930 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24931] 99 24931 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24932] 99 24932 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24933] 99 24933 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24934] 99 24934 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24935] 99 24935 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24936] 507 24936 72900 3454 98 7 0 0 php
Jun 19 03:06:07 panel kernel: [24937] 507 24937 72900 3512 100 6 0 0 php
Jun 19 03:06:07 panel kernel: [24938] 507 24938 72898 3510 99 6 0 0 php
Jun 19 03:06:07 panel kernel: [24940] 99 24940 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24941] 99 24941 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24942] 99 24942 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24944] 507 24944 72709 3228 98 6 0 0 php
Jun 19 03:06:07 panel kernel: [24945] 507 24945 72707 3210 96 6 0 0 php
Jun 19 03:06:07 panel kernel: [24946] 507 24946 72505 2756 97 6 0 0 php
Jun 19 03:06:07 panel kernel: [24947] 507 24947 72770 3394 99 6 0 0 php
Jun 19 03:06:07 panel kernel: [24948] 507 24948 72898 3511 98 7 0 0 php
Jun 19 03:06:07 panel kernel: [24950] 507 24950 72920 3491 99 6 0 0 php
Jun 19 03:06:07 panel kernel: [24952] 99 24952 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24953] 99 24953 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24954] 99 24954 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24956] 507 24956 72273 2332 95 6 0 0 php
Jun 19 03:06:07 panel kernel: [24959] 507 24959 71635 1659 96 6 0 0 php
Jun 19 03:06:07 panel kernel: [24960] 507 24960 72358 2601 97 7 0 0 php
Jun 19 03:06:07 panel kernel: [24961] 507 24961 72431 2797 96 6 0 0 php
Jun 19 03:06:07 panel kernel: [24962] 507 24962 72565 2478 97 6 0 0 php
Jun 19 03:06:07 panel kernel: [24963] 99 24963 18149 480 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24964] 507 24964 72505 2727 98 6 0 0 php
Jun 19 03:06:07 panel kernel: [24965] 507 24965 71871 1883 95 6 0 0 php
Jun 19 03:06:07 panel kernel: [24987] 99 24987 18149 467 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24988] 99 24988 18149 472 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24989] 99 24989 18149 467 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24990] 99 24990 18149 479 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24991] 99 24991 18149 477 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24992] 507 24992 24451 62 72 6 0 0 php
Jun 19 03:06:07 panel kernel: [24993] 99 24993 18149 478 48 5 132 0 httpd
Jun 19 03:06:07 panel kernel: [24994] 99 24994 2998 13 14 4 0 0 suphp
Jun 19 03:06:07 panel kernel: [24995] 507 24995 5810 9 12 4 0 0 php
Jun 19 03:06:07 panel kernel: [24996] 507 24996 3880 9 10 4 0 0 php
Jun 19 03:06:07 panel kernel: [24998] 507 24998 6373 16 15 5 0 0 php
Jun 19 03:06:07 panel kernel: [24999] 507 24999 2767 1 3 3 0 0 php
Jun 19 03:06:07 panel kernel: [25000] 0 25000 18080 432 47 5 135 0 httpd
Jun 19 03:06:07 panel kernel: Out of memory: Kill process 19964 (mysqld) score 117 or sacrifice child
Jun 19 03:06:07 panel kernel: Killed process 19964 (mysqld) total-vm:1573584kB, anon-rss:199336kB, file-rss:0kB
Jun 19 03:06:07 panel kernel: php invoked oom-killer: gfp_mask=0x280da, order=0, oom_score_adj=0
Jun 19 03:06:07 panel kernel: php cpuset=/ mems_allowed=0
這是我的 apache 設定:
Starts Servers 2
Minimum Spare Servers 6
Maximum Spare Servers 12
Server Limit 256
Max Clients 50
Max Requests Per Child 3000
Keep-Alive Off
Mysql my.cnf 設定:
[mysqld]
innodb_file_per_table=1
open_files_limit=1024000
max_connections=75
key_buffer=32M
max_allowed_packet=268435456
thread_stack=128K
table_cache=32
innodb_buffer_pool_size=320M
default-storage-engine=MyISAM
query_cache_size=8M
tmp_table_size=16M
max_heap_table_size=16M
thread_cache_size=4
table_open_cache=32
請幫忙,我已盡最大努力找出這個問題,但我無法真正找出是什麼原因造成的。
順便說一句,一些額外的隨機花絮:
-我網站上的一些頁面有很多圖片(例如超過 100 張),不確定這些是否算作額外的客戶端/請求並以某種方式影響效能。
-我的 WordPress 記憶體限制設定為 400MB 左右。
- 該網站的 Mysql 資料庫約為 175MB。其中 91MB 來自 WP_Options。
-Mysqltuner.pl 不斷告訴我增加 tmp_table_size 和 max_heap_table_size 即使我已將它們設定為高達 200M!
- 這是我現在的 htop 的螢幕截圖。似乎 mysql 不斷使用 40% 的內存,並且由於某種原因交換內存幾乎已滿。這是正常的嗎?:
更新:我已將最大客戶端數降低到 35,但仍然遇到一些奇怪的 mysql 崩潰。 Newrelic 錯誤訊息是未知儲存引擎「InnoDB」(我的 mysqltuner.pl 說 InnoDB 已停用,但它是預設儲存引擎)。我的網站告訴我像全新安裝一樣重新安裝 Wordpress,我必須重新啟動 mysql 或伺服器才能消失。
答案1
並髮用戶數一般在10人左右,不會超過20人
....但是您的螢幕截圖顯示 23 個活動 mysql 會話,並且您將網頁伺服器配置為允許 256 個。
廉價託管上的交換是一種反模式 - 一旦您的電腦開始進入交換,它將花費所有時間讀取和寫入交換文件,同時請求開始在 Apache 上備份。
關於Wordpress,我沒什麼好說的。
我從您的螢幕截圖中看到 PHP 的 CLI SAPI 正在運行。 oom Killer 認為 PHP 是系統記憶體最嚴重的破壞者。這表示您正在執行 CGI PHP,而不是 mod_php 或 php-fpm。如果是這樣的話,那麼我們不僅解決了為什麼你的主機內存不足的問題,還解決了為什麼你的頁面如此oooooooo slooooooooooowwwwwww,
保持活動狀態關閉
這確實沒有幫助。這肯定會讓瀏覽器端的體驗變得更糟。即使您配置了快取和 CDN,它的逾時時間也應低於 500 毫秒確切地正確的。
這顯然不是您的 Apache 配置的全部 - 而且許多其他設定也很重要。確保壓縮已啟用是一項重要任務(壓縮資料的 CPU 時間比處理 TCP 流量便宜,並且表示您不會讓大型 apache 程序在記憶體中等待資料傳輸)。
儘管您提供了有關發生的事情的大量信息後oom殺手你需要看看之前發生了什麼。預設情況下不會捕獲該資訊。至少要跟蹤記憶體使用量與 apache 實例數量。
答案2
由於某種原因,您遇到了 maxclients 參數。
您是否有關於伺服器宕機時每秒請求量的更多資訊?看起來您的交換區已完全填滿,導致伺服器崩潰。您知道哪些元件使用了多少記憶體嗎?
答案3
檢查伺服器記憶體使用情況的一個簡單方法是安裝一個名為 的工具htop
。 htop 將為您提供每個進程的伺服器的重要資訊。在您想要檢查記憶體的情況下,您可以載入 htop 並點擊M
按記憶體排序(或>
選擇一個類別)。
一旦你發現哪個應用程式使用了最多的記憶體(我猜是 Apache,考慮到你同時達到了最大客戶端數並觸發了 OOM 殺手),那麼你就可以對其進行微調。不過,我不懷疑你這裡有容量問題。如日誌所示,您已達到 Apache 的最大客戶端數,但您現在無法安全地增加該數量,因為您不確定您的 RAM。這正在影響您的客戶。獲得一套好的監控工具並保持在其之上。
此外,在崩潰時檢查 Apache 存取日誌可能不會有什麼壞處。您說您通常不會獲得超過 20 個並髮用戶,但您已達到 50 個 Apache 進程的最大限制。如果這是合法流量,那麼您將需要更好地調整伺服器並可能升級資源。如果不是,那麼也許可以嘗試找到一種方法來過濾垃圾(說起來容易做起來難)。