背景描述,在Linux系統中,若是添加了新的SCSI磁盤或者映射SAN存儲LUN操做,重啓操做系統以後會出現磁盤標識符(sd*)錯亂的狀況。css
例如以前添加的SAN存儲LUN的磁盤標識符爲/dev/sdd,重啓以後發現變成/dev/sdh,特別是oracle RAC環境下咱們是不但願出現這樣的狀況的。node
解決這個問題以前,須要先搞清楚Linux系統中的wwid和uuid號。oracle
1、wwidapp
根據SCSI標準,每一個SCSI磁盤都有一個WWID,相似於網卡的MAC地址,要求是獨一無二。oop
經過WWID標示SCSI磁盤就能夠保證磁盤路徑永久不變,Linux系統上/dev/disk/by-id目錄包含每一個SCSI磁盤WWID訪問路徑。ui
查看磁盤設備wwid方法1:spa
[root@rac01-node01 /]# ll /dev/disk/by-id/
total 0
lrwxrwxrwx. 1 root root 10 May 28 2017 dm-name-vg_rac01node01-LogVol01 -> ../../dm-0
lrwxrwxrwx. 1 root root 10 May 28 2017 dm-uuid-LVM-YWDtaD547sWxXQ2m9yF3Vl7gd42z61gqjQSRxV0GPavZDlE2D1dh26aPin6V59mz -> ../../dm-0
lrwxrwxrwx. 1 root root 9 May 27 19:01 scsi-360060160e2b0420004a53e678d42e711 -> ../../sdg
lrwxrwxrwx. 1 root root 9 May 27 19:01 scsi-360060160e2b04200c687b330c741e711 -> ../../sdh
lrwxrwxrwx. 1 root root 9 May 28 2017 scsi-3600605b00a8043c020b6bdd53057904d -> ../../sda
lrwxrwxrwx. 1 root root 10 May 28 2017 scsi-3600605b00a8043c020b6bdd53057904d-part1 -> ../../sda1
lrwxrwxrwx. 1 root root 10 May 28 2017 scsi-3600605b00a8043c020b6bdd53057904d-part2 -> ../../sda2操作系統
查看磁盤設備wwid方法2:ip
[root@rac01-node01 Packages]# scsi_id --whitelist /dev/sda
3600605b00a8043c020b6bdd53057904d
[root@rac01-node01 Packages]# scsi_id --whitelist /dev/sdb
360060160e2b04200c687b330c741e711ci
RHEL6使用如上命令,在RHEL5中使用scsi_id --whitelist /dev/sd*
SAN存儲:
重啓系統以後,能夠經過multipath.conf文件配置別名來保持系統磁盤標識符不變
別名的實質就是經過LUN ID和multipath -ll顯示的磁盤標識符作綁定
[root@ttest ~]# cat /etc/multipath.conf
# multipath.conf written by anaconda
defaults {
user_friendly_names yes
}
blacklist {
devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
devnode "^hd[a-z]"
devnode "^dcssblk[0-9]*"
wwid "*"
}
blacklist_exceptions {
wwid "300060160e2b042007a5ba6d44bece771"
wwid "300060160e2b042000bd016064cece771"
wwid "300060160e2b04200176ad7954cece771"
wwid "300060160e2b0420020c3fcd24cece771"
}
multipaths {
multipath {
wwid 300060160e2b042007a5ba6d44bece771
alias v5200_gi01_lun00
}
multipath {
wwid 300060160e2b04200d0990bea4bece771
alias v5200_gi01_lun01
}
multipath {
wwid 300060160e2b0420075db53f84bece771
alias v5200_gi01_lun02
}
multipath {
wwid 300060160e2b042000bd016064cece771
alias v5200_gi01_lun03
}
}
=======================================================================================
2、uuid
UUID是有文件系統在建立時候生成的,用來標記文件系統,相似WWID同樣也是獨一無二的。
所以使用UUID來標示SCSI磁盤,也能保證路徑是永久不變的。Linux上/dev/disk/by-uuid能夠看到每一個已經建立文件系統的磁盤設備以及與/dev/sd*之間的映射關係。
查看文件系統uuid:
[root@rac01-node01 /]# ll /dev/disk/by-uuid/
total 0
lrwxrwxrwx. 1 root root 10 May 28 2017 3777-9E7C -> ../../sda1
lrwxrwxrwx. 1 root root 10 May 28 2017 414563cf-af5d-467a-bca9-81b8dad6e17f -> ../../dm-0
lrwxrwxrwx. 1 root root 10 May 28 2017 948ab5bc-f796-4f74-8cd5-84b6474d79ae -> ../../dm-1
lrwxrwxrwx. 1 root root 10 May 28 2017 9cbb7f73-582c-47e4-99d7-1c79fae90efc -> ../../sda2
重啓系統以後,若是要使掛載的掛載的目錄和文件系統綁定關係不變,在/etc/fstab裏面應該使用uuid來標識,以下:
[root@rac01-node01 /]# cat /etc/fstab
# /etc/fstab
# Created by anaconda on Sun May 28 01:13:01 2017
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vg_rac01node01-LogVol01 / ext4 defaults 1 1
UUID=9cbb7f73-582c-47e4-99d7-1c79fae90efc /boot ext4 defaults 1 2
UUID=3777-9E7C /boot/efi vfat umask=0077,shortname=winnt 0 0
/dev/mapper/vg_rac01node01-LogVol00 swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
掛載文件系統以前,查看分區UUID,使用UUID mount文件系統時須要指定-t文件系統類型
[root@ca-mgmt ~]# blkid
/dev/vda1: UUID="d0bc3224-dfb4-4abd-9e04-91fe5af5c9b9" TYPE="xfs"
/dev/vda2: UUID="j7r6ci-03td-jY3T-nyKA-xI0t-9FK4-k3Bb1z" TYPE="LVM2_member"
/dev/mapper/rhel-root: UUID="a708a4d0-143e-46fe-8af9-1d5a2d330e2a" TYPE="xfs"
/dev/mapper/rhel-swap: UUID="4f927dbc-446e-49eb-939f-bc7790b823a4" TYPE="swap"