Mysql – wordpress site kills thesql

MySQLmysql-5.6Wordpress

I move client wordpress sites from one VPS to another, it all went smooth until I moved a site that kills mysql (and, consequently, all other wp sites). It used to work fine on the previous VPS.

Here's the info I have so far. Before opening in browser that site, systemctl status mysql.service -l gives

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2015-11-11 08:48:22 MSK; 14min ago
  Process: 6404 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
  Process: 6400 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 6403 (mysqld_safe)
   CGroup: /system.slice/mysql.service
           ├─6403 /bin/sh /usr/bin/mysqld_safe
           └─6761 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib/mysql/plugin --log-error=/var/log/mysql/error.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/run/mysqld/mysqld.sock --port=3306

Nov 11 08:48:21 jupiter-clean systemd[1]: Starting MySQL Community Server...
Nov 11 08:48:21 jupiter-clean mysqld_safe[6403]: 151111 08:48:21 mysqld_safe Can't log to error log and syslog at the same time.  Remove all --log-error configuration options for --syslog to take effect.
Nov 11 08:48:21 jupiter-clean mysqld_safe[6403]: 151111 08:48:21 mysqld_safe Logging to '/var/log/mysql/error.log'.
Nov 11 08:48:21 jupiter-clean mysqld_safe[6403]: 151111 08:48:21 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Nov 11 08:48:22 jupiter-clean systemd[1]: Started MySQL Community Server.
Nov 11 09:03:01 jupiter-clean systemd[1]: Started MySQL Community Server.

Going to that site makes systemctl status mysql.service -l output

● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Wed 2015-11-11 09:05:14 MSK; 1min 17s ago
  Process: 6404 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
  Process: 6403 ExecStart=/usr/bin/mysqld_safe (code=exited, status=0/SUCCESS)
  Process: 6400 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 6403 (code=exited, status=0/SUCCESS)

Nov 11 08:48:21 jupiter-clean systemd[1]: Starting MySQL Community Server...
Nov 11 08:48:21 jupiter-clean mysqld_safe[6403]: 151111 08:48:21 mysqld_safe Can't log to error log and syslog at the same time.  Remove all --log-error configuration options for --syslog to take effect.
Nov 11 08:48:21 jupiter-clean mysqld_safe[6403]: 151111 08:48:21 mysqld_safe Logging to '/var/log/mysql/error.log'.
Nov 11 08:48:21 jupiter-clean mysqld_safe[6403]: 151111 08:48:21 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Nov 11 08:48:22 jupiter-clean systemd[1]: Started MySQL Community Server.
Nov 11 09:03:01 jupiter-clean systemd[1]: Started MySQL Community Server.
Nov 11 09:05:14 jupiter-clean mysqld_safe[6403]: 151111 09:05:14 mysqld_safe Number of processes running now: 0
Nov 11 09:05:14 jupiter-clean mysqld_safe[6403]: 151111 09:05:14 mysqld_safe mysqld restarted
Nov 11 09:05:14 jupiter-clean mysqld_safe[6403]: 151111 09:05:14 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

Here's the /var/log/mysql/error.log:

151111 09:05:14 mysqld_safe Number of processes running now: 0
151111 09:05:14 mysqld_safe mysqld restarted
2015-11-11 09:05:14 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-11-11 09:05:14 0 [Note] /usr/sbin/mysqld (mysqld 5.6.27-0ubuntu1) starting as process 6929 ...
2015-11-11 09:05:14 6929 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)

2015-11-11 09:05:14 6929 [Warning] Buffered warning: Changed limits: table_open_cache: 431 (requested 2000)

