您的位置:首页 > 运维架构 > Linux

Centos 5 多路径配置步骤

2012-10-20 22:53 435 查看
Centos 5 多路径配置步骤

1、检查系统中是否已安装multipath:

    在CentOS 5中,一般情况下安装系统时multipath已经被安装,查看multipath是否安装如下:

[root@localhost vol]#  rpm  -qa  | grep  mapper

device-mapper-multipath-0.4.7-34.el5

device-mapper-1.02.39-1.el5

device-mapper-1.02.39-1.el5

device-mapper-event-1.02.39-1.el5

[root@localhost vol]#

如果没有安装,那么要安装下列rpm包(注意使用对应系统内核的rpm包):

# rpm  -ivh  device-mapper-1.02.32-1.el5.i386.rpm

# rpm  -ivh  device-mapper-1.02.32-1.el5.x86_64.rpm

# rpm  -ivh  device-mapper-event-1.02.32-1.el5.x86_64.rpm

# rpm  -ivh  device-mapper-multipath-0.4.7-30.el5.x86_64.rpm

2、设置成开机自启动multipathd:

[root@localhost vol]# chkconfig  --list  | grep  multipath

multipathd      0:关闭  1:关闭  2:关闭  3:关闭  4:关闭  5:关闭  6:关闭

[root@localhost vol]# chkconfig  --level  2345  multipathd on

[root@localhost vol]# chkconfig  --list  | grep  multipathd

multipathd      0:关闭  1:关闭  2:启用  3:启用  4:启用  5:启用  6:关闭

[root@localhost vol]#

3、启动multipathd服务:

[root@localhost vol]# service  multipathd  status

multipathd 已停

[root@localhost vol]# service  multipathd  start

正在启动守护进程multipathd:[确定]

[root@localhost vol]# lsmod  | grep  dm_multipath

dm_multipath           56921  0

scsi_dh                42177  1 dm_multipath

dm_mod                101649  4 dm_mirror,dm_multipath,dm_raid45,dm_log

[root@localhost vol]#  service  multipathd  status

multipathd (pid  9035) 正在运行...

[root@localhost vol]#

4、对multipath进行配置:

multipath的配置文件是/etc/multipath.conf

我们要对/dev/sdb 和 /dev/sdd 设置多路径,使用下面的命令检查:

[root@localhost mpath]# fdisk  -l

Disk /dev/sda: 299.4 GB, 299439751168 bytes

255 heads, 63 sectors/track, 36404 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   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        6375    51096576   82  Linux swap / Solaris

/dev/sda3            6375       36405   241219584   83  Linux

Disk /dev/sdb: 1099.5 GB, 1099511627776 bytes

255 heads, 63 sectors/track, 133674 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc (Sun disk label): 255 heads, 189 sectors, 47507 cylinders

Units = cylinders of 48195 * 512 bytes

   Device Flag    Start       End    Blocks   Id  System

/dev/sdc3  u          0     47507 1144799932+   5  Whole disk

/dev/sdc7             0     47507 1144799932+   4  SunOS usr

Disk /dev/sdc3 (Sun disk label): 255 heads, 189 sectors, 47507 cylinders

Units = cylinders of 48195 * 512 bytes

    Device Flag    Start       End    Blocks   Id  System

/dev/sdc3p3  u          0     47507 1144799932+   5  Whole disk

/dev/sdc3p7             0     47507 1144799932+   4  SunOS usr

Disk /dev/sdc7 (Sun disk label): 255 heads, 189 sectors, 47507 cylinders

Units = cylinders of 48195 * 512 bytes

    Device Flag    Start       End    Blocks   Id  System

/dev/sdc7p3  u          0     47507 1144799932+   5  Whole disk

/dev/sdc7p7             0     47507 1144799932+   4  SunOS usr

Disk /dev/sdd: 1099.5 GB, 1099511627776 bytes

255 heads, 63 sectors/track, 133674 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdd doesn't contain a valid partition table

Disk /dev/sde (Sun disk label): 64 heads, 64 sectors, 8 cylinders

Units = cylinders of 4096 * 512 bytes

   Device Flag    Start       End    Blocks   Id  System

