环境: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

找一块磁盘挂载

[root@server0 ~]# 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

[root@server0 ~]# systemctl start target ——启动iscsi服务

[root@server0 ~]# systemctl enable target

ln -s '/usr/lib/systemd/system/target.service' '/etc/systemd/system/multi-user.target.wants/target.service'

[root@server0 ~]# firewall-cmd --permanent --add-port=3260/tcp——防火墙开启3260端口

success

[root@server0 ~]# firewall-cmd --reload——重启防火墙服务

success

[root@server0 ~]#

二、iscsi客户端配置

[root@desktop0 ~]# 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

[root@desktop0 ~]# vim /etc/iscsi/initiatorname.iscsi ——修改客户端iqn名称

[root@desktop0 ~]# cat !$

cat /etc/iscsi/initiatorname.iscsi

InitiatorName=iqn.2016-02.com.example:desktop0

[root@desktop0 ~]#

[root@desktop0 ~]# systemctl start iscsi iscsid

[root@desktop0 ~]# systemctl enable iscsi iscsid

ln -s '/usr/lib/systemd/system/iscsid.service' '/etc/systemd/system/multi-user.target.wants/iscsid.service'

[root@desktop0 ~]# iscsiadm -m discovery -t st -p server0

172.25.0.11:3260,1 iqn.2016-02.com.example:server0

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

[root@desktop0 ~]# 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

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

[root@desktop0 ~]# 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

[root@desktop0 ~]# 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

[root@desktop0 ~]# mkdir /mnt/data

[root@desktop0 ~]# vim /etc/fstab

[root@desktop0 ~]# blkid

/dev/vda1: UUID="9bf6b9f7-92ad-441b-848e-0257cbb883d1" TYPE="xfs"

/dev/sda1: UUID="701f7c03-8f64-4d39-9acc-55a95d66e57d" TYPE="xfs"

[root@desktop0 ~]# vim /etc/fstab ——使用uuid挂载

[root@desktop0 ~]# 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

[root@desktop0 ~]# mount -a

[root@desktop0 ~]# 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

[root@desktop0 ~]#

注意:开机启动自动挂载还需要修改此参数

vim /var/lib/iscsi/nodes/iqn.2016-02.com.example\:server0/172.25.0.11\,3260\,1/default

node.conn[0].startup = automatic——把手动改为自动

结果成功在客户端挂载的iscsi上创建文件

linux7.3启动iscsi服务,RHEL7 配置iscsi服务端并实现客户端自动开机挂载相关推荐

  1. linux yum安装iscsi,CentOS 安装配置iscsi共享存储

    iSCSI简介: 从协议层次的角度看,通常所说的SCSI通常是指一组包含块命令.控制器管理.系统命令和enclosure服务等内容的协议规范,对应于回话层:而其下的物理通道和链接方式就对应在数据链路层 ...

  2. linux ssh服务,Linux配置SSH服务以便实现远程连接

    Linux用户们一定想要知道该怎么开启SSH服务吧,SSH服务是Linux系统远程连接的重要方式,所以如何配置SHH服务也让很多用户感到纠结.现在小编就帮大家解决这个问题. 配置方法: 查询\安装SS ...

  3. java服务负载均衡_适用于Java开发人员的微服务:配置,服务发现和负载平衡

    java服务负载均衡 1.配置,服务发现和负载平衡–简介 我们正在缓慢但稳定地朝着准备好将微服务部署到生产中的方向发展. 在本教程的这一部分中,我们将讨论三个主要主题:配置,服务发现和负载平衡. 我们 ...

  4. NFS服务的配置过程

    NFS服务的配置过程 服务端: 1)安装nfs和rcp服务 yum install nfs-utils rpcbind -y 因为NFS支持的功能多,不同的功能会使用不同的程序来启动 每启动一个功能就 ...

  5. 【Linux】SSH远程终端连接工具(SSH基本用法、ssh服务认证类型、ssh服务常见配置、常见配置总结、远程拷贝scp命令)

    一.SSH远程终端连接工具 1.SSH简介 SSH是一种网络协议,用于计算机之间的加密登录.最早的时候,互联网通信都是明 文通信,一旦被截获,内容就暴露无疑.1995年,芬兰学者Tatu Ylonen ...

  6. SpringCloud工程搭建之配置中心服务搭建(可选)

    四.配置中心服务搭建(可选) 完整工程源码:https://gitee.com/forwardxiang/spring-cloud-demo.git 4.1 创建Git托管项目 无论选择哪个Git云服 ...

  7. JumpServer配置邮件服务

    缺德地图持续为您撞墙 为什么需要配置邮件服务? 配置jumpserver邮件服务 邮件配置说明 获取邮箱授权码 个人配置案例 测试邮件配置是否可用 编辑邮件内容配置 创建用户,测试邮件提示可用性 为什 ...

  8. DHCP协议详解及DHCP服务的配置

    目录 一.DHCP概念 1.1.什么是DHCP 1.2.DHCP的作用 1.3.DHCP的好处 1.4.DHCP的架构 二.DHCP工作原理 三.DHCP种的租期 四.DHCP服务的配置 4.1.情况 ...

  9. 配置 DHCP 服务

    1.创建活动目录域,域名:test.com,域控制器的计算机名称为 Server1,其 IP 地址为 192.168.1.200. 2. 把计算机 Server1 配置为 DHCP 服务器,为网络 A ...

最新文章

  1. R语言ggplot2可视化绘制分组水平条形图并在条形图的各种位置添加数值标签实战
  2. c++17(17)-异常try catch,operator[],vector at
  3. MapReduce-流量统计求和-分区代码实现
  4. Spring Cloud Gateway 源码解析(4)-- filter
  5. mysql的explain怎么看_mysql中explain用法详解
  6. ip设置 kali 重置_和我一起配置黑客系统kali,带你成为大牛,你真的准备好了吗?...
  7. 由Net Applications的浏览器的市场份额想开的
  8. UE4 无法include “filename.generated.h”
  9. S_ISREG等几个常见的宏(转)
  10. 【渝粤教育】国家开放大学2018年春季 0471-22T畜牧学 参考试题
  11. 尚学堂python培训靠谱吗_尚学堂百战程序员:Python的字符串
  12. 使用photoshop抠图+测量颜色
  13. walsh64码 matlab,实验7 Walsh码及单用户CDMA系统直接序列扩频仿真
  14. 哔哩哔哩自动播放视频
  15. Pycharm安装、使用的一些操作
  16. 计算机设备选型的基本原则,设备选型的概念和选型依据
  17. 飞机飞行与碰撞问题matlab,建模案例—飞行管理问题.ppt
  18. 应用SerialPort实现串口扫码枪ST2200操作
  19. hypervisor - qnx
  20. 视频文件太大如何压缩变小?

热门文章

  1. 研报复现系列(五)【光大证券】放量恰是入市时:成交量择时初探
  2. Ecg信号QRS波峰检测:A Real-Time QRS Detection Algorithm (Pan-Tompkins法)
  3. outlook邮箱日历华为手机与电脑同步设置
  4. 领扣问题1. 两数之和领python解决方案
  5. 将现成的swf文件导入Flash
  6. iCON艾肯五代声卡Dyna版本驱动(全系列)
  7. PLC高级编程-西门子SCL结构化控制语言官方培训.pptx
  8. python怎么爬取新浪微博数据中心_基于Python的新浪微博位置数据获取方法研究....
  9. Ubuntu安装NVIDA、CUDA、cuDNN
  10. 卡拉OK字幕效果制作