openstack是如何修復(fù)mysql問題

本文主要給大家介紹openstack是如何修復(fù)MySQL問題,文章內(nèi)容都是筆者用心摘選和編輯的,openstack是如何修復(fù)mysql問題具有一定的針對(duì)性,對(duì)大家的參考意義還是比較大的,下面跟筆者一起了解下主題內(nèi)容吧。

專注于為中小企業(yè)提供網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)臨川免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了1000多家企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。

同事一臺(tái)openstack單節(jié)點(diǎn)云服務(wù)器由于未知原因,無法正常工作。

遠(yuǎn)程引導(dǎo)同事檢查故障。 

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

 openstack是如何修復(fù)mysql問題

出現(xiàn)錯(cuò)誤:SQL connection failed 。貌似沒有連接數(shù)據(jù)庫,看來可能是服務(wù)或數(shù)據(jù)庫有問題。

引導(dǎo)同事檢測(cè)openstack服務(wù)及數(shù)據(jù)庫:

[root@sxun init.d]# /etc/init.d/openstack-keystone status
keystone (pid  12593) is running...
[root@sxun init.d]# /etc/init.d/openstack-nova-api status
openstack-nova-api (pid  7446) is running...
[root@sxun init.d]# /etc/init.d/openstack-nova-compute status
openstack-nova-compute (pid  11728) is running...
[root@sxun init.d]# /etc/init.d/openstack-nova-conductor status
openstack-nova-conductor (pid  7704) is running...
[root@sxun init.d]# /etc/init.d/mysqld status
 openstack是如何修復(fù)mysql問題
mysql is stoppd 
[root@sxun init.d]# /etc/init.d/mysqld start
starting mysqld: [FAILED]

restart也是如此,看來是mysqld服務(wù)沒有啟動(dòng)的問題。為什么沒有啟動(dòng)了,找到了mysqld的日志查看:

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

 錯(cuò)誤日志報(bào)大致錯(cuò)誤如下:

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

......

openstack是如何修復(fù)mysql問題

因圖不完整,引用以下網(wǎng)址文本http://blog.chinaunix.net/uid-27038861-id-3667209.html?bsh_bid=310758849 ,也按照其方法處,沒動(dòng)腦地操作了一下試試

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

 130508 16:30:53 mysqld_safe Starting mysqlddaemon with databases from /data/mysql
130508 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 disabled
130508 16:30:54 InnoDB: Mutexes andrw_locks use GCC atomic builtins
130508 16:30:54 InnoDB: Compressed tablesuse zlib 1.2.3
130508 16:30:54 InnoDB: Initializing bufferpool, size = 500.0M
130508 16:30:54 InnoDB: Completedinitialization of buffer pool
130508 16:30:54 InnoDB: highest supportedfile format is Barracuda.
InnoDB: Log scan progressed past thecheckpoint lsn 27219795678
130508 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 doublewrite
InnoDB: buffer...
InnoDB: Doing recovery: scanned up to logsequence number 27219928522

 ##############引用,中間省略#############

解決辦法: 
刪除掉 
ibdata* ,
ib_logfile* ,
所有的日志。
重啟后可啟動(dòng)數(shù)據(jù)庫,因數(shù)據(jù)庫是非正常關(guān)閉引起的。所有會(huì)造成數(shù)據(jù)丟失。要做好備份工作

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

[root@sxun mysql]# ll
total 225356
drwx------ 2 mysql mysql      4096 Feb 15 16:06 cinder
drwx------ 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_logfile1
drwx------ 2 mysql mysql      4096 Oct  1  2016 keystone
drwx------ 2 mysql mysql      4096 Oct  1  2016 mysql
srwxrwxrwx 1 mysql mysql         0 Feb 16 14:52 mysql.sock
drwx------ 2 mysql mysql      4096 Oct  1  2016 nova
drwx------ 2 mysql mysql      4096 Oct  1  2016 ovs_neutron
-rw-r----- 1 mysql root      38548 Feb 16 14:52 sxun.err
drwx------ 2 mysql mysql      4096 Oct  1  2016 test

生產(chǎn)環(huán)境不敢刪除,先移動(dòng)其它地方備份記

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

服務(wù)器的數(shù)據(jù)庫已經(jīng)是啟動(dòng)起來了,也生成了新的ib*文件。測(cè)試一下keystone和nova服務(wù),但是:

[root@sxun instances]# nova-manage service list
CRITICAL 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-list
Authorization 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*文件已經(jīng)更換,數(shù)據(jù)不一樣了。nova等各項(xiàng)服務(wù)已經(jīng)出錯(cuò)了, 嘗試reboot重啟了一下云服務(wù)器,仍然不行,ib*得還原,但還原又啟動(dòng)不了mysqld了。 

直接抄襲主義不行,關(guān)鍵還得想辦法:

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

