1. 程式人生 > >[APP] 配置 ISCSI 服務

[APP] 配置 ISCSI 服務

需求:

配置system1 提供一個 ISCSI 服務,磁碟名為iqn.2014-08.com.example.group8:system1 服務埠為 3260 使用 iscsi_store 作為後端邏輯卷名稱,大小 3G 此服務只能被 system2 訪問 ;

配置 system2  使其能連線在 system1 上提供的 iqn.2014-08.com.example.group8:system1 ISCSI 裝置在系統啟動期間自動載入塊裝置 ISCSI 上包含一個大小  2100M 的分割槽,格式化為 ext4 此分割槽掛載在 /mnt/data 上,並自動掛載

system1

192.168.1.151

system2

192.168.1.152

os

rhel 7.2

[[email protected] ~]# yum install targetcli -y                                                                                                                                                            #安裝iscsi服務端軟體包

[[email protected] ~]# systemctl enable target

                                                                                                                                                                              #開機啟動此服務

ln -s'/usr/lib/systemd/system/target.service''/etc/systemd/system/multi-user.target.wants/target.service'

[[email protected]

~]#systemctl start target

[[email protected]~]# firewall-cmd --permanent--add-rich-rule'rule family="ipv4" source address="172.24.8.12/32" portport=3260 protocol=tcp accept'

#新增防火牆策略,允許system2問,訪問端口是3260

[[email protected] ~]#firewall-cmd --reload

success

[[email protected] ~]# lsblk                                                                                                                                                                                                                 #檢視磁碟容量

NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sda      8:0   0   20G  0 disk

├─sda1   8:1   0  9.8G  0 part /

└─sda2   8:2   0    3G  0 part [SWAP]

[[email protected] ~]#fdisk /dev/sda

Welcome to fdisk(util-linux 2.23.2).

Changes will remainin memory only, until you decide to write them.

Be careful beforeusing the write command.

Command (m forhelp): p

Disk /dev/sda: 21.5GB, 21474836480 bytes, 41943040 sectors

Units = sectors of 1* 512 = 512 bytes

Sector size(logical/physical): 512 bytes / 512 bytes

