客户端安装配置 iSCSI initiator
1. 安装scsi-initiator-utils 软件包
[root@localhost /]# yum install scsi-initiator-utils
2. 查看相关配置文件
# /etc/iscsi/iscsi.conf 主要配置文件,用来连接到iscsi target的设置
# /sbin/iscsid 启动iSCSI initiator的主要服务程序
# /sbin/iscsiadm 用来管理iSCSI initiator的主要设置程序
# /etc/init.d/iscsid 让本机模拟成为iSCSI initiator的主要服务
# /etc/init.d/iscsi iscsi启动脚本
3. 配置/etc/iscsi/iscsid.conf,设置自动启动与用户名密码
# 设置自动挂载,会在node中自动保存相关信息
node.startup = automatic#设置为 target 中设置的用户名和密码
node.session.auth.username = viscsiuser
node.session.auth.password = viscsipasswddiscovery.sendtargets.auth.username = viscsiuser
discovery.sendtargets.auth.password = viscsipasswd
4.配置/etc/iscsi/initiatorname.iscsi,设置主机别名
InitiatorName=iqn.2017-01.dev.iscsi-initiator:initiator
InitiatorAlias=Initiator1
5. 侦测target服务端提供的共享存储设备信息
# 侦测target设备信息
# -m 指定模式,详情见man手册
# -t 指定类型,详情见man手册
# -p 指定IP连接端口,若不使用该选项,默认端口为3260
[root@localhost init.d]# iscsiadm -m discovery -t sendtargets -p 10.0.0.11:3260
10.0.0.11:3260,1 iqn.2017-01.org.rambo:viscsidisk
[root@localhost init.d]#
[root@localhost init.d]# ll -R /var/lib/iscsi/nodes/
/var/lib/iscsi/nodes/:
total 4
drw-------. 3 root root 4096 Jan 21 08:44 iqn.2017-01.org.rambo:viscsidisk/var/lib/iscsi/nodes/iqn.2017-01.org.rambo:viscsidisk:
total 4
drw-------. 2 root root 4096 Jan 21 08:44 10.0.0.11,3260,1/var/lib/iscsi/nodes/iqn.2017-01.org.rambo:viscsidisk/10.0.0.11,3260,1:
total 4
-rw-------. 1 root root 2122 Jan 21 08:44 default# 重启服务
[root@localhost init.d]# /etc/init.d/iscsi restart
Stopping iscsi: [ OK ]
Starting iscsi: [ OK ]# 设置服务开机启动
[root@localhost init.d]# chkconfig iscsi on
[root@localhost init.d]# chkconfig iscsid on
6. 利用刚才侦测的存储设备信息登陆 target
[root@localhost init.d]# iscsiadm -m node -T iqn.2017-01.org.rambo:viscsidisk --login
7.显示已经映射结果磁盘阵列
[root@localhost init.d]# iscsiadm --mode node
10.0.0.11:3260,1 iqn.2017-01.org.rambo:viscsidisk
8.查看当前磁盘信息
[root@localhost init.d]# fdisk -lDisk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x00071b92Device Boot Start End Blocks Id System
/dev/sda1 * 1 39 307200 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 39 2350 18566144 83 Linux
/dev/sda3 2350 2611 2097152 82 Linux swap / Solaris# 这个对应于target中创建的lvm分区
Disk /dev/sdb: 838 MB, 838860800 bytes
26 heads, 62 sectors/track, 1016 cylinders
Units = cylinders of 1612 * 512 = 825344 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000# 这个对应于target中创建的分区 /dev/sda6
Disk /dev/sdc: 1082 MB, 1082587648 bytes34 heads, 61 sectors/track, 1019 cylindersUnits = cylinders of 2074 * 512 = 1061888 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x26ba39da Device Boot Start End Blocks Id System
9.对磁盘(对应target中分区)进行分区
[root@localhost init.d]# fdisk /dev/sdcWARNING: DOS-compatible mode is deprecated. It's strongly recommended toswitch off the mode (command 'c') and change display units tosectors (command 'u').Command (m for help): n
Command actione extendedp primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1019, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1019, default 1019): +1GCommand (m for help): pDisk /dev/sdc: 1082 MB, 1082587648 bytes
34 heads, 61 sectors/track, 1019 cylinders
Units = cylinders of 2074 * 512 = 1061888 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x26ba39daDevice Boot Start End Blocks Id System
/dev/sdc1 1 1012 1049413+ 83 LinuxCommand (m for help): w
The partition table has been altered!Calling ioctl() to re-read partition table.
Syncing disks.
10. 对分区进行格式化,创建挂载目录
[root@localhost init.d]# mkfs.ext4 /dev/sdc1
[root@localhost init.d]# mkdir /mnt/viscsidisk
11. 设置开机自动挂载,在配置文件 /etc/fstab 中添加如下信息
/dev/sdc1 /mnt/viscsidisk ext4 _netdev 0 0
12. 挂载与测试
[root@localhost mnt]# mount -a
[root@localhost mnt]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 18G 3.2G 14G 19% /
tmpfs 495M 372K 494M 1% /dev/shm
/dev/sda1 291M 39M 238M 14% /boot
/dev/sdc1 1008M 34M 924M 4% /mnt/viscsidisk
[root@localhost mnt]# touch viscsidisk/1.c
[root@localhost mnt]# ls viscsidisk/
1.c lost+found
至此,就完成了initiator的配置了,此时可以重启客户端查看挂载信息和刚才创建的文件来检验是否工作正常,若遇到任何问题,可以给我邮件或者评论。 :-D