MySQL 啟動故障 處理 小記

來源:互聯網
上載者:User

 

       昨天啟動MySQL時,就不太正常,要多重啟幾次,不過能啟動,也就沒放在心上,今天測試測試又出現了問題,MySQL 啟動正常,但是無法關閉:

 

[root@rac2 mysql]# service mysql stop

MySQL server PID file could not befound!                  [FAILED]

[root@rac2 mysql]# ./mysql.server stop

MySQL server PID file could not befound!                  [FAILED]

 

這裡提示的PID 檔案指:/var/lib/mysql/rac2.pid,該檔案和/var/lib/mysql/mysql.sock 檔案一樣,僅在MySQL 運行時存在,後來的驗證如下:

 

[root@rac2 lib]# ls /var/lib/mysql/rac2.pid

/var/lib/mysql/rac2.pid

[root@rac2 lib]# service mysql stop

Shutting down MySQL.                                       [  OK  ]

[root@rac2 lib]# ls /var/lib/mysql/rac2.pid

ls: /var/lib/mysql/rac2.pid: No such fileor directory

 

所以當我的MySQL 運行正常時,應該是存在這個檔案的,google的一個說法是my.cnf 參數檔案的basedir 參數錯誤,注釋掉這個參數即可,但是我都沒有設過這個參數,所以和這個應該沒有關係。

 

查看了一下預設值:

mysql> show variables like '%basedir%';

+---------------+-------+

| Variable_name | Value |

+---------------+-------+

| basedir       | /usr |

+---------------+-------+

1 row in set (0.00 sec)

 

[root@rac2 ~]# ps -ef|grep mysql

root     2161     1  0 09:38 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe--datadir=/var/lib/mysql --pid-file=/var/lib/mysql/rac2.pid

mysql    2418  2161  0 09:38 ?        00:00:00 /usr/sbin/mysqld --basedir=/usr--datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql--log-error=/var/lib/mysql/rac2.err --pid-file=/var/lib/mysql/rac2.pid--socket=/var/lib/mysql/mysql.sock --port=3306

root     3628  3596  0 09:57 pts/1    00:00:00 grep mysql

  

--log資訊

[root@rac2 ~]#cat /var/lib/mysql/rac2.err

111129 9:38:49 [Note] Plugin 'FEDERATED' is disabled.

111129 9:38:49 InnoDB: The InnoDB memory heap is disabled

111129 9:38:49 InnoDB: Mutexes and rw_locks use GCC atomic builtins

111129 9:38:49 InnoDB: Compressed tables use zlib 1.2.3

111129 9:38:49 InnoDB: Using Linux native AIO

111129 9:38:49 InnoDB: Initializing buffer pool, size = 128.0M

111129 9:38:50 InnoDB: Completed initialization of buffer pool

111129 9:38:50 InnoDB: highest supported file format is Barracuda.

111129 9:38:50  InnoDB: Waiting for thebackground threads to start

111129 9:38:51 InnoDB: 1.1.8 started; log sequence number 1605950

111129 9:38:52 [Note] Event Scheduler: Loaded 0 events

111129 9:38:52 [Note] /usr/sbin/mysqld: ready for connections.

Version: '5.5.15-log'  socket: '/var/lib/mysql/mysql.sock'  port: 3306 MySQL Community Server (GPL)

111129 10:50:36 mysqld_safe Starting mysqlddaemon with databases from /var/lib/mysql

111129 10:50:37 [Note] Plugin 'FEDERATED'is disabled.

111129 10:50:37 InnoDB: The InnoDB memoryheap is disabled

111129 10:50:37 InnoDB: Mutexes andrw_locks use GCC atomic builtins

111129 10:50:37 InnoDB: Compressed tablesuse zlib 1.2.3

111129 10:50:37 InnoDB: Using Linux nativeAIO

111129 10:50:37 InnoDB: Initializing bufferpool, size = 128.0M

111129 10:50:37 InnoDB: Completedinitialization of buffer pool

InnoDB: Unable to lock ./ibdata1, error: 11

InnoDB: Check that you do not already haveanother mysqld process

InnoDB: using the same InnoDB data or logfiles.

111129 10:50:37  InnoDB: Retrying to lock the first data file

InnoDB: Unable to lock ./ibdata1, error: 11

InnoDB: Check that you do not already haveanother mysqld process

InnoDB: using the same InnoDB data or logfiles.

InnoDB: Check that you do not already haveanother mysqld process

InnoDB: using the same InnoDB data or logfiles.

InnoDB: Unable to lock ./ibdata1, error: 11

