linux配置ISCSI服务器的方法
一.在linux下安装启动iscsitarget
1.安装启动iscsi服务
[root@wjb10000~]#yum-yinstalltargetcli.noarch
2.建立一个目录设置为iscsi设备
[root@wjb10000~]#mkdir/iscsi_disks
3.设置target
[root@wjb10000~]#targetcli Warning:Couldnotloadpreferencesfile/root/.targetcli/prefs.bin. targetclishellversion2.1.fb41 Copyright2011-2013byDatera,Incandothers. Forhelponcommands,type'help'. />cdbackstores/fileio /backstores/fileio>createdisk01/iscsi_disks/disk01.img20G Createdfileiodisk01withsize21474836480 /backstores/fileio>cd/iscsi /iscsi>createiqn.2016-06.wjb.com:storage.target0 Createdtargetiqn.2016-06.wjb.com:storage.target0. CreatedTPG1. Globalprefauto_add_default_portal=true CreateddefaultportallisteningonallIPs(0.0.0.0),port3260. /iscsi>cdiqn.2016-06.wjb.com:storage.target0/tpg1/portals/ /iscsi/iqn.20.../tpg1/portals>create192.168.1.50 UsingdefaultIPport3260 CouldnotcreateNetworkPortalinconfigFS /iscsi/iqn.20.../tpg1/portals>delete0.0.0.03260 Deletednetworkportal0.0.0.0:3260 /iscsi/iqn.20.../tpg1/portals>create192.168.1.50 UsingdefaultIPport3260 Creatednetworkportal192.168.1.50:3260. /iscsi/iqn.20.../tpg1/portals>cd../luns /iscsi/iqn.20...et0/tpg1/luns>create/backstores/fileio/disk01 CreatedLUN0. /iscsi/iqn.20...et0/tpg1/luns>cd../acls /iscsi/iqn.20...et0/tpg1/acls>createiqn.2016-06.wjb.com:www.server.com CreatedNodeACLforiqn.2016-06.wjb.com:www.server.com CreatedmappedLUN0. /iscsi/iqn.20...et0/tpg1/acls>cdiqn.2016-06.wjb.com:www.server.com/ /iscsi/iqn.20...ww.server.com>setauthuserid=username Parameteruseridisnow'username'. /iscsi/iqn.20...ww.server.com>setauthpassword=password Parameterpasswordisnow'password'. /iscsi/iqn.20...ww.server.com>exit Globalprefauto_save_on_exit=true Last10configssavedin/etc/target/backup. Configurationsavedto/etc/target/saveconfig.json
4.设置防火墙
[root@wjb10000~]#vim/etc/firewalld/services/iscsi.xml <?xmlversion="1.0"encoding="utf-8"?> <service> <short>ISCSI</short> <description>ISCSIprotocal</description> <portprotocal="tcp"port="3260"> </service> [root@wjb10000~]#firewall-cmd--permanent--add-service=iscsi [root@wjb10000~]#firewall-cmd--reload
5.启动服务
[root@wjb10000~]#systemctlenabletarget.service Createdsymlinkfrom/etc/systemd/system/multi-user.target.wants/target.serviceto/usr/lib/systemd/system/target.service. [root@wjb10000~]#systemctlstarttarget.service
6.查看端口
[root@wjb10000~]#netstat-lnp|grep3260 tcp00192.168.1.50:32600.0.0.0:*LISTEN-
二.在linux下安装启动iscsiinitiator
1.安装iscsi-initiator-utils服务
[root@wjb10000~]#yuminstalliscsi-initiator-utils
2.修改配置文件
[root@wjb10000~]#vim/etc/iscsi/initiatorname.iscsi InitiatorName=iqn.2016-06.wjb.com:www.server.com [root@wjb10000~]#vim/etc/iscsi/iscsid.conf #node.session.auth.authmethod=CHAP #node.session.auth.username=username #node.session.auth.password=password//去掉注释
3.启动服务
[root@wjb10000~]#systemctlstartiscsid
[root@wjb10000~]#systemctlenableiscsid
4.发现target
[root@wjb10000~]#iscsiadm-mdiscovery-tsendtargets-p192.168.1.50
5.查看状态
[root@wjb10000~]#iscsiadm-mnode-oshow
6.登录target建立连接
[root@wjb10000~]#iscsiadm-mnode--login
Logginginto[iface:default,target:iqn.2016-06.wjb.com:storage.target0,portal:192.168.1.50,3260](multiple)
Loginto[iface:default,target:iqn.2016-06.wjb.com:storage.target0,portal:192.168.1.50,3260]successful.
7.查看连接情况
[root@wjb10000~]#iscsiadm-msession-oshow
tcp:[1]192.168.1.50:3260,1iqn.2016-06.wjb.com:storage.target0(non-flash)
8.磁盘操作
[root@wjb10000~]#fdisk-l 磁盘/dev/sda:107.4GB,107374182400字节,209715200个扇区 Units=扇区of1*512=512bytes 扇区大小(逻辑/物理):512字节/512字节 I/O大小(最小/最佳):512字节/512字节 磁盘标签类型:dos 磁盘标识符:0x000b2ba1 设备BootStartEndBlocksIdSystem /dev/sda1*2048102604751200083Linux /dev/sda21026048624660473072000083Linux /dev/sda3624660481034260472048000083Linux /dev/sda4103426048209715199531445765Extended /dev/sda51034280961443880952048000083Linux /dev/sda6144390144152582143409600082Linuxswap/Solaris /dev/sda71525841922097151992856550483Linux 磁盘/dev/sdb:21.5GB,21474836480字节,41943040个扇区 Units=扇区of1*512=512bytes 扇区大小(逻辑/物理):512字节/512字节 I/O大小(最小/最佳):512字节/8388608字节 [root@wjb10000~]#parted--script/dev/sdb"mklabelmsdos" [root@wjb10000~]#parted--script/dev/sdb"mkpartprimary0%100%" [root@wjb10000~]#mkfs.xfs-isize=1024-ssize=4096/dev/sdb1 meta-data=/dev/sdb1isize=1024agcount=4,agsize=1310208blks =sectsz=4096attr=2,projid32bit=1 =crc=0finobt=0 data=bsize=4096blocks=5240832,imaxpct=25 =sunit=0swidth=0blks naming=version2bsize=4096ascii-ci=0ftype=0 log=internallogbsize=4096blocks=2560,version=2 =sectsz=4096sunit=1blks,lazy-count=1 realtime=noneextsz=4096blocks=0,rtextents=0 [root@wjb10000~]#mount/dev/sdb1/mnt/ [root@wjb10000~]#df-hT 文件系统类型容量已用可用已用%挂载点 /dev/sda3xfs20G68M20G1%/ devtmpfsdevtmpfs904M0904M0%/dev tmpfstmpfs913M0913M0%/dev/shm tmpfstmpfs913M8.7M904M1%/run tmpfstmpfs913M0913M0%/sys/fs/cgroup /dev/sda5xfs20G1.5G19G8%/usr /dev/sda7xfs28G33M28G1%/home /dev/sda2xfs30G694M29G3%/var /dev/sda1xfs497M128M370M26%/boot tmpfstmpfs183M0183M0%/run/user/0 /dev/sdb1xfs20G33M20G1%/mnt
以上就是小编为大家带来的linux配置ISCSI服务器的方法全部内容了,希望大家多多支持毛票票~