首先是服务器的设置:
[root@localhost 桌面]# yum install scsi-target-*  -y     安装服务  配置yum的方法太简单了,我就不写了
[root@localhost 桌面]# /etc/init.d/tgtd restart             重启服务

  配置tgt

tgt的主配置文件为/etc/tgt/targets.conf,下面我们来设置改文件。

在该文件最后新增以下设置:

<target iqn.2014-07.dev.iscsi-target:iscsidisk>
backing-store /srv/iscsi/disk1.img
backing-store /dev/sdb1
backing-store /dev/vg0/lv1
backing-store /dev/sdd
</target>

4.3 启动iSCSI target

# /etc/init.d/tgtd start

# chkconfig tgtd on

# netstat -tulnp|grep tgt

4.4 查看iSCSI target

# tgt-admin –show

LUN0 是控制器,可以看到各个LUN的大小和磁盘路径。

至此,iSCSI Target 设定完毕。

[root@www yum.repos.d]# tgtadm --lld iscsi --op show --mode target 查看本
机的设置
Target 1: iqn.2010-06.com.yahoo:disk1
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00010000
SCSI SN: beaf10
Size: 0 MB
Online: Yes
Removable media: No
Backing store type: rdwr
Backing store path: None
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: beaf11
Size: 53686 MB
Online: Yes
Removable media: No
Backing store type: rdwr
Backing store path: /dev/sdb1
Account information:
ACL information:
ALL
[root@www yum.repos.d]#

以上设置在系统重启之后失效,为了保证开机正常使用需将上面的命令写入
到/etc/rc.d/rc.local让其开机加载,如下:
[root@www 桌面]#cat /etc/rc.d/rc.local
#!/bin/sh
##
This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.
touch /var/lock/subsys/local
mount /dev/cdrom /mnt/ 这是我设置的开机自动挂载光盘
tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2010-06.com.yahoo:disk1 
tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/sdb1
tgtadm --lld iscsi --op bind --mode target --tid 1 -I ALL  以上三条命令写进去之后会开机自动运行

客户端挂载设置:

yum install -y iscsi-ini*     
[root@localhost yum.repos.d]# man iscsiadm 查看命令帮助,参数可以在帮助
里面找到,这样不用死记硬背那些无聊的命令参数
[root@localhost yum.repos.d]# iscsiadm -m discovery -t sendtargets -p
192.168.1.123 –discover 查看服务器的共享,名字和IP记得指向服务器
192.168.1.123:3260,1 iqn.2010-06.com.yahoo:disk1
[root@localhost yum.repos.d]#iscsiadm --mode node --targetname iqn.2010-
06.com.yahoo:disk1 --portal 192.168.1.123:3260 --login 在客户端登陆服务器
的共享,名字和IP地址需要自己手动指向服务器

[root@www 桌面]# fdisk -l 登陆之后查看自己的盘符
[root@www 桌面]# fdisk /dev/sdc 创建建立分区
[root@www 桌面]# mkfs.ext4 /dev/sdc1 格式化分区
[root@www 桌面]# mount /dev/sdc1 /iscsi/ 挂载分区到本机的文件夹
[root@localhost 桌面]# blkid 查看blkid,设置开机挂载
[root@www 桌面]# vim /etc/fstab 编辑开机文件
UUID="08b688b2-888f-4523-b936-dd4fcc443309" /iscsi ext4
defaults,_netdev 0 0

以下是客户端卸载过程:
[root@www /]# umount /iscsi/ 选卸载挂载
[root@localhost yum.repos.d]# iscsiadm -m node -T iqn.2010-
06.com.yahoo:disk1 -p 192.168.1.123:3260 –u 然后注销登陆,注销之后重启服务会自动登陆
Logging out of session [sid: 1, target: iqn.2010-06.com.yahoo:disk1, portal:192.168.1.123,3260]
Logout of [sid: 1, target: iqn.2010-06.com.yahoo:disk1, portal:192.168.1.123,3260] successful.
[root@www /]# iscsiadm -m node -o delete -T iqn.1013-06:disk1 -p
192.168.1.123:3260 -o delete可以将其彻底删除,这样就完全干净的删除了!如果不删除会在服务器留下进程从而影响性能,所以在真是环境下不用的时候一定要记得删除!

http://blog.csdn.net/liukuan73/article/details/46803201

