RHEL7部署ISCSI TARGET服务器

简介:

一、配置yum源

[root@rhel yum.repos.d]# vi /etc/yum.repos.d/local.repo 

[local]

name=local

baseurl=file:///mnt/media/

enable=1

gpgcheck=0


二、挂载光盘

[root@rhel yum.repos.d]# mkdir /mnt/media/

[root@rhel yum.repos.d]# mount /dev/cdrom /mnt/media/

mount: /dev/sr0 is write-protected, mounting read-only

[root@rhel yum.repos.d]# 


三、通过yum安装targetcli

[root@rhel yum.repos.d]# yum install targetcli

Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager

This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.

Resolving Dependencies

--> Running transaction check

---> Package targetcli.noarch 0:2.1.fb41-3.el7 will be installed

--> Processing Dependency: python-rtslib >= 2.1.fb41 for package: targetcli-2.1.fb41-3.el7.noarch

--> Processing Dependency: python-configshell for package: targetcli-2.1.fb41-3.el7.noarch

--> Running transaction check

---> Package python-configshell.noarch 1:1.1.fb18-1.el7 will be installed

--> Processing Dependency: pyparsing for package: 1:python-configshell-1.1.fb18-1.el7.noarch

--> Processing Dependency: python-urwid for package: 1:python-configshell-1.1.fb18-1.el7.noarch

---> Package python-rtslib.noarch 0:2.1.fb57-3.el7 will be installed

--> Processing Dependency: python-kmod for package: python-rtslib-2.1.fb57-3.el7.noarch

--> Running transaction check

---> Package pyparsing.noarch 0:1.5.6-9.el7 will be installed

---> Package python-kmod.x86_64 0:0.9-4.el7 will be installed

---> Package python-urwid.x86_64 0:1.1.1-3.el7 will be installed

--> Finished Dependency Resolution


Dependencies Resolved


==============================================================================================================================================

 Package                                 Arch                        Version                                 Repository                  Size

==============================================================================================================================================

Installing:

 targetcli                               noarch                      2.1.fb41-3.el7                          local                       61 k

Installing for dependencies:

 pyparsing                               noarch                      1.5.6-9.el7                             local                       94 k

 python-configshell                      noarch                      1:1.1.fb18-1.el7                        local                       67 k

 python-kmod                             x86_64                      0.9-4.el7                               local                       57 k

 python-rtslib                           noarch                      2.1.fb57-3.el7                          local                       88 k

 python-urwid                            x86_64                      1.1.1-3.el7                             local                      654 k


Transaction Summary

==============================================================================================================================================

Install  1 Package (+5 Dependent packages)


Total download size: 1.0 M

Installed size: 4.5 M

Is this ok [y/d/N]: y

Downloading packages:

----------------------------------------------------------------------------------------------------------------------------------------------

Total                                                                                                         2.7 MB/s | 1.0 MB  00:00:00     

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : python-kmod-0.9-4.el7.x86_64                                                                                               1/6 

  Installing : python-rtslib-2.1.fb57-3.el7.noarch                                                                                        2/6 

  Installing : pyparsing-1.5.6-9.el7.noarch                                                                                               3/6 

  Installing : python-urwid-1.1.1-3.el7.x86_64                                                                                            4/6 

  Installing : 1:python-configshell-1.1.fb18-1.el7.noarch                                                                                 5/6 

  Installing : targetcli-2.1.fb41-3.el7.noarch                                                                                            6/6 

local/productid                                                                                                        | 1.6 kB  00:00:00     

  Verifying  : python-rtslib-2.1.fb57-3.el7.noarch                                                                                        1/6 

  Verifying  : python-urwid-1.1.1-3.el7.x86_64                                                                                            2/6 

  Verifying  : 1:python-configshell-1.1.fb18-1.el7.noarch                                                                                 3/6 

  Verifying  : targetcli-2.1.fb41-3.el7.noarch                                                                                            4/6 

  Verifying  : pyparsing-1.5.6-9.el7.noarch                                                                                               5/6 

  Verifying  : python-kmod-0.9-4.el7.x86_64                                                                                               6/6 


Installed:

  targetcli.noarch 0:2.1.fb41-3.el7                                                                                                           