I/O size(minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier:0x000d9a10

   Device Boot      Start         End      Blocks  Id  System

/dev/sda1   *       2048    20482047    10240000  83  Linux

/dev/sda2        20482048    26626047    3072000   82  Linux swap / Solaris

Command (m forhelp): n

Partition type:

   p  primary (2 primary, 0 extended, 2 free)

   e  extended

Select (default p):p

Partition number(3,4, default 3):

First sector(26626048-41943039, default 26626048):

Using default value26626048

Last sector, +sectors or +size{K,M,G} (26626048-41943039, default41943039): +3G                                               #分配一個3GLVM空間

Partition 3 of typeLinux and of size 3 GiB is set

Command (m forhelp): p

Disk /dev/sda: 21.5GB, 21474836480 bytes, 41943040 sectors

Units = sectors of 1* 512 = 512 bytes

Sector size(logical/physical): 512 bytes / 512 bytes

I/O size(minimum/optimal): 512 bytes / 512 bytes

Disk label type: dos

Disk identifier:0x000d9a10

   Device Boot      Start         End      Blocks  Id  System

/dev/sda1   *       2048    20482047    10240000  83  Linux

/dev/sda2        20482048    26626047    3072000   82  Linux swap / Solaris

/dev/sda3        26626048    32917503    3145728   83  Linux

Command (m forhelp): t

Partition number(1-3, default 3): 3

Hex code (type L to list all codes): 8e                                                                                                                                 #設定格式為lvm

Changed type ofpartition 'Linux' to 'Linux LVM'

Command (m forhelp): w

The partition tablehas been altered!

Calling ioctl() tore-read partition table.

WARNING: Re-readingthe partition table failed with error 16: Device or resource busy.

The kernel stilluses the old table. The new table will be used at

the next reboot orafter you run partprobe(8) or kpartx(8)

Syncing disks.

[[email protected] ~]# partprobe                                                                                                                                       #格式化分割槽

[[email protected] ~]#lsblk

NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sda      8:0   0   20G  0 disk

├─sda1   8:1   0  9.8G  0 part /

├─sda2   8:2   0    3G  0 part [SWAP]

└─sda3   8:3   0    3G  0 part

[[email protected] ~]# pvcreate /dev/sda3                                                                                                                     #建立PV

  Physical volume "/dev/sda3"successfully created

[[email protected] ~]# vgcreate iscsi_vg /dev/sda3                                                                                                       #建立名為iscsi_vg 的卷組

  Volume group "iscsi_vg"successfully created

[[email protected] ~]# lvcreate -n iscsi_store -l 100%VG iscsi_vg                                                                                #建立名為iscsi_storeiscsi_vg卷組所有空間都分配給此邏輯卷

  Logical volume "iscsi_store"created

[[email protected] ~]# targetcli                                                                                                                                         #配置iscsi

targetcli shellversion 2.1.fb41

Copyright 2011-2013by Datera, Inc and others.

For help oncommands, type 'help'.

/> ls

o- /......................................................................................[...]

  o- backstores...........................................................................[...]

  | o- block............................................................... [StorageObjects: 0]

  | o- fileio.............................................................. [StorageObjects: 0]

  | o- pscsi............................................................... [StorageObjects: 0]

  | o- ramdisk............................................................. [Storage Objects:0]

  o- iscsi.........................................................................[Targets: 0]

  o- loopback......................................................................[Targets: 0]

/> backstores/block create name=iscsi_storedev=/dev/iscsi_vg/iscsi_store                                                      #先將本地邏輯卷加入iscsi

/> cd iscsi

/iscsi> create iqn.2014-08.com.example.group8:system1                                                                                      #定義一個iscsi裝置

Created targetiqn.2014-08.com.example.group8:system1.

Created TPG 1.

Global prefauto_add_default_portal=true

Created defaultportal listening on all IPs (0.0.0.0), port 3260.

/> cdiscsi/iqn.2014-08.com.example.group8:system1/tpg1/

/iscsi/iqn.20...:system1/tpg1> luns/ create/backstores/block/iscsi_store                                                           #將定義的iscsi裝置繫結本地邏輯卷

Created LUN 0.

/iscsi/iqn.20...:system1/tpg1> acls/ createiqn.2014-08.com.example.group8:system2                                  #允許名字為iqn.2014-08.com.example.group8:system2客戶端訪問裝置

Created Node ACL foriqn.2014-08.com.example.group8:system2

Created mapped LUN0.

/iscsi/iqn.20...:system1/tpg1> portals/ create 172.24.8.11 3260                                                                           #定義iscsi 訪問埠

Using default IPport 3260

Could not create NetworkPortal in configFS                                                                                                             #此報錯忽略,因某些版本已經建立了0.0.0.0的監聽

/iscsi/iqn.20...:system1/tpg1> set attribute authentication=0                                                                              #關閉賬號密碼驗證訪問控制

Parameterauthentication is now '0'.

/iscsi/iqn.20...:system1/tpg1> set attribute generate_node_acls=0                                                                    #使用自定義的acl實現訪問限制

Parametergenerate_node_acls is now '0'.

/iscsi/iqn.20...:system1/tpg1>cd /

/> saveconfig                                                                                                                                                                    #儲存配置

Last 10 configssaved in /etc/target/backup.

Configuration savedto /etc/target/saveconfig.json

/> ls

o- /......................................................................................[...]

  o- backstores...........................................................................[...]

  | o- block............................................................... [StorageObjects: 1]

  | | o- iscsi_store ..................[/dev/iscsi_vg/iscsi_store (3.0GiB) write-thru activated]

  | o- fileio.............................................................. [StorageObjects: 0]

  | o- pscsi............................................................... [StorageObjects: 0]

  | o- ramdisk............................................................. [Storage Objects:0]

  o- iscsi.........................................................................[Targets: 1]

  | o- iqn.2014-08.com.example.group8:system1......................................... [TPGs: 1]

  |   o-tpg1 ............................................................ [no-gen-acls,no-auth]

  |    o- acls....................................................................... [ACLs:1]

  |     |o- iqn.2014-08.com.example.group8:system2 ............................ [MappedLUNs: 1]

  |    |   o- mapped_lun0........................................ [lun0 block/iscsi_store (rw)]

  |    o- luns....................................................................... [LUNs:1]

  |     |o- lun0 ............................... [block/iscsi_store(/dev/iscsi_vg/iscsi_store)]

  |    o- portals................................................................. [Portals: 1]

  |      o- 0.0.0.0:3260.................................................................. [OK]

  o- loopback......................................................................[Targets: 0]

/>exit

[[email protected] ~]# yum install iscsi-initiator-utils -y                                                                                                      #安裝客戶端軟體包

[[email protected] ~]# vi /etc/iscsi/initiatorname.iscsi

InitiatorName=iqn.2014-08.com.example.group8:system2                                                                                          #配置客戶端名稱

[[email protected] ~]# systemctl enable iscsi iscsid.service                                                                                                #服務開機啟動

ln -s'/usr/lib/systemd/system/iscsid.service''/etc/systemd/system/multi-user.target.wants/iscsid.service'

[[email protected] ~]# systemctl start iscsi iscsid.service                                                                                                    #啟動服務

[[email protected] ~]# iscsiadm -m discovery -t st -p 172.24.8.11                                                                                    #發現遠端裝置

172.24.8.11:3260,1iqn.2014-08.com.example.group8:system1

[[email protected] ~]# iscsiadm -m node -l                                                                                                                           #登陸

Logging in to[iface: default, target: iqn.2014-08.com.example.group8:system1, portal:172.24.8.11,3260] (multiple)

Login to [iface:default, target: iqn.2014-08.com.example.group8:system1, portal:172.24.8.11,3260] successful.

[[email protected] ~]#lsblk

NAME   MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

sda      8:0   0   20G  0 disk

├─sda1   8:1   0  9.8G  0 part /

└─sda2   8:2   0    2G  0 part [SWAP]

sdb      8:16   0   3G  0 disk                                                                                                                                                     #多了一塊3G的盤

[[email protected] ~]# fdisk /dev/sdb                                                                                                                                     #新創分割槽

Welcome to fdisk(util-linux 2.23.2).

Changes will remainin memory only, until you decide to write them.

Be careful beforeusing the write command.

Device does notcontain a recognized partition table

Building a new DOSdisklabel with disk identifier 0xc3c0951e.

Command (m forhelp): n

Partition type:

   p  primary (0 primary, 0 extended, 4 free)

   e  extended

Select (default p):p

Partition number(1-4, default 1):

First sector(8192-6283263, default 8192):

Using default value8192

Last sector, +sectors or +size{K,M,G} (8192-6283263, default6283263): +2100M                                                #2100M

Partition 1 of typeLinux and of size 2.1 GiB is set

Command (m forhelp): w

The partition tablehas been altered!

Calling ioctl() tore-read partition table.

Syncing disks.

[[email protected] ~]# partprobe                                                                                                                                         #核心重新讀取分割槽表

[[email protected] ~]# mkfs.ext4 /dev/sdb1                                                                                                                     #在新建分割槽上格式化對應檔案系統

mke2fs 1.42.9(28-Dec-2013)

Filesystem label=

OS type: Linux

Block size=4096(log=2)

Fragment size=4096(log=2)

Stride=0 blocks,Stripe width=1024 blocks

134640 inodes,537600 blocks

26880 blocks (5.00%)reserved for the super user

First data block=0

Maximum filesystemblocks=551550976

17 block groups

32768 blocks pergroup, 32768 fragments per group

7920 inodes pergroup

Superblock backupsstored on blocks:

        32768, 98304, 163840, 229376, 294912

Allocating grouptables: done                           

Writing inodetables: done                           

Creating journal(16384 blocks): done

Writing superblocksand filesystem accounting information: done

[[email protected] ~]# mkdir /mnt/data                                                                                                                        #建立掛載目錄

[[email protected] ~]# blkid                                                                                                                                             #檢視裝置ID

/dev/sda1:UUID="182dc058-fb2e-45ec-8285-38f150033822" TYPE="xfs"

/dev/sda2:UUID="ded4e9e7-b20f-405f-b88b-99e26dd67bd5" TYPE="swap"

/dev/sdb1:UUID="92c2403d-1694-4e3f-90b2-f423ade6ea33" TYPE="ext4"

[[email protected] ~]# vi/etc/fstab

# /etc/fstab

# Created byanaconda on Sun Jul 24 22:29:04 2016

#

# Accessiblefilesystems, by reference, are maintained under '/dev/disk'

# See man pagesfstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

UUID=182dc058-fb2e-45ec-8285-38f150033822/                       xfs     defaults        1 1

UUID=ded4e9e7-b20f-405f-b88b-99e26dd67bd5swap                    swap    defaults        0 0

//172.24.8.11/devops/mnt/dev cifs defaults,multiuser,username=silene,password=redhat,sec=ntlmssp 00

system1:/public/mnt/nfsmount nfs defaults,sec=sys 0 0

system1:/protected/mnt/nfssecure nfs4 defaults,sec=krb5p 0 0

UUID=92c2403d-1694-4e3f-90b2-f423ade6ea33 /mnt/data ext4defaults,_netdev 0 0                            #新增此資訊

[[email protected] ~]#mount -a

[[email protected] ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda1             9.8G  3.1G 6.8G  32% /

devtmpfs              765M     0 765M   0% /dev

tmpfs                 773M     0 773M   0% /dev/shm

tmpfs                 773M   17M 757M   3% /run

tmpfs                 773M     0 773M   0% /sys/fs/cgroup

//172.24.8.11/devops  9.8G 3.2G  6.7G  33% /mnt/dev

system1:/public       9.8G 3.2G  6.7G  33% /mnt/nfsmount

system1:/protected    9.8G 3.2G  6.7G  33% /mnt/nfssecure

/dev/sdb1             2.0G  6.2M 1.9G   1% /mnt/data

相關推薦

[APP] 配置 ISCSI 服務

需求: 配置system1 提供一個 ISCSI 服務,磁碟名為iqn.2014-08.com.example.group8:system1 ;服務埠為 3260 ;使用 iscsi_store 作為後端邏輯卷名稱,大小 3G ;此服務只能被 system2 訪問 ; 配置 system2  使其能連

配置iSCSI服務

ins /etc/ /etc node 復制 day tel 順序 tip 搭建存儲服務器 Day3 啥是存儲:數據存儲介質:內存(臨時),磁盤(永久)數據存儲位置:雲存儲 本地 共享存儲 分布式存儲 存儲技術:DAS:SCSI (直連式存儲)DAS SAN:ISCSI(存

RHEL7 配置iscsi服務端並實現客戶端自動開機掛載

page been hang disco portal count term naconda tmpfs 環境:server 172.25.0.11 ——iscsi server iqn:iqn.2016-02.com.example:server0client 172.

Ubuntu 配置ISCSI服務

class ucc scsi 配置 modules removing ota star 兩個 摘要:sudo apt-get install iscsitarget立刻搞定, 然後編輯配置文件:sudovim/etc/ietd.conf默認的配置文件, 有詳細的配置說明和

配置iSCSI 服務

star p地址 inter face 表名 onf over package 一次 ISCSI服務端和客戶端的操作系統以及IP地址 環境準備 主機名稱: ISCSI服務端ISCSI客戶端 操作系統: RHEL 7.3 IP地址: 服務端192.168.0.13客戶

[RHEL 7]ISCSI服務端及客戶端連接配置

防火 root inline 磁盤 fdisk -l str att 斷開 linux lvm 環境RHEL7.4 1.搭建服務器端主機環境 網絡配置 網卡eth0 10.0.0.1 網卡eth1 10.1.0.1 網卡eth2 10.2.0.1 網卡eth3 10

Ceph分布式存儲學習筆記之ISCSI服務配置

ceph本文分兩部分分別介紹Ceph Luminous版集群的安裝以及配置ISCSI服務。 一、部署ceph集群 [root@ceph01 ~]# yum -y install ceph 1.1 Ceph Monitor部署 [root@ceph01 ~]# mkdir ceph;cd ceph [root@

002.iSCSI服務配置

一 iSCSI target的磁碟種類 大型檔案 單一分割槽(partition) 磁碟 陣列 RAID LVM 二 iSCSI建立步驟 建立用於共享的磁碟裝置(分割槽/磁碟/檔案) 建立後備磁碟 建立相應的IQN 建立相應的規則 #(可選) 為後備磁碟建立LUN 指定偵聽的

企業雲桌面-16-配置DHCP服務器-011-DC01

雲桌面 雲計算 vsphere esxi vsan 作者:學 無 止 境QQ交流群:454544014註意:《企業雲桌面》系列博文是《企業雲桌面規劃、部署與運維實踐指南》的基礎部分,因為書中內容涉及非常多,非常全面,所以基礎部分將以博文的形式給讀者展現,將在書中引用。《企業雲桌面規劃、部署

2-3-配置DHCP服務器實現動態地址分配

客戶端 -name sci oom 動態分配 工作站 request請求 負責 evel 學習一個服務的過程: 1、 此服務的概述:名字,功能,特點,端口號 2、 安裝 3、 配置文件的位置 4、 服務啟動關閉腳本,查看端口 5、 此服務的使用方法 6、 修

CloudStack+XenServer詳細部署方案 交換機配置服務器連線

cloudstack+xenserver詳細部署方案CloudStack+XenServer詳細部署方案(2):交換機配置和服務器連線 本文將根據設計文檔, 對交換機進行配置和服務器網絡連線方式進行說明.Step1.交換機規劃, 根據功能將交換機端口分為三個部分:管理區域(交換機1 – 16 口): 用於

Win10安裝Mongodb,並配置服務

append 配置文件 log 模式 日誌文件 文件夾 sta fig clas 好吧,今天突然發現新買的surface上沒有安裝mongodb,然後想著安裝一下,順便記錄一下,雖說安裝過程很簡單 一:下載安裝,然後拷貝到C盤根目錄,這個就不多說了,比QQ都簡單。 二:把b

ArchLinux配置Samba服務與Windows共享文件

window pacman 樣本 jpg user 這一 詳細 path 配置 由於最近加班,俺的高清下載機中,已經累積了200G+的高清電影了,嘿嘿,看來平時的帶寬沒浪費,充分利用了。在這之前,由於懶於配置Samba,我都是偷懶,用的SFTP,通過Linux帳號來登錄下

將本地文件傳遞到服務器--在雲服務配置FTP服務

ble 臨時 原因 logs 之前 禁止 file 遠程 note 1. 在雲服務器配置FTP服務 1) 在root權限下,通過如下命令安裝Vsftp(以CentOS系統為例): yum install vsftpd 2) 在啟動vsftpd服務之前,需要登錄雲服務器

Linux服務配置apache服務

指向 eps node 安裝 pac rep ice 系統 .com 1、查看服務器是否安裝apache服務:rpm -qa|grep (apr/apr-util/pcre/httpd)   如果不需要系統已有的服務的話,可以刪除掉重新配置(rpm -e servicena

iscsi服務器--網絡驅動器設備

internet network storage 服務器 驅動器 iscsi服務器--網絡驅動器設備Iscsi是將來自網絡的數據仿真成本機的scsi(磁盤)設備 因此可以進行諸如LVM等方面的操作 而不是單純的使用服務器端提供的文件系統不管哪個架構 它們的內部硬盤通常是以磁盤陣列(RAID

jira安裝配置服務腳本

jira安裝部署 jira服務腳本 jira授權一、安裝說明系統:CentOS 6.7 x64 export LANG="zh_CN.UTF-8" # 否則中文無法顯示,還是英文安裝java 1.7.x版本jdk安裝mysql 5.1及以上版本二、數據庫配置創建mysql:>>crea

配置 Apache 服務器禁止所有非法域名 訪問自己的服務

star ide yun imp span toml tor service sim 1、http2.4.1以前: 第一種 直接拒絕訪問 打開 httpd.conf 文件,將一下配置追加到文件最後。 <pre name="code" class="html"&

()centos6.8安裝配置ftp服務

服務 配置ftp服務器 () 控制 原理 文件結構 連接 centos6 安裝 ftp傳輸原理 客戶端通過某軟件用某個端口(a端口)向服務端發起tcp連接請求,同時告訴服務端客戶端另一個空閑端口號(b端口),服務端用21端口與客戶端建立一條控制連接通道。 接著在默認情況下,

CentOS 6.4安裝配置LNMP服務器(Nginx+PHP+MySQL)

mysql- ket 是否 分號 使用 store 重啟 isa tpi 一 安裝篇 1. 安裝nginx yum check-update #更新yum源 yum remove httpd* php* #刪除系統自帶的軟件包 yum install nginx #安裝ng