我每次启动mysql,使用/etc/init.d/mysql启动或服务mysql启动,它总是超时。
* Starting MySQL (Percona Server) database server mysqld [fail]
但是,我可以进入MySQL。 只是想知道是否安装有问题,因为它一直在发生,而不是一个错误。
mysql-error.log显示:
121214 11:25:56 mysqld_safe Starting mysqld daemon with databases from /data/mysql/ 121214 11:25:56 [Note] Plugin 'FEDERATED' is disabled. 121214 11:25:56 InnoDB: The InnoDB memory heap is disabled 121214 11:25:56 InnoDB: Mutexes and rw_locks use GCC atomic builtins 121214 11:25:56 InnoDB: Compressed tables use zlib 1.2.3 121214 11:25:56 InnoDB: Using Linux native AIO 121214 11:25:56 InnoDB: Initializing buffer pool, size = 14.0G 121214 11:25:58 InnoDB: Completed initialization of buffer pool 121214 11:26:01 InnoDB: Waiting for the background threads to start 121214 11:26:02 Percona XtraDB (http://www.percona.com) 1.1.8-rel29.2 started; log sequence number 9333955393950 121214 11:26:02 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306 121214 11:26:02 [Note] - '0.0.0.0' resolves to '0.0.0.0'; 121214 11:26:02 [Note] Server socket created on IP: '0.0.0.0'. 121214 11:26:02 [Note] Slave SQL thread initialized, starting replication in log 'mysql-bin.005163' at position 624540946, relay log '/data/mysql/mysql-relay-bin.000043' position: 624541092 121214 11:26:02 [Note] Slave I/O thread: connected to master '[email protected]:3306',replication started in log 'mysql-bin.005180' at position 823447620 121214 11:26:02 [Note] Event Scheduler: Loaded 0 events 121214 11:26:02 [Note] /usr/sbin/mysqld: ready for connections. Version: '5.5.28-29.2-log' socket: '/data/mysql/mysql.sock' port: 3306 Percona Server (GPL), Release 29.2
错误日志的显示看起来很正常
Socket文件被创buildMySQL复制启动就好了/usr/sbin/mysqld: ready for connections. 出现
特别是你看到/usr/sbin/mysqld: ready for connections. ,你应该可以连接到你刚才说的你可以的mysql。
你的mysqld进程很好。
这个错误可能来自于/etc/init.d/mysql但是在mysqld完成了所有其他事情之前,这个错误不是必须的。
如果你看看/etc/init.d/mysql里面有两行
[root@***** init.d]$ cat mysql | grep -n "&" | grep "pid-file" 313: $manager --user=$user --pid-file=$pid_file >/dev/null 2>&1 & 327: $bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &
如果/etc/init.d/mysql超时,它肯定发生在这两行之后。
这是检查pid文件的代码
wait_for_pid () { verb="$1" manager_pid="$2" # process ID of the program operating on the pid-file i=0 avoid_race_condition="by checking again" while test $i -ne $service_startup_timeout ; do case "$verb" in 'created') # wait for a PID-file to pop into existence. test -s $pid_file && i='' && break ;; 'removed') # wait for this PID-file to disappear test ! -s $pid_file && i='' && break ;; *) echo "wait_for_pid () usage: wait_for_pid created|removed manager_pid" exit 1 ;; esac # if manager isn't running, then pid-file will never be updated if test -n "$manager_pid"; then if kill -0 "$manager_pid" 2>/dev/null; then : # the manager still runs else # The manager may have exited between the last pid-file check and now. if test -n "$avoid_race_condition"; then avoid_race_condition="" continue # Check again. fi # there's nothing that will affect the file. log_failure_msg "Manager of pid-file quit without updating file." return 1 # not waiting any more. fi fi echo $echo_n ".$echo_c" i=`expr $i + 1` sleep 1 done if test -z "$i" ; then log_success_msg return 0 else log_failure_msg return 1 fi }
在启动mysqld_safe之后调用wait_for_pid()
# Give extra arguments to mysqld with the my.cnf file. This script # may be overwritten at next upgrade. pid_file=$server_pid_file $bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 & wait_for_pid created $!; return_value=$?
在最坏的情况下,mysqld运行时没有一个pid文件。 鉴于此, service mysql stop和/etc/init.d/mysql stop可能无法正常工作,因为它会检查pid文件以知道mysqld的进程ID。
没有一个PID文件,closuresmysqld的正确方法是
# mysqladmin -uroot -h127.0.0.1 --protocol=tcp -p shutdown
这不是一个现象的地方。 我也看到这发生在标准的MySQL二进制文件。
看起来,init脚本通过使用mysqladmin --defaults-file=/etc/mysql/debian.cnf ping检查Ubuntu上正在运行的MySQL / Percona服务器(请参阅/etc/init.d/mysql中的第27和77行)在这种情况下percona-server-server-5.5软件包版本5.5.28-rel29.2-360.precise )。 这可以在默认的新安装中工作,但是当从另一台机器上复制数据文件以复制数据时, debian.cnf中configuration的用户不再匹配。
因此, mysqladmin命令将会失败,初始化脚本会报告服务失败,但是它可以正常运行,就像在日志中看到的一样。
一个解决scheme是重新创buildinit脚本期望的MySQL用户。 在主,只需添加像这样的用户(似乎默认拥有所有权限?!):
GRANT ALTER, ALTER ROUTINE, CREATE, CREATE ROUTINE, CREATE TEMPORARY TABLES, CREATE USER, CREATE VIEW, DELETE, DROP, EVENT, EXECUTE, FILE, INDEX, INSERT, LOCK TABLES, PROCESS, REFERENCES, RELOAD, REPLICATION CLIENT, REPLICATION SLAVE, SELECT, SHOW DATABASES, SHOW VIEW, SHUTDOWN, SUPER, TRIGGER, UPDATE ON *.* TO 'debian-sys-maint'@'localhost' IDENTIFIED BY PASSWORD *replacethiswithaknownhash' WITH GRANT OPTION;
并创build/修改/etc/mysql/debian.cnf文件:
[client] host = localhost user = debian-sys-maint password = yourpass socket = /var/run/mysqld/mysqld.sock [mysql_upgrade] host = localhost user = debian-sys-maint password = yourpass socket = /var/run/mysqld/mysqld.sock basedir = /usr
您可能需要等待复制过程赶上,然后尝试重新启动。
在debian上有完全相同的问题。 服务器实际上启动,但初始化脚本说它失败:
/etc/mysql/debian.cnf has the mysql socket set at /var/run/mysqld/mysqld.sock
而my.cnf有可能设置
/var/lib/mysql/mysql.sock
确保my.cnf中的套接字和pidpath指向所设置的内容
/etc/mysql/debian.cnf
另外请确保指向mysqld不是mysql
我知道这有点旧了,但它的30/4/2015和Percona 5.6有同样的问题。
/etc/init.d/mysql'start'函数具有以下内容(从ln:112开始):
#wait 10sec before start checking if pid file created or server is dead if [ $dead_check_counter -lt 10 ]; then dead_check_counter=$(( dead_check_counter + 1 )) else if mysqld_status check_dead warn; then break; fi fi
我们的服务器通常需要大约40-70秒才能启动(一个97GB的innodb缓冲池的初始化大约需要35秒),所以自然的“开始”报告它已经死了,因为套接字文件还没有创build。
我刚刚增加了“10”的价值,并为我工作得很好。
干杯