歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

linux如何搭建iscsi共享存儲

iscsi服務端IP192.168.254.172

客戶端1 192.168.254.46

客戶端2 192.168.254.158

一、服務端的配置

1、服務端安裝scsi-target-utils

[root@localhost ~]# yum install scsi-target-utils  -y

2、如果有獨立的分區,可以使用獨立的分區,如果沒有合適的分區可以dd一個大文件來作為共享磁盤

[root@localhost /]# dd if=/dev/zero of=/disk1 bs=1M count=3000

3000+0 records in

3000+0 records out

3145728000 bytes (3.1 GB) copied, 11.618 seconds, 271 MB/s

3、修改iscsi的主配置文件

[root@localhost ~]# vi /etc/tgt/targets.conf

<target iqn.2013-12.com.make:ws.httpd>

backing-store /disk1

</target>

4、啟動tgtd服務

[root@localhost ~]# /etc/init.d/tgtd restart

Stopping SCSI target daemon: Stopping target framework daemon

[  OK  ]

Starting SCSI target daemon: Starting target framework daemon

二、客戶端的配置

1、安裝客戶端

[root@zabbix-client1 ~]# yum install iscsi-initiator-utils  -y

2、啟動客戶端

[root@zabbix-client1 ~]# iscsiadm -m discovery -t sendtargets -p 192.168.254.172

正在啟動  iscsid:[確定]

192.168.254.172:3260,1 iqn.2013-12.com.make:ws.httpd

192.168.254.172:3260,1 iqn.2013-12.com.make:ws.mysqld

3、使用客戶端發現掛載存儲

[root@zabbix-client1 ~]# iscsiadm -m node -T iqn.2013-12.com.make:ws.httpd -l

Logging in to [iface: default, target: iqn.2013-12.com.make:ws.httpd, portal: 192.168.254.172,3260] (multiple)

Login to [iface: default, target: iqn.2013-12.com.make:ws.httpd, portal: 192.168.254.172,3260] successful.

4、在 客戶端上對掛載的兩個磁盤進行分區並格式化成ext4格式的文件系統

[root@localhost ~]# fdisk /dev/sda

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0xcc8d06f3.

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

更多精彩內容:http://www.bianceng.cn/OS/Linux/

sectors (command 'u').

Command (m for help): n

Command action

e   extended

p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-1021, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-1021, default 1021):

Using default value 1021

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[root@localhost ~]# mkfs.ext4 /dev/sda1

mke2fs 1.41.12 (17-May-2010)

文件系統標簽=

操作系統:Linux

塊大小=4096 (log=2)

分塊大小=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

192000 inodes, 767529 blocks

38376 blocks (5.00%) reserved for the super user

第一個數據塊=0

Maximum filesystem blocks=788529152

24 block groups

32768 blocks per group, 32768 fragments per group

8000 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912

正在寫入inode表: 完成

Creating journal (16384 blocks): 完成

Writing superblocks and filesystem accounting information: 完成

三、在另一個客戶端做相同的操作,但是無需重新格式化

在兩個客戶端上分別使用fdisk -l查看

作者:csdn博客 Liteboy

Copyright © Linux教程網 All Rights Reserved