⑴ UDEV 基礎
udev 可管理儲存在/dev 目錄下的檔案、檔案只有在接入相應裝置後才會產生、裝置被拔出後自動刪除
它還允許使用者添加規則、以便修改/dev中預設的名稱和許可權、規則儲存在/etc/udev/rules.d/目錄下
⑵ MySQL 綁定裸裝置
只有InnoDB可以用裸裝置
優點:繞過了檔案系統,讀寫速度會有提高,並且資料會比較安全、同時降低檔案系統負擔、也改善系統效能
缺點:太安全了,好多備份工具可能沒法用、dd可以考慮
下面介紹如何為mysql共用資料表空間綁定裸裝置
㈠ 製作裸裝置
# fdisk /dev/sda
==> /dev/sda5
# partprobe
# fdisk -l
# pvcreate /dev/sda5
# vgcreate -s 16M mysqlvg /dev/sda5
# lvcreate -L 90M -n sharespace mysqlvg
# vim /etc/sysconfig/rawdevices
==> /dev/raw/raw1 /dev/mysqlvg/sharespace
# service rawdevices start
# chkconfig rawdevices on
# chown -R mysql:dba /dev/mapper/mysqlvg-sharespace
㈡ 配置MySQL
① 指定newraw屬性
innodb_data_home_dir =
innodb_data_file_path = /dev/mapper/mysqlvg-sharespace:60Mnewraw
② 重啟mysql服務,待其完成分區初始化工作後,再關閉mysql服務
③ 修改raw屬性
innodb_data_home_dir =
innodb_data_file_path = /dev/mapper/mysqlvg-sharespace:60Mraw
④ 重啟mysql服務
如果整個系統重啟、裸裝置的許可權會被回收、導致mysql無法開啟
官網描述如下:
will fail after the next reboot, if the /dev-tree is dynamically created by, e.g. udev, a MAKEDEV-script or similar. After reboot, the device will regain its former permission, typically excluding access by mysql.
alert 警示如下:
130719 20:42:43 InnoDB: Operating system error number 13 in a file operation.InnoDB: The error means mysqld does not have the access rights toInnoDB: the directory.InnoDB: File name /dev/mapper/mysqlvg-sharespaceInnoDB: File operation call: 'open'.InnoDB: Cannot continue operation.
此時可選方案:
1)寫個簡單的初始化指令碼、當重啟的時候自動授權
2)配置 udev條目、
[root@odd rules.d]# pwd/etc/udev/rules.d[root@odd rules.d]# cat 60-raw.rulesACTION=="add", KERNEL=="sda5", GROUP=="dba", MODE=="0660", RUN+="/bin/raw /dev/raw/raw1 %N"[root@odd rules.d]# cat 65-raw-permissions.rulesKERNEL=="sda5", GROUP="dba", MODE="0660"
By WaterBin
2013-07-20
Good LUCK