Linux_ISCSI服务器

本文涉及的产品
文件存储 NAS,50GB 3个月
简介:

网络存储

网络存储(Network Storage)是基于数据存储的一种,网络存储结构大致分为三种:直连式存储(DAS:Direct Attached Storage)、网络存储设备(NAS:Network Attached Storage)和存储网络(SAN:Storage Area Network),由于NAS对于普通消费者而言较为熟悉,所以一般网络存储都指NAS。

ISCSI

iSCSI:Internet小型计算机系统接口(iSCSI:Internet Small Computer System Interface),是一个供硬件设备使用的可以在IP协议的上层运行的SCSI指令集,这种指令集合可以实现在IP网络上运行SCSI协议。iSCSI技术是一种新储存技术,该技术是将现有SCSI接口与以太网络(Ethernet)技术结合,使服务器可与使用IP网络的储存设备互相交换数据。iSCSI的主要功能是在TCP/IP网络上的主机系统(启动器Initiator)和存储设备(目标器Target)之间进行大量数据的封装和可靠传输过程。此外,iSCSI提供了在IP网络上封装的SCSI命令,且运行在TCP上。 
技术原理:ISCSI实现了在IP协议基础上运行SCSI协议,将现有的SCSI接口和以太网技术结合。实现了ISCSI服务器可以使用IP网络的存储装备间互相交换数据。 
1. Port:TCP 3260 
2. ISCSI存储设备使用iqn标识符来命名 
ipn.YYYY-MM.反向域名.识别标识

How to setup ISCSI server

SCSI Commands

Server Side

step1 install software

yum install scsi-target-utils
  • 1
  • 1

serviceName: tgtd 
commandName:tgtadm 
step2 Create target object

service tgtd start
tgtadm -L iscsi -o new -m target -t 1 -Y iqn.2015-11.com.fan.JustShow
        -L:assign drive type
        -o:assign operation type
        -m:assign mode
        -t:assign target number
        -T:assign target identification
        new:Create the new one
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

step3. Check target detail list infomation

tgtadm -L iscsi -o show -m target
  • 1
  • 1

step4. Create LUN(逻辑单元)

tgtadm -L iscsi -o new -m logicalunit -t 1 -l 1 -b /dev/sdName
        -l assign LUN
  • 1
  • 2
  • 1
  • 2

step5. Bind Client’s IPAddr to LUN

tgtadm -L iscsi -o bind -m target -t 1 -I clientIP
  • 1
  • 1

step6. Show the Account info

sgt-admin -S
  • 1
  • 1

NOTE: 
If the AccountInfo is null, anyone can use the target. 
If ACLInfo is null, no people can use the target. 
The IPInfo will output in the ACLInfo when the ip bind to target.

Client Side

step1. Install iscsi-initiator-utils

yum install iscsi-initiator-utils
  • 1
  • 1

serviceName:iscsi 
commandName:iscsiadm 
step2. Find usable target in local client, get usable target’s iqnFlag

service iscsi start
iscsiadm -m discovery -t sendtargets -p serverIP
  • 1
  • 2
  • 1
  • 2

step3. Connect service target share device

iscsiadm -m node -T iqnFlag -l
        -l login
  • 1
  • 2
  • 1
  • 2

step4. After connect server find usable dervice in local

lsscsi
  • 1
  • 1

step5. After connect ISCSI server find the target config file

ls -R /var/lib/iscsi/nodes
  • 1
  • 1

step6. Formatling the ISCSI share device when the ISCSI device haven’t FS. And mount the device. 
NOTE: mount the device at the same time add option -netdev to /etc/fstab, the meaning is monut the device after connect the network.

mkfs.ext4 /dev/sdName
mount -t /dev/sdName /mnt/iscsi
  • 1
  • 2
  • 1
  • 2

step7. unload ISCSI drvice.

iscsiadm -m node -T iqnFlag -u  #For a short time ,logout
iscsiadm -m node -T iqnFlag -0  #Delete
  • 1
  • 2
  • 1
  • 2

Edit the ISCSI configuration file

ServerSide

vim /etc/tgt/target.conf

<target iqn.2015-01.com.fan.jmilk:lvm>
    backing-store /dev/vg_iscsi/lv_iscsi
    direct-store /dev/sda2
    initator-address 192.168.0.1      #Bind client IP
    incominguser jmilk                #authentication parameter
