本帖最后由 justgonnab 于 2018-9-29 11:57 编辑
Linux服务器架设在当今还是比较常见的,没有点基础的Linux必备开局方法还真是不行,好在像RHEL等商业化的Linux系统都自带了很多常用驱动,包括:网卡、USB、RAID、HBA等。所以在开局过程中可以事半功倍,节省很多时间而且可以使版本复杂的开源Linux系统稳定可靠运行,避免很多兼容性问题。
所以今天分享下Linux服务器架设中比较重要的一块工作:存储多路径配置。
操作系统环境:Red Hat Enterprise Linux Server release 6.5 (Santiago)
首先查看系统中是否安装了多路径软件:
device-mapper-X.X.X-X.el6.x86_64
device-mapper-persistent-data-X.X.X-2.el6.x86_64
device-mapper-libs-X.X.X-X.el6.x86_64
device-mapper-event-X.X.X-X.el6.x86_64
device-mapper-multipath-libs-X.X.X-X.el6.x86_64
device-mapper-multipath-X.X.X-X.el6.x86_64
device-mapper-event-libs-X.X.X-X.el6.x86_64
如果查询结果缺少或没有上述的安装包,则执行下面的命令进行安装:
#yum –y install device-mapper device-mapper-multipath.x86_64 device-mapper-multipath-libs.x86_64
- [root@localhost ~]# <b>yum install device-mapper-multipath.x86_64 device-mapper-multipath-libs.x86_64</b>
- Loaded plugins: fastestmirror
- Loading mirror speeds from cached hostfile
- * base: mirrors.aliyun.com
- * extras: mirrors.aliyun.com
- * updates: mirrors.aliyun.com
- Setting up Install Process
- Resolving Dependencies
- --> Running transaction check
- ---> Package device-mapper-multipath.x86_64 0:0.4.9-106.el6 will be installed
- --> Processing Dependency: kpartx = 0.4.9-106.el6 for package: device-mapper-multipath-0.4.9-106.el6.x86_64
- ---> Package device-mapper-multipath-libs.x86_64 0:0.4.9-106.el6 will be installed
- --> Running transaction check
- ---> Package kpartx.x86_64 0:0.4.9-106.el6 will be installed
- --> Finished Dependency Resolution
- Dependencies Resolved
- =============================================================================================================================================================
- Package Arch Version Repository Size
- =============================================================================================================================================================
- Installing:
- device-mapper-multipath x86_64 0.4.9-106.el6 base 133 k
- device-mapper-multipath-libs x86_64 0.4.9-106.el6 base 204 k
- Installing for dependencies:
- kpartx x86_64 0.4.9-106.el6 base 71 k
- Transaction Summary
- =============================================================================================================================================================
- Install 3 Package(s)
- Total download size: 409 k
- Installed size: 731 k
- Is this ok [y/N]: y
- Downloading Packages:
- (1/3): device-mapper-multipath-0.4.9-106.el6.x86_64.rpm | 133 kB 00:00
- (2/3): device-mapper-multipath-libs-0.4.9-106.el6.x86_64.rpm | 204 kB 00:00
- (3/3): kpartx-0.4.9-106.el6.x86_64.rpm | 71 kB 00:00
- -------------------------------------------------------------------------------------------------------------------------------------------------------------
- Total 1.0 MB/s | 409 kB 00:00
- Running rpm_check_debug
- Running Transaction Test
- Transaction Test Succeeded
- Running Transaction
- Installing : device-mapper-multipath-libs-0.4.9-106.el6.x86_64 1/3
- Installing : kpartx-0.4.9-106.el6.x86_64 2/3
- Installing : device-mapper-multipath-0.4.9-106.el6.x86_64 3/3
- Verifying : kpartx-0.4.9-106.el6.x86_64 1/3
- Verifying : device-mapper-multipath-libs-0.4.9-106.el6.x86_64 2/3
- Verifying : device-mapper-multipath-0.4.9-106.el6.x86_64 3/3
- Installed:
- device-mapper-multipath.x86_64 0:0.4.9-106.el6 device-mapper-multipath-libs.x86_64 0:0.4.9-106.el6
- Dependency Installed:
- kpartx.x86_64 0:0.4.9-106.el6
- Complete!
复制代码附:
如果服务器无法连接外网,则可以挂载本地镜像来进行安装。具体操作步骤如下:
使用xftp上传对应版本的操作系统ISO镜像到服务器本地(例如:放在/tmp目录下)
然后挂载本地镜像到/mnt目录:
[root@zxt-1 san]# mount /tmp/rhel-server-6.5-x86_64-dvd.iso /mnt/
接下来开始配置yum源:
在/etc/yum.repos.d/文件夹下创建源文件myyum.repo
编辑文件内容输入:
[myyum]
name=myyum is test
baseurl=file:///mnt/
enabled=1
gpgcheck=0
创建yum缓存:
yum makecache
然后yum安装所需要的软件包即可。
安装完毕后记得卸载挂载的ISO文件:
umount /mnt
安装完毕后,查看多路径是否开机自启动:
# chkconfig --list|grep multipathd
设置开机自启动:
# chkconfig --level 2345 multipathd on
检查安装是否正常,内核中是否存在:
# modprobe -l|grep multipath
kernel/drivers/md/dm-multipath.ko
重启操作系统加载内核或手工进行加载:
# modprobe dm-multipath
# modprobe dm-round-robin
# service multipathd start
产生multipath配置文件
[root@oracle-bak ~]# /sbin/matchpathcon --enable
一般情况下multipath.conf文件无需修改保持默认即可。
获取wwid查看是否识别硬盘:
#multipath -v3
最后重启多路径:
#service multipathd restart
重启完毕后查看多路径是否生效:
#multipath -ll
上述表明多路径建立成功,但是接下来通过fdisk命令来查看识别的磁盘:
- [root@oracle-bak ~]# fdisk -l
- ******省略部分内容******
- Disk <font color="#ff0000"><b>/dev/sdb</b></font>: 1024.0 GB, 1023997378560 bytes
- 255 heads, 63 sectors/track, 124493 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Sector size (logical/physical): 512 bytes / 512 bytes
- I/O size (minimum/optimal): 512 bytes / 1048576 bytes
- Disk identifier: 0x00000000
- Disk <b><font color="#ff0000">/dev/sdd</font></b>: 1024.0 GB, 1023997378560 bytes
- 255 heads, 63 sectors/track, 124493 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Sector size (logical/physical): 512 bytes / 512 bytes
- I/O size (minimum/optimal): 512 bytes / 1048576 bytes
- Disk identifier: 0x00000000
- Disk <b><font color="#ff0000">/dev/sde</font></b>: 1024.0 GB, 1023997378560 bytes
- 255 heads, 63 sectors/track, 124493 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Sector size (logical/physical): 512 bytes / 512 bytes
- I/O size (minimum/optimal): 512 bytes / 1048576 bytes
- Disk identifier: 0x00000000
- Disk<b><font color="#ff0000"> /dev/sdc</font></b>: 1024.0 GB, 1023997378560 bytes
- 255 heads, 63 sectors/track, 124493 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Sector size (logical/physical): 512 bytes / 512 bytes
- I/O size (minimum/optimal): 512 bytes / 1048576 bytes
- Disk identifier: 0x00000000
- Disk <font color="#ff0000"><b>/dev/mapper/mpathb</b></font>: 1024.0 GB, 1023997378560 bytes
- 255 heads, 63 sectors/track, 124493 cylinders
- Units = cylinders of 16065 * 512 = 8225280 bytes
- Sector size (logical/physical): 512 bytes / 512 bytes
- I/O size (minimum/optimal): 512 bytes / 1048576 bytes
- Disk identifier: 0x00000000
复制代码
这边会看到5块相同大小的磁盘,但是我们必须且只能挂载多路径生成的/dev/mapper/mpathb磁盘,其它4块盘sdb、sdc、sdd、sde是因为同一块映射的磁盘到主机侧有4条有效路径所以识别为4块盘,实质上都是同一个LUN映射出来的。如果挂载了其它的其中一块磁盘会发现读写正常但是其余磁盘数据无法同步,且无法实现存储链路冗余备份的作用,这也就是多路径真正的作用。
最终可以对/dev/mapper/mpathb直接进行挂载、格式化使用,或者也可以用来创建之前分享的文章所讲到的逻辑卷(LV)实现后期的磁盘可扩容。 |