千家信息网

openstack是如何修复mysql问题

发表于:2024-10-20 作者:千家信息网编辑
千家信息网最后更新 2024年10月20日,本文主要给大家介绍openstack是如何修复mysql问题,文章内容都是笔者用心摘选和编辑的,openstack是如何修复mysql问题具有一定的针对性,对大家的参考意义还是比较大的,下面跟笔者一起
千家信息网最后更新 2024年10月20日openstack是如何修复mysql问题

本文主要给大家介绍openstack是如何修复mysql问题,文章内容都是笔者用心摘选和编辑的,openstack是如何修复mysql问题具有一定的针对性,对大家的参考意义还是比较大的,下面跟笔者一起了解下主题内容吧。

同事一台openstack单节点云服务器由于未知原因,无法正常工作。

远程引导同事检查故障。

[root@localhost ~]# nova-manage service list


出现错误:SQL connection failed 。貌似没有连接数据库,看来可能是服务或数据库有问题。


引导同事检测openstack服务及数据库:

[root@sxun init.d]# /etc/init.d/openstack-keystone statuskeystone (pid  12593) is running...[root@sxun init.d]# /etc/init.d/openstack-nova-api statusopenstack-nova-api (pid  7446) is running...[root@sxun init.d]# /etc/init.d/openstack-nova-compute statusopenstack-nova-compute (pid  11728) is running...[root@sxun init.d]# /etc/init.d/openstack-nova-conductor statusopenstack-nova-conductor (pid  7704) is running...[root@sxun init.d]# /etc/init.d/mysqld status
 
mysql is stoppd [root@sxun init.d]# /etc/init.d/mysqld startstarting mysqld: [FAILED]

restart也是如此,看来是mysqld服务没有启动的问题。为什么没有启动了,找到了mysqld的日志查看:


tail -100 /var/lib/mysql/sxun.err

错误日志报大致错误如下:


170420 15:00:20  InnoDB: Database was not shut down normally!InnoDB: Starting crash recovery.

......

因图不完整,引用以下网址文本http://blog.chinaunix.net/uid-27038861-id-3667209.html?bsh_bid=310758849 ,也按照其方法处,没动脑地操作了一下试试

##############以下引用#############

 130508 16:30:53 mysqld_safe Starting mysqlddaemon with databases from /data/mysql130508 16:30:54 [Warning] The syntax'--log-slow-queries' is deprecated and will be removed in a future release.Please use '--slow-query-log'/'--slow-query-log-file' instead.130508 16:30:54 InnoDB: The InnoDB memoryheap is disabled130508 16:30:54 InnoDB: Mutexes andrw_locks use GCC atomic builtins130508 16:30:54 InnoDB: Compressed tablesuse zlib 1.2.3130508 16:30:54 InnoDB: Initializing bufferpool, size = 500.0M130508 16:30:54 InnoDB: Completedinitialization of buffer pool130508 16:30:54 InnoDB: highest supportedfile format is Barracuda.InnoDB: Log scan progressed past thecheckpoint lsn 27219795678130508 16:30:54  InnoDB: Database was not shut down normally!InnoDB: Starting crash recovery.InnoDB: Reading tablespace information fromthe .ibd files...InnoDB: Restoring possible half-writtendata pages from the doublewriteInnoDB: buffer...InnoDB: Doing recovery: scanned up to logsequence number 27219928522

##############引用,中间省略#############

解决办法:
删除掉
ibdata* ,
ib_logfile* ,
所有的日志。
重启后可启动数据库,因数据库是非正常关闭引起的。所有会造成数据丢失。要做好备份工作

##############以上引用#############


[root@sxun mysql]# lltotal 225356drwx------ 2 mysql mysql      4096 Feb 15 16:06 cinderdrwx------ 2 mysql mysql      4096 Oct  1  2016 glance-rw-rw---- 1 mysql mysql 220200960 Apr 20 18:08 ibdata1-rw-rw---- 1 mysql mysql   5242880 Apr 20 18:08 ib_logfile0-rw-rw---- 1 mysql mysql   5242880 Apr 20 18:08 ib_logfile1drwx------ 2 mysql mysql      4096 Oct  1  2016 keystonedrwx------ 2 mysql mysql      4096 Oct  1  2016 mysqlsrwxrwxrwx 1 mysql mysql         0 Feb 16 14:52 mysql.sockdrwx------ 2 mysql mysql      4096 Oct  1  2016 novadrwx------ 2 mysql mysql      4096 Oct  1  2016 ovs_neutron-rw-r----- 1 mysql root      38548 Feb 16 14:52 sxun.errdrwx------ 2 mysql mysql      4096 Oct  1  2016 test

