先敘述一下背景,本機硬碟2塊,
120G SSD = 60(linux ext4) + 60 (win7 NTFS)
2T 機械硬碟 = 600G NTFS + 600G NTFS + 700G NTFS
當初為了照顧win7對於ext分區相容性的問題,將2T的3個分區都設為了NTFS的,如今就遇到了麻煩
由於mysql要處理大資料,SSD不夠用,於是要轉移datadir,開始使用的是ln的辦法,但是怎麼搞都不行
後來發現,ntfs分區的檔案的owner不能更改,即使用chown更改了(沒有報錯),實際owner還是當前分區的掛載者(root)
試圖解決這個問題,於是修改了fstab,將根據 /dev/sda1 這種格式的掛載改為UUID掛載,但是還是沒有解決這個問題
於是改了datadir之後重啟mysql總是報錯,
zs@linux:/media/linux/lnRoot$ sudo /etc/init.d/mysql start
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql start
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start mysql
start: Job failed to start
於是上網搜啊搜……………..
ntfs掛載在ubuntu下面的檔案許可權都是777的,具體操作過程遇到的問題和解決如下:
1. 修改 /etc/mysql/my.cnf
代碼如下 |
複製代碼 |
將 datadir = /var/lib/mysql 改為 datadir = /media/MyDocuments/mysql |
嘗試重啟mysql
代碼如下 |
複製代碼 |
sudo /etc/init.d/mysql stop sudo /etc/init.d/mysql start |
結果mysql怎麼也重啟不來
查看日誌,/var/log/mysql/error.log,如下:
100819 15:10:20 [Note] Plugin 'FEDERATED' is disabled.
^G/usr/sbin/mysqld: Can't find file: './mysql/plugin.frm' (errno: 13)
100819 15:10:20 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
100819 15:10:20 InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
查了很久,基本都是說apparmor的問題,其實這個在my.cnf裡面也有提到過了,
代碼如下 |
複製代碼 |
# * IMPORTANT # If you make changes to these settings and your system uses apparmor, you may # also need to also adjust /etc/apparmor.d/usr.sbin.mysqld.
|
ok,這樣的話,就明白很多了,修改/etc/apparmor.d/usr.sbin.mysqld即可。
將
代碼如下 |
複製代碼 |
/var/lib/mysql/ r, /var/lib/mysql/** rwk,
|
改為
代碼如下 |
複製代碼 |
#/var/lib/mysql/ r, #/var/lib/mysql/** rwk, /media/MyDocuments/mysql/ r, /media/MyDocuments/mysql/** rwk,
|
再運行一下:
代碼如下 |
複製代碼 |
/etc/init.d/apparmor reload |