内容简介:1.进入配置接口2.查看帮助信息4.查看目录
[root@server ~]# systemctl enable target.service Created symlink from /etc/systemd/system/multi-user.target.wants/target.service to /usr/lib/systemd/system/target.service. [root@server ~]# systemctl start target.service
配置服务端
1.进入配置接口
[root@server ~]# targetcli Warning: Could not load preferences file /root/.targetcli/prefs.bin. targetcli shell version 2.1.fb41 Copyright 2011-2013 by Datera, Inc and others. For help on commands, type 'help'.
2.查看帮助信息
/> help GENERALITIES ============ This is a shell in which you can create, delete and configure configuration objects. The available commands depend on the current path or target path you want to run a command in: different path have different sets of available commands, i.e. a path pointing at an iscsi target will not have the same availaible commands as, say, a path pointing at a storage object. The prompt that starts each command line indicates your current path. Alternatively (useful if the prompt displays an abbreviated path to save space), you can run the pwd command to display the complete current path. Navigating the tree is done using the cd command. Without any argument, cd will present you wil the full objects tree. Just use arrows to select the destination path, and enter will get you there. Please try help cd for navigation tips. COMMAND SYNTAX ============== Commands are built using the following syntax: [TARGET_PATH] COMMAND_NAME [OPTIONS] The TARGET_PATH indicates the path to run the command from. If ommited, the command will be run from your current path. The OPTIONS depend on the command. Please use help COMMAND to get more information. AVAILABLE COMMANDS ================== The following commands are available in the current path: - bookmarks action [bookmark] - cd [path] - clearconfig [confirm] - exit - get [group] [parameter...] - help [topic] - ls [path] [depth] - pwd - refresh - restoreconfig [savefile] [clear_existing] - saveconfig [savefile] - sessions [action] [sid] - set [group] [parameter=value...] - status - version
4.查看目录
/> ls o- / ......................................................................................................................... [...] o- backstores .............................................................................................................. [...] | o- block .................................................................................................. [Storage Objects: 0] | o- fileio ................................................................................................. [Storage Objects: 0] | o- pscsi .................................................................................................. [Storage Objects: 0] | o- ramdisk ................................................................................................ [Storage Objects: 0] o- iscsi ............................................................................................................ [Targets: 0] o- loopback ......................................................................................................... [Targets: 0]
5.添加硬盘
/> backstores/block create Datastore /dev/sdb Created block storage object Datastore using /dev/sdb.
6.建立一个名称 IQN
/> /iscsi create iqn.2017-05.com.v5linux.iscsi.server0 Created target iqn.2017-05.com.v5linux.iscsi.server0. Created TPG 1. Global pref auto_add_default_portal=true Created default portal listening on all IPs (0.0.0.0), port 3260. /> ls o- / ......................................................................................................................... [...] o- backstores .............................................................................................................. [...] | o- block .................................................................................................. [Storage Objects: 1] | | o- Datastore ..................................................................... [/dev/sdb (20.0GiB) write-thru deactivated] | o- fileio ................................................................................................. [Storage Objects: 0] | o- pscsi .................................................................................................. [Storage Objects: 0] | o- ramdisk ................................................................................................ [Storage Objects: 0] o- iscsi ............................................................................................................ [Targets: 1] | o- iqn.2017-05.com.v5linux.iscsi.server0 ............................................................................. [TPGs: 1] | o- tpg1 ............................................................................................... [no-gen-acls, no-auth] | o- acls .......................................................................................................... [ACLs: 0] | o- luns .......................................................................................................... [LUNs: 0] | o- portals .................................................................................................... [Portals: 1] | o- 0.0.0.0:3260 ..................................................................................................... [OK] o- loopback ......................................................................................................... [Targets: 0] />
- 配置监听端口
默认监听的端口是2160,监听地址是任何地址
/> cd /iscsi/iqn.2017-05.com.v5linux.iscsi.server0/ /iscsi/iqn.20...iscsi.server0> ls o- iqn.2017-05.com.v5linux.iscsi.server0 ................................................................................. [TPGs: 1] o- tpg1 ................................................................................................... [no-gen-acls, no-auth] o- acls .............................................................................................................. [ACLs: 0] o- luns .............................................................................................................. [LUNs: 0] o- portals ........................................................................................................ [Portals: 1] o- 0.0.0.0:3260 ......................................................................................................... [OK] /iscsi/iqn.20...iscsi.server0>
配置提示不能创建网络配置,需要先删除默认的0。0.0.0
/> /iscsi/iqn.2017-05.com.v5linux.iscsi.server0/tpg1/portals create 172.10.100.129 ip_port=3260 Using default IP port 3260 Could not create NetworkPortal in configFS
进入到/iscsi/iqn.2017-05.com.v5linux.iscsi.server0/tpg1/portals 目录
/iscsi/iqn.20.../tpg1/portals> delete 0.0.0.0 3260 #删除 ip 和端口 Deleted network portal 0.0.0.0:3260 /iscsi/iqn.20.../tpg1/portals> ls o- portals ............................................................................................................ [Portals: 0] /iscsi/iqn.20.../tpg1/portals> /iscsi/iqn.2017-05.com.v5linux.iscsi.server0/tpg1/portals create 172.10.100.129 ip_port=3260 Using default IP port 3260 #添加 ip 和端口 Created network portal 172.10.100.129:3260. /iscsi/iqn.20.../tpg1/portals> ls o- portals ............................................................................................................ [Portals: 1] o- 172.10.100.129:3260 ...................................................................................................... [OK]
创建一个 acl
/iscsi/iqn.20.../tpg1/portals> /iscsi/iqn.2017-05.com.v5linux.iscsi.server0/tpg1/acls create iqn.2017-05.com.v5linux.iscsi.desktop Created Node ACL for iqn.2017-05.com.v5linux.iscsi.desktop
iqn.2017-05.com.v5linux.iscsi.desktop 表示客户端,这个后面会用到,名称任意
创建一个 lun (target 块设备的逻辑单元)
/iscsi/iqn.20.../tpg1/portals> /iscsi/iqn.2017-05.com.v5linux.iscsi.server0/tpg1/acls create iqn.2017-05.com.v5linux.iscsi.desktop Created Node ACL for iqn.2017-05.com.v5linux.iscsi.desktop /iscsi/iqn.20.../tpg1/portals> /iscsi/iqn.2017-05.com.v5linux.iscsi.server0/tpg1/luns create /backstores/block/Datastore Created LUN 0. Created LUN 0->0 mapping in node ACL iqn.2017-05.com.v5linux.iscsi.desktop
确认配置保存
/iscsi/iqn.20.../tpg1/portals> cd / /> saveconfig Last 10 configs saved in /etc/target/backup. Configuration saved to /etc/target/saveconfig.json />
再次查看整个目录结构
/> ls o- / ......................................................................................................................... [...] o- backstores .............................................................................................................. [...] | o- block .................................................................................................. [Storage Objects: 1] | | o- Datastore ....................................................................... [/dev/sdb (20.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.2017-05.com.v5linux.iscsi.server0 ............................................................................. [TPGs: 1] | o- tpg1 ............................................................................................... [no-gen-acls, no-auth] | o- acls .......................................................................................................... [ACLs: 1] | | o- iqn.2017-05.com.v5linux.iscsi.desktop ................................................................ [Mapped LUNs: 1] | | o- mapped_lun0 ............................................................................. [lun0 block/Datastore (rw)] | o- luns .......................................................................................................... [LUNs: 1] | | o- lun0 ..................................................................................... [block/Datastore (/dev/sdb)] | o- portals .................................................................................................... [Portals: 1] | o- 172.10.100.129:3260 .............................................................................................. [OK] o- loopback ...............
退出
/> exit Global pref auto_save_on_exit=true Last 10 configs saved in /etc/target/backup. Configuration saved to /etc/target/saveconfig.json
客户端
1.安装并且启动
[root@client ~]# yum -y install iscsi-initiator-utils Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: mirrors.zju.edu.cn Package iscsi-initiator-utils-6.2.0.873-35.el7.x86_64 already installed and latest version Nothing to do [root@client ~]# systemctl start iscsid.service
2.配置InitiatorName
[root@client ~]# cat /etc/iscsi/initiatorname.iscsi InitiatorName=iqn.1994-05.com.redhat:60b98a424980 [root@client ~]# echo InitiatorName=iqn.2017-05.com.v5linux.iscsi.desktop > /etc/iscsi/initiatorname.iscsi #注意自己的主机名一定要与 server 的 acl 匹配 [root@client ~]# cat /etc/iscsi/initiatorname.iscsi InitiatorName=iqn.2017-05.com.v5linux.iscsi.desktop
3.查找服务端
[root@client ~]# iscsiadm -m discovery -t st -p 172.10.100.129 172.10.100.129:3260,1 iqn.2017-05.com.v5linux.iscsi.server0
参数
-m discovery 表示发现查找
-t senbtargets 表示发布的 target (缩写为-t st)
-p 指定 ip 和端口 ip:port
4.重启服务
[root@client ~]# systemctl restart iscsid.service
5.连接
[root@client ~]# iscsiadm -m node -T iqn.2017-05.com.v5linux.iscsi.server0 -l Logging in to [iface: default, target: iqn.2017-05.com.v5linux.iscsi.server0, portal: 172.10.100.129,3260] (multiple) Login to [iface: default, target: iqn.2017-05.com.v5linux.iscsi.server0, portal: 172.10.100.129,3260] successful.
6.查看磁盘
[root@client ~]# fdisk -l Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 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 Disk /dev/sda: 21.5 GB, 21474836480 bytes, 41943040 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 Disk label type: dos Disk identifier: 0x0000f054 Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 41943039 19921920 8e Linux LVM Disk /dev/mapper/cl-root: 18.2 GB, 18249416704 bytes, 35643392 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 Disk /dev/mapper/cl-swap: 2147 MB, 2147483648 bytes, 4194304 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 Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 4194304 bytes
排错
1.提示no route
确认防火墙端口是否开启,确认网段是否一致
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- Kubernetes 使用 Ceph 存储
- Redis 内存使用优化与存储
- 使用Elasticsearch作为主数据存储
- 如何使用MongoDB存储Docker日志!
- 使用Azure托管磁盘简化云存储管理
- [译] 使用 Jetpack DataStore 进行数据存储
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
C# 6.0本质论
[美] Mark Michaelis(马克·米凯利斯)、[美] Eric Lippert(埃里克·利珀特) / 周靖、庞燕 / 人民邮电出版社 / 2017-2-1 / 108
这是C#领域中一部广受好评的名作,作者用一种易于理解的方式详细介绍了C#语言的各个方面。全书共有21章和4个附录(其中哟2个附录从网上下载),介绍了C#语言的数据类型、操作符、方法、类、接口、异常处理等基本概念,深入讨论了泛型、迭代器、反射、线程和互操作性等高级主题,还介绍了LINQ技术,以及与其相关的扩展方法、分部方法、Lambda表达式、标准查询操作符和查询表达式等内容。每章开头的“思维导图”......一起来看看 《C# 6.0本质论》 这本书的介绍吧!