在iSCSI设备上(FreeNAS)启用了CHAP认证(单向)。现在需要在linux下挂载,步骤如下:
安装iSCSI发起程序:
[root@localhost ~]# yum list | grep iscsi-initiator
iscsi-initiator-utils.x86_64 6.2.0.873-10.el6 base
iscsi-initiator-utils-devel.x86_64 6.2.0.873-10.el6 base
[root@localhost ~]#yum install -y iscsi-initiator-utils
启动iSCSI服务,设置开机启动。
[root@localhost ~]# service iscsi start
[root@localhost ~]# chkconfig iscsi on
[root@localhost ~]# chkconfig iscsi –list
iscsi 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
编辑iscsi配置文件,添加initiator单向认证,如果没有认证,默认即可。
[root@localhost ~]# vi /etc/iscsi/iscsid.conf
node.startup = automatic
node.session.auth.username = admin
node.session.auth.password = admin1234567890
[root@localhost ~]# service iscsi restart
停止 iscsi: [确定]
正在启动 iscsi: [确定]
发现目标:
[root@localhost ~]# iscsiadm -m discovery -t sendtargets -p 192.168.0.135
192.168.0.135:3260,1 iqn.testscsi
[root@localhost ~]#iscsiadm -m node -T iqn.testscsi -p 192.168.0.135 -l // -l登陆 -u 断开
Logging in to [iface: default, target: iqn.testscsi, portal: 192.168.0.135,3260] (multiple)
Login to [iface: default, target: iqn.testscsi, portal: 192.168.0.135,3260] successful.
如果提示下面的信息,可能是用户名密码配置错误,修改完成后需要重新发现。
重启前最好先退出target(logout)
[root@localhost ~]# iscsiadm -m node -T iqn.testscsi -p 192.168.0.135:3260 -l
Logging in to [iface: default, target: iqn.testscsi, portal: 192.168.0.135,3260] (multiple)
iscsiadm: Could not login to [iface: default, target: iqn.testscsi, portal: 192.168.0.135,3260].
iscsiadm: initiator reported error (24 – iSCSI login failed due to authorization failure)
iscsiadm: Could not log into all portals
格式化,挂载:
[root@localhost ~]# fdisk -l
Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000e4b9b
Device Boot Start End Blocks Id System
/dev/sda1 * 1 10199 81920000 83 Linux
/dev/sda2 10199 10454 2048000 82 Linux swap / Solaris
Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 4096 bytes / 1048576 bytes
Disk identifier: 0xa8a996b2
Device Boot Start End Blocks Id System
/dev/sdb1 1 1306 10482688 7 HPFS/NTFS
[root@localhost ~]# mkfs.ext3 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=1 blocks, Stripe width=256 blocks
655360 inodes, 2620672 blocks
131033 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 39 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost ~]#mkdir /mnt/iscsi
[root@localhost ~]#mount /dev/sdb1 /mnt/iscsi/
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 77G 4.3G 69G 6% /
tmpfs 120M 0 120M 0% /dev/shm
/dev/sdb1 9.9G 151M 9.2G 2% /mnt/iscsi
[root@localhost ~]#
写入到/etc/fstab自动开机挂载即可。
ISCSI常用命令:
1、发现iscsi存储: iscsiadm -m discovery -t st -p ISCSI_IP
2、查看iscsi发现记录 iscsiadm -m node
3、删除iscsi发现记录 iscsiadm -m node -o delete -T LUN_NAME -p ISCSI_IP
4、登录iscsi存储 iscsiadm -m node -T LUN_NAME -p ISCSI_IP -l
5、登出iscsi存储 iscsiadm -m node -T LUN_NAME -p ISCSI_IP -u
专注于 服务器运维与web架构
E-mail:venus#rootop.org