mhvtl+iscsi
1. 服务端
1.1 mnvtl安装
依赖安装:
yum install kernel-devel lzo wget mtx lsscsi sg3_utils -y
mhvtl安装
wget http://www.mhvtl.com/downloads/mhvtl-utils-1.5-4.x86_64.rpm wget http://www.mhvtl.com/downloads/mhvtl-utils-1.5-4.src.rpm rpm -Uvh mhvtl-utils-1.5-4.x86_64.rpm mhvtl-utils-1.5-4.src.rpm cd /root/rpmbuild/SOURCES/ tar xvfz mhvtl-2016-03-10.tgz cd mhvtl-1.5/kernel/ make make install
mhvtl启服务
/etc/init.d/mhvtl start /etc/init.d/mhvtl stop /etc/init.d/mhvtl start
查看
lsscsi -g
1.2 GUI图形化配置(可选做,或者手动映射iscsi)
安装epel源
yum -y install epel-release
安装依赖
yum install php lsscsi mtx mt-st git sysstat sg3_utils scsi-target-utils
启用iscsi
#/etc/init.d/tgtd start
systemctl start tgtd
#chkconfig tgtd on
systemctl enable tgtd
权限配置
/etc/sudoers中添加一行,注释一行(如果有就注释掉)
apache ALL=(ALL) NOPASSWD: ALL
# Defaults requiretty
禁用selinux
setenforce 0 vi /etc/selinux/config
安装图形化
mkdir -p /var/www/html/mhvtl cd /var/www/html/mhvtl
git init git pull https://github.com/markh794/mhvtl-gui.git
或(如果git失败)
wget https://codeload.github.com/markh794/mhvtl-gui/zip/refs/heads/master
unzip master
mv mhvtl-gui-master mhvtl
启服务
service mhvtl start
service tgtd start
service httpd reload
访问地址: http://mhvtl_IP/mhvtl/
访问密码:mhvtl
1.3.1 scsi-target-utils映射iscsi(若已配置GUI图形化,实际操作在web前端即可,mhvtl后端会使用此服务开启scsid)
#编辑配置文件/etc/tgt/targets.conf,并设置下iSCSI Qualified Name (IQN) #(待接磁盘/dev/sdb已格式化完成,格式化方式,此处不再赘述) #vim /etc/tgt/ targets.conf #在文件末尾添加如下内容 <target iqn.2017-02.com.easted:xiao> #iqn名字可任意 backing-store /dev/sdb initiator-address 10.10.132.0/24 #限定 允许访问的客户端地址段或具体IP write-cache off #是否开启或关闭快取 </target> #重启服务,使得修改的配置生效
# service tgtd restart
#确定iscsi server是否成功。
# tgt-admin --show
1.3.2 targetcli映射iscsi (学习笔记,不用操作)
装包:
yum install targetcli -y
配置:
# lsscsi -g [0:0:0:0] disk VMware Virtual disk 2.0 /dev/sda /dev/sg0 [3:0:0:0] cd/dvd NECVMWar VMware SATA CD00 1.00 /dev/sr0 /dev/sg1 [33:0:0:0] mediumx STK L700 0105 /dev/sch0 /dev/sg10 [33:0:1:0] tape IBM ULT3580-TD5 0105 /dev/st0 /dev/sg2 [33:0:2:0] tape IBM ULT3580-TD5 0105 /dev/st1 /dev/sg3 [33:0:3:0] tape IBM ULT3580-TD4 0105 /dev/st2 /dev/sg4 [33:0:4:0] tape IBM ULT3580-TD4 0105 /dev/st3 /dev/sg5 [33:0:8:0] mediumx STK L80 0105 /dev/sch1 /dev/sg11 [33:0:9:0] tape STK T10000B 0105 /dev/st4 /dev/sg6 [33:0:10:0] tape STK T10000B 0105 /dev/st5 /dev/sg7 [33:0:11:0] tape STK T10000B 0105 /dev/st6 /dev/sg8 [33:0:12:0] tape STK T10000B 0105 /dev/st7 /dev/sg9
后端存储对象创建测试
for i in {2..11};do targetcli /backstores/pscsi create dev=/dev/sg${i} name=sg${i};done
查看
targetcli backstores/pscsi ls
删除
for i in {2..11};do targetcli /backstores/pscsi delete sg${i};done
iscsi targets创建
查询本机iqn
cat /etc/iscsi/initiatorname.iscsi
创建iscsi target
targetcli /iscsi create iqn.1994-05.com.redhat:28b3319e12
2. 客户端
装包:
yum install iscsi-initiator-utils -y
配置:
iscsi连接存储设备的命令
发现设备,ip换成真实存储ip
iscsiadm -m discovery -t sendtargets -p 192.168.3.43
登录连接上一条命令查询出的设备,将iqn换成上一条查询出来的,如果是登录虚拟带库,机械臂和驱动器会单独列出,每个都输入一次
登陆(--login/-l)
iscsiadm -m node -T iqn.2011-04.com.nia:mhvtl01:mhvtl:stgt:1 -p 192.168.3.43 -l
登出(--logout/-u)
iscsiadm -m node -T iqn.2011-04.com.nia:mhvtl01:mhvtl:stgt:1 -p 192.168.3.43 -u
这条为开机自动登录
iscsiadm -m node -T iqn.2011-04.com.nia:mhvtl01:mhvtl:stgt:2 -p 192.168.3.43 --op update -n node.startup -v automatic
附
iscsiadm -m, --mode op specify the mode. op must be one of discovery, discoverydb, node, fw, host iface or session. -n, --name=name In node mode, specify a field name in a record. In flashnode submode of host mode, specify name of the flash node parameter. -o, --op=op Specifies a database operator op. op must be one of new, delete, update, show or nonpersistent. -p, --portal=ip[:port] Use target portal with ip-address ip and port. If port is not passed in the default port value is 3260. IPv6 addresses can be specified as [ddd.ddd.ddd.ddd]:port or ddd.ddd.ddd.ddd. Hostnames can also be used for the ip argument. This option is only valid for discovery, or for node operations with the new operator. This should be used along with --target in node mode, to specify what the open-iscsi docs refer to as a node or node record. Note: open-iscsi's use of the word node, does not match the iSCSI RFC's iSCSI Node term. -P, --print=printlevel If in node mode print nodes in tree format. If in session mode print sessions in tree format. If in discovery mode print the nodes in tree format. -T, --targetname=targetname Use target targetname. This should be used along with --portal in node mode, to specify what the open-iscsi docs refer to as a node or node record. Note: open-iscsi's use of the word node, does not match the iSCSI RFC's iSCSI Node term. -s, --stats Display session statistics. This option when used with host mode, displays host statistics. -S, --show When displaying records, do not hide masked values, such as the CHAP secret (password). This option is only valid for node and session mode. -v, --value=value Specify a value for use with the update operator. This option is only valid for node mode and flashnode submode of host mode. -u, --logout logout for a specified record. This option is only valid for node and session mode. -D, --discover Discover targets using the discovery record with the recid matching the the discovery type and portal passed in. If there is no matching record, it will be created using the iscsid.conf discovery settings. This must be passed in discoverydb mode to instruct iscsiadm to perform discovery. This option is only valid for SendTargets discovery mode. -l, --login For node and fw mode, login to a specified record. For discovery mode, login to all discovered targets. This option is only valid for discovery and node modes. -L, --loginall=[all|manual|automatic] For node mode, login all sessions with the node or conn startup values passed in or all running session, except ones marked onboot, if all is passed in. This option is only valid for node mode (it is valid but not functional for session mode). -k, --killiscsid=[priority] Currently priority must be zero. This will immediately stop all iscsid operations and shutdown iscsid.