怎样检查设备或者文件系统的UUID(文档 ID 1505398.1)

APPLIES TO:

Linux OS - Version Oracle Linux 5.0 and later
Linux x86-64
Linux x86

GOAL

在Linux中,有时设备或文件系统的名称不是持久的,这将使系统陷入trouble,在这种情况下,指定UUID(通用唯一标识符)是识别系统中唯一组件的唯一解决方案。

SOLUTION

1. 设备 uuid

In OL5.x:

# scsi_id -u -g -s /block/sda
35000c50032387713

In OL6.x:

# scsi_id --whitelisted /dev/sdd
3600144f0da627ad70000503ad6ce0006

Or:

# udevadm info --query=all --path=/sys/block/sda
P: /devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:2:0/0:2:0:0/block/sda
N: sda
W: 99
S: block/8:0
S: disk/by-id/scsi-364403a78570b200018ac2cd20575ec04
S: disk/by-path/pci-0000:01:00.0-scsi-0:2:0:0
S: disk/by-id/wwn-0x64403a78570b200018ac2cd20575ec04
E: UDEV_LOG=3
E: DEVPATH=/devices/pci0000:00/0000:00:01.0/0000:01:00.0/host0/target0:2:0/0:2:0:0/block/sda
E: MAJOR=8
E: MINOR=0
E: DEVNAME=/dev/sda
E: DEVTYPE=disk
E: SUBSYSTEM=block
E: MPATH_SBIN_PATH=/sbin
E: ID_SCSI=1
E: ID_VENDOR=LSI
E: ID_VENDOR_ENC=LSI
E: ID_MODEL=MRSASRoMB-4i
E: ID_MODEL_ENC=MRSASRoMB-4i
E: ID_REVISION=2.12
E: ID_TYPE=disk
E: ID_SERIAL_RAW=364403a78570b200018ac2cd20575ec04
E: ID_SERIAL=364403a78570b200018ac2cd20575ec04
E: ID_SERIAL_SHORT=64403a78570b200018ac2cd20575ec04
E: ID_WWN=0x64403a78570b2000
E: ID_WWN_VENDOR_EXTENSION=0x18ac2cd20575ec04
E: ID_WWN_WITH_EXTENSION=0x64403a78570b200018ac2cd20575ec04
E: ID_SCSI_SERIAL=0004ec7505d22cac1800200b57783a40
E: ID_BUS=scsi
E: ID_PATH=pci-0000:01:00.0-scsi-0:2:0:0
E: ID_PART_TABLE_TYPE=dos
E: LVM_SBIN_PATH=/sbin
E: DEVLINKS=/dev/block/8:0 /dev/disk/by-id/scsi-364403a78570b200018ac2cd20575ec04 /dev/disk/by-path/pci-0000:01:00.0-scsi-0:2:0:0 /dev/disk/by-id/wwn-0x64403a78570b200018ac2cd20575ec04

For multipath devices:

# multipath -ll -v

360080e500024a048000004044f3c64ee dm-0 SUN,LCSM100_F
size=95G features='1 queue_if_no_path' hwhandler='1 rdac' wp=rw
|-+- policy='round-robin 0' prio=6 status=active
| `- 7:0:0:0 sdb 8:16  active ready running
`-+- policy='round-robin 0' prio=1 status=enabled
  `- 8:0:0:0 sdk 8:160 active ghost running

注意:设备uuid是固定值,dm-mp设备的uuid应该与其路径的uuid相同。 在大多数情况下不能修改,除非设备支持动态uuid功能。

Usage:

设备uuid通常用于持久化设备名称或dm-mpath名称,下面的示例将名称为oraasm1的wwid持久地绑定。

       multipath {
               wwid                  36006048caf0b141598afa8e2875797a1
               alias                   oraasm1
       }

注意:分区(例如sda1或sdb1)没有uuid.

2. File system uuid

In OL5.x:

# blkid /dev/sda1

/dev/sda1: LABEL="/boot1" UUID="ae298adb-1b94-42a0-9dc9-a121c7561a5b" TYPE="ext3" SEC_TYPE="ext2" 

# /lib/udev/vol_id /dev/sda1
ID_FS_USAGE=filesystem
ID_FS_TYPE=ext3
ID_FS_VERSION=1.0
ID_FS_UUID=ae298adb-1b94-42a0-9dc9-a121c7561a5b
ID_FS_LABEL=/boot1
ID_FS_LABEL_SAFE=boot1

Note: /dev/sdxx 必须格式化为文件系统

Usage:

应在/ etc / fstab中指定uuid以永久绑定具有挂载目录的设备。

UUID=xxx-xxx-xxx-xxx            /mount_dir                   ext3    defaults        1 2

注意: 文件系统的UUID在重新被创建(格式化)的时候会被修改

3. LVM2 uuid

# pvs -v
  PV         VG   Fmt  Attr PSize  PFree  DevSize PV UUID   
  /dev/sda2  vg0  lvm2 a--  48.81G     0   48.83G xCJzmN-oJmL-kMFl-JCrb-lfoH-movY-6x6K6O
  /dev/sda3  vg0  lvm2 a--  48.81G     0   48.83G 9iXmmM-kKqV-OYDb-eSVN-ymCw-wwVk-uY6fXo

# lvs
  LV       VG   #Seg Attr   LSize   Maj Min KMaj KMin Origin Snap%  Move Copy%  Log Convert LV UUID                               
  lvroot   vg0     3 -wi-ao 146.44G  -1  -1 253  0                                          C0l0R2-KhH8-N7Nk-BhXn-MJhS-35dn-XXdL1B
  lvasmlib vg1     1 -wi-a-   4.88G  -1  -1 253  6                                          5nlcKy-1kvs-l7qb-eIts-tEs6-E2JG-RisWDx

# vgs -v
  VG   Attr   Ext    #PV #LV #SN VSize   VFree  VG UUID                               
  vg0  wz--n- 32.00M   3   1   0 146.44G     0  ereADB-2w9v-O2P9-58OS-RN9Q-t2pV-8wXpSc
  vg1  wz--n-  4.00M   3   3   0 139.71G  9.95G LczKdV-Nq82-lNrr-EmI1-cerd-numb-1qV6m4

Usage:

在某些情况下,需要恢复一些pv设备,请使用pvcreate命令的--uuid和--restorefile参数来恢复物理卷。 以下命令是使用备份的元数据恢复物理卷标签。

# pvcreate --uuid "0YnHNn-1COx-dohx-bwPf-aLyl-pO8F-f5PI5R" --restorefile /etc/lvm/archive/vg0_00000-1324010847.vg /dev/sda2
  Physical volume "/dev/sda2" successfully created

Note: lvm2 uuid 在被重新创建之后将会被改变

你可能感兴趣的:(Oracle)