19,612
社区成员
发帖
与我相关
我的任务
分享
[root@localhost /]# vi /etc/sysconfig/network-scripts/ifcfg-ens192
TYPE=Ethernet
BOOTPROTO=none
IPADDR=10.20.1.100
NETMASK=255.255.255.0
GATEWAY=10.20.1.254
NAME=ens192
ONBOOT=yes
[root@localhost /]#systemctl stop firewalld
[root@localhost /]# cd /mnt
[root@localhost /]# mkdir rehl7
[root@localhost /]# mount /dev/sr0 /mnt/rehl7/ //虚拟光驱,提前做好的
[root@localhost /]# vim /etc/yum.repos.d/base.repo
[base]
name=base
baseurl=file:///mnt/rehl7
enable=1
gpgcheck=0
[root@localhost /]# yum clean all //清除缓存
[root@localhost /]# yum makecache //重载缓存
[root@localhost /]# fdisk -l
Disk /dev/sdb: 536.9 GB, 536870912000 bytes, 1048576000 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
[root@localhost ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x8fa166b8.
Command (m for help): 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 (2048-1048575999, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-1048575999, default 1048575999):
Using default value 1048575999
Partition 1 of type Linux and of size 500 GiB is set
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'
Command (m for help): p
Disk /dev/sdb: 536.9 GB, 536870912000 bytes, 1048576000 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: 0x8fa166b8
Device Boot Start End Blocks Id System
/dev/sdb1 2048 1048575999 524286976 8e Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost /]# partprobe /dev/sdb1 //重载分区表
[root@localhost /]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
[root@localhost /]# vgcreate iSCSI /dev/sdb1
Volume group "iSCSI" successfully created
[root@localhost /]# lvcreate -L 150G -n iscsi_56 iSCSI
Logical volume "iscsi_56" created
[root@localhost /]# lvcreate -L 150G -n iscsi_57 iSCSI
Logical volume "iscsi_57" created
[root@localhost /]# lvcreate -L 150G -n iscsi_55 iSCSI
Logical volume "iscsi_55" created
[root@localhost /]# vgs
VG #PV #LV #SN Attr VSize VFree
iSCSI 1 3 0 wz--n- 500.00g 50.00g
rhel 1 2 0 wz--n- 83.80g 0
[root@localhost /]# lvs
LV VG Attr LSize Pool Origin Data% Move Log Cpy%Sync Convert
iscsi_55 iSCSI -wi-a----- 150.00g
iscsi_56 iSCSI -wi-a----- 150.00g
iscsi_57 iSCSI -wi-a----- 150.00g
home rhel -wi-ao---- 4.88g
root rhel -wi-ao---- 78.92g
[root@localhost /]# yum install targetcli –y //安装iscsi 服务管理器
[root@localhost /]# systemctl start target //启动target服务
[root@localhost /]# systemctl enable target //将服务设置为开机自动启动
[root@localhost /]# yum install iscsi-initiator-utils //安装iscsi Initiator
[root@localhost /]# vim /etc/iscsi/initiatorname.iscsi //修改iqn name
InitiatorName=iqn.1994-05.com.redhat:iSCSIserver
[root@localhost etc]# targetcli
Warning: Could not load preferences file /root/.targetcli/prefs.bin.
targetcli shell version 2.1.fb34
Copyright 2011-2013 by Datera, Inc and others.
For help on commands, type 'help'.
/> ls //查看树状结构布局
o- / ............................................................................ [...]
o- backstores ................................................................. [...]
| o- block ..................................................... [Storage Objects: 0]
| o- fileio .................................................... [Storage Objects: 0]
| o- pscsi ..................................................... [Storage Objects: 0]
| o- ramdisk ................................................... [Storage Objects: 0]
o- iscsi ............................................................... [Targets: 0]
o- loopback ............................................................ [Targets: 0]
/> /backstores/block create iscsi55_data /dev/iSCSI/iscsi_55 //分别使用LV创建存储块。
Created block storage object iscsi55_data using /dev/iSCSI/iscsi_55.
/> /backstores/block create iscsi56_data /dev/iSCSI/iscsi_56 //创建iscsi56-data
Created block storage object iscsi56_data using /dev/iSCSI/iscsi_56.
/> /backstores/block create iscsi57_data /dev/iSCSI/iscsi_57 //创建iscsi57-data
Created block storage object iscsi57_data using /dev/iSCSI/iscsi_57.
/> iscsi/ create iqn.1994-05.com.redhat:iSCSIserver //配置服务端iSCSITarget名,该名称已经在前面写入到文件里。
Created target iqn.1994-05.com.redhat:iSCSIserver.
Created TPG 1.
/> iscsi/iqn.1994-05.com.redhat:server/tpg1/portals create 10.20.1.100 //配置服务端IP及端口,端口默认为3260
Using default IP port 3260
Created network portal 10.20.1.100:3260.
/>ls //查看配置情况
/> cd iscsi/iqn.1994-05.com.redhat:iscsiserver/tpg1/acls
/iscsi/iqn.19...ver/tpg1/acls> create iqn.1991-05.com.microsoft:mq57master
Created Node ACL for iqn.1991-05.com.microsoft:mq57master
[root@FTPServer ~]# pvcreate /dev/sdc1 //创建PV
Physical volume "/dev/sdc1" successfully created
[root@FTPServer ~]# vgcreate FtpDataGroup /dev/sdc1 //创建VG
Volume group "FtpDataGroup" successfully created
[root@FTPServer ~]# lvcreate -l 38398 -n FtpData FtpDataGroup //创建LV
Logical volume "FtpData" created
[root@FTPServer ~]# mkfs.xfs /dev/FtpDataGroup/FtpData //格式化为xfs