InnoDB: Check that you do not already haveanother mysqld process

--這個提示的意思有多個mysqld 進程在運行。

 

 

解決方案:

(1)重新用:ps -ef|grep mySQL 查詢所有的進程,然後把所有的進程kill掉,

(2)重新對相關的目錄賦權

[root@rac2 /]# chown mysql.mysql -R/var/lib/mysql/*

[root@rac2 /]# chmod 755 -R/var/lib/mysql/*

 

--再次啟動成功:

[root@rac2 /]# service mysql start

Starting MySQL......                                       [  OK  ]

[root@rac2 /]# ps -ef|grep mysql

root    27936     1  1 14:08 pts/1    00:00:00 /bin/sh /usr/bin/mysqld_safe--datadir=/var/lib/mysql --pid-file=/var/lib/mysql/rac2.pid

mysql   28193 27936  3 14:08 pts/1    00:00:00 /usr/sbin/mysqld --basedir=/usr--datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql--log-error=/var/lib/mysql/rac2.err --pid-file=/var/lib/mysql/rac2.pid--socket=/var/lib/mysql/mysql.sock --port=3306

root    28220  3596  0 14:08 pts/1    00:00:00 grep mysql

[root@rac2 /]# ll /var/lib/mysql/mysql.sock

srwxrwxrwx 1 mysql mysql 0 Nov 29 14:08/var/lib/mysql/mysql.sock

 

再次查看log:

[root@rac2 lib]#  tail -20 /var/lib/mysql/rac2.err

111129 14:51:53 [Note] Event Scheduler:Purging the queue. 0 events

111129 14:51:53  InnoDB: Starting shutdown...

111129 14:51:54  InnoDB: Shutdown completed; log sequencenumber 1605950

111129 14:51:54 [Note] /usr/sbin/mysqld:Shutdown complete

 

111129 14:51:54 mysqld_safe mysqld from pidfile /var/lib/mysql/rac2.pid ended

111129 14:53:34 mysqld_safe Starting mysqlddaemon with databases from /var/lib/mysql

111129 14:53:34 [Note] Plugin 'FEDERATED'is disabled.

111129 14:53:34 InnoDB: The InnoDB memoryheap is disabled

111129 14:53:34 InnoDB: Mutexes andrw_locks use GCC atomic builtins

111129 14:53:34 InnoDB: Compressed tablesuse zlib 1.2.3

111129 14:53:34 InnoDB: Using Linux nativeAIO

111129 14:53:34 InnoDB: Initializing bufferpool, size = 128.0M

111129 14:53:34 InnoDB: Completed initializationof buffer pool

111129 14:53:35 InnoDB: highest supportedfile format is Barracuda.

111129 14:53:35 InnoDB:1.1.8 started; log sequence number 1605950

111129 14:53:35 [Warning] Neither--relay-log nor --relay-log-index were used; so replication may break when thisMySQL server acts as a slave and has his hostname changed!! Please use'--relay-log=rac2-relay-bin' to avoid this problem.

111129 14:53:35 [Note] Event Scheduler:Loaded 0 events

111129 14:53:35 [Note]/usr/sbin/mysqld: ready for connections.

Version: '5.5.15-log'  socket: '/var/lib/mysql/mysql.sock'  port: 3306 MySQL Community Server (GPL)

[root@rac2 lib]#

 

 

說明:

       因為之前沒有保留的相關資訊,修改之後,雖重複類比多次,都不能還原當時的故障,所有缺少足夠多的一手資料來證明這個問題。但是我這裡的2種方法都可以嘗試一下:

    

MySQL server PID file could not befound!  

--可能是相關目錄的許可權問題導致

 

Check that you do not already have anothermysqld process

--重複進程導致,可以先ps,在kill掉相關進程在重試。

 

 

 

 

-------------------------------------------------------------------------------------------------------

著作權,文章允許轉載,但必須以連結方式註明源地址,否則追究法律責任!

Blog:     http://blog.csdn.net/tianlesoftware

Weibo: http://weibo.com/tianlesoftware

Email:   tianlesoftware@gmail.com

Skype: tianlesoftware

 

-------加群需要在備忘說明Oracle資料表空間和資料檔案的關係,否則拒絕申請----

DBA1 群:62697716(滿);   DBA2 群:62697977(滿)  DBA3 群:62697850(滿)  

DBA 超級群:63306533(滿);  DBA4 群:83829929   DBA5群: 142216823

DBA6 群:158654907    DBA7 群:172855474  DBA8群:102954821    

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.