分类: 系统运维
2014-12-31 14:26:42
1 yum -y install iscsi* 或者 rpm -ivh iscsi-initiator-utils-6.2.0.871-0.10.el5.x86_64.rpm
2 iscsiadm -m discovery -t sendtargets -p 10.0.10.10:3260
3 启动iscsi服务/etc/init.d/iscsi
restart
[root@svn etc]# fdisk -l
Disk /dev/sda: 299.4 GB, 299439751168 bytes
255 heads, 63 sectors/track, 36404 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0008c810
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 1070 8388608 82 Linux swap / Solaris
/dev/sda3 1070 36405 283827200 83 Linux
Disk /dev/sdb: 343.6 GB, 343597383680 bytes
255 heads, 63 sectors/track, 41773 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa65da31b
Disk /dev/sde: 343.6 GB, 343597383680 bytes
255 heads, 63 sectors/track, 41773 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa65da31b
Disk /dev/sdc: 343.6 GB, 343597383680 bytes
255 heads, 63 sectors/track, 41773 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa65da31b
Disk /dev/sdd: 343.6 GB, 343597383680 bytes
255 heads, 63 sectors/track, 41773 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk
identifier: 0xa65da31b
[root@localhost ~]# fdisk /dev/sdb
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/sdb: 998.6 GB, 998579896320 bytes
255 heads, 63 sectors/track, 121403 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5df6a8ad
Device Boot Start End Blocks Id System
/dev/sdb1 1 262 2104483+ 83 Linux
Command (m for help): d 1
Selected partition 1
Command (m for help): p
Disk /dev/sdb: 998.6 GB, 998579896320 bytes
255 heads, 63 sectors/track, 121403 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5df6a8ad
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-121403, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-121403, default 121403): +512M
Command (m for help): p
Disk /dev/sdb: 998.6 GB, 998579896320 bytes
255 heads, 63 sectors/track, 121403 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5df6a8ad
Device Boot Start End Blocks Id System
/dev/sdb1 1 66 530113+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@localhost ~]# mkfs.ext3 /dev/sdb1
mke2fs 1.41.12 (17-May-2010)
文件系统标签=
操作系统:Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
33200 inodes, 132528 blocks
6626 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=138412032
5 block groups
32768 blocks per group, 32768 fragments per group
6640 inodes per group
Superblock backups stored on blocks:
32768, 98304
正在写入inode表: 完成
Creating journal (4096 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 21 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
这些容量相同的磁盘对应着存储上面的数据端口(一一对应)
由于需要实现存储设备的多路径访问及故障切换,故需要运行multipath服务,这个在centos中已经安装好了。如没有执行下面的命令。
(原理为EVA4400中的一个真实的virtual disk通过与2个冗余阵列控制器连接的2个MPX100B对外提供映射,故服务器上可以看到两个物理磁盘,但此磁盘对应一个真实的一个真实的virtual
disk,故这两条路径间可以实现故障切换和负载均衡)
rpm –ivh device-mapper-1.02.13-6.9.i686.rpm
rpm –ivh multipath-tools-0.4.7-34.18.i686.rpm
[root@svn etc]# rpm -aq | grep mapper
device-mapper-multipath-0.4.9-46.el6.x86_64
device-mapper-event-libs-1.02.66-6.el6.x86_64
device-mapper-multipath-libs-0.4.9-46.el6.x86_64
device-mapper-libs-1.02.66-6.el6.x86_64
device-mapper-event-1.02.66-6.el6.x86_64
device-mapper-1.02.66-6.el6.x86_64
安装完成后,使用命令modprobe dm_multipath来加载相应的模块,
可以使用lsmod |grep dm_multipath来检查安装是否正常。
/etc/multipath.conf 是多路径软件的配置文件,其中大部分配置是注释掉的,可以将他保存为备用,然后新建一个multipath.conf 文件,编辑新的配置文件:
实际有用的就是下面这些参数:其余参数都可以注释掉:
defaults {
user_friendly_names yes
udev_dir /dev
path_grouping_policy multibus
failback immediate
no_path_retry fail
}
保存退出
启动服务
service multipathd restart
[root@localhost ~]# fdisk -l
Disk /dev/sda: 299.0 GB, 298999349248 bytes
255 heads, 63 sectors/track, 36351 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0004e761
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 102400 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 13 536 4194304 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 536 36352 287693824 83 Linux
Disk /dev/sdb: 998.6 GB, 998579896320 bytes
255 heads, 63 sectors/track, 121403 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5df6a8ad
Device Boot Start End Blocks Id System
/dev/sdb1 1 66 530113+ 83 Linux
Disk /dev/sdc: 998.6 GB, 998579896320 bytes
255 heads, 63 sectors/track, 121403 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5df6a8ad
Device Boot Start End Blocks Id System
/dev/sdc1 1 66 530113+ 83 Linux
Disk /dev/sdd: 998.6 GB, 998579896320 bytes
255 heads, 63 sectors/track, 121403 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5df6a8ad
Device Boot Start End Blocks Id System
/dev/sdd1 1 66 530113+ 83 Linux
Disk /dev/sde: 998.6 GB, 998579896320 bytes
255 heads, 63 sectors/track, 121403 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5df6a8ad
Device Boot Start End Blocks Id System
/dev/sde1 1 66 530113+ 83 Linux
Disk /dev/mapper/mpathb: 998.6 GB, 998579896320 bytes
255 heads, 63 sectors/track, 121403 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x5df6a8ad
Device Boot Start End Blocks Id System
/dev/mapper/mpathbp1 1 66 530113+ 83 Linux
Disk /dev/mapper/mpathbp1: 542 MB, 542836224 bytes
255 heads, 63 sectors/track, 65 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/mpathbp1 doesn't contain a valid partition table
[root@localhost ~]# mount /dev/mapper/mpathbp1 /tang/
[root@localhost ~]# mount
/dev/sda3 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/mapper/mpathbp1 on /tang type ext3 (rw)
[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用%% 挂载点
/dev/sda3 271G 3.1G 254G 2% /
tmpfs 12G 88K 12G 1% /dev/shm
/dev/sda1 97M 31M 61M 34% /boot
/dev/mapper/mpathbp1 510M 17M 468M 4% /tang