Centos7 配置iscsi客户端

版权声明:本文为博主原创文章,转载请指明地址。 https://blog.csdn.net/Mr_rsq/article/details/84065840

1 客户端安装iscsi并配置好iqn及CHAP

[root@ceshi ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@ceshi ~]# yum install iscsi-initiator-utils -y

2 开启iscsi并设置开机自启

[root@ceshi ~]# systemctl start iscsi
[root@ceshi ~]# systemctl enable iscsi

3 修改配置文件开启并配置CHAP

[root@ceshi ~]# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.centos:ceshi
InitiatorAlias=ceshi     #<==可不配置
[root@ceshi ~]# vim /etc/iscsi/iscsid.conf
# To enable CHAP authentication set node.session.auth.authmethod
# to CHAP. The default is None.
node.session.auth.authmethod = CHAP    #<==开启CHAP功能

# To set a CHAP username and password for initiator
# authentication by the target(s), uncomment the following lines:
node.session.auth.username = test      #<==配置CHAP账号
node.session.auth.password = abcdef12345678   #<==配置CHAP密码

4 客户端iscsi发现存储设备

# 查看目标存储(这里需要已知目标存储的IP及端口信息)
[root@ceshi ~]# iscsiadm -m discovery -t sendtargets -p 10.0.0.12 3746

# 查看核对信息
[root@ceshi ~]# iscsiadm -m node -o show 

# 登录发现的全部目标存储
[root@ceshi ~]# iscsiadm --m node --login

# 登录指定目标存储
[root@ceshi ~]# iscsiadm --mode node --portal 10.0.0.12 3746 --login

5 查看获取磁盘信息并格式化

[root@ceshi ~]# fdisk -l
Disk /dev/sda: 2199.0 GB, 2199023255552 bytes, 4294967296 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

# 格式化
[root@ceshi ~]# mkfs.xfs /dev/sda

# 挂载磁盘
[root@ceshi ~]# mkdir /data
[root@ceshi ~]# mount /dev/sda /data

# 查看磁盘空间大小
[root@ceshi ~]# df -h
Filesystem           Size  Used Avail Use% Mounted on
......
/dev/sda             2.0T   33M  2.0T   1% /data

6 设置开机自动挂载

[root@ceshi ~]# vim /etc/fstab
/dev/sda		/data			xfs	defaults	0 0
[root@ceshi ~]# mount -a

7 参考博客

CentOS iSCSI客户端使用配置

猜你喜欢

转载自blog.csdn.net/Mr_rsq/article/details/84065840