[Linux] Configure iSCSI on Linux5 (both target and initiator)

************************************************************
********************Target********************************
************************************************************

[[email protected] ~]# yum list installed | grep scsi
iscsi-initiator-utils.x86_64 6.2.0.872-16.el5 installed ★initiator Only, Target rpm needed
[[email protected] ~]# yum install scsi-target-utils ★install Target
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package scsi-target-utils.x86_64 0:1.0.14-2.el5 set to be updated
--> Processing Dependency: libibverbs.so.1(IBVERBS_1.1)(64bit) for package: scsi-target-utils
--> Processing Dependency: librdmacm.so.1(RDMACM_1.0)(64bit) for package: scsi-target-utils
--> Processing Dependency: perl(Config::General) for package: scsi-target-utils
--> Processing Dependency: libibverbs.so.1()(64bit) for package: scsi-target-utils
--> Processing Dependency: librdmacm.so.1()(64bit) for package: scsi-target-utils
--> Running transaction check
---> Package libibverbs.x86_64 0:1.1.6-3.el5 set to be updated
--> Processing Dependency: openib >= 1.0 for package: libibverbs
---> Package librdmacm.x86_64 0:1.0.15-2.el5 set to be updated
---> Package perl-Config-General.noarch 0:2.40-1.el5 set to be updated
--> Running transaction check
---> Package openib.noarch 0:1.5.4.1-4.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================================================================================
Installing:
scsi-target-utils x86_64 1.0.14-2.el5 base 172 k
Installing for dependencies:
libibverbs x86_64 1.1.6-3.el5 base 46 k
librdmacm x86_64 1.0.15-2.el5 base 28 k
openib noarch 1.5.4.1-4.el5 base 23 k
perl-Config-General noarch 2.40-1.el5 base 68 k

Transaction Summary
================================================================================================================================================================================================================
Install 5 Package(s)
Upgrade 0 Package(s)

Total download size: 337 k
Is this ok [y/N]: y
Downloading Packages:
(1/5): openib-1.5.4.1-4.el5.noarch.rpm | 23 kB 00:00
(2/5): librdmacm-1.0.15-2.el5.x86_64.rpm | 28 kB 00:00
(3/5): libibverbs-1.1.6-3.el5.x86_64.rpm | 46 kB 00:00
(4/5): perl-Config-General-2.40-1.el5.noarch.rpm | 68 kB 00:00
(5/5): scsi-target-utils-1.0.14-2.el5.x86_64.rpm | 172 kB 00:00
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 151 kB/s | 337 kB 00:02
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : perl-Config-General 1/5
Installing : openib 2/5
Installing : libibverbs 3/5
Installing : librdmacm 4/5
Installing : scsi-target-utils 5/5

Installed:
scsi-target-utils.x86_64 0:1.0.14-2.el5

Dependency Installed:
libibverbs.x86_64 0:1.1.6-3.el5 librdmacm.x86_64 0:1.0.15-2.el5 openib.noarch 0:1.5.4.1-4.el5 perl-Config-General.noarch 0:2.40-1.el5

