MySQL下常見的啟動失敗與備份失敗問題的解決教程_Mysql

來源:互聯網
上載者:User

啟動失敗
重啟伺服器後-->重啟應用服務(Confluence)-->報錯,資料庫連接失敗(mysql設定了開機自啟動)-->查看mysql資料庫狀態:

[root@fisheye ~]# ps -ef | grep mysqlroot   25555 21974 0 11:28 pts/0  00:00:00 grep mysql

啟動mysql伺服器

[root@fisheye data]# service mysql start
MySQL server PID file could not be found![失敗]Starting MySQL.............. ERROR! The server quit without updating PID file (/mydata/data/fisheye..pid).[失敗]

查看錯誤記錄檔:

[root@fisheye data]# tail -100 fisheye.err
InnoDB: Last MySQL binlog file position 0 337403929, file name ./mysql-bin.000016141013 1:13:28 InnoDB: Waiting for the background threads to start141013 1:13:29 InnoDB: 5.5.33 started; log sequence number 100664715217:13:29 UTC - mysqld got signal 11 ;This could be because you hit a bug. It is also possible that this binaryor one of the libraries it was linked against is corrupt, improperly built,or misconfigured. This error can also be caused by malfunctioning hardware.We will try our best to scrape up some info that will hopefully helpdi141013 01:13:29 mysqld_safe mysqld from pid file /mydata/data/fisheye.pid ended

未發現明顯性錯誤提示,所以手動建立一個pid檔案試試

[root@fisheye data]# touch /mydata/data/fisheye.pi

再進行重啟服務:

[root@fisheye data]# service mysql restart
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

突然想到之前看過此類報錯的文章,記得有可能是磁碟空間不足導致的mysql無法啟動。

[root@fisheye data]# df -h

(檔案系統              容量  已用 可用 已用% 掛載點)

/dev/sda1       9.5G 9.5G 0 100% //dev/sda4       5.5G 1.3G 4.0G 24% /mnt/backup/dev/mapper/IhuilianVG-IhuilianLV00            22G 4.2G  17G 20% /var/www/apptmpfs         1.3G   0 1.3G  0% /dev/shm

果然如此,下面羅列一些類似問題(無法啟動)的解決思路:
1.可能是datadir目錄存在的分區滿了(df -h )
       解決方案:開啟設定檔/etc/my.cnf,在[mysqld]節下重新指定資料目錄(datadir),並將原來的資料目錄遷移到重新制定的資料目錄處
       關於遷移:(1)、cp或者tar的時候一定要把許可權給帶上,但是為防止意外建議再授權一次;(2)、資料比較大時一定要先壓縮再遷移,保證完整性,特別是scp到其他機器時可能會逾時所以一定要壓縮(tar.gz);(3)、若是移動至另外的伺服器一定要保證mysql版本一致。

2.可能是/mydata/data/fisheye.pid檔案沒有寫的許可權
      解決方案 :給予許可權,執行 “chown -R mysql:mysql /mydata/data/”  然後重新啟動mysqld!

3.可能進程裡已經存在mysql進程
      解決方案:用命令“ps -ef|grep mysqld”查看是否有mysqld進程,如果有使用“kill -9  進程號”殺死,然後重新啟動mysqld!

4.可能是第二次在機器上安裝mysql,有殘餘資料影響了服務的啟動。
       解決方案:去mysql的資料目錄/data看看,如果存在mysql-bin.index,就趕快把它刪除掉吧,它就是罪魁禍首了。

5.skip-federated欄位問題(報錯資訊:[ERROR] /mydata/data/mysql/libexec/mysqld: unknown option '--skip-federated')
       解決方案:檢查一下/etc/my.cnf檔案中有沒有沒被注釋掉的skip-federated欄位,如果有就立即注釋掉吧。

6.selinux惹的禍,如果是centos系統,預設會開啟selinux
       解決方案:關閉它,開啟/etc/selinux/config,把SELINUX=enforcing改為SELINUX=disabled後存檔退出重啟機器試試。

備份失敗
說明
執行 mysqldump 時出現找不到某一個 tables 並且中斷執行?及鎖表後延伸出現的問題記錄!
問題及方案如下
Error Meaage: 執行mysqldump 時出現找不到某一個 tables 並且中斷執行

[root@test100 data]# mysqldump fx > fx.sql
mysqldump: Got error: 1146: Table 'user_suggest_report' doesn't exist when using LOCK TABLES

考慮加上 --skip-lock-tables或者-R進行鎖表試試,也是不行,資訊如下

[root@test100 data]#mysqldump --skip-lock-tables fx > fx.sql
Error: Couldn't read status information for table vote_results () mysqldump: Couldn't execute 'show create table `user_suggest_report`': Table 'fx.user_suggest_report' doesn't exist (1146)

登陸伺服器查看是否存在此表

 [root@test100 data]#mysql -h127.0.0.1 -D fx mysql> show tables;      #查看所有的表 --> 發現是表存在的
+--------------------------------+| Tables_in_fx          |+--------------------------------+| user_suggest_report      |+--------------------------------+80 rows in set (0.00 sec)

刪除此表

mysql> drop table user_suggest_report;      #既然是存在的,但是系統卻認定不存在說明存在問題,索性想刪除試試
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'user_suggest_report' at line 1

進入mysql儲存目錄下將其資料表移動或刪除

[root@test100 data]# cat /etc/my.cnf | grep datadirdatadir=/var/lib/mysql[root@test100 data]# cd /var/lib/mysql/fx/[root@test100 fx]# mv user_suggest_report.frm /data

重啟mysql伺服器

[root@test100 fx]# service mysqld restart

重新備份操作

[root@test100 data]# mysqldump fx > fx.150109.sql  #操作成功

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.