問題在于這個(gè)錯(cuò)誤,數(shù)據(jù)庫非正常關(guān)機(jī),然后數(shù)據(jù)庫重啟后有一個(gè)恢復(fù)操作,恢復(fù)不了就掛了。

 

后續(xù)的解決方案:

1、還原ib*文件,

2、在配置文件加入 不強(qiáng)制恢復(fù)數(shù)據(jù)的 關(guān)掉 #innodb_force_recover = 6。

3、啟動(dòng)數(shù)據(jù)庫,mysqldump將數(shù)據(jù)庫導(dǎo)出。
4、刪除數(shù)據(jù)庫文件,mysql啟動(dòng)完成后重新導(dǎo)入mysql數(shù)據(jù)庫

 

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

[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 stop
Stopping mysqld:                                          [  OK  ]
 
[root@sxun01 mysql(keystone_admin)]# rm -rfibdata1 ib_logfile0 ib_logfile1
[root@sxun01 mysql(keystone_admin)]# vi/etc/my.cnf
[client]
port   = 3306
socket   = /var/lib/mysql/mysql.sock
[mysqld_safe]
socket   = /var/lib/mysql/mysql.sock
[client]
port   = 3306
socket   = /var/lib/mysql/mysql.sock
[mysqld_safe]
socket   = /var/lib/mysql/mysql.sock
nice   = 0
[mysqld]
user   = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket   = /var/lib/mysql/mysql.sock
port     = 3306
basedir  = /usr
datadir  = /var/lib/mysql
tmpdir   = /tmp
skip-external-locking
 
#innodb_force_recover = 6
bind-address    = 0.0.0.0
 
 
key_buffer         = 16M
max_allowed_packet = 16M
thread_stack       = 192K
thread_cache_size  = 8
myisam-recover     = BACKUP
query_cache_limit  = 1M
query_cache_size   = 16M
log_error          = /var/log/mysqld.log
expire_logs_days   = 10
max_binlog_size    = 100M
 
default-storage-engine = InnoDB
 
 
 
[mysqldump]
quick
quote-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 20
drwx------ 2 mysql mysql 4096 Oct 25 15:08cinder
drwx------ 2 mysql mysql 4096 Oct 25 15:08glance
drwx------ 2 mysql mysql 4096 Oct 25 15:08keystone
drwx------ 2 mysql mysql 4096 Oct 25 15:08nova
drwx------ 2 mysql mysql 4096 Oct 25 15:08ovs_neutron
[root@sxun01 mysql(keystone_admin)]# ll
total 29648
drwxr-xr-x 2 root  root     4096 Apr 20 15:15 aaa
drwxr-xr-x 2 root  root     4096 Apr 20 15:33 bbb
drwxr-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.dump
drwx------ 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 restart
Stopping mysqld:                                          [  OK  ]
Starting mysqld:                                          [  OK  ]
[root@sxun01 mysql(keystone_admin)]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 22
Server 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 its
affiliates. Other names may be trademarksof their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.
 
mysql> quit
Bye
[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)]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 93
Server 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 its
affiliates. Other names may be trademarksof their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' toclear the current input statement.
 
mysql> use nova ;
Reading table information for completion oftable and column names
You can turn off this feature to get aquicker startup with -A
 
Database changed
 
mysql> select * from  instances;
 
mysql> quit
Bye
 
[root@sxun01 mysql(keystone_admin)]#nova-manage service list
Binary           Host                                 Zone             Status     State Updated_At
nova-consoleauth sxun01                               internal         enabled    XXX  2017-04-20 05:31:48
nova-scheduler   sxun01                               internal         enabled    XXX  2017-04-20 05:31:54
nova-conductor   sxun01                               internal         enabled    :-)  2017-04-20 07:49:07
nova-cert        sxun01                               internal         enabled    XXX  2017-04-20 05:31:55
nova-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 list
Binary           Host                                 Zone             Status     State Updated_At
nova-consoleauth sxun01                               internal         enabled    :-)  2017-04-20 07:53:28
nova-scheduler   sxun01                               internal         enabled    :-)  2017-04-20 07:53:28
nova-conductor   sxun01                               internal         enabled    :-)  2017-04-20 07:53:28
nova-cert        sxun01                               internal         enabled    :-)  2017-04-20 07:53:28
nova-compute     sxun01                               nova             enabled    :-)  2017-04-20 07:53:24

看完以上關(guān)于openstack是如何修復(fù)mysql問題,很多讀者朋友肯定多少有一定的了解,如需獲取更多的行業(yè)知識(shí)信息 ,可以持續(xù)關(guān)注我們的行業(yè)資訊欄目的。

新聞名稱:openstack是如何修復(fù)mysql問題
文章來源:http://bm7419.com/article0/jcsoio.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供軟件開發(fā)、外貿(mào)網(wǎng)站建設(shè)標(biāo)簽優(yōu)化、響應(yīng)式網(wǎng)站服務(wù)器托管、定制開發(fā)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)公司