iSCSI 2-环境搭建一
生活随笔
收集整理的這篇文章主要介紹了
iSCSI 2-环境搭建一
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
實驗環境
操作系統:CentOS release 6.5 (Final)
iSCSI Target:10.0.0.11 (#yum install scsi-target-utils)
iSCSI Initiator 1:10.0.0.12 (#yum install iscsi-initiator-utils)
iSCSI Initiator 2::10.0.0.13 (#yum install iscsi-initiator-utils)
防火墻已關閉/iptables:Firewall is not running. (#service iptables stop or #/etc/init.d/iptables stop)
SELINUX: disabled (#setenforce 0)
驗證:配置好之后三臺主機之間可以相互 ping 通
存儲服務器上安裝配置 iSCSI target
1. 安裝scsi-target-utils 軟件
[root@localhost /]# yum install scsi-target-utils2. 查看相關配置文件
# /etc/tgt/targets.conf 主配置文件,設置要共享的磁盤格式與塊設備等 # /usr/sbin/tgt-admin 查詢、刪除target等功能的設置工具 # /usr/sbin/tgt-setup-lun 建立target以及設置共享的磁盤與可使用的客戶端等的程序 # /usr/sbin/tgtadm iscsi target管理程序(可使用配置文件取代) # /usr/sbin/tgtd 提供iSCSI target服務的主程序 # /usr/sbin/tgtimg 搭建共享鏡像文件設備程序3. ?建立分區配置存儲
# 首先確認下當前系統磁盤 fdisk -l # 然后對此磁盤進行新建分區 [root@localhost /]# fdisk /dev/sda WARNING: DOS-compatible mode is deprecated. It's strongly recommended toswitch off the mode (command 'c') and change display units tosectors (command 'u').# 在此選擇DOS兼容模式查看分區大小,單位為柱面,默認或者選擇 'u',則單位為扇區 Command (m for help): c DOS Compatibility flag is not setCommand (m for help): m Command actiona toggle a bootable flagb edit bsd disklabelc toggle the dos compatibility flagd delete a partitionl list known partition typesm print this menun add a new partitiono create a new empty DOS partition tablep print the partition tableq quit without saving changess create a new empty Sun disklabelt change a partition's system idu change display/entry unitsv verify the partition tablew write table to disk and exitx extra functionality (experts only)# 查看分區表 Command (m for help): pDisk /dev/sda: 16.1 GB, 16106127360 bytes 255 heads, 63 sectors/track, 1958 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0006c4a5Device Boot Start End Blocks Id System /dev/sda1 * 1 26 204800 83 Linux /dev/sda2 26 1070 8388608 83 Linux /dev/sda3 1070 1332 2097152 82 Linux swap / Solaris /dev/sda4 1332 1959 5037056 5 Extended /dev/sda5 1332 1593 2097152 83 Linux# 新建分區 Command (m for help): n First cylinder (1593-1959, default 1593): Using default value 1593 # 容量分配為1個G Last cylinder, +cylinders or +size{K,M,G} (1593-1959, default 1959): +1G# 新建分區 Command (m for help): nFirst cylinder (1725-1959, default 1725): Using default value 1725 # 容量分配為1個G Last cylinder, +cylinders or +size{K,M,G} (1725-1959, default 1959): +1GCommand (m for help): pDisk /dev/sda: 16.1 GB, 16106127360 bytes255 heads, 63 sectors/track, 1958 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x0006c4a5 Device Boot Start End Blocks Id System/dev/sda1 * 1 26 204800 83 Linux/dev/sda2 26 1070 8388608 83 Linux/dev/sda3 1070 1332 2097152 82 Linux swap / Solaris/dev/sda4 1332 1959 5037056 5 Extended/dev/sda5 1332 1593 2097152 83 Linux/dev/sda6 1593 1724 1056221+ 83 Linux/dev/sda7 1725 1856 1059266 83 Linux # 改變分區系統ID,也就是轉換分區 Command (m for help): t Partition number (1-7): 7 # 輸入LVM類型編碼 8e Hex code (type L to list codes): 8e Changed system type of partition 7 to 8e (Linux LVM)Command (m for help): pDisk /dev/sda: 16.1 GB, 16106127360 bytes 255 heads, 63 sectors/track, 1958 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x0006c4a5Device Boot Start End Blocks Id System /dev/sda1 * 1 26 204800 83 Linux /dev/sda2 26 1070 8388608 83 Linux /dev/sda3 1070 1332 2097152 82 Linux swap / Solaris /dev/sda4 1332 1959 5037056 5 Extended /dev/sda5 1332 1593 2097152 83 Linux /dev/sda6 1593 1724 1056221+ 83 Linux /dev/sda7 1725 1856 1059266 8e Linux LVMCommand (m for help): q#管理LVM分區-創建物理卷與卷組邏輯卷(刪除則是按照與創建相反的順序) [root@localhost /]# pvcreate /dev/sda7Physical volume "/dev/sda7" successfully created [root@localhost /]# vgcreate -s 8M VolGroup00 /dev/sda sda sda1 sda2 sda3 sda4 sda5 sda6 sda7 [root@localhost /]# vgcreate -s 8M VolGroup00 /dev/sda7Volume group "VolGroup00" successfully created [root@localhost /]# lvcreate -L 800M -n iscsi00 VolGroup00Logical volume "iscsi00" created [root@localhost /]# lvscanACTIVE '/dev/VolGroup00/iscsi00' [800.00 MiB] inherit [root@localhost /]# lvdisplay--- Logical volume ---LV Path /dev/VolGroup00/iscsi00LV Name iscsi00VG Name VolGroup00LV UUID Dzt8dM-d6zS-6ff8-aNlP-4R1Z-7KGL-n0yUQHLV Write Access read/writeLV Creation host, time localhost.iscsi, 2017-01-20 15:34:58 +0800LV Status available# open 0LV Size 800.00 MiBCurrent LE 100Segments 1Allocation inheritRead ahead sectors auto- currently set to 256Block device 253:04. 配置/etc/tgt/targets.conf,設置共享存儲設備的路徑相關屬性
# 在配置文件中加入下列語句 <target iqn.2017-01.org.rambo:viscsidisk>backing-store /dev/sda6backing-store /dev/VolGroup00/iscsi00initiator-address 10.0.0.12initiator-address 10.0.0.13initiator-address 10.0.0.0/24incominguser viscsiuser viscsipasswdwrite-cache off </target> # 說明 # iqn = iSCSI Qualified Name # backing-store 邏輯單元號(Logical Unit Number,LUN),這個實驗中有2個LUN。 # target iSCSI target名稱,規則如下:#iqn.2017-01.org.rambo:viscsidisk (格式: iqn.年份-月份.域名反寫.設備識別) # initiator-address 允許的initiator IP地址 # incominguser 配置通過用戶名密碼訪問5. 重啟 tgtd 服務
[root@localhost tgt]# /etc/init.d/tgtd restart 停止 SCSI target daemon: [確定] 正在啟動 SCSI target daemon: [確定]6. 查看iscsi target共享存儲的相關信息,使用tgt-admin --show命令
[root@localhost tgt]# tgt-admin --show Target 1: iqn.2017-01.org.rambo:viscsidiskSystem information:Driver: iscsiState: readyI_T nexus information:LUN information:LUN: 0Type: controllerSCSI ID: IET 00010000SCSI SN: beaf10Size: 0 MB, Block size: 1Online: YesRemovable media: NoPrevent removal: NoReadonly: NoBacking store type: nullBacking store path: NoneBacking store flags: LUN: 1Type: diskSCSI ID: IET 00010001SCSI SN: beaf11Size: 839 MB, Block size: 512Online: YesRemovable media: NoPrevent removal: NoReadonly: NoBacking store type: rdwrBacking store path: /dev/VolGroup00/iscsi00Backing store flags: LUN: 2Type: diskSCSI ID: IET 00010002SCSI SN: beaf12Size: 1083 MB, Block size: 512Online: YesRemovable media: NoPrevent removal: NoReadonly: NoBacking store type: rdwrBacking store path: /dev/sda6Backing store flags: Account information:viscsiuserACL information:10.0.0.1210.0.0.1310.0.0.0/24
通過輸出信息,可以看到我們之前設置的用于共享的磁盤和允許的客戶端IP信息。至此,target 服務器配置就完成了。
總結
以上是生活随笔為你收集整理的iSCSI 2-环境搭建一的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 富文本编辑器初探
- 下一篇: AccessControl专业智能门禁管