RHEL7 配置iscsi服务端并实现客户端自动开机挂载

环境:server 172.25.0.11 ——iscsi server iqn:iqn.2016-02.com.example:server0
client 172.25.0.10 ——iscsi client iqn:iqn.2016-02.com.example:desktop0
一、iscsi服务端配置

安装targetcli
yum install targetcli -y
找一块磁盘挂载

[[email protected] ~]# targetcli   ——进入此命令配置iscsi服务端
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.fb34
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type ‘help‘.

/> 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]
/> backstores/block create iscsi_store /dev/vdb1——使用刚才分区的磁盘vdb创建iscsi存储块
Created block storage object iscsi_store using /dev/vdb1.
/> ls
o- / ......................................................................................................................... [...]
  o- backstores .............................................................................................................. [...]
  | o- block .................................................................................................. [Storage Objects: 1]
  | | o- iscsi_store ................................................................... [/dev/vdb1 (3.0GiB) write-thru deactivated]
  | o- fileio ................................................................................................. [Storage Objects: 0]
  | o- pscsi .................................................................................................. [Storage Objects: 0]
  | o- ramdisk ................................................................................................ [Storage Objects: 0]
  o- iscsi ............................................................................................................ [Targets: 0]
  o- loopback ......................................................................................................... [Targets: 0]