生产环境不敢删除,先移动其它地方备份记

 [root@sxun init.d]#mv ibdata*  /root/ [root@sxun init.d]#mv ib_logfile*   /root/ [root@sxun init.d]# /etc/init.d/mysqld startstarting mysqld:                   [OK]

云服务器的数据库已经是启动起来了,也生成了新的ib*文件。测试一下keystone和nova服务,但是:

[root@sxun instances]# nova-manage service listCRITICAL nova[req-97fd8f67-8a06-4ab7-b421-01d36bc6ad02 None None] (ProgrammingError) (1146,"Table 'nova.services' doesn't exist") 'SELECT services.created_at ASservices_created_at, services.updated_at AS services_updated_at,services.deleted_at AS services_deleted_at, services.deleted ASservices_deleted, services.id AS services_id, services.host AS services_host,services.`binary` AS services_binary, services.topic AS services_topic,services.report_count AS services_report_count, services.disabled ASservices_disabled, services.disabled_reason AS services_disabled_reason \nFROMservices \nWHERE services.deleted = %s' (0,)  [root@sxun instances]# keystone user-listAuthorization Failed: An unexpected errorprevented the server from fulfilling your request. (ProgrammingError) (1146,"Table 'keystone.domain' doesn't exist") 'SELECT domain.id ASdomain_id, domain.name AS domain_name, domain.enabled AS domain_enabled,domain.extra AS domain_extra \nFROM domain \nWHERE domain.id = %s' ('default',)(HTTP 500)

mysqld起来了,但由于ib*文件已经更换,数据不一样了。nova等各项服务已经出错了, 尝试reboot重启了一下云服务器,仍然不行,ib*得还原,但还原又启动不了mysqld了。

直接抄袭主义不行,关键还得想办法:

InnoDB: Database was not shut down normally!InnoDB: Starting crash recovery.

问题在于这个错误,数据库非正常关机,然后数据库重启后有一个恢复操作,恢复不了就挂了。

后续的解决方案:

1、还原ib*文件,

2、在配置文件加入 不强制恢复数据的 关掉 #innodb_force_recover = 6。

3、启动数据库,mysqldump将数据库导出。
4、删除数据库文件,mysql启动完成后重新导入mysql数据库

同事操的刀,具体操作如下:

[root@sxun01 mysql(keystone_admin)]#mysqldump -uroot  --all-database  >> my_mysql.dump-- Warning: Skipping the data of tablemysql.event. Specify the --events option explicitly. [root@sxun01 mysql(keystone_admin)]#/etc/init.d/mysqld stopStopping mysqld:                                          [  OK  ] [root@sxun01 mysql(keystone_admin)]# rm -rfibdata1 ib_logfile0 ib_logfile1[root@sxun01 mysql(keystone_admin)]# vi/etc/my.cnf[client]port   = 3306socket   = /var/lib/mysql/mysql.sock[mysqld_safe]socket   = /var/lib/mysql/mysql.sock[client]port   = 3306socket   = /var/lib/mysql/mysql.sock[mysqld_safe]socket   = /var/lib/mysql/mysql.socknice   = 0[mysqld]user   = mysqlpid-file = /var/run/mysqld/mysqld.pidsocket   = /var/lib/mysql/mysql.sockport     = 3306basedir  = /usrdatadir  = /var/lib/mysqltmpdir   = /tmpskip-external-locking #innodb_force_recover = 6bind-address    = 0.0.0.0  key_buffer         = 16Mmax_allowed_packet = 16Mthread_stack       = 192Kthread_cache_size  = 8myisam-recover     = BACKUPquery_cache_limit  = 1Mquery_cache_size   = 16Mlog_error          = /var/log/mysqld.logexpire_logs_days   = 10max_binlog_size    = 100M default-storage-engine = InnoDB   [mysqldump]quickquote-names"/etc/my.cnf" 43L, 811C written [root@sxun01 mysql(keystone_admin)]# mkdirdatabase_bak[root@sxun01 mysql(keystone_admin)]# mvcinder/ glance/ keystone/ nova/ ovs_neutron/ database_bak/[root@sxun01 mysql(keystone_admin)]# lldatabase_bak/total 20drwx------ 2 mysql mysql 4096 Oct 25 15:08cinderdrwx------ 2 mysql mysql 4096 Oct 25 15:08glancedrwx------ 2 mysql mysql 4096 Oct 25 15:08keystonedrwx------ 2 mysql mysql 4096 Oct 25 15:08novadrwx------ 2 mysql mysql 4096 Oct 25 15:08ovs_neutron[root@sxun01 mysql(keystone_admin)]# lltotal 29648drwxr-xr-x 2 root  root     4096 Apr 20 15:15 aaadrwxr-xr-x 2 root  root     4096 Apr 20 15:33 bbbdrwxr-xr-x 7 root  root     4096 Apr 20 15:47 database_bak-rw-r--r-- 1 root  root 29610746 Apr 20 15:45 my_mysql.dumpdrwx------ 2 mysql mysql     4096 Oct 25 15:05 mysql-rw-r----- 1 mysql root     82317 Apr 20 15:46 sxun01.err-rw-r----- 1 mysql root    637765 Apr 20 15:35 sxun01.err--drwx------ 2 mysql mysql     4096 Oct 25 15:05 test[root@sxun01 mysql(keystone_admin)]#[root@sxun01 mysql(keystone_admin)]#[root@sxun01 mysql(keystone_admin)]#/etc/init.d/mysqld restartStopping mysqld:                                          [  OK  ]Starting mysqld:                                          [  OK  ][root@sxun01 mysql(keystone_admin)]# mysqlWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 22Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or itsaffiliates. All rights reserved. Oracle is a registered trademark of OracleCorporation and/or itsaffiliates. Other names may be trademarksof their respectiveowners. Type 'help;' or '\h' for help. Type '\c' toclear the current input statement. mysql> quitBye[root@sxun01 mysql(keystone_admin)]# mysql-uroot < my_mysql.dump[root@sxun01 mysql(keystone_admin)]#[root@sxun01 mysql(keystone_admin)]#[root@sxun01 mysql(keystone_admin)]# mysqlWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 93Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or itsaffiliates. All rights reserved. Oracle is a registered trademark of OracleCorporation and/or itsaffiliates. Other names may be trademarksof their respectiveowners. Type 'help;' or '\h' for help. Type '\c' toclear the current input statement. mysql> use nova ;Reading table information for completion oftable and column namesYou can turn off this feature to get aquicker startup with -A Database changed mysql> select * from  instances; mysql> quitBye [root@sxun01 mysql(keystone_admin)]#nova-manage service listBinary           Host                                 Zone             Status     State Updated_Atnova-consoleauth sxun01                               internal         enabled    XXX  2017-04-20 05:31:48nova-scheduler   sxun01                               internal         enabled    XXX  2017-04-20 05:31:54nova-conductor   sxun01                               internal         enabled    :-)  2017-04-20 07:49:07nova-cert        sxun01                               internal         enabled    XXX  2017-04-20 05:31:55nova-compute     sxun01                               nova             enabled    XXX  2017-04-20 05:31:53[root@sxun01 mysql(keystone_admin)]# reboot[root@sxun01 mysql(keystone_admin)]#Broadcast message from root@sxun01       (/dev/pts/0) at 15:49 ... The system is going down for reboot NOW!Last login: Thu Apr 20 15:28:26 2017  [root@sxun01 ~]# nova-manage service listBinary           Host                                 Zone             Status     State Updated_Atnova-consoleauth sxun01                               internal         enabled    :-)  2017-04-20 07:53:28nova-scheduler   sxun01                               internal         enabled    :-)  2017-04-20 07:53:28nova-conductor   sxun01                               internal         enabled    :-)  2017-04-20 07:53:28nova-cert        sxun01                               internal         enabled    :-)  2017-04-20 07:53:28nova-compute     sxun01                               nova             enabled    :-)  2017-04-20 07:53:24

看完以上关于openstack是如何修复mysql问题,很多读者朋友肯定多少有一定的了解,如需获取更多的行业知识信息 ,可以持续关注我们的行业资讯栏目的。

0