2015-11-11 09:05:14 6929 [Warning] Using unique option prefix myisam-recover instead of myisam-recover-options is deprecated and will be removed in a future release. Please use the full name instead.
2015-11-11 09:05:14 6929 [Note] Plugin 'FEDERATED' is disabled.
2015-11-11 09:05:14 6929 [ERROR] Function 'innodb' already exists
2015-11-11 09:05:14 6929 [Warning] Couldn't load plugin named 'innodb' with soname 'ha_innodb.so'.
2015-11-11 09:05:14 6929 [ERROR] Function 'federated' already exists
2015-11-11 09:05:14 6929 [Warning] Couldn't load plugin named 'federated' with soname 'ha_federated.so'.
2015-11-11 09:05:14 6929 [ERROR] Function 'blackhole' already exists
2015-11-11 09:05:14 6929 [Warning] Couldn't load plugin named 'blackhole' with soname 'ha_blackhole.so'.
2015-11-11 09:05:14 6929 [ERROR] Function 'archive' already exists
2015-11-11 09:05:14 6929 [Warning] Couldn't load plugin named 'archive' with soname 'ha_archive.so'.
2015-11-11 09:05:14 6929 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-11-11 09:05:14 6929 [Note] InnoDB: The InnoDB memory heap is disabled
2015-11-11 09:05:14 6929 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-11-11 09:05:14 6929 [Note] InnoDB: Memory barrier is not used
2015-11-11 09:05:14 6929 [Note] InnoDB: Compressed tables use zlib 1.2.8
2015-11-11 09:05:14 6929 [Note] InnoDB: Using Linux native AIO
2015-11-11 09:05:14 6929 [Note] InnoDB: Using CPU crc32 instructions
2015-11-11 09:05:14 6929 [Note] InnoDB: Initializing buffer pool, size = 128.0M
InnoDB: mmap(137363456 bytes) failed; errno 12
2015-11-11 09:05:14 6929 [ERROR] InnoDB: Cannot allocate memory for the buffer pool
2015-11-11 09:05:14 6929 [ERROR] Plugin 'InnoDB' init function returned error.
2015-11-11 09:05:14 6929 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2015-11-11 09:05:14 6929 [ERROR] Unknown/unsupported storage engine: InnoDB
2015-11-11 09:05:14 6929 [ERROR] Aborting

2015-11-11 09:05:14 6929 [Note] Binlog end
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'partition'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'BLACKHOLE'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'ARCHIVE'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'PERFORMANCE_SCHEMA'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_SYS_DATAFILES'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_SYS_TABLESPACES'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN_COLS'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_SYS_FOREIGN'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_SYS_FIELDS'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_SYS_COLUMNS'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_SYS_INDEXES'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_SYS_TABLESTATS'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_SYS_TABLES'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_FT_INDEX_TABLE'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_FT_INDEX_CACHE'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_FT_CONFIG'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_FT_BEING_DELETED'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_FT_DELETED'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_FT_DEFAULT_STOPWORD'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_METRICS'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_BUFFER_POOL_STATS'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE_LRU'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_BUFFER_PAGE'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX_RESET'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_CMP_PER_INDEX'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_CMPMEM_RESET'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_CMPMEM'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_CMP_RESET'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_CMP'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_LOCK_WAITS'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_LOCKS'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'INNODB_TRX'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'CSV'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'MEMORY'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'MRG_MYISAM'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'MyISAM'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'sha256_password'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'mysql_old_password'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'mysql_native_password'
2015-11-11 09:05:14 6929 [Note] Shutting down plugin 'binlog'
2015-11-11 09:05:14 6929 [Note] /usr/sbin/mysqld: Shutdown complete

151111 09:05:14 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

Here's syslog:

