众客华禹

 找回密码
立即注册

QQ登录

只需一步,快速开始

查看: 225|回复: 0

磁盘多路径挂载

[复制链接]

70

主题

70

帖子

378

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
378
发表于 2022-3-22 11:36:43 | 显示全部楼层 |阅读模式
背景:项目中,92-98物理机采用的是华三的3par集中式网络存储,每台机器挂载有一个2TB的硬盘,由于使用的多路径,所以展示出来的结果就是多个盘。
多路径:多条链路提供存储,一条链路出现问题,不影响磁盘使用。

挂载方法:
1、安装插件
  1. yum install -y device-mapper-multipath
复制代码
2、新建 /etc/multipath.conf 文件
  1. # This is a basic configuration file with some examples, for device mapper
  2. # multipath.
  3. #
  4. # For a complete list of the default configuration values, run either
  5. # multipath -t
  6. # or
  7. # multipathd show config
  8. #
  9. # For a list of configuration options with descriptions, see the multipath.conf
  10. # man page

  11. ## By default, devices with vendor = "IBM" and product = "S/390.*" are
  12. ## blacklisted. To enable mulitpathing on these devies, uncomment the
  13. ## following lines.
  14. #blacklist_exceptions {
  15. #    device {
  16. #        vendor    "IBM"
  17. #        product    "S/390.*"
  18. #    }
  19. #}

  20. ## Use user friendly names, instead of using WWIDs as names.
  21. #defaults {
  22. #    user_friendly_names yes
  23. #    find_multipaths yes
  24. #}
  25. ##
  26. ## Here is an example of how to configure some standard options.
  27. ##
  28. #
  29. #defaults {
  30. #    polling_interval     10
  31. #    path_selector        "round-robin 0"
  32. #    path_grouping_policy    multibus
  33. #    uid_attribute        ID_SERIAL
  34. #    prio            alua
  35. #    path_checker        readsector0
  36. #    rr_min_io        100
  37. #    max_fds            8192
  38. #    rr_weight        priorities
  39. #    failback        immediate
  40. #    no_path_retry        fail
  41. #    user_friendly_names    yes
  42. #}
  43. ##
  44. ## The wwid line in the following blacklist section is shown as an example
  45. ## of how to blacklist devices by wwid.  The 2 devnode lines are the
  46. ## compiled in default blacklist. If you want to blacklist entire types
  47. ## of devices, such as all scsi devices, you should use a devnode line.
  48. ## However, if you want to blacklist specific devices, you should use
  49. ## a wwid line.  Since there is no guarantee that a specific device will
  50. ## not change names on reboot (from /dev/sda to /dev/sdb for example)
  51. ## devnode lines are not recommended for blacklisting specific devices.
  52. ##
  53. #blacklist {
  54. #       wwid 26353900f02796769
  55. #    devnode "^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*"
  56. #    devnode "^hd[a-z]"
  57. #}
  58. #multipaths {
  59. #    multipath {
  60. #        wwid            3600508b4000156d700012000000b0000
  61. #        alias            yellow
  62. #        path_grouping_policy    multibus
  63. #        path_selector        "round-robin 0"
  64. #        failback        manual
  65. #        rr_weight        priorities
  66. #        no_path_retry        5
  67. #    }
  68. #    multipath {
  69. #        wwid            1DEC_____321816758474
  70. #        alias            red
  71. #    }
  72. #}
  73. #devices {
  74. #    device {
  75. #        vendor            "COMPAQ  "
  76. #        product            "HSV110 (C)COMPAQ"
  77. #        path_grouping_policy    multibus
  78. #        path_checker        readsector0
  79. #        path_selector        "round-robin 0"
  80. #        hardware_handler    "0"
  81. #        failback        15
  82. #        rr_weight        priorities
  83. #        no_path_retry        queue
  84. #    }
  85. #    device {
  86. #        vendor            "COMPAQ  "
  87. #        product            "MSA1000         "
  88. #        path_grouping_policy    multibus
  89. #    }
  90. #}

  91. blacklist {
  92. }
  93. defaults {
  94. polling_interval 10
  95. user_friendly_names no
  96. find_multipaths yes
  97. }
  98. devices {
  99. device {
  100. vendor "3PARdata"
  101. product "VV"
  102. path_grouping_policy group_by_prio
  103. path_selector "round-robin 0"
  104. path_checker tur
  105. features "0"
  106. hardware_handler "1 alua"
  107. prio alua
  108. failback immediate
  109. rr_weight uniform
  110. no_path_retry 18
  111. rr_min_io_rq 1
  112. detect_prio yes
  113. }
  114. }
  115. multipaths {
  116. multipath {
  117. wwid 360002ac00000000000000020000209e9
  118. alias oradata
  119. }
  120. multipath {
  121. wwid 360002ac00000000000000025000209e9
  122. alias management1
  123. }
  124. multipath {
  125. wwid 360002ac00000000000000026000209e9
  126. alias management2
  127. }
  128. multipath {
  129. wwid 360002ac00000000000000027000209e9
  130. alias votting1
  131. }
  132. multipath {
  133. wwid 360002ac00000000000000028000209e9
  134. alias votting2
  135. }
  136. }
