CentOS 6.5 安装使用iscsi-initiator

分类:CentOS教程 阅读:81127 次

[root@I-IT ~]# yum install iscsi\* [root@I-IT ~]# rpm -qa | grep iscsi\* iscsi-initiator-utils-devel-6.2.0.873-10.el6.x86_64 iscsi-initiator-utils-6.2.0.873-10.el6.x86_64

[root@I-IT ~]# ls /etc/iscsi/ | sort initiatorname.iscsi ##软件iSCSI initiator的intiator名称配置文件## iscsid.conf ##所有刚发起的iSCSI session默认都将使用这个文件中的参数设定## 确认iscsi服务随系统启动而启动 ###################################################################### [root@I-IT ~]# chkconfig --list | grep iscsi iscsi 0:off 1:off 2:off 3:on 4:on 5:on 6:off iscsid 0:off 1:off 2:off 3:on 4:on 5:on 6:off ######################################################################

[root@I-IT ~]# cat /etc/iscsi/initiatorname.iscsi InitiatorName=iqn.2014-04.com.i-it:test-iscsi ##接受参数的名字严格区分大小写## ##遵循IQN命名规范iqn.domaindate.reverse.domain.name:optional name

###编辑/etc/iscsi/iscsi.conf文件,确认node.startup的值为automatic,如果iSCSI存储服务器的target上启用了CHAP认证,则还需要配置CAHP认证:### |这块注释很容易懂| #node.session.auth.authmethod = CHAP #node.session.auth.username = username #node.session.auth.password = password #至少12个字符哦# node.startup = automatic 自动登录(默认是automatic) node.startup = manual 手动登录。 node.session.timeo.replacement_timeout = 120 #应用程序的超时时间

########可以看到我前面共享出来的设备########## [root@itchenyi ~]# iscsiadm -m discovery -t sendtargets -p www.i-it.info 10.204.10.204:3260,1 iqn.2014-04.i-it.info:test-iscsi

[root@itchenyi ~]# iscsiadm -m node -o show # BEGIN RECORD 6.2.0-873.10.el6 node.name = iqn.2014-04.i-it.info:test-iscsi node.tpgt = 1 node.startup = automatic ##省略若干行.....##

[root@itchenyi ~]# iscsiadm -m node --targetname iqn.2014-04.i-it.info:test-iscsi --portal www.i-it.info --login Logging in to [iface: default, target: iqn.2014-04.i-it.info:test-iscsi, portal: 10.204.10.204,3260] (multiple) Login to [iface: default, target: iqn.2014-04.i-it.info:test-iscsi, portal: 10.204.10.204,3260] successful. ## 登入所有扫描到到iscsi ## iscsiadm -m node --login

[root@itchenyi ~]# fdisk -l ###.....省略多行### Disk /dev/sdc: 10.7 GB, 10742151168 bytes 64 heads, 32 sectors/track, 10244 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xf2fa270c Device Boot Start End Blocks Id System /dev/sdc1 1 10244 10489840 83 Linux ###.....省略多行### [root@itchenyi ~]# mkfs.ext4 /dev/sdc1

[root@itchenyi ~]# cat /etc/ ###.....省略多行### /dev/sdc1 /mnt ext4 defaults 0 0 [root@itchenyi ~]# mount -a [root@itchenyi ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3 74G 61G 9.6G 87% / tmpfs 2.9G 500K 2.9G 1% /dev/shm /dev/sda1 194M 32M 152M 18% /boot /dev/sda5 372G 2.7G 351G 1% /data /dev/sdc1 9.9G 151M 9.2G 2% /mnt

 ###注销指定targets### ###注销前请卸载当前挂载的iSCSI共享磁盘### [root@itchenyi ~]# iscsiadm -m node -T iqn.2014-04.i-it.info:test-iscsi --portal www.i-it.info -u Logging out of session [sid: 1, target: iqn.2014-04.i-it.info:test-iscsi, portal: 10.204.10.204,3260] Logout of [sid: 1, target: iqn.2014-04.i-it.info:test-iscsi, portal: 10.204.10.204,3260] successful. ###注销所有targets### [root@itchenyi ~]# iscsiadm -m node --logoutall=all ###删除targets信息### [root@itchenyi ~]# iscsiadm -m node -o delete -T iqn.2014-04.i-it.info:test-iscsi --portal www.i-it.info ###查看当前iSCSI数据库中存储了哪些target记录### [root@itchenyi ~]# iscsiadm -m node iscsiadm: No records found