概述
ISCSI
环境
主机名 | ip地址 | 角色 | 系统 |
---|---|---|---|
dc1 | 10.10.70.101 | ISCSI-server | debian 11 |
dc2 | 10.10.70.102 | ISCSI-client | debian 11 |
配置
servr
#安装targetcli-fb
apt -y install targetcli-fb
#创建一个目录
root@dlp:~# mkdir /var/lib/iscsi_disks
#进入管理控制台
root@dlp:~# targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.53
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.
/> cd backstores/fileio
#添加一块磁盘,在挂历控制台上添加上
/backstores/fileio> create disk01 /var/lib/iscsi_disks/disk01.img 10G
Created fileio disk01 with size 10737418240
/backstores/fileio> cd /iscsi
# create a target
# naming rule : [ iqn.(year)-(month).(reverse of domain name):(any name you like) ]
/iscsi> create iqn.2021-08.world.srv:dlp.target01
Created target iqn.2021-08.world.srv:dlp.target01.
Created TPG 1.
Global pref auto_add_default_portal=true
Created default portal listening on all IPs (0.0.0.0), port 3260.
/iscsi> cd iqn.2021-08.world.srv:dlp.target01/tpg1/luns
# set LUN
/iscsi/iqn.20...t01/tpg1/luns> create /backstores/fileio/disk01
Created LUN 0.
/iscsi/iqn.20...t01/tpg1/luns> cd ../acls
# set ACL (it's the IQN of an initiator you permit to connect)
/iscsi/iqn.20...t01/tpg1/acls> create iqn.2021-08.world.srv:node01.initiator01
Created Node ACL for iqn.2021-08.world.srv:node01.initiator01
Created mapped LUN 0.
/iscsi/iqn.20...t01/tpg1/acls> cd iqn.2021-08.world.srv:node01.initiator01
# set UserID and Password for authentication
/iscsi/iqn.20...w.initiator01> set auth userid=username
Parameter userid is now 'username'.
/iscsi/iqn.20...w.initiator01> set auth password=password
Parameter password is now 'password'.
/iscsi/iqn.20...w.initiator01> exit
Global pref auto_save_on_exit=true
Configuration saved to /etc/rtslib-fb-target/saveconfig.json
# after configuration above, the target enters in listening like follows
root@dlp:~# ss -napt | grep 3260
LISTEN 0
256
0.0.0.0:3260
0.0.0.0:*
root@dlp:~# systemctl enable rtslib-fb-targetctl
#示例
#session认证
/iscsi/iqn.20....iscsi:client>
set auth userid=LinuxServerUser password=ServerPassword
mutual_userid=LinuxClientUser mutual_password=ClientPassword
Parameter userid is now 'LinuxServerUser'.
Parameter password is now 'ServerPassword'.
Parameter mutual_userid is now 'LinuxClientUser'.
Parameter mutual_password is now 'ClientPassword'.
#discover认证
/iscsi>
set
discovery_auth
userid=LinuxServerUser password=ServerPassword
mutual_userid=LinuxClientUser mutual_password=ClientPassword
Parameter userid is now 'LinuxServerUser'.
Parameter password is now 'ServerPassword'.
Parameter mutual_userid is now 'LinuxClientUser'.
Parameter mutual_password is now 'ClientPassword'.
client
root@node01:~# apt -y install open-iscsi
root@node01:~# vi /etc/iscsi/initiatorname.iscsi
# 修改为与iSCSI目标服务器上设置的IQN相同
InitiatorName=iqn.2021-08.world.srv:node01.initiator01
root@node01:~# vi /etc/iscsi/iscsid.conf
# 第58行:取消注释
node.session.auth.authmethod = CHAP
# 第69、70行:取消注释并指定在iSCSI目标服务器上设置的用户名和密码
node.session.auth.username = username
node.session.auth.password = password
# 重启服务
root@node01:~# systemctl restart iscsid open-iscsi
# 发现目标
root@node01:~# iscsiadm -m discovery -t sendtargets -p 10.0.0.30
10.0.0.30:3260,1 iqn.2021-08.world.srv:dlp.target01
# 发现后确认状态
root@node01:~# iscsiadm -m node -o show
# 开始记录2.1.3
node.name = iqn.2021-08.world.srv:dlp.target01
node.tpgt = 1
node.startup = manual
node.leading_login = No
iface.iscsi_ifacename = default
.....
.....
node.conn[0].iscsi.HeaderDigest = None
node.conn[0].iscsi.DataDigest = None
node.conn[0].iscsi.IFMarker = No
node.conn[0].iscsi.OFMarker = No
# 结束记录
# 登录到目标器
root@node01:~# iscsiadm -m node --login
Logging in to [iface: default, target: iqn.2021-08.world.srv:dlp.target01, portal: 10.0.0.30,3260]
Login to [iface: default, target: iqn.2021-08.world.srv:dlp.target01, portal: 10.0.0.30,3260] successful.
# 确认建立的会话
root@node01:~# iscsiadm -m session -o show
tcp: [1] 10.0.0.30:3260,1 iqn.2021-08.world.srv:dlp.target01 (non-flash)
# 确认分区
root@node01:~# cat /proc/partitions
major minor
#blocks
name
254
0
31457280 sda
254
1
498688 sda1
254
2
1 sda2
254
5
30955520 sda5
253
0
29949952 dm-0
253
1
1003520 dm-1
11
0
1048575 sr0
8
0
10485760 sdb
# 添加了目标服务器提供的新设备[sdb]
2.完成iSCSI设备的设置后,需要在启动器上进行如下配置才能使用iSCSI设备。
root@node01:~# apt -y install parted
# create label
root@node01:~# parted --script /dev/sdb "mklabel gpt"
# create partiton
root@node01:~# parted --script /dev/sdb "mkpart primary 0% 100%"
# format with ext4
root@node01:~# mkfs.ext4 /dev/sdb1
mke2fs 1.46.2 (28-Feb-2021)
Creating filesystem with 2617344 4k blocks and 655360 inodes
Filesystem UUID: 0d55d46a-e2d1-45d1-b55c-e030c23c18f5
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
root@node01:~# mount /dev/sdb1 /mnt
root@node01:~# df -hT
Filesystem
Type
Size
Used Avail Use% Mounted on
udev
devtmpfs
2.0G
0
2.0G
0% /dev
tmpfs
tmpfs
394M
540K
393M
1% /run
/dev/mapper/debian--vg-root ext4
28G
1.1G
26G
4% /
tmpfs
tmpfs
2.0G
0
2.0G
0% /dev/shm
tmpfs
tmpfs
5.0M
0
5.0M
0% /run/lock
/dev/sda1
ext2
470M
48M
398M
11% /boot
tmpfs
tmpfs
394M
0
394M
0% /run/user/0
/dev/sdb1
ext4
9.8G
24K
9.3G
1% /mnt
最后
以上就是不安小熊猫为你收集整理的debian 11搭建ISCSI TargetISCSI的全部内容,希望文章能够帮你解决debian 11搭建ISCSI TargetISCSI所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复