复制代码
3、验证生成wwn文件,查看磁盘id
  1. ll /dev/disk/by-id
  2. total 0

  3. lrwxrwxrwx 1 root root 10 Mar 15 19:18 dm-name-cl-swap -> ../../dm-0
  4. lrwxrwxrwx 1 root root 10 Mar 15 19:18 dm-uuid-LVM-w8tBZQeobwqkqq2whhl3jqYpUh2s2zh8rx2rTOpjORXiwW43hqWhD4tgaVgb0T7d -> ../../dm-0
  5. lrwxrwxrwx 1 root root 10 Mar 15 19:18 lvm-pv-uuid-2Ka8iQ-ZlMi-a1Ae-13kD-qI6U-xDZ3-rFgR5g -> ../../sda4
  6. lrwxrwxrwx 1 root root  9 Mar 15 19:18 scsi-360002ac0000000000000daf300025d53 -> ../../sdi
  7. lrwxrwxrwx 1 root root  9 Mar 15 19:18 scsi-3600605b0110ca9b029c31a1eed563978 -> ../../sda
  8. lrwxrwxrwx 1 root root 10 Mar 15 19:18 scsi-3600605b0110ca9b029c31a1eed563978-part1 -> ../../sda1
  9. lrwxrwxrwx 1 root root 10 Mar 15 19:18 scsi-3600605b0110ca9b029c31a1eed563978-part2 -> ../../sda2
  10. lrwxrwxrwx 1 root root 10 Mar 15 19:18 scsi-3600605b0110ca9b029c31a1eed563978-part3 -> ../../sda3
  11. lrwxrwxrwx 1 root root 10 Mar 15 19:18 scsi-3600605b0110ca9b029c31a1eed563978-part4 -> ../../sda4
  12. lrwxrwxrwx 1 root root 10 Mar 15 19:18 scsi-3600605b0110ca9b029c31a1eed563978-part5 -> ../../sda5
  13. lrwxrwxrwx 1 root root  9 Mar 15 19:18 wwn-0x60002ac0000000000000daf300025d53 -> ../../sdf
  14. lrwxrwxrwx 1 root root  9 Mar 15 19:18 wwn-0x600605b0110ca9b029c31a1eed563978 -> ../../sda
  15. lrwxrwxrwx 1 root root 10 Mar 15 19:18 wwn-0x600605b0110ca9b029c31a1eed563978-part1 -> ../../sda1
  16. lrwxrwxrwx 1 root root 10 Mar 15 19:18 wwn-0x600605b0110ca9b029c31a1eed563978-part2 -> ../../sda2
  17. lrwxrwxrwx 1 root root 10 Mar 15 19:18 wwn-0x600605b0110ca9b029c31a1eed563978-part3 -> ../../sda3
  18. lrwxrwxrwx 1 root root 10 Mar 15 19:18 wwn-0x600605b0110ca9b029c31a1eed563978-part4 -> ../../sda4
  19. lrwxrwxrwx 1 root root 10 Mar 15 19:18 wwn-0x600605b0110ca9b029c31a1eed563978-part5 -> ../../sda5
复制代码
4、查看是否存在两组随机字符串
  1. cat /sys/class/fc_host/host*/port_name
  2. 0x210034800d3f3a05
  3. 0x210034800d3f3d58
复制代码
5、查看磁盘的id
  1. multipath -l

  2. baidu_data1 (360002ac0000000000000daf300025d53) dm-1 3PARdata,VV              
  3. size=2.1T features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
  4. `-+- policy='round-robin 0' prio=0 status=active
  5.   |- 2:0:0:0  sdb 8:16  active undef running
  6.   |- 16:0:0:0 sdf 8:80  active undef running
  7.   |- 2:0:1:0  sdc 8:32  active undef running
  8.   |- 16:0:1:0 sdg 8:96  active undef running
  9.   |- 2:0:2:0  sdd 8:48  active undef running
  10.   |- 16:0:2:0 sdh 8:112 active undef running
  11.   |- 2:0:7:0  sde 8:64  active undef running
  12.   `- 16:0:7:0 sdi 8:128 active undef running