centos iscsi 配置的更多相关文章

  1. Centos网络配置

    网上搜索:centos网络配置的方法,主要包括dns.网关.IP地址,主要是配置resolv.conf\network\ifcfg-eth0这些网络配置文件. 稍后我会就centos7的网络配置进行实 ...

  2. 阿里云服务器Linux CentOS安装配置(零)目录

    阿里云服务器Linux CentOS安装配置(零)目录 阿里云服务器Linux CentOS安装配置(一)购买阿里云服务器 阿里云服务器Linux CentOS安装配置(二)yum安装svn 阿里云服 ...

  3. 阿里云服务器Linux CentOS安装配置(九)shell编译、打包、部署

    阿里云服务器Linux CentOS安装配置(九)shell编译.打包.部署 1.查询当前目录以及子目录下所有的java文件,并显示查询结果 find . -name *.java -type f - ...

  4. 阿里云服务器Linux CentOS安装配置(八)nginx安装、配置、域名绑定

    阿里云服务器Linux CentOS安装配置(八)nginx安装.配置.域名绑定 1.安装nginx yum -y install nginx 2.启动nginx service nginx star ...

  5. 阿里云服务器Linux CentOS安装配置(七)域名解析

    阿里云服务器Linux CentOS安装配置(七)域名解析 1.购买域名 登录阿里云,左侧菜单点击[域名],然后[域名注册],完成域名购买.(一般首年45元) 2.添加域名解析 在域名列表里点击你的域 ...

  6. 阿里云服务器Linux CentOS安装配置(六)resin多端口配置、安装、部署

    阿里云服务器Linux CentOS安装配置(六)resin多端口配置.安装.部署 1.下载resin包 http://125.39.66.162/files/2183000003E08525/cau ...

  7. 阿里云服务器Linux CentOS安装配置(五)jetty配置、部署

    阿里云服务器Linux CentOS安装配置(五)jetty配置.部署 1.官网下载jetty:wget http://repo1.maven.org/maven2/org/eclipse/jetty ...

  8. 阿里云服务器Linux CentOS安装配置(四)yum安装tomcat

    阿里云服务器Linux CentOS安装配置(四)yum安装tomcat 1.yum -y install tomcat  执行命令后,会帮你把jdk也安装好 2.tomcat安装目录:/var/li ...

  9. 阿里云服务器Linux CentOS安装配置(三)yum安装mysql

    阿里云服务器Linux CentOS安装配置(三)yum安装mysql 1.执行yum安装mysql命令:yum -y install mysql-server mysql-devel 2.启动mys ...

随机推荐

  1. hdu 3622(二分+2-sat判断可行性)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3622 思路:二分是容易想到的,由于题目中有明显的矛盾关系,因此可以用2-sat来验证其可行性.关键是如 ...

  2. Android无线测试之—UiAutomator UiDevice API介绍一

    UiDevice 类介绍 1.UiDevice 代表设备状态 2.UiDevice 为单例模式 获取UiDevice实例的方式: 1) UiDevice.getInstance() 2) getUiD ...

  3. iphone断点下载,断点续传

    本文转载至 http://blog.csdn.net/zaitianaoxiang/article/details/6650469 - (void)loadView { NSURLConnection ...

  4. 面试十大常见Java String问题

    本文介绍Java中关于String最常见的10个问题: 1. 字符串比较,使用 "==" 还是 equals() ?简单来说, "==" 判断两个引用的是不是同 ...

  5. 【BZOJ4403】序列统计 Lucas定理

    [BZOJ4403]序列统计 Description 给定三个正整数N.L和R,统计长度在1到N之间,元素大小都在L到R之间的单调不降序列的数量.输出答案对10^6+3取模的结果. Input 输入第 ...

  6. 【BZOJ3073】[Pa2011]Journeys 线段树+堆优化Dijkstra

    [BZOJ3073][Pa2011]Journeys Description Seter建造了一个很大的星球,他准备建造N个国家和无数双向道路.N个国家很快建造好了,用1..N编号,但是他发现道路实在 ...

  7. Exponentiation(高精度大数)

    Exponentiation Description Problems involving the computation of exact values of very large magnitud ...

  8. EasyPlayer.js网页全终端播放器安装使用文档

    EasyPlayer.js 集 rtmp, hls, flv, websocket 于一身的网页直播/点播播放器, 使用简单, 功能强大 属性(Property) video-url 视频流地址 St ...

  9. coursera 《现代操作系统》 -- 第十一周 IO系统

    本周要求 错题 下列I/O控制方式中,哪一个不需要硬件支持? 中断方式 轮询方式 DMA方式 I/O处理机方式 中断方式:中断控制器 轮询方式:CPU不断查询设备以了解其是否就绪 DMA:使用到了   ...

  10. ECMAScript6面对大于0xFFFF的Unicode字符如何正确返回长度

    一.match() 1.定义 match()方法用于检索字符串内指定(字符串或正则)的值,返回指定值的数组,若找不到,返回null. 2.语法 str.match(searchvalue) str.m ...