Dependency Installed:

  pyparsing.noarch 0:1.5.6-9.el7                 python-configshell.noarch 1:1.1.fb18-1.el7          python-kmod.x86_64 0:0.9-4.el7         

  python-rtslib.noarch 0:2.1.fb57-3.el7          python-urwid.x86_64 0:1.1.1-3.el7                  


Complete!

[root@rhel yum.repos.d]# 


四、使用fdisk -l查看一下需要分享的磁盘是否正常

[root@rhel ~]# fdisk -l


Disk /dev/sda: 85.9 GB, 85899345920 bytes, 167772160 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: 0x000cc61d


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1            2048     8390655     4194304   82  Linux swap / Solaris

/dev/sda2   *     8390656   167772159    79690752   83  Linux


Disk /dev/sdb: 5368 MB, 5368709120 bytes, 10485760 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: 5368 MB, 5368709120 bytes, 10485760 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@rhel ~]# 


五、使用targetcli配置服务器

5、1先help一下,查看一下支持的命令有哪些

[root@rhel ~]# 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'.


/> 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 

/> 

5、2配置目标服务器的iqn

[root@rhel ~]# 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'.


/> 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 

/> 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]

/> cd iscsi 

/iscsi> create iqn.2016-10.com.server:001

Created target iqn.2016-10.com.server:001.

Created TPG 1.

Global pref auto_add_default_portal=true

Created default portal listening on all IPs (0.0.0.0), port 3260.

/iscsi> ls

o- iscsi .............................................................................................................. [Targets: 1]

  o- iqn.2016-10.com.server:001 .......................................................................................... [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> cd /

/> 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: 1]

  | o- iqn.2016-10.com.server:001 ........................................................................................ [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]

/> cd backstores/

/backstores> ls

o- backstores ................................................................................................................ [...]

  o- block .................................................................................................... [Storage Objects: 0]

  o- fileio ................................................................................................... [Storage Objects: 0]

  o- pscsi .................................................................................................... [Storage Objects: 0]

  o- ramdisk .................................................................................................. [Storage Objects: 0]

/backstores> cd  block 

/backstores/block> ls

o- block ...................................................................................................... [Storage Objects: 0]

/backstores/block> ?

/backstores/block> 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] 

  - create name dev [readonly] 

  - delete name 

  - exit 

  - get [group] [parameter...] 

  - help [topic] 

  - ls [path] [depth] 

  - pwd 

  - refresh 

  - set [group] [parameter=value...] 

  - status 

/backstores/block> create lun0 /dev/sdb

Created block storage object lun0 using /dev/sdb.

/backstores/block> create lun1 /dev/sdc

Created block storage object lun1 using /dev/sdc.

/backstores/block> ls

o- block ...................................................................................................... [Storage Objects: 2]

  o- lun0 ............................................................................... [/dev/sdb (5.0GiB) write-thru deactivated]

  o- lun1 ............................................................................... [/dev/sdc (5.0GiB) write-thru deactivated]

/backstores/block> cd /

/> ls

