[转帖]MySQL多实例启动失败 重新初始化数据库要把目录里的文件删除干净_MySQL, Oracle及数据库讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  MySQL, Oracle及数据库讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 1974 | 回复: 0   主题: [转帖]MySQL多实例启动失败 重新初始化数据库要把目录里的文件删除干净        下一篇 
zlasdf
注册用户
等级:新兵
经验:72
发帖:70
精华:0
注册:2011-10-17
状态:离线
发送短消息息给zlasdf 加好友    发送短消息息给zlasdf 发消息
发表于: IP:您无权察看 2014-11-7 14:18:19 | [全部帖] [楼主帖] 楼主

    事情发生在5日,视频“L10-008-lamp环境之MySQL多实例安装配置指南”看到第2857秒的时候。
  在视频里,oldboy故意让多实例启动没有成功,并进行处理。但我在按照视频里的操作步骤执行时,却出现问题。授权、删除文件之后,重新初始化数据库文件,在启动显示正常的情况下,“netstat”命令却没有显示启动成功。于是,我又一次陷入解决问题的漫长过程。
  先是根据错误日志,去百度查资料:

[root@Web 3306]# tail mysql_oldboy3306.err
InnoDB: Setting log file ./ib_logfile2 size to 4 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
140605 16:37:06  InnoDB: Started; log sequence number 0 0
/usr/local/mysql/libexec/mysqld: Error writing file '/data/3306/slow.log' (Errcode: 28)
:
:
[root@Web 3306]# tail /data/3307/mysql_oldboy3307.err
InnoDB: Some operating system error numbers are described at
InnoDB: http://dev.mysql.com/doc/refman/5.1/en/operating-system-error-codes.html
InnoDB: Error in creating ./ibdata1: probably out of disk space
140605 16:37:05 [ERROR] Plugin 'InnoDB' init function returned error.
140605 16:37:05 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
/usr/local/mysql/libexec/mysqld: Error writing file '/data/3307/slow.log' (Errcode: 28)
140605 16:37:06 [ERROR] Unknown/unsupported table type: InnoDB
140605 16:37:06 [ERROR] Aborting


140605 16:37:06 mysqld_safe mysqld from pid file /data/3307/mysqld.pid ended   但是,根据日志里信息,在百度上找到的信息没有一点有用的。当然,上面的信息也不过是一小部分。
  在想办法的过程中,我曾经多次只保留目录里的2个文件:

[root@Web 3306]# ll
total 5
drwxr-xr-x 4 mysql mysql 1024 Jun  5 20:30 data
-rw-r--r-- 1 mysql mysql 1887 Apr 12  2012 my.cnf
-rwx------ 1 mysql mysql 1053 Apr 12  2012 mysql   但就是没有敢删除data目录里的mysql子目录里的文件,因为mysql目录里面的文件都是初始化数据库产生的文件。


  在我针对一些方法反复尝试都失败(其实都是一些无用功),又到山穷水尽的时候,我开始越看mysql目录里的文件越不顺眼。因为问题拖了3、4个小时,但在我反复初始化数据库3次之后,mysql目录里的文件还是我第1次初始化的时间戳。
  我就感觉有点不对劲。
  抱着彻底没招,如果还不行就去oldboy QQ群里提问的想法,我决心把data/mysql里面的所有文件也全部删除。大不了,就重新安装数据库。
  奇迹,就这样出现了。
  下面是3307实例的解决步骤:

[root@Web 3306]# cd ../3307
[root@Web 3307]# ll
total 8
drwxr-xr-x 4 mysql mysql 1024 Jun  5 20:41 data
-rw-r--r-- 1 mysql mysql 1888 Apr 12  2012 my.cnf
-rwx------ 1 mysql mysql 1038 Apr 12  2012 mysql
-rw-rw---- 1 mysql mysql 1738 Jun  5 20:41 mysql_oldboy3307.err
-rw-rw---- 1 mysql mysql  185 Jun  5 20:41 slow.log
[root@Web 3307]# rm -rf slow.log mysql_oldboy3307.err
[root@Web 3307]# ll
total 5
drwxr-xr-x 4 mysql mysql 1024 Jun  5 20:41 data
-rw-r--r-- 1 mysql mysql 1888 Apr 12  2012 my.cnf
-rwx------ 1 mysql mysql 1038 Apr 12  2012 mysql
[root@Web 3307]# cd data/
[root@Web data]# ll
total 33106
-rw-rw---- 1 mysql mysql 33763328 Jun  5 16:52 ibdata1
drwx------ 2 mysql mysql     3072 Jun  5 16:51 mysql
drwx------ 2 mysql mysql     1024 Jun  5 16:51 test
[root@Web data]# rm -rf *
[root@Web data]# cd ..   现在,只有2个文件(my.cnf和mysql)和1个空目录(data)。这样,才是正确的。
[root@Web 3307]# mysql_install_db --datadir=/data/3307/data --user=mysql
Installing MySQL system tables...
140605 21:21:50 [Warning] '--default-character-set' is deprecated and will be removed in a future release. Please use '--character-set-server' instead.
140605 21:21:50 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
Filling help tables...
140605 21:21:50 [Warning] '--default-character-set' is deprecated and will be removed in a future release. Please use '--character-set-server' instead.
140605 21:21:50 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/mysql/bin/mysqladmin -u root -h Web password 'new-password'
Alternatively you can run:
/usr/local/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/mysql/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/local/mysql/bin/mysqlbug script!


  启动MySQL实例:

[root@Web 3307]# /data/3307/mysql start
Starting MySQL...
[root@Web 3307]# netstat -lnt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 0.0.0.0:2049                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:963                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:873                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:3307                0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:51925               0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:23                  0.0.0.0:*                   LISTEN
tcp        0      0 0.0.0.0:927                 0.0.0.0:*                   LISTEN


问题解决后我才想起来要回看视频里oldboy这部分处理问题的讲解,发现他说的都没有问题。只是他删除data目录里的所有文件,都是很快的过程。现在想来,即使当时反复看,也不见得能发现这个对我而言,非常关键的地方。
  还是自己的老问题,总是抓不住重点。在一些非重点的地方,浪费太多的精力。
  在视频的这部分讲解里:oldboy发现无法启动实例后,先后进行重新授权、删除data目录里的所有文件、重新初始化数据库(加上参数“--user=mysql”)的操作(前后顺序我已经记不清了)。当时,考虑到整理文档,我实在是无法确认这3步操作那1步是对启动实例成功有效的。
  最近几次在遇到故障报错后的处理,我发现错误日志基本没有对我带来帮助。特别是这一次!在百度上搜索相关错误信息,一次次把我带到歧途,令我一次次走向崩溃。
  当然,这里只是表达一下对自己的不满。说起来,可能还是自己功夫不到家吧。
  下面的2个日志文件信息,对我就完全没有帮助。

[root@Web ~]# tail -20 /data/3306/mysql_oldboy3306.err
140605 20:26:08 mysqld_safe Starting mysqld daemon with databases from /data/3306/data
140605 20:26:08 [Warning] '--log-long-format' is deprecated and will be removed in a future release. Please use '--log-short-format' instead.
140605 20:26:08 [Warning] '--log_slow_queries' is deprecated and will be removed in a future release. Please use ''--slow_query_log'/'--slow_query_log_file'' instead.
140605 20:26:08 [Warning] --myisam_max_extra_sort_file_size is deprecated and does nothing in this version.  It will be removed in a future release.
140605 20:26:08  InnoDB: Initializing buffer pool, size = 32.0M
140605 20:26:08  InnoDB: Completed initialization of buffer pool
InnoDB: No valid checkpoint found.
InnoDB: If this error appears when you are creating an InnoDB database,
InnoDB: the problem may be that during an earlier attempt you managed
InnoDB: to create the InnoDB data files, but log file creation failed.
InnoDB: If that is the case, please refer to
InnoDB: http://dev.mysql.com/doc/refman/5.1/en/error-creating-innodb.html
140605 20:26:08 [ERROR] Plugin 'InnoDB' init function returned error.
140605 20:26:08 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140605 20:26:08 [ERROR] Unknown/unsupported table type: InnoDB
140605 20:26:08 [ERROR] Aborting
140605 20:26:08 [Note] /usr/local/mysql/libexec/mysqld: Shutdown complete
140605 20:26:08 mysqld_safe mysqld from pid file /data/3306/mysqld.pid ended
[root@Web 3307]# tail -20 mysql_oldboy3307.err
140605 20:41:14  InnoDB: Initializing buffer pool, size = 32.0M
140605 20:41:14  InnoDB: Completed initialization of buffer pool
InnoDB: Error: auto-extending data file ./ibdata1 is of a different size
InnoDB: 2048 pages (rounded down to MB) than specified in the .cnf file:
InnoDB: initial 8192 pages, max 0 (relevant if non-zero) pages!
InnoDB: Could not open or create data files.
InnoDB: If you tried to add new data files, and it failed here,
InnoDB: you should now edit innodb_data_file_path in my.cnf back
InnoDB: to what it was, and remove the new ibdata files InnoDB created
InnoDB: in this failed attempt. InnoDB only wrote those files full of
InnoDB: zeros, but did not yet use them in any way. But be careful: do not
InnoDB: remove old data files which contain your precious data!
140605 20:41:14 [ERROR] Plugin 'InnoDB' init function returned error.
140605 20:41:14 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
140605 20:41:14 [ERROR] Unknown/unsupported table type: InnoDB
140605 20:41:14 [ERROR] Aborting
140605 20:41:14 [Note] /usr/local/mysql/libexec/mysqld: Shutdown complete


140605 20:41:14 mysqld_safe mysqld from pid file /data/3307/mysqld.pid ended   也可能是最近这段时间,google始终连不上的原因。

--转自 北京联动北方科技有限公司




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论