centos iscsi 配置

來源:互聯網
上載者:User

標籤:

首先是伺服器的設定:
[[email protected] 案頭]# yum install scsi-target-*  -y     安裝服務  配置yum的方法太簡單了,我就不寫了
[[email protected] 案頭]# /etc/init.d/tgtd restart             重啟服務
[[email protected] yum.repos.d]# tgtadm --lld iscsi --op new --mode target --tid 1 -T iqn.2010-06.com.yahoo:disk1     為iscsi裝置起一個名字,名字是反寫的網域名稱,
也可以不要網域名稱直接寫成iqn.2010-06:disk1,這樣也可以
[[email protected] yum.repos.d]# tgtadm --lld iscsi --op new --mode logicalunit --tid 1 --lun 1 -b /dev/sdb1 指定一個本機存放區位置
[[email protected] yum.repos.d]# tgtadm --lld iscsi --op bind --mode target --tid 1 -IALL 設定所有IP可以訪問,也可以是192.168.1.0/24這樣的單獨網段,但是不能設定多個網段
[[email protected] 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
[[email protected] yum.repos.d]#

以上設定在系統重啟之後失效,為了保證開機正常使用需將上面的命令寫入
到/etc/rc.d/rc.local讓其開機載入,如下:
[[email protected] 案頭]#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  以上三條命令寫進去之後會開機自動運行

用戶端掛載設定:
[[email protected] yum.repos.d]# man iscsiadm 查看命令協助,參數可以在協助
裡面找到,這樣不用死記硬背那些無聊的命令參數
[[email protected] 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
[[email protected] yum.repos.d]#iscsiadm --mode node --targetname iqn.2010-
06.com.yahoo:disk1 --portal 192.168.1.123:3260 --login 在用戶端登陸伺服器
的共用,名字和IP地址需要自己手動指向伺服器


[[email protected] 案頭]# fdisk -l 登陸之後查看自己的盤符
[[email protected] 案頭]# fdisk /dev/sdc 建立建立分區
[[email protected] 案頭]# mkfs.ext4 /dev/sdc1 格式化分區
[[email protected] 案頭]# mount /dev/sdc1 /iscsi/ 掛載分區到原生檔案夾
[[email protected] 案頭]# blkid 查看blkid,設定開機掛載
[[email protected] 案頭]# vim /etc/fstab 編輯開機檔案
UUID="08b688b2-888f-4523-b936-dd4fcc443309" /iscsi ext4
defaults,_netdev 0 0

以下是用戶端卸載過程:
[[email protected] /]# umount /iscsi/ 選卸載掛載
[[email protected] 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.
[[email protected] /]# iscsiadm -m node -o delete -T iqn.1013-06:disk1 -p
192.168.1.123:3260 -o delete可以將其徹底刪除,這樣就完全乾淨的刪除了!如果不刪除會在伺服器留下進程從而影響效能,所以在真是環境下不用的時候一定要記得刪除!

 

centos iscsi 配置

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.