复制代码
6、把第5步看到的id号替换掉 /etc/multipath.conf文件中以下行
  1. multipaths {
  2. multipath {
  3. wwid 360002ac00000000000000020000209e9       #磁盘id
  4. alias oradata                                #可以随边取名
  5. }
复制代码
7、启动服务
  1. systemctl restart multipathd.service
  2. systemctl status multipathd.service
复制代码
8、查看磁盘信息
  1. lsblk
  2. NAME            MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
  3. sdd               8:48   0   2.1T  0 disk  
  4. └─h3c_jzcc      253:2    0   2.1T  0 mpath
  5. sdb               8:16   0   2.1T  0 disk  
  6. └─h3c_jzcc      253:2    0   2.1T  0 mpath
  7. sde               8:64   0   2.1T  0 disk  
  8. └─h3c_jzcc      253:2    0   2.1T  0 mpath
  9. sdc               8:32   0   2.1T  0 disk  
  10. └─h3c_jzcc      253:2    0   2.1T  0 mpath
  11. sda               8:0    0 278.9G  0 disk  
  12. ├─sda2            8:2    0     1G  0 part  /boot
  13. ├─sda3            8:3    0 277.7G  0 part  
  14. │ ├─centos-swap 253:1    0     4G  0 lvm   
  15. │ ├─centos-root 253:0    0    80G  0 lvm   /
  16. │ └─centos-home 253:5    0 193.7G  0 lvm   /home
  17. └─sda1            8:1    0   200M  0 part  /boot/efi
复制代码
9、进行分区,记得必须要分两个区
  1. fdisk /dev/mapper/h3c_jzcc

  2. Welcome to fdisk (util-linux 2.23.2).



  3. Changes will remain in memory only, until you decide to write them.

  4. Be careful before using the write command.



  5. Device does not contain a recognized partition table

  6. Building a new DOS disklabel with disk identifier 0x1a464a06.



  7. WARNING: The size of this disk is 2.3 TB (2308544921600 bytes).

  8. DOS partition table format can not be used on drives for volumes

  9. larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID

  10. partition table format (GPT).





  11. Command (m for help): n

  12. Partition type:

  13.    p   primary (0 primary, 0 extended, 4 free)

  14.    e   extended

  15. Select (default p):

  16. Using default response p

  17. Partition number (1-4, default 1):

  18. First sector (32768-4294967295, default 32768):

  19. Using default value 32768

  20. Last sector, +sectors or +size{K,M,G} (32768-4294967294, default 4294967294):

  21. Using default value 4294967294

  22. Partition 1 of type Linux and of size 2 TiB is set



  23. Command (m for help): w

  24. The partition table has been altered!



  25. Calling ioctl() to re-read partition table.



  26. WARNING: Re-reading the partition table failed with error 22: Invalid argument.

  27. The kernel still uses the old table. The new table will be used at

  28. the next reboot or after you run partprobe(8) or kpartx(8)

  29. Syncing disks.
复制代码
10、挂载
  1. lsblk -f
  2. NAME            FSTYPE       LABEL UUID                                   MOUNTPOINT
  3. sdd             mpath_member       db8cf5b2-c1c0-4192-9cd7-0d26a1e32bca   
  4. └─h3c_jzcc      ext4               db8cf5b2-c1c0-4192-9cd7-0d26a1e32bca   
  5.   ├─h3c_jzcc2                                                            
  6.   └─h3c_jzcc1   ext4               bfcf1ea9-6f70-4715-abab-73feb6a9077f   /data
  7. sdb             mpath_member       db8cf5b2-c1c0-4192-9cd7-0d26a1e32bca   
  8. └─h3c_jzcc      ext4               db8cf5b2-c1c0-4192-9cd7-0d26a1e32bca   
  9.   ├─h3c_jzcc2                                                            
  10.   └─h3c_jzcc1   ext4               bfcf1ea9-6f70-4715-abab-73feb6a9077f   /data
  11. sde             mpath_member       db8cf5b2-c1c0-4192-9cd7-0d26a1e32bca   
  12. └─h3c_jzcc      ext4               db8cf5b2-c1c0-4192-9cd7-0d26a1e32bca   
  13.   ├─h3c_jzcc2                                                            
  14.   └─h3c_jzcc1   ext4               bfcf1ea9-6f70-4715-abab-73feb6a9077f   /data
  15. sdc             mpath_member       db8cf5b2-c1c0-4192-9cd7-0d26a1e32bca   
  16. └─h3c_jzcc      ext4               db8cf5b2-c1c0-4192-9cd7-0d26a1e32bca   
  17.   ├─h3c_jzcc2                                                            
  18.   └─h3c_jzcc1   ext4               bfcf1ea9-6f70-4715-abab-73feb6a9077f   /data
  19. sda                                                                       
  20. ├─sda2          ext4               8cc8c9c5-c80f-4144-bd83-dd5b833c0382   /boot
  21. ├─sda3          LVM2_member        JKVITB-A0aV-rXVS-q0vO-YlW3-Kvel-Fw1GNP
  22. │ ├─centos-swap swap               297cfdff-eb63-4193-a460-575e98d74075   
  23. │ ├─centos-root ext4               841d4192-5fba-4ad7-81ca-aaa0b7181e95   /
  24. │ └─centos-home ext4               5c7b9ba4-5cde-4c1c-b5ae-8a4550c16cc2   /home
  25. └─sda1          vfat               4266-FFA9                              /boot/efi

  26. ## 写入
  27. partprobe  /dev/mapper/h3c_jzcc1

  28. ##格式化分区
  29. mkfs.ext4 /dev/mapper/h3c_jzcc1
  30. ## 创建挂载点
  31. mkdir /data
  32. ## 写入启动挂载文件
  33. echo "UUID=bfcf1ea9-6f70-4715-abab-73feb6a9077f /data         ext4    defaults        0 0" >>/etc/fstab
  34. ## 挂载
  35. mount -a      
复制代码


回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|众客华禹 ( 蜀ICP备2021016660号 )

GMT+8, 2022-5-17 09:36 , Processed in 0.050214 second(s), 18 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表