标签:图片 同名 str 直接 内容 ram 存储 type 系统识别
ISCSI服务端和客户端的操作系统以及IP地址
ISCSI服务端
ISCSI客户端
RHEL 7.3
服务端192.168.0.13
客户端192.168.0.10
[root@linuxprobe ~]# yum -y install targetd targetcli
[root@linuxprobe ~]# systemctl start targetd
[root@linuxprobe ~]# systemctl enable targetd
[root@linuxprobe ~]# targetcli
/> cd iscsi
/iscsi>
/iscsi> create
Created target iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.d497c356ad80.
Created TPG 1.
/iscsi> cd iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.d497c356ad80/
/iscsi/iqn.20....d497c356ad80> ls
o- iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.d497c356ad80 .... [TPGs: 1]
o- tpg1 ............................................. [no-gen-acls, no-auth]
o- acls ........................................................ [ACLs: 0]
o- luns ........................................................ [LUNs: 0]
o- portals .................................................. [Portals: 0]
/iscsi/iqn.20....d497c356ad80> cd tpg1/luns
/iscsi/iqn.20...d80/tpg1/luns> create /backstores/block/disk0
Created LUN 0.
/iscsi/iqn.20...d80/tpg1/luns> cd ..
/iscsi/iqn.20...c356ad80/tpg1> cd acls
/iscsi/iqn.20...d80/tpg1/acls> create iqn.2003-01.org.linux-iscsi.linuxprobe.
x8664:sn.d497c356ad80:client
Created Node ACL for iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.d497c356ad80:
client
Created mapped LUN 0.
/iscsi/iqn.20...d80/tpg1/acls> cd ..
/iscsi/iqn.20...c356ad80/tpg1> cd portals
/iscsi/iqn.20.../tpg1/portals> create 192.168.0.13
Using default IP port 3260
Created network portal 192.168.10.10:3260.
/iscsi/iqn.20.../tpg1/portals> ls /
o- / ........................... [...]
o- backstores................. [...]
| o- block ................... [Storage Objects: 1]
| | o- disk0 ................. [/dev/md0 (40.0GiB) write-thru activated]
| o- fileio .................. [Storage Objects: 0]
| o- pscsi ................... [Storage Objects: 0]
| o- ramdisk ................. [Storage Objects: 0]
o- iscsi ..................... [Targets: 1]
| o- iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.d497c356ad80 ... [TPGs: 1]
| o- tpg1 .................. [no-gen-acls, no-auth]
| o- acls ............................................... [ACLs: 1]
| | o- iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.d497c356ad80:client
[Mapped LUNs: 1]
| | o- mapped_lun0 .......................... [lun0 block/disk0 (rw)]
o- luns .................... [LUNs: 1]
| | o- lun0 .............. [block/disk0 (/dev/md0)]
| o- portals ............. [Portals: 1]
| o- 192.168.0.13:3260 [OK]
o- loopback .................. [Targets: 0]
/> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json
[root@linuxprobe ~]# systemctl restart targetd
[root@linuxprobe ~]# firewall-cmd --permanent --add-port=3260/tcp
success
[root@linuxprobe ~]# firewall-cmd --reload
success
iSCSI 服务端配置完成。
[root@linuxprobe ~]# yum install iscsi-initiator-utils
Loaded plugins: langpacks, product-id, subscription-manager
Package iscsi-initiator-utils-6.2.0.873-21.el7.x86_64 already installed and
latest version
Nothing to do
[root@linuxprobe ~]# vim /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.d497c356ad80:client
[root@linuxprobe ~]# systemctl restart iscsid
[root@linuxprobe ~]# systemctl enable iscsid
ln -s ‘/usr/lib/systemd/system/iscsid.service‘ ‘/etc/systemd/system/multi-user.
target.wants/iscsid.service‘
[root@linuxprobe ~]# iscsiadm -m discovery -t st -p 192.168.0.13
192.168.10.10:3260,1 iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.d497c356ad80
[root@linuxprobe ~]# iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.linuxprobe.
x8664:sn.d497c356ad80 -p 192.168.10.10 --login
Logging in to [iface: default, target: iqn.2003-01.org.linux-iscsi.linuxprobe.
x8664:sn.d497c356ad80, portal: 192.168.10.10,3260] (multiple)
Login to [iface: default, target: iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:
sn.d497c356ad80, portal: 192.168.10.10,3260] successful.
[root@linuxprobe ~]# file /dev/sdb
/dev/sdb: block special
[root@linuxprobe ~]# mkfs.xfs /dev/sdb
log stripe unit (524288 bytes) is too large (maximum is 256KiB)
log stripe unit adjusted to 32KiB
meta-data=/dev/sdb isize=256 agcount=16, agsize=654720 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=10475520, imaxpct=25
= sunit=128 swidth=256 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=5120, version=2
= sectsz=512 sunit=8 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@linuxprobe ~]# mkdir /iscsi
[root@linuxprobe ~]# mount /dev/sdb /iscsi
[root@linuxprobe ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel-root 18G 3.4G 15G 20% /
devtmpfs 734M 0 734M 0% /dev
tmpfs 742M 176K 742M 1% /dev/shm
tmpfs 742M 8.8M 734M 2% /run
tmpfs 742M 0 742M 0% /sys/fs/cgroup
/dev/sr0 3.5G 3.5G 0 100% /media/cdrom
/dev/sda1 497M 119M 379M 24% /boot
/dev/sdb 40G 33M 40G 1% /iscsi
[root@linuxprobe ~]# blkid | grep /dev/sdb
/dev/sdb: UUID="eb9cbf2f-fce8-413a-b770-8b0f243e8ad6" TYPE="xfs"
[root@linuxprobe ~]# iscsiadm -m node -T iqn.2003-01.org.linux-iscsi.linuxprobe.
x8664:sn.d497c356ad80 -u
Logging out of session [sid: 7, target : iqn.2003-01.org.linux-iscsi.linuxprobe.
x8664:sn.d497c356ad80, portal: 192.168.10.10,3260]
Logout of [sid: 7, target: iqn.2003-01.org.linux-iscsi.linuxprobe.x8664:sn.
d497c356ad80,portal:192.168.10.10,3260] successful.
本文源自:刘遄老师的<Linux就该这么学>一书中的部分章节,内容细致因此收入博文中,便于随时查看
标签:图片 同名 str 直接 内容 ram 存储 type 系统识别
原文地址:http://blog.51cto.com/996665552/2349754