zoukankan      html  css  js  c++  java
  • centos iscsi 配置

    首先是服务器的设置:
    [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.4 查看iSCSI target

    # tgt-admin –show

    5

    6

    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

  • 相关阅读:
    2021.07.01 学习总结
    2021.06.30 学习总结
    2021.06.29 学习总结
    2021.06.28 学习总结
    ubuntu 安装nginx报错./configure: error: SSL modules require the OpenSSL library
    Docker 启动alpine镜像中可执行程序文件遇到 not found
    docker基于cenots7 制作nginx镜像
    【Linux报错】VM虚拟机的CentOS7系统启动时报Generating /run/initramfs/rdsosreport.txt
    Docker Swarm 集群概念扩展
    Docker Swarm 集群弹性、动态扩缩容
  • 原文地址:https://www.cnblogs.com/jjp816/p/5231933.html
Copyright © 2011-2022 走看看