MySQL无法在Ubuntu 16.04上重新启动


14

保存脚本后,我尝试重新启动MySQL。错误状态

Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.

运行时systemctl status mysql.service,我得到的是:

Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: activating (start-post) (Result: exit-code) since Isn 2016-09-26 17:15:28 MYT; 17s ago
  Process: 17478 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
  Process: 17474 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 17478 (code=exited, status=1/FAILURE);         : 17479 (mysql-systemd-s)
   CGroup: /system.slice/mysql.service
           └─control
             ├─17479 /bin/bash /usr/share/mysql/mysql-systemd-start post
             └─17516 sleep 1

我不确定从哪里开始解决此问题。

这是我在重启mysql之前保存的脚本:

[mysqld]
innodb_rollback_on_timeout=1
innodb_lock_wait_timeout=600
max_connections=350
log-bin=mysql-bin
binlog-format = 'ROW'

跑步journalctl -xe | tail -20给我这个:

Sep 26 17:46:29 guest mysqld[21937]: 2016-09-26T09:46:29.037709Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
Sep 26 17:46:29 guest mysqld[21937]: 2016-09-26T09:46:29.037798Z 0 [Warning] Changed limits: max_connections: 214 (requested 350)
Sep 26 17:46:29 guest mysqld[21937]: 2016-09-26T09:46:29.037809Z 0 [Warning] Changed limits: table_open_cache: 400 (requested 2000)
Sep 26 17:46:29 guest mysqld[21937]: 2016-09-26T09:46:29.187886Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
Sep 26 17:46:29 guest mysqld[21937]: 2016-09-26T09:46:29.189296Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.15-0ubuntu0.16.04.1-log) starting as process 21937 ...
Sep 26 17:46:29 guest mysqld[21937]: 2016-09-26T09:46:29.191216Z 0 [ERROR] You have enabled the binary log, but you haven't provided the mandatory server-id. Please refer to the proper server start-up parameters documentation
Sep 26 17:46:29 guest mysqld[21937]: 2016-09-26T09:46:29.191242Z 0 [ERROR] Aborting
Sep 26 17:46:29 guest mysqld[21937]: 2016-09-26T09:46:29.191255Z 0 [Note] Binlog end
Sep 26 17:46:29 guest mysqld[21937]: 2016-09-26T09:46:29.191300Z 0 [Note] /usr/sbin/mysqld: Shutdown complete
Sep 26 17:46:29 guest systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Sep 26 17:46:32 guest NetworkManager[878]: <info>  [1474883192.2910] device (eth0): Lowering IPv6 MTU (9000) to match device MTU (1500)

跑步ulimit && ulimit -Sa给我:

unlimited
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 128071
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 128071
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

1
您可以将输出追加journalctl -xe | tail -50到您的问题吗?
LD詹姆斯

@LDJames整个输出?很大 还是仅仅是最后几位?
Edd 2016年

输出将是50行。实际上,15或20行就足够了。您可以将更-50改为-15。我只是想确保包含实际发生问题的行。
LD詹姆斯

我看到了@LDJames,所以这就是tail命令的作用。我添加了journalctl -xe | tail -20输出。
Edd 2016年

2
关于“错误:您已启用二进制日志...”消息怎么办?您打算这样做吗?MySQL希望在那里有一个服务器ID,我只能从主从设置中知道。
乔斯(Jos)2016年

Answers:


8

致命错误:

MYQL无法启动,因为如Journalctl输出所示,but you haven't provided the mandatory server-id. 按照下面的代码所示添加必需的ID。

/etc/mysql/mysql.conf.d/mysqld.cnf
更改自:

log-bin=mysql-bin
binlog-format = 'ROW'

改成:

server-id=master-01
log-bin=mysql-bin
binlog-format = 'ROW'

当您解决所需日志记录的正确格式时,这将使服务器运行。

非致命警告:

对于错误的打开文件数限制,您将不得不使用以下方法来减少对编辑配置的需求,或者通过以下方式增加系统的限制:

/etc/security/limits.conf

* soft nofile [new number]
* hard nofile [new number]

第一列描述了世卫组织要申请的限额。“ ”是通配符,表示所有用户。要提高root用户的限制,您必须明确输入“ root”而不是“ ”。

摘自:https :
//askubuntu.com/a/162230/29012


工作了!是因为明确指出它是主设备吗?我尝试在server-id = 1此之前放入,但是没有用。
Edd 2016年

这些内容应在哪个文件中更改?
维杰·夏尔玛

对于mysql配置,请编辑/etc/mysql/mysql.conf.d/mysqld.cnf。有关系统的信息,open files limit请参见:/etc/security/limits.conf 。稍后,我将使用此信息更新我的答案。您能否解决问题让我知道?这样,我可以在答案中包含其他任何相关信息。
LD詹姆斯

2

遇到了同样的错误,但在我的情况下,只是磁盘已满。还要确保检查一下。

df -h --total

+1这就是给我的。释放一些空间,然后启动服务。
赛义夫'18

0

通过以下方法解决问题:

  1. 添加交换文件
  2. 添加innodb_buffer_pool_size = 20M到配置文件/etc/mysql/my.cnf以确保它在一个组中

0

我的问题是主机的IP已更改。

因此bind-address/etc/mysql/my.cnf将其编辑为正确的。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.