成都网站建设设计

将想法与焦点和您一起共享

linux查看多路径命令 linux 查看当前路径大小

linux查看目录下文件的命令

linux中查看文件和目录的命令是:LS

创新互联是一家从事企业网站建设、网站建设、成都网站建设、行业门户网站建设、网页设计制作的专业网站制作公司,拥有经验丰富的网站建设工程师和网页设计人员,具备各种规模与类型网站建设的实力,在网站建设领域树立了自己独特的设计风格。自公司成立以来曾独立设计制作的站点1000多家。

LS英文原意:list,命令所在路径:/bin/ls,适用于所有用户权限,主要功能就是以列表形式显示目录文件。

其语法: ls 选项【-ald】【文件或目录】

其中,-a 显示所有文件,包括隐藏文件;

-l 详细信息显示;

-d 仅显示目录名,而不显示目录下的内容列表;

-h 人性化显示(hommization);

-i 查看任意一个文件的i节点(类似于身份证唯一信息);

-t 用文件和目录的更改时间排序;可以用第一个显示的文件判断最近修改的文件;

注意:. 开头的文件除非是目录,否则就是隐藏文件

扩展资料:

创建目录命令:mkdir,英文原意:make directories,命令所在路径:/bin/mkdir,适用于所有用户权限,功能在于创建新的目录。

其语法: mkdir 【-p】【目录名】

-p 递归创建

例子:a)创建单个目录:mkdir /tmp/vae.txt

b)创建多个目录:mkdir /tmp/a.txt /tmp/b.txt

使用时的注意事项:

1、创建的目录已经存在, 那么 Linux 会提示我们 Linux 无法创建它。

2、不带任何参数运行 mkdir 命令会在当前目录下创建目录。

3、不带上-p,如果新建的文件上级目录不存在则不会执行成功这种说法是错误的。加或者不加上 -p 前面的目录没有得都会依次创建。

4、创建目录的首要条件是, 在想要创建目录的目标路径下你必须具有访问权限。

如何使用Linux自带多路径DM

一、多路径解释

多路径,顾名思义就是有多种选择的路径。在SAN或IPSAN环境,主机和存储之间外加了光纤交换机,这就导致主机和存储之间交换速度和效率增强,一条路径肯定是不行的,也是不安全不稳定的。多路径就是要来解决从主机到磁盘之间最快,最高效的问题。主要实现如下几个功能

故障的切换和恢复

IO流量的负载均衡

磁盘的虚拟化

多路径之前一直是存储厂商负责解决,竟来被拆分出来单独卖钱了。

构架基本是这样的:存储,多路径软件,光纤交换机,主机,主机系统。

二、LINUX下的multipath

1、查看是否自带安装?

1

2

3

4

5

6

[root@web2 multipath]# rpm -qa|grep device

device-mapper-1.02.39-1.el5

device-mapper-1.02.39-1.el5

device-mapper-multipath-0.4.7-34.el5

device-mapper-event-1.02.39-1.el5

[root@web2 multipath]#

2、安装

1

2

3

4

5

6

rpm -ivh device-mapper-1.02.39-1.el5.rpm #安装映射包

rpm -ivh device-mapper-multipath-0.4.7-34.el5.rpm #安装多路径包

外加加入开机启动

chkconfig –level 2345 multipathd on #设置成开机自启动multipathd

lsmod |grep dm_multipath #来检查安装是否正常

3、配置

1

2

3

4

5

6

7

8

9

10

11

12

13

14

# on the default devices.

blacklist {

devnode "^(ram|raw|loop|fd|md|dm-|sr|sr|scd|st)[0-9]*"

devnode "^hd[a-z]"

}

devices {

device {

vendor "HP"

path_grouping_policy multibus

features "1 queue_if_no_path"

path_checker readsector()

failback immediate

}

}brbr完整的配置如下:

blacklist {

devnode "^sda"

}

defaults {

user_friendly_names no

}

multipaths {

multipath {

wwid 14945540000000000a67854c6270b4359c66c272e2f356321

alias iscsi-dm0

path_grouping_policy multibus

path_checker tur

path_selector "round-robin 0"

}

multipath {

wwid 14945540000000000dcca2eda91d70b81edbcfce2357f99ee

alias iscsi-dm1

path_grouping_policy multibus

path_checker tur

path_selector "round-robin 0"

}

multipath {

wwid 1494554000000000020f763489c165561101813333957ed96

alias iscsi-dm2

path_grouping_policy multibus

path_checker tur

path_selector "round-robin 0"

}

multipath {

wwid 14945540000000000919ca813020a195422ba3663e1f03cc3

alias iscsi-dm3

path_grouping_policy multibus

path_checker tur

path_selector "round-robin 0"

}

}

