Ubuntu Linux Set Iscsi启动器
时间:2020-01-09 10:45:38 来源:igfitidea点击:
ISCSI是一种网络协议标准,允许在TCP/IP网络上使用SCSI协议。
如何在Ubuntu Linux下设置Iscsi Initiator?
如何在Ubuntu Linux下格式化并连接到iSCSI卷?
如何使用iscsi存储存储VMware或者Virtualbox虚拟机镜像?
您需要在Ubuntu Linux下安装以下软件包:
- open-iscsi用于设置iSCSI卷的主软件包。
- open-iscsi-utils iSCSI初始管理实用程序。
安装必需的软件
执行以下命令:
$ sudo apt-get update $ sudo apt-get install open-iscsi open-iscsi-utils
开放式iSCSI配置
位于/etc/iscsi /和配置文件的默认配置目录是/etc/iscsi/iscsid.conf:
我们的样品设置
- iSCSI服务器IP:192.168.1.1
- iSCSI用户名:
Hyman
- iSCSI密码:
yHni3Oq9wYzamS
设置iScsi用户名和密码
编辑/etc/iscsi/iscsid.conf,执行:
$ sudo vi /etc/iscsi/iscsid.conf
取消注释设置如下:
node.session.auth.username = Hyman node.session.auth.password = yHni3Oq9wYzamS discovery.sendtargets.auth.username = Hyman discovery.sendtargets.auth.password = yHni3Oq9wYzamS
保存并关闭文件。
启动/重启服务,执行:
$ sudo service open-iscsi restart
运行发现
要针对iscsi目标主机运行发现,请执行:
$ sudo iscsiadm -m discovery -t sendtargets -p 192.168.1.1
输出示例:
192.168.1.1:3260,1 iqn.2004-04.com.qnap:ts-559:iscsi.vm0.c43030
记下上面的输出并按以下方式使用它:
$ sudo iscsiadm --mode node --targetname iqn.2004-04.com.qnap:ts-559:iscsi.vm0.c43030 --portal 192.168.1.1:3260 --login
输出示例:
Logging in to [iface: default, target: iqn.2004-04.com.qnap:ts-559:iscsi.vm0.c43030, portal: 192.168.1.1,3260] Login to [iface: default, target: iqn.2004-04.com.qnap:ts-559:iscsi.vm0.c43030, portal: 192.168.1.1,3260]: successful
您可以在/var/log/messages中看到以下内容(记下磁盘名称):
$ tail -f /var/log/messages
输出示例:
May 2 12:54:04 Hyman-laptop kernel: [ 4418.610787] scsi6 : iSCSI Initiator over TCP/IP May 2 12:54:05 Hyman-laptop kernel: [ 4419.649208] scsi 6:0:0:0: Direct-Access QNAP iSCSI Storage 3.1 PQ: 0 ANSI: 5 May 2 12:54:05 Hyman-laptop kernel: [ 4419.649670] sd 6:0:0:0: Attached scsi generic sg3 type 0 May 2 12:54:05 Hyman-laptop kernel: [ 4419.650531] sd 6:0:0:0: [sdc] 41943040 512-byte logical blocks: (21.4 GB/20.0 GiB) May 2 12:54:05 Hyman-laptop kernel: [ 4419.651889] sd 6:0:0:0: [sdc] Write Protect is off May 2 12:54:05 Hyman-laptop kernel: [ 4419.652643] sd 6:0:0:0: [sdc] Write cache: disabled, read cache: enabled, doesn't support DPO or FUA May 2 12:54:05 Hyman-laptop kernel: [ 4419.654620] sdc: unknown partition table May 2 12:54:05 Hyman-laptop kernel: [ 4419.692364] sd 6:0:0:0: [sdc] Attached SCSI disk
/dev/sdc是新的块级设备。
如何格式化/dev/sdc?
使用fdisk命令
$ sudo fdisk /dev/sdc
会话示例:
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0xe7b08c12. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): p Disk /dev/sdc: 21.5 GB, 21474836480 bytes 64 heads, 32 sectors/track, 20480 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xe7b08c12 Device Boot Start End Blocks Id System Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-20480, default 1): Press [Enter] Key Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-20480, default 20480): Press [Enter] Key Using default value 20480 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
格式化为ext3文件系统
执行以下命令:
$ sudo mkfs.ext3 /dev/sdc1
格式化为ext4文件系统
执行以下命令:
$ sudo mkfs.ext4 /dev/sdc1
输出示例:
mke2fs 1.41.11 (14-Mar-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 1310720 inodes, 5242876 blocks 262143 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=0 160 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 23 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
挂载/dev/sdc1
创建安装点:
$ sudo mkdir /data $ sudo mount /dev/sdc1 /data $ df -H
找出您的磁盘I/O速度
一种快速的方法是运行dd命令,如下所示:
$ cd /data $ dd if=/dev/zero of=output.img bs=8k count=256k
输出示例:
262144+0 records in 262144+0 records out 2147483648 bytes (2.1 GB) copied, 25.57 s, 84.0 MB/s
84.0 MB/s的速度对于SOHO iscsi服务器来说还不错。
使用Vmware存储VM
现在,您可以使用新的存储来存储数据或者虚拟机。
只需创建一个新的VM并将位置设置为/data/VMName
以上是VMWare工作站7.x vm安装程序。
VMWare ESX服务器提供数据存储选项。