Nov 11 08:48:21 localhost systemd[1]: Starting MySQL Community Server...
Nov 11 08:48:21 localhost mysqld_safe[6403]: 151111 08:48:21 mysqld_safe Can't log to error log and syslog at the same time.  Remove all --log-error configuration options for --syslog to take effect.
Nov 11 08:48:21 localhost mysqld_safe[6403]: 151111 08:48:21 mysqld_safe Logging to '/var/log/mysql/error.log'.
Nov 11 08:48:21 localhost mysqld_safe[6403]: 151111 08:48:21 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Nov 11 08:48:21 localhost kernel: [ 4919.689076] audit: type=1400 audit(1447220901.895:21): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/usr/my.cnf" pid=6761 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=108 ouid=0
Nov 11 08:48:22 localhost systemd[1]: Started MySQL Community Server.
Nov 11 08:55:33 localhost systemd[1]: session-16.scope: Cannot determine UID from slice user-0.slice
Nov 11 08:55:33 localhost systemd[1]: Started Session 16 of user root.
Nov 11 09:00:01 localhost CRON[6841]: (smmsp) CMD (test -x /etc/init.d/sendmail && test -x /usr/share/sendmail/sendmail && test -x /usr/lib/sm.bin/sendmail && /usr/share/sendmail/sendmail cron-msp)
Nov 11 09:03:01 localhost systemd[1]: Started MySQL Community Server.
Nov 11 09:05:14 localhost kernel: [ 5931.833511] php5-fpm invoked oom-killer: gfp_mask=0x201da, order=0, oom_score_adj=0
Nov 11 09:05:14 localhost kernel: [ 5931.833529] php5-fpm cpuset=/ mems_allowed=0
Nov 11 09:05:14 localhost kernel: [ 5931.833582] CPU: 0 PID: 6914 Comm: php5-fpm Not tainted 4.2.0-16-generic #19-Ubuntu
Nov 11 09:05:14 localhost kernel: [ 5931.833589] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
Nov 11 09:05:14 localhost kernel: [ 5931.833600]  0000000000000000 000000002c9946d9 ffff88000f5ff958 ffffffff817e8c09
Nov 11 09:05:14 localhost kernel: [ 5931.833609]  0000000000000000 ffff88001cf16e00 ffff88000f5ff9e8 ffffffff817e69ff
Nov 11 09:05:14 localhost kernel: [ 5931.833613]  ffffffff810c3d61 0000000000000000 0000000000000001 0000000000000000
Nov 11 09:05:14 localhost kernel: [ 5931.833616] Call Trace:
Nov 11 09:05:14 localhost kernel: [ 5931.833674]  [] dump_stack+0x45/0x57
Nov 11 09:05:14 localhost kernel: [ 5931.833682]  [] dump_header+0x8c/0x214
Nov 11 09:05:14 localhost kernel: [ 5931.833716]  [] ? __raw_callee_save___pv_queued_spin_unlock+0x11/0x20
Nov 11 09:05:14 localhost kernel: [ 5931.833739]  [] oom_kill_process+0x1e1/0x3b0
Nov 11 09:05:14 localhost kernel: [ 5931.833744]  [] out_of_memory+0x556/0x5b0
Nov 11 09:05:14 localhost kernel: [ 5931.833749]  [] __alloc_pages_nodemask+0x8c1/0xa10
Nov 11 09:05:14 localhost kernel: [ 5931.833771]  [] alloc_pages_current+0x91/0x100
Nov 11 09:05:14 localhost kernel: [ 5931.833776]  [] __page_cache_alloc+0xa0/0xc0
Nov 11 09:05:14 localhost kernel: [ 5931.833780]  [] filemap_fault+0x14a/0x3f0
Nov 11 09:05:14 localhost kernel: [ 5931.833790]  [] __do_fault+0x50/0xe0
Nov 11 09:05:14 localhost kernel: [ 5931.833795]  [] handle_mm_fault+0xf5b/0x17e0
Nov 11 09:05:14 localhost kernel: [ 5931.833804]  [] ? __wake_up+0x48/0x60
Nov 11 09:05:14 localhost kernel: [ 5931.833809]  [] ? __raw_callee_save___pv_queued_spin_unlock+0x11/0x20
Nov 11 09:05:14 localhost kernel: [ 5931.833826]  [] __do_page_fault+0x197/0x400
Nov 11 09:05:14 localhost kernel: [ 5931.833831]  [] trace_do_page_fault+0x37/0xa0
Nov 11 09:05:14 localhost kernel: [ 5931.833840]  [] do_async_page_fault+0x19/0x70
Nov 11 09:05:14 localhost kernel: [ 5931.833848]  [] async_page_fault+0x28/0x30
Nov 11 09:05:14 localhost kernel: [ 5931.833855] Mem-Info:
Nov 11 09:05:14 localhost kernel: [ 5931.833865] active_anon:112864 inactive_anon:1012 isolated_anon:0
Nov 11 09:05:14 localhost kernel: [ 5931.833865]  active_file:270 inactive_file:324 isolated_file:0
Nov 11 09:05:14 localhost kernel: [ 5931.833865]  unevictable:0 dirty:0 writeback:0 unstable:0
Nov 11 09:05:14 localhost kernel: [ 5931.833865]  slab_reclaimable:2725 slab_unreclaimable:2449
Nov 11 09:05:14 localhost kernel: [ 5931.833865]  mapped:9930 shmem:16693 pagetables:1403 bounce:0
Nov 11 09:05:14 localhost kernel: [ 5931.833865]  free:1156 free_pcp:30 free_cma:0
Nov 11 09:05:14 localhost kernel: [ 5931.833873] Node 0 DMA free:1972kB min:88kB low:108kB high:132kB active_anon:12808kB inactive_anon:60kB active_file:0kB inactive_file:0kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:15992kB managed:15908kB mlocked:0kB dirty:0kB writeback:0kB mapped:1260kB shmem:1660kB slab_reclaimable:252kB slab_unreclaimable:312kB kernel_stack:32kB pagetables:132kB unstable:0kB bounce:0kB free_pcp:0kB local_pcp:0kB free_cma:0kB writeback_tmp:0kB pages_scanned:0 all_unreclaimable? yes
Nov 11 09:05:14 localhost kernel: [ 5931.833890] lowmem_reserve[]: 0 471 471 471
Nov 11 09:05:14 localhost kernel: [ 5931.833898] Node 0 DMA32 free:2652kB min:2732kB low:3412kB high:4096kB active_anon:438648kB inactive_anon:3988kB active_file:1080kB inactive_file:1296kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:507896kB managed:484772kB mlocked:0kB dirty:0kB writeback:0kB mapped:38460kB shmem:65112kB slab_reclaimable:10648kB slab_unreclaimable:9484kB kernel_stack:1680kB pagetables:5480kB unstable:0kB bounce:0kB free_pcp:120kB local_pcp:120kB free_cma:0kB writeback_tmp:0kB pages_scanned:16600 all_unreclaimable? yes
Nov 11 09:05:14 localhost kernel: [ 5931.833906] lowmem_reserve[]: 0 0 0 0
Nov 11 09:05:14 localhost kernel: [ 5931.833910] Node 0 DMA: 17*4kB (UM) 6*8kB (UM) 4*16kB (U) 0*32kB 10*64kB (UM) 7*128kB (UEM) 1*256kB (M) 0*512kB 0*1024kB 0*2048kB 0*4096kB = 1972kB
Nov 11 09:05:14 localhost kernel: [ 5931.833936] Node 0 DMA32: 205*4kB (UE) 161*8kB (E) 34*16kB (UE) 0*32kB 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 2652kB
Nov 11 09:05:14 localhost kernel: [ 5931.833958] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=1048576kB
Nov 11 09:05:14 localhost kernel: [ 5931.833960] Node 0 hugepages_total=0 hugepages_free=0 hugepages_surp=0 hugepages_size=2048kB
Nov 11 09:05:14 localhost kernel: [ 5931.833962] 17296 total pagecache pages
Nov 11 09:05:14 localhost kernel: [ 5931.833971] 0 pages in swap cache
Nov 11 09:05:14 localhost kernel: [ 5931.833974] Swap cache stats: add 0, delete 0, find 0/0
Nov 11 09:05:14 localhost kernel: [ 5931.833976] Free swap  = 0kB
Nov 11 09:05:14 localhost kernel: [ 5931.833978] Total swap = 0kB
Nov 11 09:05:14 localhost kernel: [ 5931.833981] 130972 pages RAM
Nov 11 09:05:14 localhost kernel: [ 5931.833984] 0 pages HighMem/MovableOnly
Nov 11 09:05:14 localhost kernel: [ 5931.833987] 5802 pages reserved
Nov 11 09:05:14 localhost kernel: [ 5931.833989] 0 pages cma reserved
Nov 11 09:05:14 localhost kernel: [ 5931.833991] 0 pages hwpoisoned
Nov 11 09:05:14 localhost kernel: [ 5931.833994] [ pid ]   uid  tgid total_vm      rss nr_ptes nr_pmds swapents oom_score_adj name
Nov 11 09:05:14 localhost kernel: [ 5931.834004] [  203]     0   203    31441      610      64       3        0             0 systemd-journal
Nov 11 09:05:14 localhost kernel: [ 5931.834019] [  210]     0   210    10965      164      21       3        0         -1000 systemd-udevd
Nov 11 09:05:14 localhost kernel: [ 5931.834030] [  498]   100   498    25075       65      20       3        0             0 systemd-timesyn
Nov 11 09:05:14 localhost kernel: [ 5931.834036] [  558]   104   558    64093      207      28       4        0             0 rsyslogd
Nov 11 09:05:14 localhost kernel: [ 5931.834042] [  565]     0   565     7135       76      18       3        0             0 systemd-logind
Nov 11 09:05:14 localhost kernel: [ 5931.834047] [  584]   105   584    10715      112      26       3        0          -900 dbus-daemon
Nov 11 09:05:14 localhost kernel: [ 5931.834052] [  604]     0   604     7599       69      20       3        0             0 cron
Nov 11 09:05:14 localhost kernel: [ 5931.834058] [  607]     0   607    71148      215      39       3        0             0 accounts-daemon
Nov 11 09:05:14 localhost kernel: [ 5931.834062] [  651]     0   651     6015       95      15       3        0             0 vsftpd
Nov 11 09:05:14 localhost kernel: [ 5931.834068] [  736]     0   736    62752     2266      78       4        0             0 php5-fpm
Nov 11 09:05:14 localhost kernel: [ 5931.834073] [  857]     0   857    26139      485      49       3        0             0 sendmail-mta
Nov 11 09:05:14 localhost kernel: [ 5931.834079] [ 1143]     0  1143    17493      191      38       4        0         -1000 sshd
Nov 11 09:05:14 localhost kernel: [ 5931.834082] [ 1148]     0  1148     4330       41      13       3        0             0 agetty
Nov 11 09:05:14 localhost kernel: [ 5931.834085] [ 1161]     0  1161    58312      737      53       4        0             0 nginx
Nov 11 09:05:14 localhost kernel: [ 5931.834088] [ 1168]     0  1168     9184      202      22       3        0             0 systemd
Nov 11 09:05:14 localhost kernel: [ 5931.834091] [ 1169]     0  1169    14725      438      32       3        0             0 (sd-pam)
Nov 11 09:05:14 localhost kernel: [ 5931.834094] [ 1192]     0  1192    24962      257      52       3        0             0 sshd
Nov 11 09:05:14 localhost kernel: [ 5931.834097] [ 1210]     0  1210     5914      395      16       3        0             0 bash
Nov 11 09:05:14 localhost kernel: [ 5931.834099] [ 1382]  1001  1382    58355      884      51       4        0             0 nginx
Nov 11 09:05:14 localhost kernel: [ 5931.834103] [ 5879]  1001  5879    74907    22161     118       4        0             0 php5-fpm
Nov 11 09:05:14 localhost kernel: [ 5931.834106] [ 6339]  1001  6339    75760    22995     117       4        0             0 php5-fpm
Nov 11 09:05:14 localhost kernel: [ 5931.834109] [ 6341]  1001  6341    72891    20096     112       4        0             0 php5-fpm
Nov 11 09:05:14 localhost kernel: [ 5931.834112] [ 6403]   108  6403     1119       39       8       3        0             0 mysqld_safe
Nov 11 09:05:14 localhost kernel: [ 5931.834115] [ 6761]   108  6761   248107    29148     112       4        0             0 mysqld
Nov 11 09:05:14 localhost kernel: [ 5931.834118] [ 6820]     0  6820    24962      270      52       3        0             0 sshd
Nov 11 09:05:14 localhost kernel: [ 5931.834121] [ 6838]     0  6838     3216       61      12       3        0             0 sftp-server
Nov 11 09:05:14 localhost kernel: [ 5931.834124] [ 6912]  1001  6912    75446    14104      98       4        0             0 php5-fpm
Nov 11 09:05:14 localhost kernel: [ 5931.834126] [ 6914]  1001  6914    75006    13555      96       4        0             0 php5-fpm
Nov 11 09:05:14 localhost kernel: [ 5931.834129] Out of memory: Kill process 6761 (mysqld) score 233 or sacrifice child
Nov 11 09:05:14 localhost kernel: [ 5931.834552] Killed process 6761 (mysqld) total-vm:992428kB, anon-rss:116592kB, file-rss:0kB
Nov 11 09:05:14 localhost mysqld_safe[6403]: 151111 09:05:14 mysqld_safe Number of processes running now: 0
Nov 11 09:05:14 localhost mysqld_safe[6403]: 151111 09:05:14 mysqld_safe mysqld restarted
Nov 11 09:05:14 localhost kernel: [ 5931.983543] audit: type=1400 audit(1447221914.187:22): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/usr/my.cnf" pid=6929 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=108 ouid=0
Nov 11 09:05:14 localhost mysqld_safe[6403]: 151111 09:05:14 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

I' running ubuntu 15.10, mysql 5.6.27, nginx 1.9.6, PHP 5.6.11-1ubuntu3.1 (fpm-fcgi).

So, how to fix that?

And, being a newbie at mysql, I wonder why mysql is so fragile and can be so easily killed (and make the whole bunch of sites connected to it unavailable). How to make it more robust?

Best Answer

"Nov 11 09:05:14 localhost kernel: [ 5931.834129] Out of memory: Kill process 6761 (mysqld) score 233 or sacrifice child"

You are crossing system memory and then kernel is killing highest user of memory - in your case that'd be mysqld. Consider revising mysql global and per-thread variables in order to limit total usage under control. You may use this procedure to estimate MySQL memory usage or you might want to fill in here to check the usage details.

Also... Swapping is not good for MySQL, it's better to have swappiness set to 1-10 or 0 depending on your kernel version. Refer here.