/dev/sde3  u          0         8     16384    5  Whole disk

/dev/sde7             0         8     16384    4  SunOS usr

Disk /dev/sde3 (Sun disk label): 64 heads, 64 sectors, 8 cylinders

Units = cylinders of 4096 * 512 bytes

    Device Flag    Start       End    Blocks   Id  System

/dev/sde3p3  u          0         8     16384    5  Whole disk

/dev/sde3p7             0         8     16384    4  SunOS usr

Disk /dev/sde7 (Sun disk label): 64 heads, 64 sectors, 8 cylinders

Units = cylinders of 4096 * 512 bytes

    Device Flag    Start       End    Blocks   Id  System

/dev/sde7p3  u          0         8     16384    5  Whole disk

/dev/sde7p7             0         8     16384    4  SunOS usr

备份下/etc/multipath.conf文件:

[root@localhost etc]# cp  /etc/multipath.conf  /etc/multipath.conf.bak

修改后的/etc/multipath.conf配置如下:

blacklist {

        devnode "sdc"

        devnode "sde"

}

defaults {

        user_friendly_names yes

        udev_dir /dev

        path_grouping_policy multibus

        failback immediate

        no_path_retry fail

}

其它行都注释掉了。

重启multipathd服务:

[root@localhost mpath]# service  multipathd  restart

正在关闭multipathd 端口监控程序:[确定]

正在启动守护进程multipathd:[确定]

查看多路径:

[root@localhost mpath]# multipath  -ll

mpath1 (3600144f09307fd8700004fb0babc0002) dm-0 SUN,ZFS Storage 7320

[size=1.0T][features=0][hwhandler=0][rw]

\_ round-robin 0 [prio=2][active]

 \_ 3:0:0:1 sdb 8:16  [active][ready]

 \_ 3:0:3:1 sdd 8:48  [active][ready]

检查安装是否正常:

[root@localhost mpath]# lsmod  | grep  multipath

dm_multipath       56921  2 dm_round_robin

scsi_dh            42177  1 dm_multipath

dm_mod            101649  10 dm_mirror,dm_multipath,dm_raid45,dm_log

[root@localhost mpath]# ll  /dev/mpath/

lrwxrwxrwx 1 root root 7 06-12 10:27 mpath1 -> ../dm-0

[root@localhost mpath]# ll  /dev/mapper/

总计 0

crw------- 1 root root  10, 63 06-11 17:13 control

brw-rw---- 1 root disk 253,  0 06-12 10:27 mpath1

[root@localhost mpath]# ll  /dev/dm-0

brw-rw---- 1 root root 253, 0 06-12 10:27 /dev/dm-0

创建并格式化物理卷:

[root@localhost mpath]# pvcreate  /dev/mapper/mpath1

  Physical volume "/dev/mapper/mpath1" successfully created

[root@localhost mpath]# fdisk  /dev/mapper/mpath1

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

Building a new DOS disklabel. Changes will remain in memory only,

until you decide to write them. After that, of course, the previous

content won't be recoverable.

The number of cylinders for this disk is set to 133674.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

   (e.g., DOS FDISK, OS/2 FDISK)

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): m

Command action

   a   toggle a bootable flag

   b   edit bsd disklabel

   c   toggle the dos compatibility flag

   d   delete a partition

   l   list known partition types

   m   print this menu

   n   add a new partition

   o   create a new empty DOS partition table

   p   print the partition table

   q   quit without saving changes

   s   create a new empty Sun disklabel

   t   change a partition's system id

   u   change display/entry units

   v   verify the partition table

   w   write table to disk and exit

   x   extra functionality (experts only)

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-133674, default 1):

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-133674, default 133674):

Using default value 133674

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: 无效的参数.

The kernel still uses the old table.

The new table will be used at the next reboot.

Syncing disks.

删除现有路径:

[root@localhost mapper]# multipath  -F

格式化路径:

[root@localhost mapper]# multipath  -v3

loop0: blacklisted

loop1: blacklisted

loop2: blacklisted

loop3: blacklisted

loop4: blacklisted

loop5: blacklisted

