1. 程式人生 > >Centos7 配置iscsi客戶端

Centos7 配置iscsi客戶端

1 客戶端安裝iscsi並配置好iqn及CHAP

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

2 開啟iscsi並設定開機自啟

[[email protected] ~]# systemctl start iscsi
[[email protected] ~]# systemctl enable iscsi

3 修改配置檔案開啟並配置CHAP

[[email protected] ~]# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.1994-05.com.centos:ceshi
InitiatorAlias=ceshi     #<==可不配置
[[email protected] ~]# 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及埠資訊)
[[email protected] ~]# iscsiadm -m discovery -t sendtargets -p 10.0.0.12 3746

# 檢視核對資訊
[[email protected] ~]# iscsiadm -m node -o show 

# 登入發現的全部目標儲存
[[email protected] ~]# iscsiadm --m node --login

# 登入指定目標儲存
[[email protected] ~]# iscsiadm --mode node --portal 10.0.0.12 3746 --login

5 檢視獲取磁碟資訊並格式化

[[email protected] ~]# 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

# 格式化
[[email protected] ~]# mkfs.xfs /dev/sda

# 掛載磁碟
[[email protected] ~]# mkdir /data
[[email protected] ~]# mount /dev/sda /data

# 檢視磁碟空間大小
[[email protected] ~]# df -h
Filesystem           Size  Used Avail Use% Mounted on
......
/dev/sda             2.0T   33M  2.0T   1% /data

6 設定開機自動掛載

[[email protected] ~]# vim /etc/fstab
/dev/sda		/data			xfs	defaults	0 0
[[email protected] ~]# mount -a

7 參考部落格

CentOS iSCSI客戶端使用配置