IOR 测试
一 本地文件系统测试 1 安装依赖 1 sudo apt update && sudo apt install -y git build-essential automake libopenmpi-dev openmpi-bin libaio-dev
2 克隆并编译 IOR 1 2 3 4 5 git clone https://github.com/hpc/ior.git cd ior./bootstrap ./configure make
3 测试文件系统 1 2 ./src/ior -a POSIX -w -r -t 1m -b 1g -s 1 -o /path/to/ext4/testfile -e -C
4 测试结果
二 分布式文件系统测试
配置:至少两个节点,节点间能互相ping通 这里使用两台virtualBox模拟两个节点,通过桥接模式连接 ior11作为客户端 ip 地址为 192.168.222.154,ubuntu20作为服务器 ip 地址为 192.168.222.233 文中node1和node2在此测试中分别为ubuntu20和ior11
1 部署 GlusterFS
更新系统并添加 GlusterFS PPA(在所有节点上执行)
1 2 3 4 sudo apt updatesudo apt install software-properties-common -ysudo add-apt-repository ppa:gluster/glusterfs-10 -ysudo apt update
安装 GlusterFS 服务器(在所有节点上执行)
1 sudo apt install glusterfs-server -y
启动并启用 GlusterFS 服务(在所有节点上执行)
1 2 3 sudo systemctl start glusterdsudo systemctl enable glusterdsudo systemctl status glusterd
配置主机名解析(在所有节点上执行): 编辑 /etc/hosts 文件,添加所有节点的 IP 和主机名。例如
添加内容如下:
1 2 3 192.168.1.101 node1 192.168.1.102 node2
这一步的目的是确保双方能ping通
配置防火墙(如果启用,在所有节点上执行): GlusterFS 使用端口 24007-24008、49152 等。
1 2 3 4 sudo ufw allow from 192.168.1.0/24 to any port 24007:24008 proto tcpsudo ufw allow from 192.168.1.0/24 to any port 49152:49160 proto tcp sudo ufw reload
这一步我没整,因为虚拟机没启用防火墙
建立节点间的信任(从服务器节点上执行)
1 2 sudo gluster peer probe node2sudo gluster peer status
只要能ping通就能连接
创建存储砖 (brick,在所有节点上执行): 为 GlusterFS 准备专用目录和分区(例如,使用 /data/brick1)。假设您有一个空分区 /dev/sdb:
通过在virtualbox中添加虚拟磁盘可以为虚拟机增加一个空分区sdb
1 2 3 4 sudo mkfs.xfs /dev/sdbsudo mkdir -p /data/brick1sudo mount /dev/sdb /data/brick1
编辑 /etc/fstab 添加自动挂载:
1 /dev/sdb /data/brick1 xfs defaults 0 0
创建分布式卷(从服务器节点执行): 这里创建一个简单的分布式复制卷(replicated volume),副本数为 2
1 2 3 sudo gluster volume create test-volume replica 2 node1:/data/brick1 node2:/data/brick1 forcesudo gluster volume start test-volumesudo gluster volume info test-volume
挂载 GlusterFS 卷(在客户端节点或测试节点上执行): 安装客户端(如果不是服务器节点)
1 sudo apt install glusterfs-client -y
1 2 sudo mkdir /mnt/glustersudo mount -t glusterfs node1:/test-volume /mnt/gluster
此时就在客户端节点上挂载了服务器端的卷,客户端或服务器写这个卷两边都会同时修改
如果重启虚拟机,则需要重新挂载一一遍glusterfs
1 sudo mount -t glusterfs node1:/test-volume /mnt/gluster
或者设置自动挂载
1 2 sudo vim /etc/fstabnode1:/test-volume /mnt/gluster glusterfs defaults,_netdev,backupvolfile-server=node2 0 0
在服务器上使用 echo "Hello Gluster" > /mnt/gluster/testfile
测试是否挂载成功
或者使用 mount | grep /mnt/gluster
查看是否挂载了 gluster 卷,如果为空则没有挂载
2 安装 MPI 和 IOR
IOR 是一个 I/O 基准测试工具,需要 MPI支持分布式测试,这里使用OpenMPI
安装OpenMPI(在所有测试节点上执行)
1 2 3 sudo apt updatesudo apt install openmpi-bin openmpi-common libopenmpi-dev -ympirun --version
如果需要 SSH 支持分布式运行(多节点)
1 2 3 4 5 6 7 sudo apt install openssh-server -yssh-keygen -t rsa ssh-copy-id user@node2 ssh-keygen -t rsa ssh-copy-id user@node1
配置无密码 SSH 时要注意,如果node1或2的ssh配置文件没有设置 PermitRootLogin yes PasswordAuthentication yes 是无法通过密码 ssh 到 node1或2 上的 修改完ssh配置后,使用sudo sshd -t检查是否有语法错误,然后重启ssh服务 sudo systemctl restart ssh sudo systemctl status ssh # 检查服务是否运行,无错误
安装 IOR(在测试节点上执行,从源代码编译,因为 Ubuntu 仓库中没有直接包): IOR 需要 MPI 支持,所以在配置时指定
1 2 3 4 5 6 7 sudo apt install git autoconf automake libtool make gcc -y # 安装依赖 git clone https://github.com/hpc/ior.git cd ior ./bootstrap ./configure --prefix=/usr/local --with-mpiio make sudo make install
如果提示 autoconf 版本不正确,则通过以下命令升级autoconf版本 sudo apt update && sudo apt install -y wget tar make m4 perl wget https://ftp.gnu.org/gnu/autoconf/autoconf-2.71.tar.gz tar -xzf autoconf-2.71.tar.gz cd autoconf-2.71 ./configure –prefix=/usr/local make sudo make install
3 使用 IOR 通过 MPI 测试 GlusterFS 性能
IOR 支持多种 I/O 模式(如 POSIX、MPI-IO),可以测试读/写带宽、IOPS 等。使用 MPI 允许分布式测试(多进程/多节点)
单机测试写入性能(MPI-IO 接口,2 进程,块大小 1MB,传输大小 1MB,重复 3 次)
1 mpirun -np 2 ior -a MPIIO -b 1m -t 1m -i 3 -o /mnt/gluster/testfile -w
-np 2: 使用 2 个 MPI 进程(根据您的 CPU 核心调整)
-a MPIIO: 使用 MPI-IO 接口(适合分布式文件系统)
-b 1m: 块大小(block size)
-t 1m: 传输大小(transfer size)。
-i 3: 重复迭代 3 次。
-o: 输出文件路径(在 Gluster 卷上)
-w: 只测试写入。 输出将显示带宽(MB/s)、操作时间等
测试读取性能
1 mpirun -np 2 ior -a MPIIO -b 1m -t 1m -i 3 -o /mnt/gluster/testfile -r
多节点测试(重点部分)
使用 -hostfile 指定主机: 创建 hostfile.txt:
1 2 node1 slots=2 // slots是可用cpu数量 node2 slots=2
进行测试
1 mpirun --hostfile hostfile.txt ior -a MPIIO -b 1m -t 1m -i 3 -o /mnt/gluster/testfile -w
4 总结
做完了前面的准备工作后,使用ior测试分布式文件系统gluster的性能就这么几步
在所有节点上启动 GlusterFS 服务
1 2 3 sudo systemctl start glusterdsudo systemctl enable glusterdsudo systemctl status glusterd
挂载 GlusterFS 卷
1 sudo mount -t glusterfs node1:/test-volume /mnt/gluster
进行测试
1 2 3 node1 slots=2 node2 slots=2
1 2 mpirun --hostfile hostfile.txt ior -a MPIIO -b 1m -t 1m -i 3 -o /mnt/gluster/testfile -w
三 离线环境下安装 IOR