Linux
01.系统维护
CPU
内存
drop_cache为什么有些不释放
swap交换分区
磁盘
lvm磁盘扩容
文件夹加密ecryptfs-utils
linux挂载ISCSI磁盘
创建lvm
fstab挂载文件系统
systemd.mount
存储故障
曲线为目录配置限额
lvm缩容
进程
如何找到某一个正在运行的进程?
CRIU进程快照
网络
TCP连接的10种状态
Ubuntu禁用ipv6
close_wait数量过多阻塞网络连接
IP地址与二进制转换
支持ACME的DNS服务器PowerDNS
系统
CentOS版本及对应默认内核版本
修改shell语言
系统启动流程
cgroup
CentOS7升级内核并开启BBR
配置内核参数优化linux
更新grub2默认启动的内核
CentOS-SCLo源
修改键盘映射
Debian12升级时内核编译错误
timesync(ntp)
内核
drop_caches
软件
更新openssl
GUI
Gnome Workspace Names
02.系统安全
Auditd审计服务配置
ssh登陆免公钥验证
恶意脚本处置
2023挖矿脚本m0nad
为ssh服务添加多因子认证
03.基本概念
Out Of Memory
70.QEMU
磁盘格式转换
80.LFS
90.常用脚本
使用except修改操作系统密码
init.d脚本模板
shell脚本判断参数数量
安装oh-my-zsh
systemd脚本模板
端口测试
适用于truenas的ipv6阿里云ddns脚本
更新nginx白名单
将文件改名为md5值
djvu转换为pdf并ocr
99.常用命令
man page中命令后的数字释义
tcpdump
nslookup
nc
rsync
awk
sed
echo
rm
tar
chage
auditctl
ausearch
ab
openssl
parted
find
date
firewall-cmd
sort
vmstat
nice-调整进程的优先级
top
taskset-进程绑定CPU核心
iptables
iostat
sysctl
tr
rpmbuild
转载nginx.spec含说明
安装使用rpmbuild
unpacked files found
grep
vimtutor
tlinux - tos
snmpwalk
chattr
本文档使用 MrDoc 发布
-
+
首页
linux挂载ISCSI磁盘
# linux挂载ISCSI磁盘 ## 安装软件 ```shell yum install -y iscsi-initiator-utils ``` ### 配置服务器IQN ```shell [root@localhost ~]# vim /etc/iscsi/initiatorname.iscsi # 修改InitiatorName后面的IQN名称,注意保持原格式例如 InitiatorName=iqn.2021-06.test.com:myfirstiscsi [root@localhost ~]# systemctl enable iscsid [root@localhost ~]# systemctl start iscsid ``` ## 连接存储 ### 1.发现 ```shell [root@localhost ~]# iscsiadm -m discovery -t st -p 存储控制器IP 192.168.192.1:3260,7938 iqn.2006-08.com.huawei:oceanstor:2222222222222222::22222:192.168.192.1 ``` ### 2.登陆 ```shell [root@localhost ~]# iscsiadm -m node -T 存储IQN -p 存储控制器IP:端口 -l [root@localhost ~]# iscsiadm -m node -T iqn.2006-08.com.huawei:oceanstor:2222222222222222::22222:192.168.192.1 -p 192.168.192.1:3260 -l Logging in to [iface: default, target: iqn.2006-08.com.huawei:oceanstor:2222222222222222::22222:192.168.192.1, portal: 192.168.192.1,3260] Login to [iface: default, target: iqn.2006-08.com.huawei:oceanstor:2222222222222222::22222:192.168.192.1, portal: 192.168.192.1,3260] successful. ``` ### 3.登出 ``` [root@localhost ~]# iscsiadm -m node -T 存储IQN -p 存储控制器IP:端口 -u [root@localhost ~]# iscsiadm -m node -T iqn.2006-08.com.huawei:oceanstor:2222222222222222::22222:192.168.192.1 -p 192.168.192.1:3260 -l Logging out of [iface: default, target: iqn.2006-08.com.huawei:oceanstor:2222222222222222::22222:192.168.192.1, portal: 192.168.192.1,3260] Logout of [iface: default, target: iqn.2006-08.com.huawei:oceanstor:2222222222222222::22222:192.168.192.1, portal: 192.168.192.1,3260] successful. ``` ### 4. 删除 ```shell iscsiadm -m node -u -T IQN号 -p 存储控制器IP iscsiadm -m node -o delete -T IQN号 ``` ## 连接多路径存储 如果是多路径存储,会通过iscsi多个控制器,这时候系统会出现与控制器数量相同的磁盘数如下: ```shell Disk /dev/sda: 3.5 TiB, 3795677347840 bytes, 7413432320 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 Disk /dev/sdb: 3.5 TiB, 3795677347840 bytes, 7413432320 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 ``` 可以看出来这两块盘的大小完全一致,实际上就是一块盘。那么正确使用他们的姿势就是通过`multipath`多路径软件将他们合并为一个多路径磁盘来使用。 ### 安装multipath ``` [root@localhost ~]# yum install -y device-mapper-multipath [root@localhost ~]# systemctl enable multipathd [root@localhost ~]# systemctl start multipathd [root@localhost ~]# systemctl status multipathd ● multipathd.service - Device-Mapper Multipath Device Controller Loaded: loaded (/usr/lib/systemd/system/multipathd.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2021-06-19 21:02:17 CST; 5s ago Process: 22001 ExecStartPre=/sbin/multipath -A (code=exited, status=0/SUCCESS) Process: 21999 ExecStartPre=/sbin/modprobe -a scsi_dh_alua scsi_dh_emc scsi_dh_rdac dm-multipath (code=exited, status=0/SUCCESS) Main PID: 22003 (multipathd) Status: "up" Tasks: 7 Memory: 16.1M CGroup: /system.slice/multipathd.service └─22003 /sbin/multipathd -d -s Jun 19 21:02:17 localhost systemd[1]: Starting Device-Mapper Multipath Device Controller... Jun 19 21:02:17 localhost multipathd[22003]: --------start up-------- Jun 19 21:02:17 localhost multipathd[22003]: read /etc/multipath.conf Jun 19 21:02:17 localhost multipathd[22003]: path checkers start up Jun 19 21:02:17 localhost multipathd[22003]: mpatha: load table [0 7413432320 multipath 0 0 2 1 service-time 0 1 1 8:0 1 service-time 0 1 1 8:16 1] Jun 19 21:02:17 localhost systemd[1]: Started Device-Mapper Multipath Device Controller. ``` ### 1.查看磁盘 ```shell [root@localhost ~]# multipath -ll mpatha (360022a11000dd76eaff3acb400000004) dm-2 HUAWEI,S5500T size=3.5T features='0' hwhandler='0' wp=rw |-+- policy='service-time 0' prio=1 status=active | `- 2:0:0:0 sda 8:0 active ready running `-+- policy='service-time 0' prio=1 status=enabled `- 3:0:0:0 sdb 8:16 active ghost running ``` 从上面可以看出,mpatha这个磁盘下面包含了两块磁盘,`sda`和`sdb`,我们只需要格式化并使用`mpatha`这块磁盘就可以了。 磁盘在下面的位置: ```shell [root@localhost ~]# ls -la /dev/mapper/mpatha lrwxrwxrwx 1 root root 7 Jun 19 21:02 /dev/mapper/mpatha -> ../dm-2 ``` ### 2.为磁盘改名 如果不喜欢`mpatha`可以通过修改配置文件将磁盘改名,比如`vda` ```shell # 查看磁盘mpatha的wwid [root@localhost ~]# /etc/multipath/wwids # Multipath wwids, Version : 1.0 # NOTE: This file is automatically maintained by multipath and multipathd. # You should not need to edit this file in normal circumstances. # # Valid WWIDs: /360022a11000dd76eaff3acb400000004/ # 将下面的mpatha修改为想要的磁盘名称即可 [root@localhost ~]# cat /etc/multipath/bindings # Multipath bindings, Version : 1.0 # NOTE: this file is automatically maintained by the multipath program. # You should not need to edit this file in normal circumstances. # # Format: # alias wwid # mpatha 360022a11000dd76eaff3acb400000004 # 修改完成后重启服务,多路径磁盘就完成重命名了。 ```
zhangky
2021年6月19日 21:19
分享文档
收藏文档
上一篇
下一篇
微信扫一扫
复制链接
手机扫一扫进行分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码