安装ISCSI
yum install iscsi-initiator-utils
#启动服务
service iscsi start
#发现目标
iscsiadm -m discovery -t sendtargets -p 172.20.0.201:3260
#登入
iscsiadm -m node –T 172.20.0.11:3260,1 iqn.1988-11.com.dell:01.array.bc305bf10426 -p 172.20.0.201:3260 -l
如果开启CHAP,需要配置CHAP
vim /etc/iscsi/iscsid.conf #将相关项前面的注释符#删除掉
node.session.auth.authmethod = CHAP //开启CHAP认证
node.session.auth.username = xxxxx //配置账号
node.session.auth.password = xxxxx //密码
登录
iscsiadm -m node -T iqn.1988-11.com.dell:01.array.bc305bf10426 -p 172.20.0.201 -l
#开机自动登入
iscsiadm -m node –T iqn.1988-11.com.dell:01.array.bc305bf10426 -p 172.20.0.201:3260 --op update -n node.startup -v automatic
注销所有连接
iscsiadm -m node --logoutall=all
删除全部
iscsiadm -m node -o delete
查看target记录
iscsiadm -m node
查看所有iscsi连接
iscsiadm -m session
注销单个节点
iscsiadm -m node -T iqn.1988-11.com.dell:01.array.bc305bf10426 172.20.0.11 -u
删除target
iscsiadm -m node -o delete -T iqn.1988-11.com.dell:01.array.bc305bf10426 -p 172.20.0.11:3260
登录全部target
sudo iscsiadm -m node --login
扫描所有登录的target/session
iscsiadm -m session --rescan
查看链接状态
netstat -anp |grep 3260
iscsiadm -m iface -I iface0 --op=new
New interface iface0 added
iscsiadm -m iface -I iface1 --op=new
New interface iface1 added
接口文件保存在/var/lib/iscsi/ifaces目录中
cd /var/lib/iscsi/ifaces/
ls
iface0 iface1
cat iface0
BEGIN RECORD 2.0-871
iface.iscsi_ifacename = iface0
iface.transport_name = tcp
END RECORD
cat iface1
BEGIN RECORD 2.0-871
iface.iscsi_ifacename = iface1
iface.transport_name = tcp
END RECORD
配置iface
iscsiadm -m iface -I iface0 --op=update -n iface.net_ifacename -v eth0
iface0 updated.
iscsiadm -m iface -I iface1 --op=update -n iface.net_ifacename -v eth1
iface1 updated.
确认iface配置
iscsiadm -m iface
default tcp,<empty>,<empty>,<empty>,<empty>
iser iser,<empty>,<empty>,<empty>,<empty>
iface1 tcp,<empty>,<empty>,eth1,<empty>
iface0 tcp,<empty>,<empty>,eth0,<empty>
iface搜索ISCSI Target
iscsiadm -m discovery -t st -p 172.20.0.11 -I iface0 -I iface1
查看disk
fdisk -l
格式化分区略过
查看存储UUID
[root@localhost me4084]# lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
sda
└─sda107 xfs c642d968-4d56-4f51-a750-0d326fd7d440
sdb
└─sdb108 xfs 7479d580-bb1e-4256-8e5a-4a7950766518
sdc
└─sdc109 xfs 0d6587d3-f215-4ce2-80c4-719983c3577b
编辑fstab
vim /etc/fstab
添加
UUID=0d6587d3-f215-4ce2-80c4-719983c3577b /me4084/NVR9_1 xfs _netdev 0 0