/> iscsi/ create iqn.2016-02.com.example:server0——创建iscsi服务器端iqn
Created target iqn.2016-02.com.example:server0.
Created TPG 1.
/> iscsi/iqn.2016-02.com.example:server0/tpg1/
iscsi/iqn.2016-02.com.example:server0/tpg1/*         iscsi/iqn.2016-02.com.example:server0/tpg1/luns/
iscsi/iqn.2016-02.com.example:server0/tpg1/acls/     iscsi/iqn.2016-02.com.example:server0/tpg1/portals/
...path
/> iscsi/iqn.2016-02.com.example:server0/tpg1/
iscsi/iqn.2016-02.com.example:server0/tpg1/*         iscsi/iqn.2016-02.com.example:server0/tpg1/luns/
iscsi/iqn.2016-02.com.example:server0/tpg1/acls/     iscsi/iqn.2016-02.com.example:server0/tpg1/portals/
...path
/> iscsi/iqn.2016-02.com.example:server0/tpg1/luns create /backstores/block/iscsi_store ——创建iscsi存储lun
Created LUN 0.
/> iscsi/iqn.2016-02.com.example:server0/tpg1/acls create iqn.2016-02.com.example:desktop0 ——允许客户端iqn访问此服务器iscsi服务
Created Node ACL for iqn.2016-02.com.example:desktop0
Created mapped LUN 0.
/> iscsi/iqn.2016-02.com.example:server0/tpg1/portals create 172.25.0.11 3260——创建服务器端侦听ip和端口
Using default IP port 3260
Created network portal 172.25.0.11:3260.
/> saveconfig ——保存配置
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json
/> exit
Global pref auto_save_on_exit=true
Last 10 configs saved in /etc/target/backup.
Configuration saved to /etc/target/saveconfig.json
[[email protected] ~]# systemctl start target  ——启动iscsi服务
[[email protected] ~]# systemctl enable target
ln -s ‘/usr/lib/systemd/system/target.service‘ ‘/etc/systemd/system/multi-user.target.wants/target.service‘
[[email protected] ~]# firewall-cmd --permanent --add-port=3260/tcp——防火墙开启3260端口
success
[[email protected] ~]# firewall-cmd --reload——重启防火墙服务
success
[[email protected] ~]# 

二、iscsi客户端配置

[[email protected] ~]# yum install iscsi-initiator-utils -y
Loaded plugins: langpacks
Package iscsi-initiator-utils-6.2.0.873-21.el7.x86_64 already installed and latest version
Nothing to do
[[email protected] ~]# vim /etc/iscsi/initiatorname.iscsi ——修改客户端iqn名称
[[email protected] ~]# cat !$
cat /etc/iscsi/initiatorname.iscsi
InitiatorName=iqn.2016-02.com.example:desktop0
[[email protected] ~]#
[[email protected] ~]# systemctl start iscsi iscsid
[[email protected] ~]# systemctl enable iscsi iscsid
ln -s ‘/usr/lib/systemd/system/iscsid.service‘ ‘/etc/systemd/system/multi-user.target.wants/iscsid.service‘
[[email protected] ~]# iscsiadm -m discovery -t st -p server0
172.25.0.11:3260,1 iqn.2016-02.com.example:server0
[[email protected] ~]# iscsiadm -m node -T iqn.2016-02.com.example:server0 -p 172.25.0.11 -l
Logging in to [iface: default, target: iqn.2016-02.com.example:server0, portal: 172.25.0.11,3260] (multiple)
Login to [iface: default, target: iqn.2016-02.com.example:server0, portal: 172.25.0.11,3260] successful.
[[email protected] ~]# lsblk
NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda      8:0    0   3G  0 disk
vda    253:0    0  10G  0 disk
└─vda1 253:1    0  10G  0 part /
vdb    253:16   0  10G  0 disk
[[email protected] ~]# fdisk /dev/sda——分区挂载的iscsi磁盘
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0xa975526e.

Command (m for help): p

Disk /dev/sda: 3221 MB, 3221225472 bytes, 6291456 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
Disk label type: dos
Disk identifier: 0xa975526e

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1):
First sector (8192-6291455, default 8192):
Using default value 8192
Last sector, +sectors or +size{K,M,G} (8192-6291455, default 6291455):
Using default value 6291455
Partition 1 of type Linux and of size 3 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[[email protected] ~]# fdisk -l
Disk /dev/sda: 3221 MB, 3221225472 bytes, 6291456 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
Disk label type: dos
Disk identifier: 0xa975526e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            8192     6291455     3141632   83  Linux

[[email protected] ~]# mkfs.xfs /dev/sda1——格式化文件类型为xfs
meta-data=/dev/sda1              isize=256    agcount=8, agsize=98176 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0
data     =                       bsize=4096   blocks=785408, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal log           bsize=4096   blocks=2560, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[[email protected] ~]# mkdir /mnt/data
[[email protected] ~]# vim /etc/fstab
[[email protected] ~]# blkid
/dev/vda1: UUID="9bf6b9f7-92ad-441b-848e-0257cbb883d1" TYPE="xfs"
/dev/sda1: UUID="701f7c03-8f64-4d39-9acc-55a95d66e57d" TYPE="xfs"
[[email protected] ~]# vim /etc/fstab ——使用uuid挂载
[[email protected] ~]# cat !$
cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Wed May  7 01:22:57 2014
#
# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=9bf6b9f7-92ad-441b-848e-0257cbb883d1 /                       xfs     defaults        1 1
UUID=701f7c03-8f64-4d39-9acc-55a95d66e57d /mnt/data xfs _netdev 0 0   ——注意使用_netdev
[[email protected] ~]# mount -a
[[email protected] ~]# df -Th
Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/vda1      xfs        10G  3.1G  7.0G  31% /
devtmpfs       devtmpfs  906M     0  906M   0% /dev
tmpfs          tmpfs     921M  124K  921M   1% /dev/shm
tmpfs          tmpfs     921M   17M  904M   2% /run
tmpfs          tmpfs     921M     0  921M   0% /sys/fs/cgroup
/dev/sda1      xfs       3.0G   33M  3.0G   2% /mnt/data
[[email protected] ~]# 

注意:开机启动自动挂载还需要修改此参数
vim /var/lib/iscsi/nodes/iqn.2016-02.com.example\:server0/172.25.0.11\,3260\,1/default
node.conn[0].startup = automatic——把手动改为自动
结果成功在客户端挂载的iscsi上创建文件

原文地址:http://blog.51cto.com/12185273/2283659

时间: 2024-08-01 12:53:51

RHEL7 配置iscsi服务端并实现客户端自动开机挂载的相关文章

配置iSCSI 服务端

ISCSI服务端和客户端的操作系统以及IP地址 环境准备 主机名称: ISCSI服务端ISCSI客户端 操作系统: RHEL 7.3 IP地址: 服务端192.168.0.13客户端192.168.0.10 服务端配置过程 第一步:配置好Yum 软件仓库后安装iSCSI 服务端程序以及配置命令工具.通过在yum命令的后面添加-y 参数,在安装过程中就不需要再进行手动确认了: [root@linuxprobe ~]# yum -y install targetd targetcli 安装完成后启动

centos 6.5环境利用iscsi搭建SAN网络存储服务及服务端target和客户端initiator配置详解

一.简介 iSCSI(internet SCSI)技术由IBM公司研究开发,是一个供硬件设备使用的.可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速千兆以太网上进行路由选择.iSCSI技术是一种新储存技术,该技术是将现有SCSI接口与以太网络(Ethernet)技术结合,使服务器可与使用IP网络的储存装置互相交换资料. iSCSI是一种基于TCP/IP 的协议,用来建立和管理IP存储设备.主机和客户机等之间的相互连接,并创建存储区域网

[ Centos 7 iscsi搭建 及 1台客户端同时挂载多台iscsi服务端问题 ]

一.什么是iscsi iSCSI技术是一种由IBM公司研究开发的,是一个供硬件设备使用的可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议,使其能够在诸如高速千兆以太网上进行路由选择.iSCSI技术是一种新储存技术,该技术是将现有SCSI接口与以太网络(Ethernet)技术结合,使服务器可与使用IP网络的储存装置互相交换资料. 二.需求分析 最近在做虚拟化,需要通过一个主机挂载来自两个iscsi服务器的targets,如图: 三.实现思路        

SpringCloud系列九:SpringCloudConfig 基础配置(SpringCloudConfig 的基本概念、配置 SpringCloudConfig 服务端、抓取配置文件信息、客户端使用 SpringCloudConfig 进行配置、单仓库目录匹配、应用仓库自动选择、仓库匹配模式)

1.概念:SpringCloudConfig 基础配置 2.具体内容 通过名词就可以发现,SpringCloudConfig 核心作用一定就在于进行配置文件的管理上.也就是说为了更好的进行所有微服务的配置项的管理,在 SpringCloud 设计架构里面就考虑到了针对于所有的核心配置文件(application.yml)进行的一项统一管理的工具. 2.1.SpringCloudConfig 的基本概念 现在可以思考一个问题:在一个实际的项目开发过程之中,有可能会出现有上百个微服务(创建微服务的标

linux存储技术与应用:配置iSCSI服务及应用示例

实验:配置iSCSI服务,(服务4.103,客户4.254/4.100) 先添加一块新硬盘 fdisk -cu /dev/sdb    # 进入磁盘分区模式 分区模式中输入以下信息进行:分区 -n            #新建分区 -p            #创建主分区 1             #第一个分区 回车 +1G        #第一个分区大小 w             #保存并退出 lsblk    可以发现新分区已经存在 mount /dev/sdb1  /var/lib/m

Cluster基础(一):配置iSCSI服务、编写udev规则、配置并访问NFS共享、部署Multipath多路径环境

一.配置iSCSI服务 目标: 本案例要求先搭建好一台iSCSI服务器,并将整个磁盘共享给客户端: 虚拟机添加新的磁盘 将新添加的磁盘分区并创建两个逻辑卷 逻辑卷名称分别为:/dev/myvg/iscsi1和/dev/myvg/iscsi2 服务器通过配置文件与命令两种方式共享逻辑卷 然后客户机挂载iSCSI服务器共享的磁盘: 客户端使用命令探测服务器共享的iSCSI磁盘 客户端挂载iSCSI磁盘 分区并格式化 方案: 使用2台RHEL6虚拟机,其中一台作为iSCSI服务器(192.168.4.

Service系统服务(六):rsync基本用法、rsync+SSH同步、配置rsync服务端、访问rsync共享资源、使用inotifywait工具、配置Web镜像同步、配置并验证Split分离解析

一.rsync基本用法 目标: 本例要求掌握远程同步的基本操作,使用rsync命令完成下列任务: 1> 将目录 /boot 同步到目录 /todir 下   2> 将目录 /boot 下的文档同步到目录 /todir 下   3> 在目录 /boot 下新增文件 a.txt,删除 /todir 下的子目录 grub2,再次同步使 /todir 与 /boot 一致   4> 验证 -a.-n.-v.--delete 选项的含义 方案: 本地同步操作: rsync [选项...] 本

Spring Cloud 服务端注册与客户端调用

Spring Cloud 服务端注册与客户端调用 上一篇中,我们已经把Spring Cloud的服务注册中心Eureka搭建起来了,这一章,我们讲解如何将服务注册到Eureka,以及客户端如何调用服务. 一.注册服务 首先要再项目中引入Eureka Client,在pom.xml中加入如下配置: <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cl

14.1-14.3 NFS介绍,服务端安装,客户端挂载NFS

14.1 NFS介绍 NFS是Network File System的缩写 NFS最早由Sun公司开发,分2,3,4三个版本,2和3由Sun起草开发,4.0开始Netapp公司参与并主导开发,最新为4.1版本 NFS数据传输基于RPC协议,RPC为Remote Procedure Call的简写. NFS应用场景是:A,B,C三台机器上需要保证被访问到的文件是一样的,A共享数据出来,B和C分别去挂载A共享的数据目录,从而B和C访问到的数据和A上的一致 NFS架构 应用场景: A B C为别是三台