devices {

device {

vendor "iSCSI-Enterprise"

product "Virtual disk"

path_grouping_policy multibus

getuid_callout "/sbin/scsi_id -g -u -s /block/%n"

path_checker readsector0

path_selector "round-robin 0"

}

}

4、命令

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

[root@web2 ~]# multipath -h

multipath-tools v0.4.7 (03/12, 2006)

Usage: multipath [-v level] [-d] [-h|-l|-ll|-f|-F|-r]

[-p failover|multibus|group_by_serial|group_by_prio]

[device]

-v level verbosity level

0 no output

1 print created devmap names only

2 default verbosity

3 print debug information

-h print this usage text

-b file bindings file location

-d dry run, do not create or update devmaps

-l show multipath topology (sysfs and DM info)

-ll show multipath topology (maximum info)

-f flush a multipath device map

-F flush all multipath device maps

-r force devmap reload

-p policy force all maps to specified policy :

failover 1 path per priority group

multibus all paths in 1 priority group

group_by_serial 1 priority group per serial

group_by_prio 1 priority group per priority lvl

group_by_node_name 1 priority group per target node

device limit scope to the device's multipath

(udev-style $DEVNAME reference, eg /dev/sdb

or major:minor or a device map name)

[root@web2 ~]#

5、启动关闭

1

2

3

4

# /etc/init.d/multipathd start #开启mulitipath服务

service multipath start

service multipath restart

service multipath shutdown

6、如何获取wwid

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

1、

[root@vxfs01 ~]# cat /var/lib/multipath/bindings

# Multipath bindings, Version : 1.0

# NOTE: this file is automatically maintained by the multipath program.

# You should not need to edit this file in normal circumstances.

#

# Format:

# alias wwid

#

mpath0 36006016051d50e0035744871c912de11

mpath1 36006016051d50e0034744871c912de11

mpath2 36006016051d50e0032744871c912de11

mpath3 36006016051d50e0039744871c912de11

mpath4 36006016051d50e003a744871c912de11

2、

[root@vxfs01 ~]# multipath -v3 |grep 3600

sdb: uid = 36006016051d50e003a744871c912de11 (callout)

sdc: uid = 36006016051d50e003a744871c912de11 (callout)

sdd: uid = 36006016051d50e003a744871c912de11 (callout)

sde: uid = 36006016051d50e003a744871c912de11 (callout)

36006016051d50e003a744871c912de11 1:0:0:0 sdb 8:16 0 [undef][ready] DGC,RAI

36006016051d50e003a744871c912de11 1:0:1:0 sdc 8:32 1 [undef][ready] DGC,RAI

36006016051d50e003a744871c912de11 2:0:0:0 sdd 8:48 1 [undef][ready] DGC,RAI

36006016051d50e003a744871c912de11 2:0:1:0 sde 8:64 0 [undef][ready] DGC,RAI

Found matching wwid [36006016051d50e003a744871c912de11] in bindings file.

比较详细的文字:

RHEL官网资料:

Linux系统怎么配置多路径

Linux多路径指的是除了主机和硬盘一条路径的连接,还包括了主机和网络服务器的连接形成的主机一对多的路径连接关系。通过多路径的连接,实现了磁盘的虚拟化。

1、安装多路径软件包:

device-mapper-1.02.67-2.el5

device-mapper-event-1.02.67.2.el5

device-mapper-multipath-0.4.7-48.el5

[root@RKDB01 Server]# rpm -ivh device-mapper-1.02.67-2.el5.x86_64.rpm

warning: device-mapper-1.02.67-2.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 37017186

Preparing.。。 ########################################### [100%]

package device-mapper-1.02.67-2.el5.x86_64 is already installed

[root@RKDB01 Server]# rpm -ivh device-mapper-event-1.02.67-2.el5.x86_64.rpm

warning: device-mapper-event-1.02.67-2.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 37017186

Preparing.。。 ########################################### [100%]

package device-mapper-event-1.02.67-2.el5.x86_64 is already installed

[root@RKDB01 Server]# rpm -ivh device-mapper-multipath-0.4.7-48.el5.x86_64.rpm

warning: device-mapper-multipath-0.4.7-48.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 37017186

Preparing.。。 ########################################### [100%]

package device-mapper-multipath-0.4.7-48.el5.x86_64 is already installed

2、设置开机启动,并检查安装包是否正常:

chkconfig --level 345 multipathd on

lsmod |grep dm_multipath

[root@RKDB01 Server]# chkconfig --level 345 multipathd on

[root@RKDB01 Server]# lsmod |grep dm_multipath

dm_multipath 58969 0

scsi_dh 42561 1 dm_multipath

dm_mod 102417 4 dm_mirror,dm_multipath,dm_raid45,dm_log

[root@RKDB01 Server]#

