VPS服务器LAMP - 建立数据库连接时出错

时间:2016-09-30 14:57:08

标签: mysql apache server lamp vps

我在LAMP服务器上有wordpress然后经常关闭。 错误消息是"建立数据库连接错误"。我不知道为什么! db的用户和密码是正确的,如果我重新启动所有服务器都会再次运行。

VPS有2GB的内存。 我在1024M和wordpress配置

中升级php.ini中的php限制

我不明白为什么服务器总是坏掉,请帮助我! 这里是syslog:

   /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/lib/php5 ] && /usr/lib/php5/sessionclean /var/lib/php5 $(/usr/lib/php5/maxlifetime))
Sep 29 11:29:02 vps142555 -- MARK --
Sep 29 11:32:01 vps142555 /USR/SBIN/CRON[6000]: (root) CMD (cd / && run-parts --report /etc/cron.hourly)
Sep 29 11:39:01 vps142555 /USR/SBIN/CRON[6004]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/lib/php5 ] && /usr/lib/php5/sessionclean /var/lib/php5 $(/usr/lib/php5/maxlifetime))
Sep 29 11:59:33 vps142555 -- MARK --
Sep 29 12:09:01 vps142555 /USR/SBIN/CRON[6024]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime ] && [ -x /usr/lib/php5/sessionclean ] && [ -d /var/lib/php5 ] && /usr/lib/php5/sessionclean /var/lib/php5 $(/usr/lib/php5/maxlifetime))
Sep 29 12:32:01 vps142555 /USR/SBIN/CRON[6048]: (root) CMD (cd / && run-parts --report /etc/cron.hourly)
Sep 29 12:37:06 vps142555 kernel: [2410889.511488] Out of memory in UB 142555: OOM killed process 1996 (mysqld) score 0 vm:488652kB, rss:67976kB, swap:39012kB
Sep 29 12:37:08 vps142555 kernel: [2410891.904013] Out of memory in UB 142555: OOM killed process 4997 (apache2) score 0 vm:238648kB, rss:47692kB, swap:2812kB
Sep 29 12:37:11 vps142555 mysqld_safe: Number of processes running now: 0
Sep 29 12:37:11 vps142555 mysqld_safe: mysqld restarted
Sep 29 12:37:13 vps142555 kernel: [2410895.275214] Out of memory in UB 142555: OOM killed process 5978 (apache2) score 0 vm:240468kB, rss:49756kB, swap:2460kB
Sep 29 12:37:14 vps142555 kernel: [2410896.933917] Out of memory in UB 142555: OOM killed process 5976 (apache2) score 0 vm:238232kB, rss:47720kB, swap:2672kB
Sep 29 12:37:13 vps142555 mysqld: 160929 12:37:13 [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.
Sep 29 12:37:14 vps142555 mysqld: 160929 12:37:14 [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.
Sep 29 12:37:14 vps142555 mysqld: 160929 12:37:14 [Note] Plugin 'FEDERATED' is disabled.
Sep 29 12:37:14 vps142555 mysqld: 160929 12:37:14 InnoDB: The InnoDB memory heap is disabled
Sep 29 12:37:14 vps142555 mysqld: 160929 12:37:14 InnoDB: Mutexes and rw_locks use GCC atomic builtins
Sep 29 12:37:14 vps142555 mysqld: 160929 12:37:14 InnoDB: Compressed tables use zlib 1.2.7
Sep 29 12:37:14 vps142555 mysqld: 160929 12:37:14 InnoDB: Using Linux native AIO
Sep 29 12:37:15 vps142555 kernel: [2410897.519920] Out of memory in UB 142555: OOM killed process 5941 (apache2) score 0 vm:236836kB, rss:30424kB, swap:17708kB
Sep 29 12:37:14 vps142555 mysqld: 160929 12:37:14 InnoDB: Initializing buffer pool, size = 128.0M
Sep 29 12:37:15 vps142555 kernel: [2410898.744883] Out of memory in UB 142555: OOM killed process 5955 (apache2) score 0 vm:232268kB, rss:23744kB, swap:22364kB
Sep 29 12:37:16 vps142555 kernel: [2410899.545623] Out of memory in UB 142555: OOM killed process 6061 (apache2) score 0 vm:230300kB, rss:38016kB, swap:6004kB
Sep 29 12:37:16 vps142555 mysqld: 160929 12:37:16 InnoDB: Completed initialization of buffer pool
Sep 29 12:37:17 vps142555 kernel: [2410900.015311] Out of memory in UB 142555: OOM killed process 6062 (apache2) score 0 vm:227740kB, rss:34284kB, swap:7128kB
Sep 29 12:37:17 vps142555 kernel: [2410900.690501] Out of memory in UB 142555: OOM killed process 5980 (apache2) score 0 vm:222252kB, rss:30612kB, swap:6816kB
Sep 29 12:37:17 vps142555 mysqld: 160929 12:37:17 InnoDB: highest supported file format is Barracuda.
Sep 29 12:37:17 vps142555 mysqld: InnoDB: Log scan progressed past the checkpoint lsn 2365452992
Sep 29 12:37:17 vps142555 mysqld: 160929 12:37:17  InnoDB: Database was not shut down normally!
Sep 29 12:37:17 vps142555 mysqld: InnoDB: Starting crash recovery.
Sep 29 12:37:17 vps142555 mysqld: InnoDB: Reading tablespace information from the .ibd files...
Sep 29 12:37:18 vps142555 mysqld: InnoDB: Restoring possible half-written data pages from the doublewrite
Sep 29 12:37:18 vps142555 mysqld: InnoDB: buffer...
Sep 29 12:37:18 vps142555 kernel: [2410901.336589] Out of memory in UB 142555: OOM killed process 5977 (apache2) score 0 vm:222000kB, rss:14816kB, swap:21748kB
Sep 29 12:37:18 vps142555 kernel: [2410901.723385] Out of memory in UB 142555: OOM killed process 6057 (apache2) score 0 vm:222544kB, rss:30148kB, swap:6068kB
Sep 29 12:37:18 vps142555 mysqld: InnoDB: Doing recovery: scanned up to log sequence number 2365502829
Sep 29 12:37:19 vps142555 kernel: [2410902.245687] Out of memory in UB 142555: OOM killed process 6071 (apache2) score 0 vm:223576kB, rss:34220kB, swap:3200kB
Sep 29 12:37:19 vps142555 kernel: [2410903.117311] Out of memory in UB 142555: OOM killed process 6335 (mysqld) score 0 vm:344240kB, rss:38588kB, swap:0kB
Sep 29 12:37:20 vps142555 kernel: [2410903.724624] Out of memory in UB 142555: OOM killed process 6077 (apache2) score 0 vm:223832kB, rss:29632kB, swap:7960kB
Sep 29 12:37:20 vps142555 kernel: [2410904.218604] Out of memory in UB 142555: OOM killed process 6064 (apache2) score 0 vm:222544kB, rss:23472kB, swap:12720kB
Sep 29 12:37:21 vps142555 kernel: [2410904.505518] OOM killer in rage, 1 tasks killed
Sep 29 12:37:21 vps142555 kernel: [2410904.505694] Out of memory in UB 142555: OOM killed process 6073 (apache2) score 0 vm:222544kB, rss:23692kB, swap:12588kB
Sep 29 12:37:21 vps142555 mysqld_safe: mysqld from pid file /var/run/mysqld/mysqld.pid ended
Sep 29 12:37:22 vps142555 kernel: [2410905.456095] OOM killer in rage, 2 tasks killed
Sep 29 12:37:22 vps142555 kernel: [2410905.456283] Out of memory in UB 142555: OOM killed process 6074 (apache2) score 0 vm:222544kB, rss:24760kB, swap:11536kB
Sep 29 12:37:23 vps142555 kernel: [2410906.469929] Out of memory in UB 142555: OOM killed process 6078 (apache2) score 0 vm:222544kB, rss:29304kB, swap:7268kB
Sep 29 12:37:23 vps142555 kernel: [2410906.972042] Out of memory in UB 142555: OOM killed process 6081 (apache2) score 0 vm:221256kB, rss:27988kB, swap:7444kB
Sep 29 12:37:24 vps142555 kernel: [2410907.732515] Out of memory in UB 142555: OOM killed process 6099 (apache2) score 0 vm:223576kB, rss:27932kB, swap:9608kB
Sep 29 12:37:26 vps142555 kernel: [2410909.311145] Out of memory in UB 142555: OOM killed process 6080 (apache2) score 0 vm:222588kB, rss:27872kB, swap:8680kB
Sep 29 12:37:27 vps142555 kernel: [2410910.762627] Out of memory in UB 142555: OOM killed process 6090 (apache2) score 0 vm:223832kB, rss:25812kB, swap:11936kB
Sep 29 12:37:29 vps142555 kernel: [2410912.842178] Out of memory in UB 142555: OOM killed process 6089 (apache2) score 0 vm:224084kB, rss:32840kB, swap:5748kB
Sep 29 12:37:30 vps142555 kernel: [2410913.865956] Out of memory in UB 142555: OOM killed process 6087 (apache2) score 0 vm:223832kB, rss:29124kB, swap:8940kB

2 个答案:

答案 0 :(得分:1)

Sep 29 12:37:14 vps142555 mysqld: 160929 12:37:14 InnoDB: Initializing buffer pool, size = 128.0M
Sep 29 12:37:15 vps142555 kernel: [2410898.744883] Out of memory in UB 142555: OOM killed process 5955 (apache2) score 0 vm:232268kB, rss:23744kB, swap:22364kB
Sep 29 12:37:16 vps142555 kernel: [2410899.545623] Out of memory in UB 142555: OOM killed process 6061 (apache2) score 0 vm:230300kB, rss:38016kB, swap:6004kB

查看日志

内核已杀死mysqld,因为它没有为innodb缓冲池分配的内存。检查谁在吃记忆。

因为内核已经停止了mysql,这就是显示连接问题的原因。

答案 1 :(得分:0)

php版本中存在一个奇怪的错误,所有错误都在内存中。 我升级了php版本并解决了这个问题。 TKS