标签:网络技术 target account 客户端 update
scsi: Small Computer System Interface
scsi是一种I/O技术
scsi总线是SCSI设备间传输数据的通路
iscsi协议
借助现有的网络技术,以延长ISCSI设备的传输长度
ISCSI Initator三种工作方式:
ISCSI HBA卡:采用内建SCSI指令及TOE引擎的ASIC芯片。价格最贵,性能最好
ISCSI TOE卡:内建TOE引擎,ISCSI指令以软件方式动作,会占用CPU资源
ISCSI Initator驱动程序:占用大量CPU资源,性能最差
ISCSI Target:
监听3260/tcp端口
iSCSI Target:
scsi-target-utils软件
3260/tcp
客户端认证方式:
1)基于IP
2)基于用户,CHAP
iSCSI Initator:
iscsi-initator-utils软件
tgtadm模式化命令
常用模式:target,logicalunit,account
target --op
new,delete,show,update,bind,unbind
logicalunit --op
new,delete
account --op
new,delete,bind,unbind
--lld, -L
--tid, -t
--lun, -l
--backing-store <path>, -b
--initator-address <address>, -I
--targetname <name>, -T
targetname格式:
iqn.YYYY-MM.reverse domain name[:identifier]
iqn.2015-11.com.bj:testdb
iscsiadm模式化命令:
-m { discovery | node | session | iface }
discovery: 发现某服务器是否有target输出,以及输出了哪些target
node: 管理跟某target的关联关系
session: 会话管理
iface:接口管理
iscsiadm -m discovery [-d debug_level] [-P printlevel] [ -I iface -t type -p ip:port [-l] ] | [ -p ip:port [ -l | -D]]
-d:0-8
-I
-t type : sendtarget(st),SLP,and ISNS
-p: IP:PORT
iscsiadm -m node [[ [ -T targetname -p ip:port -I ifaceN ] [ -l | -u ] ]
-l:登录
-u:登出
示例:配置基于IP认证的iscsi
环境描述:
server1.bj.com 172.16.1.1 ISCSI TARGET
server2.bj.com 172.16.1.2 ISCSI INITATOR
server3.bj.com 172.16.1.3 ISCSI INITATOR
在server1上添加20G硬盘,创建两个主分区,并将其通过iscsi导出共享
1、在server1上分别创建两个主分区/dev/sdb1 /dev/sdb2
2、在server1上安装iscsi-target-utils软件,并启动tgtd服务
# yum install -y scsi-target-utils
# chkconfig tgtd on
# netstat -tnlp | grep tgtd
tcp 0 0 0.0.0.0:3260 0.0.0.0:* LISTEN 3449/tgtd
tcp 0 0 :::3260 :::* LISTEN 3449/tgtd
3、创建target,名称为iqn.2015-11.com.bj:teststore.disk1,并查看其状态
# tgtadm --lld iscsi --mode target --op new --targetname iqn.2015-11.com.bj:teststore.disk1 --tid 1
# tgtadm --lld iscsi --mode target --op show
Target 1: iqn.2015-11.com.bj:teststore.disk1
System information:
Driver: iscsi
State: ready
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:
Account information:
ACL information:
4、在target 1中创建lun 1,并指定其后端存储为/dev/sdb1
# tgtadm --lld iscsi --mode logicalunit --op new --lun 1 --tid 1 --backing-store /dev/sdb1
# tgtadm --lld iscsi --mode target --op show
Target 1: iqn.2015-11.com.bj:teststore.disk1
System information:
Driver: iscsi
State: ready
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: 5009 MB, Block size: 512
Online: Yes
Removable media: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/sdb1
Backing store flags:
Account information:
ACL information:
5、绑定initiator客户端地址,允许172.16.1.0/24网络的客户端访问target 1
# tgtadm --lld iscsi --mode target --op bind --tid 1 --initiator-address 172.16.1.0/24
# tgtadm --lld iscsi --mode target --op show
Target 1: iqn.2015-11.com.bj:teststore.disk1
System information:
Driver: iscsi
State: ready
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: 5009 MB, Block size: 512
Online: Yes
Removable media: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/sdb1
Backing store flags:
Account information:
ACL information:
172.16.1.0/24
6、在server2上安装iscsi-initiator-utils软件,并启动iscsi服务
# yum install -y iscsi-initiator-utils
# /etc/init.d/iscsi start
7、设置server2的initiator名称
# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2015-11.com.bj:server2
8、探索服务器端的target
# iscsiadm -m discovery -t sendtargets -p 172.16.1.1:3260
172.16.1.3:3260,1 iqn.2015-11.com.bj:teststore.disk1
9、登录到iqn.2015-11.com.bj:teststore.disk1
# iscsiadm -m node -T iqn.2015-11.com.bj:teststore.disk1 -p 172.16.1.1:3260 -l
Logging in to [iface: default, target: iqn.2015-11.com.bj:teststore.disk1, portal: 172.16.1.3,3260] (multiple)
Login to [iface: default, target: iqn.2015-11.com.bj:teststore.disk1, portal: 172.16.1.3,3260] successful.
登录成功后,在server2上会映射出/dev/sdb硬盘,此时可以在此硬盘进行分区、格式化、挂载使用
在server3上进行同样的操作,探索target,登录target,同样可发现/dev/sdb1分区
iscsi-initator-utils软件:
不支持discovery认证
如果要使用基于CHAP认证,还要同时开启基于IP的认证
示例:配置基于CHAP认证的iscsi
1、分别在server2/server3上分别清除已经登录的iscsi target信息
# umount /data
# iscsiadm -m node -T iqn.2015-11.com.bj:teststore.disk1 -p 172.16.1.1 -u
Logging out of session [sid: 3, target: iqn.2015-11.com.bj:teststore.disk1, portal: 172.16.1.1,3260]
Logout of [sid: 3, target: iqn.2015-11.com.bj:teststore.disk1, portal: 172.16.1.1,3260] successful.
# iscsiadm -m node -T iqn.2015-11.com.bj:teststore.disk1 -p 172.16.1.1 -o delete
# ls /var/lib/iscsi/send_targets/172.16.1.1,3260/
st_config
# rm -rf /var/lib/iscsi/send_targets/172.16.1.1,3260/
# /etc/init.d/iscsi restart
iscsiadm: No matching sessions found
Stopping iSCSI daemon:
iscsid is stopped [ OK ]
Starting iSCSI daemon: [ OK ]
[ OK ]
Setting up iSCSI targets: iscsiadm: No records found
[ OK ]
2、在server1上创建用户、密码,并与taget 1绑定
# tgtadm --lld iscsi --mode account --op new --user iscsiuser --password redhat
# tgtadm --lld iscsi --mode account --op bind --tid 1 --user iscsiuser
# tgtadm --lld iscsi --mode target --op show
Target 1: iqn.2015-11.com.bj:teststore.disk1
System information:
Driver: iscsi
State: ready
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: 10010 MB, Block size: 512
Online: Yes
Removable media: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/sdb1
Backing store flags:
Account information:
iscsiuser
ACL information:
172.16.1.0/24
3、分别在server2/server3上编辑iscsid.conf配置文件,指定认证的用户名及密码
# vim /etc/iscsi/iscsid.conf
node.session.auth.authmethod = CHAP
node.session.auth.username = iscsiuser
node.session.auth.password = redhat
# /etc/init.d/iscsi restart
iscsiadm: No matching sessions found
Stopping iSCSI daemon:
iscsid is stopped [ OK ]
Starting iSCSI daemon: [ OK ]
[ OK ]
Setting up iSCSI targets: iscsiadm: No records found
[ OK ]
4、重新探索target,并登录
# iscsiadm -m discovery -t st -p 172.16.1.1
172.16.1.1:3260,1 iqn.2015-11.com.bj:teststore.disk1
# iscsiadm -m node -T iqn.2015-11.com.bj:teststore.disk1 -p 172.16.1.1 -l
Logging in to [iface: default, target: iqn.2015-11.com.bj:teststore.disk1, portal: 172.16.1.1,3260] (multiple)
Login to [iface: default, target: iqn.2015-11.com.bj:teststore.disk1, portal: 172.16.1.1,3260] successful.
iscsi initiator端重启iscsi服务后会自动发现target,但iscsi target端所有配置在重启tgtd服务或者重启主机后会消失,为保证iscsi target端配置永久保存生效,建议将iscsi target相应配置保存到/etc/tgt/targets.conf配置文件
示例如下:
# vim /etc/tgt/targets.conf
<target iqn.2015-11.com.bj:teststore.disk1>
<backing-store /dev/sdb1>
vendor_id test
lun 3
</backing-store>
initiator-address 172.16.1.0/24
incominguser iscsiuser redhat
</target>
# tgtadm --lld iscsi --mode target --op show
Target 1: iqn.2015-11.com.bj:teststore.disk1
System information:
Driver: iscsi
State: ready
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: 3
Type: disk
SCSI ID: IET 00010003
SCSI SN: beaf13
Size: 10010 MB, Block size: 512
Online: Yes
Removable media: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/sdb1
Backing store flags:
Account information:
iscsiuser
ACL information:
172.16.1.0/24
此时,iscsi initiator重新探索登录target设备,在iscsi initiator上会把设备重新识别为/dev/sdc
配置gfs2集群文件系统
mkfs.gfs2参数说明 :
-j <number>:指定日志区域的个数,有几个节点需要挂载,日志区域就要有几个
-J <number>:指定每个日志区域的大小 ,单位为MB,默认大小 为128Mb
-p { lock_dlm | lock_nolock }:指定锁协议
-t <name>:指定锁表名称;格式为clustername:locktablename,clustername要与节点所在的集群名称一致;locktablename要在集群内唯一
示例:配置rhcs+iscsi+gfs2
环境描述:
server1.bj.com 172.16.1.1 集群节点/iscsi initiator
server2.bj.com 172.16.1.2 集群节点/iscsi initiator
server3.bj.com 172.16.1.3 集群节点/iscsi initiator
server4.bj.com 172.16.1.4 集群节点/iscsi target
在server4上通过iscsi导出磁盘,并格式化为集群文件系统供server1---server3三个节点使用
一、在server1---server3三个节点上安装RHCS套件,并启动集群
1、配置主机名解析,时间同步
2、安装cman ,rgmanager,system-config-cluster软件
# yum install -y cman rgmanager system-config-cluster
3、启动system-config-cluster工具,新建配置文件,配置集群名称,配置fence设备
4、分别启动cman rgmanager服务
5、查看集群状态
# clustat
Cluster Status for tcluster @ Fri Dec 11 04:13:54 2015
Member Status: Quorate
Member Name ID Status
------ ---- ---- ------
server1.bj.com 1 Online, Local
server2.bj.com 2 Online
server3.bj.com 3 Online
二、配置基于用户认证的iscsi,将server4上的/dev/sdb1导出
1、创建5G分区 /dev/sdb1
2、安装scsi-target-utils软件
# yum install -y scsi-target-utils
3、编辑配置文件/etc/tgt/targets.conf,指定导出设备
# vim /etc/tgt/targets.conf
<target iqn.2015-11.com.bj:teststore.disk1>
<backing-store /dev/sdb1>
vendor_id test
lun 1
</backing-store>
initiator-address 172.16.1.0/24
incominguser iscsiuser redhat
</target>
# tgtadm --lld iscsi --mode target --op show
Target 1: iqn.2015-11.com.bj:teststore.disk1
System information:
Driver: iscsi
State: ready
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: 5009 MB, Block size: 512
Online: Yes
Removable media: No
Readonly: No
Backing store type: rdwr
Backing store path: /dev/sdb1
Backing store flags:
Account information:
iscsiuser
ACL information:
172.16.1.0/24
# /etc/init.d/tgtd start
# chkconfig tgtd on
4、分别在server1----server3上探索并登录target
# yum install -y iscsi-initiator-utils
配置各自的initiator名称
# cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2015-11.com.bj:server1
在配置文件中指定认证的用户名,密码
# vim /etc/iscsi/iscsid.conf
node.session.auth.authmethod = CHAP
node.session.auth.username = iscsiuser
node.session.auth.password = redhat
# /etc/init.d/iscsi restart
iscsiadm: No matching sessions found
Stopping iSCSI daemon:
iscsid is stopped [ OK ]
Starting iSCSI daemon: [ OK ]
[ OK ]
Setting up iSCSI targets: iscsiadm: No records found
[ OK ]
探索并登录target
# iscsiadm -m discovery -t st -p 172.16.1.4
172.16.1.4:3260,1 iqn.2015-11.com.bj:teststore.disk1
# iscsiadm -m node -T iqn.2015-11.com.bj:teststore.disk1 -p 172.16.1.4 -l
Logging in to [iface: default, target: iqn.2015-11.com.bj:teststore.disk1, portal: 172.16.1.4,3260] (multiple)
Login to [iface: default, target: iqn.2015-11.com.bj:teststore.disk1, portal: 172.16.1.4,3260] successful.
5、在server1上识别的target设备上创建分区/dev/sdb1
在server1上执行创建分区操作即可,在其他两个节点上执行partprobe命令
三、安装gfs2-utils软件,并分区/dev/sdb1格式化为集群文件系统
1、在server1上安装gfs2-utils软件
# yum install -y gfs2-utils
2、将/dev/sdb1格式化为gfs2文件系统
# mkfs.gfs2 -j 3 -J 128 -p lock_dlm -t tcluster:teststore /dev/sdb1
This will destroy any data on /dev/sdb1.
Are you sure you want to proceed? [y/n] y
Device: /dev/sdb1
Blocksize: 4096
Device Size 0.93 GB (245047 blocks)
Filesystem Size: 0.93 GB (245046 blocks)
Journals: 3
Resource Groups: 4
Locking Protocol: "lock_dlm"
Lock Table: "tcluster:teststore"
UUID: F4EEF765-FCBE-E311-217B-428CB6BC758F
3、挂载/dev/sdb1到 /data目录
# mount.gfs2 /dev/sdb1 /data
在三个节点分别挂载完成后,由于是集群文件系统,无论在哪个节点创建文件,另外两个节点都可以即时看到
cLVM-------------Cluster LVM
借助HA的功能
开启集群LVM功能 /etc/lvm/lvm.conf locking-type=3
启动clvmd服务
配置cLVM及gfs2
1、在server1节点上创建/dev/sdb2分区,作为cLVM的准备
2、分别在三个节点安装lvm2-cluster软件 ,开启cLVM功能,并启动clvmd服务
# yum install -y lvm2-cluster
开启cLVM功能
# lvmconf --enable-cluster
# grep "locking_type" /etc/lvm/lvm.conf
locking_type = 3
# /etc/init.d/clvmd start
# chkconfig lvmd on
3、创建集群逻辑卷/dev/clustervg/clusterlv
# pvcreate /dev/sdb2
# vgcreate clustervg /dev/sdb2
# lvcreate -L 2G -n clusterlv clustervg
4、将逻辑卷格式化为gfs2文件 系统
# mkfs.gfs2 -j 3 -p lock_dlm -t tcluster:clvmstore /dev/clustervg/clusterlv
5、挂载
# mount.gfs2 /dev/clustervg/clusterlv /mydata
扩展逻辑卷空间
# lvextend -L +2G /dev/clustervg/clusterlv
# gfs2_grow /dev/clustervg/clusterlv
本文出自 “江湖笑笑生” 博客,请务必保留此出处http://hashlinux.blog.51cto.com/9647696/1760518
scsi: Small Computer System Interface
标签:网络技术 target account 客户端 update
原文地址:http://hashlinux.blog.51cto.com/9647696/1760518