3、配置multipathd 使其正常工作,编辑/etc/multipath.conf,开放如下内容:

defaults {

udev_dir /dev

polling_interval 10

selector “round-robin 0”

path_grouping_policy multibus

getuid_callout “/sbin/scsi_id -g -u -s /block/%n”

prio_callout none

path_checker readsector0

rr_min_io 100

max_fds 8192

rr_weight priorities

failback immediate

no_path_retry fail

user_friendly_names yes

}

blacklist {

wwid 26353900f02796769

devnode “^(ram|raw|loop|fd|md|dm-|sr|scd|st)[0-9]*”

devnode “^hd[a-z]”

}

4、并关闭如下内容

#blacklist {

# devnode “*”

#}

#defaults {

27 # user_friendly_names yes

28 #}

5、完成之后执行如下命令发现多路径:

[root@RKDB01 Server]# modprobe dm-multipath

[root@RKDB01 Server]# multipath -F

[root@RKDB01 Server]# multipath dm-multipath

[root@RKDB01 Server]# multipath dm-round-robin

[root@RKDB01 Server]# service multipathd restart

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

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

[root@RKDB01 Server]# multipath -v2

[root@RKDB01 Server]# multipath -v2

[root@RKDB01 Server]# multipath -ll

mpath1 (3600d02310000011b16a5d57c6a1bd99a) dm-0 TOYOU,NetStor_iSUM510

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

\_ round-robin 0 [prio=2][ena bled]

\_ 1:0:0:0 sdb 8:16 [failed][ready]

\_ 1:0:1:0 sdc 8:32 [failed][ready]

[root@RKDB01 Server]#

6、重启服务器后,可以看到多路径信息了:

[root@RKDB01 ~]# ll /dev/mapper/

总计 0

crw------- 1 root root 10, 60 11-05 22:35 control

brw-rw---- 1 root disk 253, 0 11-05 22:35 mpath1

brw-rw---- 1 root disk 253, 1 11-05 22:35 mpath2

[root@RKDB01 ~]# multipath -ll

mpath2 (3600d02310000011b76128b9c63138cf4) dm-1 TOYOU,NetStor_iSUM510

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

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

\_ 1:0:0:1 sdc 8:32 [active][ready]

\_ 1:0:1:1 sde 8:64 [active][ready]

mpath1 (3600d02310000011b16a5d57c6a1bd99a) dm-0 TOYOU,NetStor_iSUM510

[size=20G][features=0][hwhandler=0][rw]

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

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

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

7、通过fdisk 看可以生成了DM-0/DM-1两个盘,正是上面sdc/sde,sdb/sdd多路径后出来的:

[root@RKDB01 ~]# 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 38 305203+ 83 Linux

/dev/sda2 39 13092 104856255 83 Linux

/dev/sda3 13093 19619 52428127+ 83 Linux

/dev/sda4 19620 36404 134825512+ 5 Extended

/dev/sda5 19620 26146 52428096 83 Linux

/dev/sda6 26147 28757 20972826 83 Linux

/dev/sda7 28758 30324 12586896 82 Linux swap / Solaris

/dev/sda8 30325 36404 48837568+ 83 Linux

Disk /dev/sdb: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

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

Disk /dev/sdc: 3568.4 GB, 3568429957120 bytes

255 heads, 63 sectors/track, 433836 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn’t contain a valid partition table

Disk /dev/sdd: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

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

Disk /dev/sde: 3568.4 GB, 3568429957120 bytes

255 heads, 63 sectors/track, 433836 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sde doesn’t contain a valid partition table

Disk /dev/dm-0: 21.4 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/dm-0 doesn‘t contain a valid partition table

Disk /dev/dm-1: 3568.4 GB, 3568429957120 bytes

255 heads, 63 sectors/track, 433836 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/dm-1 doesn’t contain a valid partition table

Disk /dev/sdf: 4009 MB, 4009754624 bytes

255 heads, 63 sectors/track, 487 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sdf4 * 1 488 3915744+ b W95 FAT32

Partition 4 has different physical/logical endings:

phys=(486, 254, 63) logical=(487, 125, 22)

[root@RKDB01 ~]#

8、同时也可以在/dev/mapper目录中查看到多路径映射的信息:

[root@RKDB01 ~]# ll /dev/mapper/

总计 0

crw------- 1 root root 10, 60 11-06 00:49 control

brw-rw---- 1 root disk 253, 2 11-06 00:49 data-data001

brw-rw---- 1 root disk 253, 0 11-06 00:49 mpath1

brw-rw---- 1 root disk 253, 1 11-06 00:49 mpath2


网站栏目:linux查看多路径命令 linux 查看当前路径大小
链接URL:http://chengdu.cdxwcx.cn/article/ddojoeg.html