o- / ......................................................................................................................... [...]

  o- backstores .............................................................................................................. [...]

  | o- block .................................................................................................. [Storage Objects: 2]

  | | o- lun0 ........................................................................... [/dev/sdb (5.0GiB) write-thru deactivated]

  | | o- lun1 ........................................................................... [/dev/sdc (5.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.2016-10.com.server:001 ........................................................................................ [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]

/> cd iscsi/iqn.2016-10.com.server:001/tpg1/luns 

/iscsi/iqn.20...001/tpg1/luns> ls

o- luns .................................................................................................................. [LUNs: 0]

/iscsi/iqn.20...001/tpg1/luns> create /backstores/block/lun0

Created LUN 0.

/iscsi/iqn.20...001/tpg1/luns> create /backstores/block/lun1

Created LUN 1.

/iscsi/iqn.20...001/tpg1/luns> ls

o- luns .................................................................................................................. [LUNs: 2]

  o- lun0 .................................................................................................. [block/lun0 (/dev/sdb)]

  o- lun1 .................................................................................................. [block/lun1 (/dev/sdc)]

/iscsi/iqn.20...001/tpg1/luns> cd /

/> cd iscsi/iqn.2016-10.com.server:001/tpg1/acls 

/iscsi/iqn.20...001/tpg1/acls> create iqn.2016-10.com.microsoft:node1

Created Node ACL for iqn.2016-10.com.microsoft:node1

Created mapped LUN 1.

Created mapped LUN 0.

/iscsi/iqn.20...001/tpg1/acls> ls

o- acls .................................................................................................................. [ACLs: 1]

  o- iqn.2016-10.com.microsoft:node1 .............................................................................. [Mapped LUNs: 2]

    o- mapped_lun0 .......................................................................................... [lun0 block/lun0 (rw)]

    o- mapped_lun1 .......................................................................................... [lun1 block/lun1 (rw)]

/iscsi/iqn.20...001/tpg1/acls> 

/iscsi/iqn.20...001/tpg1/acls> cd /

/> saveconfig 

Last 10 configs saved in /etc/target/backup.

Configuration saved to /etc/target/saveconfig.json

/> 


六、查看targetcli的状态及端口号是否正常

[root@rhel ~]# systemctl is-active target.service 

active

[root@rhel ~]# netstat -tunlp|grep 3260

tcp        0      0 0.0.0.0:3260            0.0.0.0:*               LISTEN      - 


七、防火墙放行并设置开机启动

[root@rhel ~]# firewall-cmd --add-service=iscsi-target --permanent

success

[root@rhel ~]# systemctl enable target


八、可以使用windows或linux挂载并使用了


 本文转自 技术花妞妞 51CTO博客,原文链接:http://blog.51cto.com/xiaogongju/1947597


相关文章
|
8天前
|
弹性计算 监控 负载均衡
|
27天前
|
监控 安全 Linux
RHEL 环境下 Subversion 服务器部署与配置
【10月更文挑战第18天】在RHEL环境下部署Subversion服务器需依次完成安装Subversion、创建版本库、配置服务器、启动服务、客户端连接及备份维护等步骤。确保遵循安全最佳实践,保障数据安全。
|
1天前
|
弹性计算 开发工具 git
2分钟在阿里云ECS控制台部署个人应用(图文示例)
作为一名程序员,我在部署托管于Github/Gitee的代码到阿里云ECS服务器时,经常遇到繁琐的手动配置问题。近期,阿里云ECS控制台推出了一键构建部署功能,简化了这一过程,支持Gitee和GitHub仓库,自动处理git、docker等安装配置,无需手动登录服务器执行命令,大大提升了部署效率。本文将详细介绍该功能的使用方法和适用场景。
2分钟在阿里云ECS控制台部署个人应用(图文示例)
|
8天前
|
PHP 数据库 数据安全/隐私保护
布谷直播源码部署服务器关于数据库配置的详细说明
布谷直播系统源码搭建部署时数据库配置明细!
|
17天前
|
关系型数据库 MySQL Linux
基于阿里云服务器Linux系统安装Docker完整图文教程(附部署开源项目)
基于阿里云服务器Linux系统安装Docker完整图文教程(附部署开源项目)
154 2
|
17天前
|
NoSQL Linux PHP
|
18天前
|
弹性计算 数据库连接 Nacos
阿里云ECS服务器在docker中部署nacos
docker pull nacos 失败,docker部署nacos遇到的问题,nacos数据库连接,nacos端口映射
77 1
|
24天前
|
监控 网络安全 调度
Quartz.Net整合NetCore3.1,部署到IIS服务器上后台定时Job不被调度的解决方案
解决Quartz.NET在.NET Core 3.1应用中部署到IIS服务器上不被调度的问题,通常需要综合考虑应用配置、IIS设置、日志分析等多个方面。采用上述策略,结合细致的测试和监控,可以有效地提高定时任务的稳定性和可靠性。在实施任何更改后,务必进行充分的测试,以验证问题是否得到解决,并监控生产环境的表现,确保长期稳定性。
37 1
|
28天前
|
安全 Linux 数据安全/隐私保护
RHEL 环境下 Subversion 服务器部署与配置
【10月更文挑战第17天】在RHEL环境下部署Subversion服务器包括安装Subversion、创建和配置版本库、启动服务器、客户端连接以及备份与恢复等步骤。通过这些步骤,可确保服务器的安全性和稳定性,满足版本控制需求。
|
30天前
|
前端开发 Java Shell
后端项目打包上传服务器部署运行记录
后端项目打包上传服务器部署运行记录
27 0
下一篇
无影云桌面