Sunday, January 20, 2013

mysql启动时报错

mysql启动时报错: [Note] Plugin 'FEDERATED' is disabled. Plugin 'ndbcluster' is disabled 

通过innobackupex对mysql进行数据恢复时,恢复完成后导致mysql服务不能正常启动了。。。

innobackupex --defaults-file=/etc/my.cnf --copy-back /data/2012-04-09_00-05-09/


这两天在对mysql数据库进行迁移时,碰到一些小问题,导致恢复后mysql服务无法正常启动,错误日志如下:

120409 13:47:17 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
120409 13:47:18 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
120409 13:47:18 [Warning] '--default-character-set' is deprecated and will be removed in a future release. Please use '--character-set-server' instead.
120409 13:47:18 [Note] Plugin 'FEDERATED' is disabled.
120409 13:47:18 [Note] Plugin 'ndbcluster' is disabled.
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use GCC atomic builtins
120409 13:47:19  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name /usr/local/mysql/data/ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
120409 13:47:19 mysqld_safe mysqld from pid file /usr/local/mysql/data/mysql-db.pid ended


再看看,libdata1的文件大小:

# ls -lh /usr/local/mysql/data/

-rw-r--r-- 1 root  root  1073741824 03-29 00:40 ibdata1
-rw-r--r-- 1 root  root 51287949312 03-29 00:40 ibdata2
-rw-r--r-- 1 root  root  1073741824 03-29 00:40 ibdata3
-rw-r--r-- 1 root  root  5343543296 03-29 00:40 ibdata4

再看下/etc/my.cnf配置文件:

innodb_data_file_path = ibdata1:1000M:autoextend

问题原因,mysql/data目录下的ibdata1文件大小和配置文件里的文件大小不一致造成
原来配置文件里设置的libdata的二进制数据目录就一个,且数据大小也设置过低,需要做下改动(按恢复的数据文件大小来设置),设置如下:

innodb_data_file_path = ibdata1:1024M;ibdata2:48912M;ibdata3:1024M;ibdata4:1024M:autoextend]


再次启动mysql服务,还是报错。。原来是属主权限不对:

120409 14:24:39 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
120409 14:24:39 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
120409 14:24:39 [Warning] '--default-character-set' is deprecated and will be removed in a future release. Please use '--character-set-server' instead.
120409 14:24:39 [Note] Plugin 'FEDERATED' is disabled.
120409 14:24:39 [Note] Plugin 'ndbcluster' is disabled.
InnoDB: The InnoDB memory heap is disabled
InnoDB: Mutexes and rw_locks use GCC atomic builtins
120409 14:24:40  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name /usr/local/mysql/data/ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
120409 14:24:40 mysqld_safe mysqld from pid file /usr/local/mysql/data/mysql-db.pid ended

将数据目录权限改为mysql用户所有:

# chown -R mysql.mysql ../data

OK,再次启动,就可以了。。