Complete! ★
[[email protected] ~]# yum list installed | grep scsi
iscsi-initiator-utils.x86_64 6.2.0.872-16.el5 installed
scsi-target-utils.x86_64 1.0.14-2.el5 installed ★Target rpm is installed
[[email protected] ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
#127.0.0.1 localhost.localdomain localhost
#::1 localhost6.localdomain6 localhost6

127.0.0.1 node3 localhost
#172.16.20.34 node2 localhost

192.168.56.105 node2 ★initiator
192.168.56.104 node3 ★Target

[[email protected] ~]# ping node2 ★ping to initiator ,No problem
PING node2 (192.168.56.105) 56(84) bytes of data.
64 bytes from node2 (192.168.56.105): icmp_seq=1 ttl=64 time=2.43 ms
64 bytes from node2 (192.168.56.105): icmp_seq=2 ttl=64 time=1.06 ms

--- node2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 999ms
rtt min/avg/max/mdev = 1.064/1.748/2.432/0.684 ms
[[email protected] ~]# fdisk -l ★Check Disk info

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 3916 31350847+ 8e Linux LVM

Disk /dev/sdb: 2147 MB, 2147483648 bytes ★Test Disk, No disk partition
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn‘t contain a valid partition table

Disk /dev/dm-0: 25.8 GB, 25836912640 bytes
255 heads, 63 sectors/track, 3141 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/dm-0 doesn‘t contain a valid partition table

Disk /dev/dm-1: 6241 MB, 6241124352 bytes
255 heads, 63 sectors/track, 758 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/dm-1 doesn‘t contain a valid partition table
[[email protected] ~]# fdisk /dev/sdb ★Create disk partition
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won‘t be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n ★
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1 ★
First cylinder (1-261, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-261, default 261):
Using default value 261

Command (m for help): w ★
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[[email protected] ~]# partprobe /dev/sdb ★
[[email protected] ~]# fdisk -l ★

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 3916 31350847+ 8e Linux LVM

Disk /dev/sdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 261 2096451 83 Linux ★Done

Disk /dev/dm-0: 25.8 GB, 25836912640 bytes
255 heads, 63 sectors/track, 3141 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/dm-0 doesn‘t contain a valid partition table

Disk /dev/dm-1: 6241 MB, 6241124352 bytes
255 heads, 63 sectors/track, 758 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/dm-1 doesn‘t contain a valid partition table

[[email protected] ~]# more /etc/tgt/targets.conf ★
# This is a sample config file for tgt-admin.
# By default, tgt-admin looks for its config file in /etc/tgt/targets.conf
#
# The "#" symbol disables the processing of a line.

# This one includes other config files:

#include /etc/tgt/temp/*.conf

# Set the driver. If not specified, defaults to "iscsi".

default-driver iscsi

....
[[email protected] ~]# vi /etc/tgt/targets.conf ★rectify configuration file , between tag <target..</target>
[[email protected] ~]# more /etc/tgt/targets.conf
<target qn.2001-04.com.jp-lin03-sdb:tgtd> ★
backing-store /dev/sdb1 ★
initiator-address 192.168.56.105 ★
</target> ★

# This is a sample config file for tgt-admin.
# By default, tgt-admin looks for its config file in /etc/tgt/targets.conf
#
# The "#" symbol disables the processing of a line.

# This one includes other config files:

#include /etc/tgt/temp/*.conf

# Set the driver. If not specified, defaults to "iscsi".

default-driver iscsi

....

[[email protected] ~]# service tgtd start ★start tgtd service
Starting SCSI target daemon: Starting target framework daemon

[[email protected] ~]# chkconfig tgtd on ★bring tgtd service up automatically next time when the OS starts
[[email protected] ~]# chkconfig --list tgtd ★
tgtd 0:off 1:off 2:on 3:on 4:on 5:on 6:off ★OK
[[email protected] ~]# netstat -tulnp | grep tgtd ★find the Port number of iscsi target
tcp 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN 4141/tgtd
[[email protected] ~]# iptables -L ★
Chain INPUT (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere

Chain FORWARD (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Chain RH-Firewall-1-INPUT (2 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT icmp -- anywhere anywhere icmp any
ACCEPT esp -- anywhere anywhere
ACCEPT ah -- anywhere anywhere
ACCEPT udp -- anywhere 224.0.0.251 udp dpt:mdns
ACCEPT udp -- anywhere anywhere udp dpt:ipp
ACCEPT tcp -- anywhere anywhere tcp dpt:ipp
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ftp
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:nfs
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:telnet
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

.... ★Add Firewall port rules from GUI(tcp and udp on port 3260)
[[email protected] ~]# iptables -L ★
Chain INPUT (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere

Chain FORWARD (policy ACCEPT)
target prot opt source destination
RH-Firewall-1-INPUT all -- anywhere anywhere

Chain OUTPUT (policy ACCEPT)
target prot opt source destination

Chain RH-Firewall-1-INPUT (2 references)
target prot opt source destination
ACCEPT all -- anywhere anywhere
ACCEPT icmp -- anywhere anywhere icmp any
ACCEPT esp -- anywhere anywhere
ACCEPT ah -- anywhere anywhere
ACCEPT udp -- anywhere 224.0.0.251 udp dpt:mdns
ACCEPT udp -- anywhere anywhere udp dpt:ipp
ACCEPT tcp -- anywhere anywhere tcp dpt:ipp
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ftp
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:nfs
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:telnet
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:iscsi-target ★
ACCEPT udp -- anywhere anywhere state NEW udp dpt:iscsi-target ★
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited

[[email protected] ~]# tgt-admin -s ★Check Target service
Target 1: qn.2001-04.com.jp-lin03-sdb:tgtd
System information:
Driver: iscsi
State: ready ★OK
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00010000
SCSI SN: beaf10
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Readonly: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: beaf11
Size: 2147 MB, Block size: 512
Online: Yes
Removable media: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/sdb1 ★OK
Backing store flags:
Account information:
ACL information:
192.168.56.105

************************************************************
********************Initiator****************************
************************************************************
[[email protected] ~]# yum list installed | grep scsi ★
iscsi-initiator-utils.x86_64 6.2.0.872-16.el5 installed ★
[[email protected] ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
#127.0.0.1 localhost.localdomain localhost
#::1 localhost6.localdomain6 localhost6

127.0.0.1 node2 localhost

192.168.56.105 node2
192.168.56.104 node3

[[email protected] ~]# cat /etc/iscsi/initiatorname.iscsi
#InitiatorName=iqn.1994-05.com.redhat:ca542ec6f39b
#InitiatorName=iqn.2001-04.com.example:node2 ★
[[email protected] ~]# vi /etc/iscsi/initiatorname.iscsi ★rectify configuration file
[[email protected] ~]# cat /etc/iscsi/initiatorname.iscsi
#InitiatorName=iqn.1994-05.com.redhat:ca542ec6f39b
InitiatorName=iqn.2001-04.com.example:node2 ★
[[email protected] ~]# /etc/init.d/iscsi restart ★restart
iscsiadm: No matching sessions found
Stopping iSCSI daemon:
iscsid は停止しています [ OK ]
Starting iSCSI daemon: [ OK ]
[ OK ]
iSCSI ターゲットを設定中: Logging in to [iface: default, target: qn.2001-04.com.jp-lin03-sdb:tgtd, portal: 192.168.56.104,3260] (multiple)
Login to [iface: default, target: qn.2001-04.com.jp-lin03-sdb:tgtd, portal: 192.168.56.104,3260] successful.
[ OK ]
[[email protected] ~]# fdisk -l ★

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 3916 31350847+ 8e Linux LVM

Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn‘t contain a valid partition table

Disk /dev/dm-0: 46.2 GB, 46238007296 bytes
255 heads, 63 sectors/track, 5621 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/dm-0 doesn‘t contain a valid partition table

Disk /dev/dm-1: 6241 MB, 6241124352 bytes
255 heads, 63 sectors/track, 758 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/dm-1 doesn‘t contain a valid partition table

Disk /dev/sdc: 2146 MB, 2146765824 bytes ★Worked
67 heads, 62 sectors/track, 1009 cylinders
Units = cylinders of 4154 * 512 = 2126848 bytes

Disk /dev/sdc doesn‘t contain a valid partition table
[[email protected] ~]#

原文地址:https://www.cnblogs.com/Frank-20160505/p/10288376.html

时间: 2024-10-12 12:08:21

[Linux] Configure iSCSI on Linux5 (both target and initiator)的相关文章

linux 下iscsi网络存储配置

iSCSI 的主要功能是在TCP/IP 网络上的主机系统(启动器 initiator)和存储设备(目标器 target)之间进行大量数据的封装和可靠传输过程.需要在linux的服务端装上target,客户机上装上inititor. 配置过程如下: 在主机上测试IP为192.168.157.144 [[email protected] ~]# yum install iscsi-initiator-utils.i386 [[email protected] ~]# yum install scsi

Linux挂载iscsi存储

Linux挂载iscsi存储     iscsi 提供给Linux挂载有两种方式,一种通过iscsi 协议的ip映射,一种通过文件共享 nfs挂载.其中通过iscsi 协议的ip映射 方式挂载到Linux中以磁盘形式展现,ip映射之后还需要对该磁盘分区,并格式化分区. 挂载步骤: 1:检查iscsi rpm包 2:启动iscsi服务并设置开机自启动 3:查找存储对外提供的逻辑卷 4:映射逻辑卷到Linux系统中 5:设置开机自动映射 6:对映射出来的磁盘进行分区 7:分区之后进行格式化 8:挂载

linux ./configure 的参数详解

转载自http://blog.csdn.net/zjt289198457/article/details/6918656 linux ./configure 的参数详解   ./configure 该脚本将运行一些测试来猜测一些系统相关的变量并检测你的操作   系统的特殊设置,并且最后在制做树中创建一些文件以记录它找到了什么. 缺省设置将制作服务器和应用程序,还有所有只需要C编译器的客户端程序和接口. 缺省时所有文件都将安装到   /usr/local/pgsql.         你可以通过给

Lenovo DS存储Linux下ISCSI 多路径映射配置

Lenovo  DS存储Linux下ISCSI 多路径映射配置 Renren  2018-01-17 实验环境: DS4200存储,B控制器池划分一个大小为18G的volume,通过两个1G ISCSI口port2和port3同时映射给客户机.Port B2口IP为172.16.1.14/24 :port B3口IP为172.16.1.15/24. 客户机系统为centos 6.9,两个以太网口,eth0口IP为172.16.1.195/24,eth1口的IP为172.16.1.196/24.网

CentOS/Linux 连接 iscsi 磁盘阵列

CentOS/Linux连接ISCSI磁盘整列 iSCSI:即Internet Small Computer System Interface 系统环境:CentOS 6.5 mini 磁盘阵列:联想EMC ISCSI IP:192.168.100.201 一.安装ISCSI 1:确认是否安装iscsi # rpm -qa|grep iscsi 2:安装iscsi(如未安装) # yum -y install iscsi-initiator* 3:启动iscsi服务 (默认系统启动后自动运行)

linux初学者-iscsi篇

linux初学者-iscsi篇 之前介绍过网络文件共享系统NFS和CIFS.在系统中,设备也是可以共享的,这就是iSCSI,它可以用来建立和管理IP存储设备.主机和客户机等之间的相互连接.下文将简要介绍这种网络设备共享系统.       1.安装 因为iSCSI是设备共享系统,所以在进行操作之间,需要先有一个硬盘设备.本文中是使用"fdisk /dev/vdb"来新建一个分区设备"/dev/vdb1"来作为共享设备. "yum install target

Linux配置iSCSI存储

一.基础知识1.1.存储相关 直接存储(DAS):例如本机上的磁盘,就是属于直接存储设备. 存储区域网络(SAN):来自网络内的其他存储设备提供的磁盘.Iscsi就是属于该方式. 网络文件系统(NAS):直接提供文件系统,可以立即使用. 1.2.ISCSI相关基础 iscsi target:存储设备端,服务器端的设备,为其他服务器提供“磁盘”. Iscsi initiator:使用target提供“磁盘”的客户端. 二.ISCSI服务器端安装配置 以192.168.28.130作为target,

Configure iSCSI Target on RHEL7

在RHEL7中,已经使用targetcli软件替换了scsi-target-utils,相对于scsi-target-utils软件,targetcli更加方便易用.具体如下: 1.创建逻辑卷: [[email protected] ~]# lvcreate -n vv01 -L +500G datavg [[email protected] ~]# lvcreate -n vv02 -L +500G datavg [[email protected] ~]# lvcreate -n vv03 

Linux 挂载iscsi存储磁盘设备

1,check网络 [[email protected] ~]# ping -I eth0 11.110.10.138 PING 11.110.10.138 (11.110.10.138) from 11.110.10.138eth0: 56(84) bytes of data. 64 bytes from 11.110.10.138: icmp_seq=1ttl=64 time=0.023 ms 64 bytes from 11.110.10.138: icmp_seq=2ttl=64 tim