ubuntu上配置multipath

简介: ubuntu上配置multipath

参考

框图

步骤

上文中在ubuntu下搭建了iscsi存储,下面基于iscsi存储创建multipath环境。

  • 给Host添加一块存储设备

/dev/nvme0n2

  • 配置tgt
    cat /etc/tgt/conf.d/iscsi.conf
cat /etc/tgt/conf.d/iscsi.conf
<target iqn.2023-02.pendl.com:disk1>
backing-store /dev/nvme0n1
initiator-address 192.168.159.144
</target>
<target iqn.2023-02.pendl.com:disk2>
backing-store /dev/nvme0n2
</target>

上面第二个target是要创建的multipath iscsi存储,对应的是host上的/dev/nvme0n2,这里没有指定IP地址,所有可以通过Host的多个IP访问。

  • 重启tgt,并查看状态
systemctl restart tgt
systemctl status tgt

可以看到如下信息:

➜  x86 sudo systemctl status tgt.service
● tgt.service - (i)SCSI target daemon
Loaded: loaded (/lib/systemd/system/tgt.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2023-02-13 17:35:23 PST; 2s ago
Docs: man:tgtd(8)
Process: 8403 ExecStartPost=/usr/sbin/tgtadm --op update --mode sys --name State -v offline (code=exited, status=0/SUCCESS)
Process: 8404 ExecStartPost=/usr/sbin/tgt-admin -e -c /etc/tgt/targets.conf (code=exited, status=0/SUCCESS)
Process: 8455 ExecStartPost=/usr/sbin/tgtadm --op update --mode sys --name State -v ready (code=exited, status=0/SUCCESS)
Main PID: 8402 (tgtd)
Status: "Starting event loop..."
Tasks: 33
Memory: 1.6M
CGroup: /system.slice/tgt.service
└─8402 /usr/sbin/tgtd -f
Feb 13 17:35:23 ubuntu systemd[1]: Starting (i)SCSI target daemon...
Feb 13 17:35:23 ubuntu tgtd[8402]: tgtd: iser_ib_init(3431) Failed to initialize RDMA; load kernel modules?
Feb 13 17:35:23 ubuntu tgtd[8402]: tgtd: work_timer_start(146) use timer_fd based scheduler
Feb 13 17:35:23 ubuntu tgtd[8402]: tgtd: bs_init(387) use signalfd notification
Feb 13 17:35:23 ubuntu tgtd[8402]: tgtd: device_mgmt(246) sz:18 params:path=/dev/nvme0n1
Feb 13 17:35:23 ubuntu tgtd[8402]: tgtd: bs_thread_open(409) 16
Feb 13 17:35:23 ubuntu tgtd[8402]: tgtd: device_mgmt(246) sz:18 params:path=/dev/nvme0n2
Feb 13 17:35:23 ubuntu tgtd[8402]: tgtd: bs_thread_open(409) 16
Feb 13 17:35:23 ubuntu systemd[1]: Started (i)SCSI target daemon.
  • 验证target
sudo tgtadm --mode target --op show

可以看到如下信息:

// 这里省去了Target1的信息
Target 2: iqn.2023-02.pendl.com:disk2
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET     00020000
SCSI SN: beaf20
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
SWP: No
Thin-provisioning: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 1
Type: disk
SCSI ID: IET     00020001
SCSI SN: beaf21
Size: 21475 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
SWP: No
Thin-provisioning: No
Backing store type: rdwr
Backing store path: /dev/nvme0n2
Backing store flags:
Account information:
ACL information:
ALL

客户端

  • 可以再给客户端增加一块网卡

为了简单,客户端只用了一块网卡,只是服务端有多块网卡。

  • 发现target
root@ubuntu-vm:~# iscsiadm -m discovery -t st -p 192.168.159.130
192.168.159.130:3260,1 iqn.2023-02.pendl.com:disk2
root@ubuntu-vm:~# iscsiadm -m discovery -t st -p 192.168.159.144
192.168.159.144:3260,1 iqn.2023-02.pendl.com:disk1
192.168.159.144:3260,1 iqn.2023-02.pendl.com:disk2
  • 登录
root@ubuntu-vm:~# iscsiadm -m node -l
Logging in to [iface: default, target: iqn.2023-02.pendl.com:disk2, portal: 192.168.159.130,3260] (multiple)
Logging in to [iface: default, target: iqn.2023-02.pendl.com:disk2, portal: 192.168.159.144,3260] (multiple)
Logging in to [iface: default, target: iqn.2023-02.pendl.com:disk1, portal: 192.168.159.144,3260] (multiple)
Login to [iface: default, target: iqn.2023-02.pendl.com:disk2, portal: 192.168.159.130,3260] successful.
Login to [iface: default, target: iqn.2023-02.pendl.com:disk2, portal: 192.168.159.144,3260] successful.
Login to [iface: default, target: iqn.2023-02.pendl.com:disk1, portal: 192.168.159.144,3260] successful.

登录以后,服务端也会有相应的变化:

Target 2: iqn.2023-02.pendl.com:disk2
System information:
Driver: iscsi
State: ready
I_T nexus information:
I_T nexus: 10
Initiator: iqn.2023-02.pendl.com:client alias: ubuntu-vm
Connection: 0
IP Address: 192.168.159.130
I_T nexus: 11
Initiator: iqn.2023-02.pendl.com:client alias: ubuntu-vm
Connection: 0
IP Address: 192.168.159.144
LUN information:
LUN: 0
Type: controller
SCSI ID: IET     00020000
SCSI SN: beaf20
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
SWP: No
Thin-provisioning: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 1
Type: disk
SCSI ID: IET     00020001
SCSI SN: beaf21
Size: 21475 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
SWP: No
Thin-provisioning: No
Backing store type: rdwr
Backing store path: /dev/nvme0n2
Backing store flags:
Account information:
ACL information:
ALL
  • 安装multipath软件包
apt-get install multipath-tools
  • 查看multipath状态
root@ubuntu-vm:~# multipath -ll
mpathc (360000000000000000e00000000020001) dm-0 IET     ,VIRTUAL-DISK
size=20G features='0' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=enabled
  |- 2:0:0:1 sda 8:0  active ready running
  `- 3:0:0:1 sdb 8:16 active ready running
  • 分区格式化
root@ubuntu-vm:~# ls /dev/mapper/ -l
total 0
crw------- 1 root root 10, 236 Feb 14 09:42 control
lrwxrwxrwx 1 root root       7 Feb 14 10:24 mpathc -> ../dm-0

下面对/dev/mpathc进行分区格式化

root@ubuntu-vm:~# fdisk -l /dev/mapper/mpathc
Disk /dev/mapper/mpathc: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
root@ubuntu-vm:~# fdisk /dev/mapper/mpathc
Welcome to fdisk (util-linux 2.34).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xf7a0076c.
Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p):
Using default response p.
Partition number (1-4, default 1):
First sector (2048-41943039, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-41943039, default 41943039):
Created a new partition 1 of type 'Linux' and of size 20 GiB.
Command (m for help): w
The partition table has been altered.
Syncing disks.
root@ubuntu-vm:~# mkfs.ext4 /dev/mapper/mpathc
mke2fs 1.45.5 (07-Jan-2020)
Found a dos partition table in /dev/mapper/mpathc
Proceed anyway? (y,N) y
Creating filesystem with 5242880 4k blocks and 1310720 inodes
Filesystem UUID: cdf9c090-5de1-41d9-a264-5ccdc45a27e2
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
BASH 折叠 复制 全屏
  • 挂载
mount /dev/mapper/mpathc ./demo
相关文章
|
1月前
|
人工智能 Ubuntu 前端开发
Dify部署全栈指南:AI从Ubuntu配置到HTTPS自动化的10倍秘籍
本文档介绍如何部署Dify后端服务及前端界面,涵盖系统环境要求、依赖安装、代码拉取、环境变量配置、服务启动、数据库管理及常见问题解决方案,适用于开发与生产环境部署。
379 1
|
2月前
|
Ubuntu Linux 网络安全
Linux服务器之Ubuntu的安装与配置
Ubuntu Desktop是目前最成功、最流行的图形界面的Linux发行版;而Ubuntu Server也在服务器端市场占据了较大的份额。今天为大家详细介绍了Ubuntu Server的安装与配置,希望对你能有所帮助。关于VMware、VirtualBox等虚拟化软件的使用,朱哥还会在后续的文章中为大家详细介绍,敬请关注!
|
26天前
|
Ubuntu 安全 应用服务中间件
详细指南:配置Nginx服务器在Ubuntu平台上
以上步骤涵盖了基本流程:从软件包管理器获取 Ngnix, 设置系统服务, 调整UFW规则, 创建并激活服务器块(也称作虚拟主机), 并进行了初步优化与加固措施。这些操作都是建立在命令行界面上,并假设用户具有必要权限(通常是root用户)来执行这些命令。每个操作都有其特定原因:例如,设置开机启动确保了即使重启后也能自动运行 Ngnix;而编辑server block则定义了如何处理进入特定域名请求等等。
185 18
|
28天前
|
Ubuntu 安全 应用服务中间件
详细指南:配置Nginx服务器在Ubuntu平台上
以上步骤涵盖了基本流程:从软件包管理器获取 Ngnix, 设置系统服务, 调整UFW规则, 创建并激活服务器块(也称作虚拟主机), 并进行了初步优化与加固措施。这些操作都是建立在命令行界面上,并假设用户具有必要权限(通常是root用户)来执行这些命令。每个操作都有其特定原因:例如,设置开机启动确保了即使重启后也能自动运行 Ngnix;而编辑server block则定义了如何处理进入特定域名请求等等。
188 17
|
1月前
|
Ubuntu 安全 关系型数据库
安装与配置MySQL 8 on Ubuntu,包括权限授予、数据库备份及远程连接指南
以上步骤提供了在Ubuntu上从头开始设置、配置、授权、备份及恢复一个基础但完整的MySQL环境所需知识点。
259 7
|
1月前
|
消息中间件 人工智能 运维
Ubuntu环境下的 RabbitMQ 安装与配置详细教程
本文聚焦在Ubuntu下RabbitMQ安装与配置教程,旨在帮助读者快速构建稳定可用的消息队列服务。
|
2月前
|
缓存 Ubuntu Docker
Ubuntu环境下删除Docker镜像与容器、配置静态IP地址教程。
如果遇见问题或者想回滚改动, 可以重启系统.
183 16
|
2月前
|
缓存 监控 Ubuntu
在Ubuntu 16.04上配置GitLab Runner以激活GitLab CI/CD流程
完成以上步骤后,每当代码被推送到远端仓库中相对应分支上时,GitLb CI / CD 流水线就会自动触发,并由之前注册好了 GitLb runner 的机器去完成定义好了 ` .gitlabcicd.yml ` 文件里面定义好各种任务(如编译测试部署等).
90 13
|
2月前
|
XML Ubuntu Java
如何在Ubuntu系统上安装和配置JMeter和Ant进行性能测试
进入包含 build.xml 的目录并执行:
140 13
|
3月前
|
Ubuntu 关系型数据库 MySQL
在Ubuntu上配置phpMyAdmin和WordPress环境的步骤
执行以上步骤后,你将成功配置Ubuntu系统上的phpMyAdmin和WordPress环境。需要注意的是,应该根据自己实际的环境如具体的Ubuntu版本、WordPress版本和个人的安全需求做适当调整。此配置指南假定你拥有一个干净的Ubuntu服务器环境,某些步骤比如MySQL的root密码已经设置好了。
102 14