</target>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

Step2. restart the tgt service

service tgtd restart
  • 1
  • 1

ClientPort

step1.

iscsiadm -m discovery -t sendtargets -p serverIP
  • 1
  • 1

step2. Defined connect authentication method, create auth user.

 iscsiadm -m node -o update -T iqnFlag -n node.session.auth authmethod -V CHAP
 iscsiadm -m node -o update -T iqnFlag -n node.session.auth username -V jmilk
 iscsiadm -m node -o update -T iqnFlag -n node.session.auth passwork -V jmilk.com
  • 1
  • 2
  • 3
  • 1
  • 2
  • 3

step3.

iscsiadm -m node -T iqnFlag -l
  • 1
  • 1

step4.

lsscsi


转载:http://blog.csdn.net/jmilk/article/details/50061409

相关实践学习
基于ECS和NAS搭建个人网盘
本场景主要介绍如何基于ECS和NAS快速搭建个人网盘。
阿里云文件存储 NAS 使用教程
阿里云文件存储(Network Attached Storage,简称NAS)是面向阿里云ECS实例、HPC和Docker的文件存储服务,提供标准的文件访问协议,用户无需对现有应用做任何修改,即可使用具备无限容量及性能扩展、单一命名空间、多共享、高可靠和高可用等特性的分布式文件系统。 产品详情:https://www.aliyun.com/product/nas
目录
相关文章
|
22天前
|
Linux 网络安全 数据安全/隐私保护
SSH工具连接远程服务器或者本地Linux系统
SSH工具连接远程服务器或者本地Linux系统
21 0
|
24天前
|
Unix Linux 数据安全/隐私保护
Linux服务器如何远程连接?服务器远程连接图文教程
服务器操作系统可以实现对计算机硬件与软件的直接控制和管理协调,任何计算机的运行离不开操作系统,服务器也一样,服务器操作系统主要分为四大流派:Windows Server、Netware、Unix和Linux。 今天驰网飞飞就给你们分享下Linux、Unix系统远程连接图文操作方法
24 4
Linux服务器如何远程连接?服务器远程连接图文教程
|
2天前
|
关系型数据库 MySQL Linux
服务器Linux系统配置mysql数据库主从自动备份
这是一个基本的配置主从复制和设置自动备份的指南。具体的配置细节和命令可能因您的环境和需求而有所不同,因此建议在操作前详细阅读MySQL文档和相关资源,并谨慎操作以避免数据丢失或不一致。
11 3
|
4天前
|
Oracle Java 关系型数据库
【服务器】python通过JDBC连接到位于Linux远程服务器上的Oracle数据库
【服务器】python通过JDBC连接到位于Linux远程服务器上的Oracle数据库
14 6
|
6天前
|
运维 监控 安全
2023年最详细的:本地Linux服务器安装宝塔面板,并内网穿透实现公网远程登录
2023年最详细的:本地Linux服务器安装宝塔面板,并内网穿透实现公网远程登录
|
8天前
|
Linux 网络安全 数据库
linux centos系统搭建samba文件服务器 NetBIOS解析 (超详细)
linux centos系统搭建samba文件服务器 NetBIOS解析 (超详细)
|
8天前
|
域名解析 存储 缓存
Linux中搭建DNS 域名解析服务器(详细版)
Linux中搭建DNS 域名解析服务器(详细版)
|
8天前
|
安全 Linux 网络安全
Linux _ apache服务器部署 不同域名—访问不同网站(多网站)
Linux _ apache服务器部署 不同域名—访问不同网站(多网站)
|
8天前
|
Web App开发 安全 Unix
Linux 配置FTP服务器 + vsftpd服务安装配置 (Good篇)
Linux 配置FTP服务器 + vsftpd服务安装配置 (Good篇)
|
14天前
|
Prometheus 监控 Cloud Native
构建高效可靠的Linux服务器监控体系
【4月更文挑战第30天】 在维护企业级Linux服务器的稳定性和性能方面,一个周全的监控体系是至关重要的。本文将探讨如何利用开源工具和实践构建一个高效、灵活且用户友好的监控系统。我们将重点讨论核心组件的选择、配置、报警机制以及数据分析方法,旨在帮助读者打造一个能够实时响应并预防潜在问题的监控环境。