loop6: blacklisted

loop7: blacklisted

md0: blacklisted

ram0: blacklisted

ram10: blacklisted

ram11: blacklisted

ram12: blacklisted

ram13: blacklisted

ram14: blacklisted

ram15: blacklisted

ram1: blacklisted

ram2: blacklisted

ram3: blacklisted

ram4: blacklisted

ram5: blacklisted

ram6: blacklisted

ram7: blacklisted

ram8: blacklisted

ram9: blacklisted

sda: not found in pathvec

sda: mask = 0x1f

sda: bus = 1

sda: dev_t = 8:0

sda: size = 584843264

sda: vendor = Dell

sda: product = VIRTUAL DISK

sda: rev = 1028

sda: h:b:t:l = 0:1:0:0

sda: serial =

sda: path checker = readsector0 (config file default)

sda: checker timeout = 60000 ms (sysfs setting)

sda: state = 2

sda: getuid = /sbin/scsi_id -g -u -s /block/%n (config file default)

sda: uid = 3600508e00000000082106bf5fc170406 (callout)

sda: getprio = NULL (internal default)

sda: prio = 1

sdb: not found in pathvec

sdb: mask = 0x1f

sdb: bus = 1

sdb: dev_t = 8:16

sdb: size = 2147483648

sdb: vendor = SUN

sdb: product = ZFS Storage 7320

sdb: rev = 1.0

sdb: h:b:t:l = 3:0:0:1

sdb: tgt_node_name = 0x20000024ff3b6fb9

sdb: serial =     

sdb: path checker = readsector0 (config file default)

sdb: checker timeout = 60000 ms (sysfs setting)

sdb: state = 2

sdb: getuid = /sbin/scsi_id -g -u -s /block/%n (config file default)

sdb: uid = 3600144f09307fd8700004fb0babc0002 (callout)

sdb: getprio = NULL (internal default)

sdb: prio = 1

sdc: blacklisted

sdd: not found in pathvec

sdd: mask = 0x1f

sdd: bus = 1

sdd: dev_t = 8:48

sdd: size = 2147483648

sdd: vendor = SUN

sdd: product = ZFS Storage 7320

sdd: rev = 1.0

sdd: h:b:t:l = 3:0:3:1

sdd: tgt_node_name = 0x20000024ff3b6fb6

sdd: serial =     

sdd: path checker = readsector0 (config file default)

sdd: checker timeout = 60000 ms (sysfs setting)

sdd: state = 2

sdd: getuid = /sbin/scsi_id -g -u -s /block/%n (config file default)

sdd: uid = 3600144f09307fd8700004fb0babc0002 (callout)

sdd: getprio = NULL (internal default)

sdd: prio = 1

sde: blacklisted

sr0: blacklisted

===== paths list =====

uuid      hcil    dev dev_t pri dm_st  chk_st  vend/pr

3600508e00000000082106bf5fc170406 0:1:0:0 sda 8:0   1   [undef][ready] Dell,VI

3600144f09307fd8700004fb0babc0002 3:0:0:1 sdb 8:16  1   [undef][ready] SUN,ZFS

3600144f09307fd8700004fb0babc0002 3:0:3:1 sdd 8:48  1   [undef][ready] SUN,ZFS

Found matching wwid [3600508e00000000082106bf5fc170406] in bindings file.

Setting alias to mpath0

sda: ownership set to mpath0

sda: not found in pathvec

sda: mask = 0xc

sda: state = 2

sda: prio = 1

mpath0: pgfailback = -2 (config file default)

mpath0: pgpolicy = multibus (config file default)

mpath0: selector = round-robin 0 (internal default)

mpath0: features = 0 (internal default)

mpath0: hwhandler = 0 (internal default)

mpath0: rr_weight = 1 (internal default)

mpath0: minio = 1000 (config file default)

mpath0: no_path_retry = -1 (config file default)

pg_timeout = NONE (internal default)

mpath0: set ACT_CREATE (map does not exist)

mpath0: failed to load map (a path might be in use)

mpath0: domap (0) failure for create/reload map

Found matching wwid [3600144f09307fd8700004fb0babc0002] in bindings file.

