实验目的:RedHat下实现远程网络存储的共享
实验环境:192.168.0.13(服务器)
192.168.0.12(客户端)
(主机名和ip要保持一致,iptables应清空)
实验所需安装包: iscsi-initiator-utils-*.rpm (客户端)
scsi-target-utils-*.rpm (服务器)
实验步骤:
A:服务器:
1.。配置YUM仓库:
# cd /etc/yum.repos.d/
# vim server1.repo 配置如下:
--------------------------------------
# repos on server1 for classroom use
# Main rhel5 server
[base]
name=Server1 Server Repository
baseurl=ftp://192.168.0.254/pub/Server
gpgcheck=0
enabled=1
# This one is needed for xen packages
[VT]
name=Server1 VT Repository
baseurl=ftp://192.168.0.254/pub/VT
gpgcheck=0
enabled=1
# GLS rpms go in here
[GLS]
name=Server1 GLS Repository
baseurl=ftp://192.168.0.254/pub/gls/RPMS
gpgcheck=0
enabled=1
# rhel5 udates
[Updates]
name=Server1 Updates Repository
baseurl=ftp://192.168.0.254/pub/errata
gpgcheck=0
enabled=1
[Cluster]
name=Server1 Cluster Repository
baseurl=ftp://192.168.0.254/pub/Cluster
gpgcheck=0
enabled=1
[ClusterStorage]
name=Server1 CusterStorage Repository
baseurl=ftp://192.168.0.254/pub/ClusterStorage
gpgcheck=0
enabled=1
--------------------------------------
# yum clean all
2。 安装服务器软件包:
# yum -y install scsi-target-utils
3。创建要共享的分区:
# fdisk /dev/hda
----> p --> t --> 1 --> --> +300M --> w
--------------------分区效果-----------------------
Device Boot Start End Blocks Id System
/dev/hda1 1 621 293391 83 Linux
--------------------------------------------------
# partprobe
4。打开服务并设置为开机自启:
# service tgtd start
# chkconfig tgtd on
5。创建共享名:
# tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2009.11.com.example.station13:disk1
6。挂载要共享的分区:
# tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/hda1
7。绑定到指定IP(允许哪台主机访问共享存储)
# tgtadm --lld iscsi --op bind --mode target --tid 1 -I 192.168.0.12
8。探测下本机创建的共享存储:
# tgtadm --lld iscsi --op show --mode target
9。允许0.12机器通过3260端口访问服务器
# iptables -I INPUT -s 192.168.0.12 -p tcp --dport 3260 -j ACCEPT
# service iptables save