CentOS6.5挂载iSCSI存储详细教程
1.客户端安装iscsi的相关安装包,并启动
使用yum方式安装必须能够访问外网。
[root@localhost~]#yum install binutils iscsi-initiator-utils kmod-xfs xfsprogs -y
[root@localhost~]#service iscsi start
[root@localhost~]#chkconfig iscsi on
[root@localhost~]# chkconfig iscsid on
其中kmod-xfs xfsprogs为xfs文件系统的组件。
2. 发现target
[root@localhost~]# iscsiadm -m discovery -t sendtargets -p 1.1.1.1
1.1.1.1:3260,0iqn.2001-06.cn.com.toyou:isum420g5-000ce0cb0:dev0
3.配置initiatiorname(可选这是更改服务器本身的iqn号,存储映射LUN的时候指定的主机,如果映射的时候主机是全部,这个步骤不需要)
将initiatorname.iscsi 里添加target的名称
[root@localhost~]#vi /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.sphy.com.toyou:isum420g5-000ce0cb0:dev0
?
4.登陆target
[root@localhost~]#iscsiadm -m node -T iqn.2001-06.cn.com.toyou:isum420g5-000ce0cb0:dev0 ?-p 1.1.1.1 –login
Logging in to [iface:default, target: iqn.2001-06.cn.com.toyou:isum420g5-000ce0cb0:dev0, portal:1.1.1.1,3260] (multiple)
Login to [iface: default,target: iqn.2001-06.cn.com.toyou:isum420g5-000ce0cb0:dev0, portal:1.1.1.1,3260] successful.
5.查看存储是否挂载上
[root@localhost~]# fdisk -l
Disk /dev/sda:1999.0 GB, 1998998994944 bytes
255 heads, 63sectors/track, 243031 cylinders
Units = cylindersof 16065 * 512 = 8225280 bytes
Sector size(logical/physical): 512 bytes / 4096 bytes
I/O size(minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier:0x000bb04e
?? Device Boot????? Start???????? End????? Blocks??Id? System
/dev/sda1?? *??????????1????????? 26????? 204800??83? Linux
Partition 1 doesnot end on cylinder boundary.
/dev/sda2????????????? 26??????? 2066???16384000?? 82? Linux swap / Solaris
/dev/sda3??????????? 2066????? 243032?1935557632?? 83? Linux
Disk /dev/sdb:16002.0 GB, 16001974403072 bytes(此处为挂载的硬盘)
255 heads, 63sectors/track, 1945462 cylinders
Units = cylindersof 16065 * 512 = 8225280 bytes
Sector size(logical/physical): 512 bytes / 512 bytes
I/O size(minimum/optimal): 512 bytes / 512 bytes
Disk identifier:0x00000000
6.用parted进行分区
[root@localhost~]# parted? /dev/sdb
GNU Parted 2.1
使用 /dev/sdb
Welcome to GNUParted! Type 'help' to view a list of commands.?????????????????????????????????????????????????
(parted) mklabelgpt(磁盘容量大于2T要用gpt分区)
(parted)mkpart? primary 0% 100%?????????????????????????????????????????
(parted) print
Model: TOYOU iSUM420G5(scsi)
Disk /dev/sdb: 16.0TB
Sector size(logical/physical): 512B/512B
Partition Table: gpt
Number? Start??End???? Size??? File system?Name???? 标志
?1?????1049kB? 16.0TB? 16.0TB?????????????? primary
(parted) quit????????????????????????????????????????????????????????????
信息: You may need toupdate /etc/fstab.?????
注:fdisk支持小于2TB的磁盘,大于2TB的磁盘需要用parted
7.格式化分区
[root@localhost~]#mkfs.ext4 -T largefile /dev/sdb1
注:-T largefile对格式化大文件速度要快很多
查看磁盘的uuid
[root@localhost~]#blkid /dev/sdb1
/dev/sdb1:UUID="3fa56f3f-e905-42e5-94cf-e39c49dffc2e" TYPE="ext4"
8.挂载硬盘(注意:挂载分区到录像资源/usr/iactive/rec_resource下会删除原来的存储的录像数据)
[root@localhost~]#mount? -t ext4 /dev/sdb1 ?/usr/iactive/rec_resource??
9.开机自动挂载
先在/etc/rc.local进行登陆
[root@localhost~]#vi /etc/rc.lcoal
iscsiadm -m node-T iqn.2001-06.cn.com.toyou:isum420g5-000ce0cb0:dev0 ?-p 1.1.1.1 –login
[root@localhost~]#vi ?/etc/fstab
UUID=3fa56f3f-e905-42e5-94cf-e39c49dffc2e? /usr/iactive/rec_resource? ext4?defaults? 0? 0
修改完要用mount –a命令检查fstab文件是否有错误。(fstab文件有错误会导致系统无法启动)
注:default后面的一定要注意,第一个0为是否支持dump(检查一个文件系统应该以多快频率转储,不需要则为0),第二个0问支持fsck,这个在启动后会fsck /dev/sdb1(检查挂载的分区文件,0不检查)。