Setting alias to mpath1

sdb: ownership set to mpath1

sdb: not found in pathvec

sdb: mask = 0xc

sdb: state = 2

sdb: prio = 1

sdd: ownership set to mpath1

sdd: not found in pathvec

sdd: mask = 0xc

sdd: state = 2

sdd: prio = 1

mpath1: pgfailback = -2 (config file default)

mpath1: pgpolicy = multibus (config file default)

mpath1: selector = round-robin 0 (internal default)

mpath1: features = 0 (internal default)

mpath1: hwhandler = 0 (internal default)

mpath1: rr_weight = 1 (internal default)

mpath1: minio = 1000 (config file default)

mpath1: no_path_retry = -1 (config file default)

pg_timeout = NONE (internal default)

mpath1: set ACT_CREATE (map does not exist)

create: mpath1 (3600144f09307fd8700004fb0babc0002)  SUN,ZFS Storage 7320

[size=1.0T][features=0][hwhandler=0][n/a]

\_ round-robin 0 [prio=2][undef]

 \_ 3:0:0:1 sdb 8:16  [undef][ready]

 \_ 3:0:3:1 sdd 8:48  [undef][ready]

创建文件系统并挂载:

[root@localhost mapper]# ll  /dev/mapper

crw------- 1 root root  10, 63 06-11 17:13 control

brw-rw---- 1 root disk 253,  0 06-12 10:51 mpath1

brw-rw---- 1 root disk 253,  1 06-12 10:51 mpath1p1

[root@localhost mapper]# mount  /dev/mapper/mpath1p1 /u1

mount: you must specify the filesystem type

[root@localhost mapper]# mkfs.ext3  /dev/mapper/mpath1p1

mke2fs 1.39 (29-May-2006)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

134217728 inodes, 268434093 blocks

13421704 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=4294967296

8192 block groups

32768 blocks per group, 32768 fragments per group

16384 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,

        102400000, 214990848

Writing inode tables: done                            

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 20 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@localhost mapper]#

[root@localhost mapper]# mount  /dev/mapper/mpath1p1  /u1

[root@localhost mapper]# df  -h

文件系统              容量  已用 可用 已用% 挂载点

/dev/sda3             223G  3.5G  208G   2% /

/dev/sda1              97M   12M   81M  13% /boot

tmpfs                 7.9G     0  7.9G   0% /dev/shm

/dev/mapper/mpath1p1 1008G  200M  957G   1% /u1

将挂载信息写入/etc/fstab :

[root@localhost vol]# cat /etc/fstab

LABEL=/                /        ext3    defaults        1 1

LABEL=/boot            /boot    ext3    defaults        1 2

/dev/mapper/mpath1p1   /u1      ext3    defaults        0 0

tmpfs                 /dev/shm  tmpfs   defaults        0 0

devpts                /dev/pts  devpts  gid=5,mode=620  0 0

sysfs                 /sys      sysfs   defaults        0 0

proc                  /proc     proc    defaults        0 0

LABEL=SWAP-sda2      swap       swap    defaults        0 0

更多参考:

AIX mount RedHat的NFS

误删除/dev/dsk 和/dev/rdsk 下的文件怎么办?

unary operator expected

bash: /root/.bash_profile: line 15: syntax error: unexpected end of file

Linux下如何查看文件秒级修改及访问时间

EM乱码解决

linux里端口转发

windows xp 下使用FileZilla密钥

java.net.SocketException: Too many open files 问题的解决办法

UNExcepted inconsistency; run fsck manually

如何修改linux的mac地址?

mysqldump: Got error: 1066: Not unique table/alias

rsync详解一

rsync详解二

更改mysql的默认安装目录

httpd: apr_sockaddr_info_get() failed for centos1113

Real domain name required for sender address

Connection refused by [127.0.0.1]

MySQL bin_log文件占用空间太大

Centos 5 多路径配置步骤

rpc mount export: RPC: Unable to receive; errno = No route to host

nohup和screen的比较

vmware workstation 8 共享磁盘

Initializing the Oracle ASMLib driver: [FAILED]

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息