澳门新萄京官方网站-www.8455.com-澳门新萄京赌场网址

tune2fs调解保留块百分比,Linux下选取tune2fs命令来

2019-08-31 作者:澳门新萄京官方网站   |   浏览(168)

[20180806]tune2fs调整保留块百分比.txt

在Linux下让我们利用tune2fs来查看和硬盘有关的参数吧,也许这里有你所需的信息:

linux中inode是个什么概念呢?简单的说inode是一个不能重复的标号一样,每个文件或目录对应一个inode值,那个inode包含哪些部分,有什么作用呢?这里拿ext3文件系统的inode数据结构来说:
struct ext3_inode {
 __u16 i_mode;    /* File mode */
 __u16 i_uid;     /* Low 16 bits of Owner Uid */
 __u32 i_size;    /* 文件大小,单位是 byte */
 __u32 i_atime;   /* Access time 访问时间*/
 __u32 i_ctime;   /* Creation time 创建时间*/
 __u32 i_mtime;   /* Modification time 修改时间*/
 __u32 i_dtime;   /* Deletion Time 删除时间*/
 __u16 i_gid;     /* Low 16 bits of Group Id */
 __u16 i_links_count;          /* Links count */
 __u32 i_blocks;               /* blocks 计数 */
 __u32 i_flags;                /* File flags */
 __u32 l_i_reserved1;          /* 可以忽略 */
 __u32 i_block[EXT3_N_BLOCKS]; /* 一组 block 指针 ,指向数据文件在磁盘上的指针*/
 __u32 i_generation;           /* 可以忽略 */
 __u32 i_file_acl;             /* 可以忽略 */
 __u32 i_dir_acl;              /* 可以忽略 */
 __u32 i_faddr;                /* 可以忽略 */
 __u8  l_i_frag;               /* 可以忽略 */
 __u8  l_i_fsize;              /* 可以忽略 */
 __u16 i_pad1;                 /* 可以忽略 */
 __u16 l_i_uid_high;           /* 可以忽略 */
 __u16 l_i_gid_high;           /* 可以忽略 */
 __u32 l_i_reserved2;          /* 可以忽略 */
};
之前在(浅析ext3删除文件慢的原因 http://www.linuxidc.com/Linux/2012-05/59492.htmtune2fs调解保留块百分比,Linux下选取tune2fs命令来查看硬盘相关新闻。)也简单研究过它。

blockdev命令  blkid命令  lsblk命令

[root@localhost ~]# tune2fs -l /dev/sda1
tune2fs 1.39 (29-May-2006)
Filesystem volume name:   /boot
Last mounted on:          <not available>
Filesystem UUID:          b6bbfdcc-6fc2-42b6-9585-19790e22c951
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery sparse_super
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              32128
Block count:              128488
Reserved block count:     6424
Free blocks:              113011
Free inodes:              32093
First block:              1
Block size:               1024
Fragment size:            1024
Reserved GDT blocks:      256
Blocks per group:         8192
Fragments per group:      8192
Inodes per group:         2008
Inode blocks per group:   251
Filesystem created:       Fri Sep 17 18:33:57 2010
Last mount time:          Fri Sep 17 14:30:30 2010
Last write time:          Fri Sep 17 14:30:30 2010
Mount count:              5
Maximum mount count:      -1
Last checked:             Fri Sep 17 18:33:57 2010
Check interval:           0 (<none>)
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               128
Journal inode:            8
Default directory hash:   tea
Directory Hash Seed:      414fec59-16a9-459a-8c84-b405e8c1678e
Journal backup:           inode blocks 

--//生产系统一台dg磁盘空间满了.我前一阵子已经将*convert参数修改,增加磁盘,但是这个分区里面的数据文件还可以增长,这样依旧存
--//在磁盘空间不足的情况,正常应该移动数据文件到别的分区,然后rename.突然想起建立分区时有一定的保留区给root用户,我们这个分
--//区磁盘很大接近2T,这样按照5%的比例计算,有将近100G的空间可能浪费了.

[root@localhost ~] ~# tune2fs -l /dev/sdc1
tune2fs 1.35 (28-Feb-2004)
Filesystem volume name: /data2
Last mounted on: <not available>
Filesystem UUID: cc571d4e-715d-43fa-802b-50e30a3ccb16
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal resize_inode filetype needs_recovery sparse_super large_file
Default mount options: (none)
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 36634624
Block count: 73240327
Reserved block count: 3662016
Free blocks: 72066127
Free inodes: 36634613
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 1024
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 16384
Inode blocks per group: 512
tune2fs调解保留块百分比,Linux下选取tune2fs命令来查看硬盘相关新闻。Filesystem created: Sat Jun 21 06:38:52 2008
Last mount time: Sat Jun 21 06:41:59 2008
Last write time: Sat Jun 21 06:41:59 2008
Mount count: 1
Maximum mount count: 34
Last checked: Sat Jun 21 06:38:52 2008
Check interval: 15552000 (6 months)
Next check after: Thu Dec 18 06:38:52 2008
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128
Journal inode: 8
Default directory hash: tea
Directory Hash Seed: db692f72-bbb3-43d4-8011-1664854a8364
Journal backup: inode blocks
[root@localhost ~] ~# tune2fs -l /dev/sde1
tune2fs 1.35 (28-Feb-2004)
Filesystem volume name: /data3
Last mounted on: <not available>
Filesystem UUID: 68985487-0e63-4c7c-a5f6-e2f36da55d33
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal resize_inode filetype needs_recovery sparse_super large_file
Default mount options: (none)
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 36634624
Block count: 73240327
Reserved block count: 3662016
Free blocks: 72066127
Free inodes: 36634613
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 1024
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 16384
Inode blocks per group: 512
Filesystem created: Sat Jun 21 06:40:24 2008
Last mount time: Sat Jun 21 06:41:59 2008
Last write time: Sat Jun 21 06:41:59 2008
Mount count: 1
Maximum mount count: 26
Last checked: Sat Jun 21 06:40:24 2008
Check interval: 15552000 (6 months)
Next check after: Thu Dec 18 06:40:24 2008
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 128
Journal inode: 8
Default directory hash: tea
Directory Hash Seed: 17a1e87f-434b-468d-8048-9a35b66b227c
Journal backup: inode blocks
[root@localhost ~] ~#

因为inode主要是占用磁盘空间的,那么今天就讨论一下inode分配与占用磁盘问题,之前听人说xfs文件系统inode占用的磁盘空间达到了相当多G,当然这是因为他的文件系统本来就是用来存放小文件的,所以导致inode占用的空间也很大。

几个常用的参数
-c:表示文件系统在mount次数达到设定后,需要运行fsck检查文件系统。
-i:文件系统的检查间隔时间。系统在达到时间间隔时,自动检查文件系统。
-l:显示文件系统的参数的详细信息。
-j:转换为ext3文件系统。
-m: 设置保留的空间百分比
-o: 设置默认加载参数
-I 设置自检天数

--//参考以前测试的链接:
--//注意如果在mount状态下修改无效!!

[ The End ]

在你为一个硬盘或是分区建好文件系统以后,文件系统已经确定了这块硬盘或是分区最后能有多少inode被分配,这些inode能占用多大的空间。查看一个硬盘或分区的文件系统信息,可以通过dumpe2fs -h device_name 来查看,比如我的系统中一个分区/dev/sda8 (ext3)
$ dumpe2fs -h /dev/sda8

block相关的命令

查看os系统页的大小

1.环境:
# cat /proc/version
Linux version 2.6.39-300.26.1.el5uek (mockbuild@ca-build56.us.oracle.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-52)) #1 SMP Thu Jan 3 18:31:38 PST 2013

澳门新萄京官方网站 1

dumpe2fs 1.41.12 (17-May-2010)
Filesystem volume name:   home
Last mounted on:          <not available>
Filesystem UUID:          78a58693-dc1a-43c0-9eaf-6c0807626c14
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery sparse_super large_file
Filesystem flags:         signed_directory_hash 
Default mount options:    (none)
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              16318464
Block count:              65241965
Reserved block count:     652419
Free blocks:              58319070
Free inodes:              16135620
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      1008
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
Filesystem created:       Fri Oct 14 16:13:01 2011
Last mount time:          Wed Feb 29 16:29:51 2012
Last write time:          Wed Feb 29 16:29:51 2012
Mount count:              5
Maximum mount count:      -1
Last checked:             Fri Oct 14 16:13:01 2011
Check interval:           0 (<none>)
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
澳门新萄京官方网站,First inode:              11
Inode size:          256
Required extra isize:     28
Desired extra isize:      28
Journal inode:            8
First orphan inode:       8437776
Default directory hash:   half_md4
Directory Hash Seed:      0eddc0e6-7fa9-4226-8534-59b633b5e88b
Journal backup:           inode blocks
Journal features:         journal_incompat_revoke
日志大小:             128M
Journal length:           32768
Journal sequence:         0x006cea77
Journal start:            3735澳门新萄京官方网站 2

 

[root@localhost ~]# getconf PAGESIZE
4096

# df -h /u02
Filesystem            Size  Used Avail Use% Mounted on
/dev/cciss/c0d1p1     1.7T  1.6T   20G  99% /u02
--//剩余20G.

这篇文章主要介绍了Linux blockdev命令设置文件预读大小介绍,blockdev 工具允许从命令行调用区块设备控制程序,本文就讲解了它的使用实例,需要的朋友可以参考下

getconf命令是将系统配置变量值写入标准输出。

# tune2fs -l /dev/cciss/c0d1p1
tune2fs 1.39 (29-May-2006)
Filesystem volume name:   /u02
Last mounted on:          <not available>
Filesystem UUID:          d9c0c411-25ea-4e21-b383-3ef446d2c064
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal resize_inode dir_index filetype needs_recovery sparse_super large_file
Default mount options:    (none)
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              219774976
Block count:              439520246
Reserved block count:     21976012

在命令行调用设备的ioctl函数。在Linux系统中,似乎对设备的直接操作只有ioctl函数了。他接受的参数不是太多,而且都是一一对应的。

getconf  -a   查看可显示的系统设置值 

Free blocks:              432573167  
Free inodes:              219774965  
First block:              0  
Block size:               4096

blockdev - 从命令行调用区块设备控制程序

另:系统块大小设置

Fragment size:            4096
Reserved GDT blocks:      919
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         16384
Inode blocks per group:   512
Filesystem created:       Thu Feb 23 09:42:17 2017
Last mount time:          Thu Feb 23 09:55:13 2017
Last write time:          Thu Feb 23 09:55:13 2017
Mount count:              3
Maximum mount count:      -1
Last checked:             Thu Feb 23 09:42:17 2017
Check interval:           0 (<none>)
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               128
Journal inode:            8
Default directory hash:   tea
Directory Hash Seed:      6e38ec2b-9916-496f-a143-b9b22a7e1f09
Journal backup:           inode blocks

blockdev [options] commands devices

创建文件系统时,可以指定块的大小。如果文件系统中大多是较大的文件,使用较大的块大小将得到较好的性能。如块大小调整为4096byte而不是缺省的1024byte,可以减少文件碎片,加快fsck扫描的速度和文件删除以及读操作的速度。
在文件系统中,为根目录保留了5%的空间。
块过大虽性能有所提高,但会造成磁盘空间较大的浪费。故需在性能和磁盘的代价上平衡。
如:mkfs.ext3 -b 1024 -i 4096 /dev/sda1  //改变block size,使4个block与1个inode相对应,好处是对大文件来说节省空间,节省inode数量,整个系统所能存储的文件数较多。

--//21976012*4096/1024/1024/1024 = 83.83183288574218750000,保留84G.
--//实际上-m 1也是浪费,我采用-r参数保留一定数量的块.
--//保留1G ,1024*1024*1024/4096 = 262144

blockdev 工具允许从命令行调用区块设备控制程序。

澳门新萄京官方网站 3

2.调整保留块百分比:
--//关闭数据库.
SYS@xxxxdg> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.

--getra 读取预读值
--getfra 读取文件系统预读
--setfra FSREADAHEAD 设置文件系统预读
--setra READAHEAD 设置设备预读
--getra 读取设备的预读值
--setbsz BLOCKSIZE 在文件描述符打开块设备的时候设置块大小
--getioopt 读取设备优化IO大小
--getiomin 读取设备最小IO大小
-–setro 设置设备为只读
-–getro 读取设备是否为只读(成功为1,0则为可读写)
-–setrw 设置设别为可读写
-–getss 打印设备的扇区大小也叫逻辑块大小,通常是512
--getpbsz 读取设备物理块大小,通常是4096
--getbsz 读取设备块大小,通常是4096
-–getsize(-getsz) 打印设备的容量,按照一个扇区512个字节计算
--getsize64 打印设备的容量,以字节为单位显示
-–setra N 设置预读扇区(512字节)为N个.Set readahead to N 512-byte sectors.
-–getra 打印readahead(预读扇区)
-–flushbufs 刷新缓冲
-–rereadpt 重读分区表。

# umount /dev/cciss/c0d1p1
umount: /u02: device is busy
umount: /u02: device is busy

觉得–setro,setrw比较有用,这个mount -o ro(rw)是有区别的,mount是在文件系统这个级别上对某个分区挂载为只读或可读写。而blockdev则是在设别这个级别上设置为只读和可读写。
看下面的命令输出结果就一目了然了。

# lsof /u02
COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
tnslsnr 9361 oracle  cwd    DIR 104,17     4096    2 /u02
--//奇怪.监听进程怎么会关联到/u02

 

# cat /proc/9361/environ  | tr '' 'n'| grep u02
PWD=/u02

[root@lancy ~]# blockdev –setro /dev/hda4
[root@lancy ~]# blockdev –getro /dev/hda4
1
[root@lancy ~]# mount /dev/hda4 /misc -o rw
mount: block device /dev/hda4 is write-protected, mounting read-only
[root@lancy ~]# umount /dev/hda4
[root@lancy ~]# blockdev –setrw /dev/hda4
[root@lancy ~]# blockdev –getro /dev/hda4
0
[root@lancy ~]# mount /dev/hda4 /misc -o rw
[root@lancy ~]# touch /misc/one
[root@lancy ~]# umount /dev/hda4
[root@lancy ~]# mount /dev/hda4 /misc -o ro
[root@lancy ~]# rm -f /misc/one
rm: 无法删除‘/misc/one’: 只读文件系统

--//原来当时监听启动时的目录是/u02,停止监听进程.
$ lsnrctl stop
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 06-AUG-2018 08:29:12
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.76)(PORT=1521)))
The command completed successfully

 

# sync;sync
# umount /dev/cciss/c0d1p1
# tune2fs -r 262144 /dev/cciss/c0d1p1
tune2fs 1.39 (29-May-2006)
Setting reserved blocks count to 262144

刷新buffer

# tune2fs -l /dev/cciss/c0d1p1 | egrep "Reserved block count"
Reserved block count:     262144

free -m
total used free shared buffers cached
Mem: 15907 15665 242 0 158 4702
-/ buffers/cache: 10803 5104
Swap: 7999 0 7999

# mount /u02
# df -h /u02
Filesystem            Size  Used Avail Use% Mounted on
/dev/cciss/c0d1p1     1.7T  1.6T  103G  94% /u02

# blockdev --flushbufs /dev/sda5
# free -m
total used free shared buffers cached
Mem: 15907 15536 371 0 31 4702
-/ buffers/cache: 10802 5105
Swap: 7999 0 7999

--//现在多了83G,应该不会再遇到磁盘空间不足的问题在/u02分区.

 

3.启动数据库.略.
$ lsnrctl start


SYS@xxxxdg> startup open read only;
ORACLE instance started.

 

Total System Global Area 8.0973E 10 bytes
Fixed Size                  2261968 bytes
Variable Size            9663679536 bytes
Database Buffers         7.1135E 10 bytes
Redo Buffers              171487232 bytes
Database mounted.
Database opened.

tune2fs命令

DGMGRL> show database xxxxdg
Database - xxxxdg
  Enterprise Manager Name: xxxx_dg
  Role:                    PHYSICAL STANDBY
  Intended State:          APPLY-ON
  Transport Lag:           0 seconds (computed 0 seconds ago)
  Apply Lag:               0 seconds (computed 0 seconds ago)
  Apply Rate:              34.40 MByte/s
  Real Time Query:         ON
  Instance(s):
    xxxxdg
Database Status:
SUCCESS

查看文件系统信息

tune2fs -l /dev/sda5
tune2fs 1.41.12 (17-May-2010)
Filesystem volume name: <none>
Last mounted on: /data
Filesystem UUID: 35389d47-d4ed-406d-a8b8-2c7a69cfa4ce
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize
Filesystem flags: signed_directory_hash
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 58589184
Block count: 234333952
Reserved block count: 11716697
Free blocks: 226871715
Free inodes: 58589166
First block: 0
Block size: 4096
Fragment size: 4096
Reserved GDT blocks: 968
Blocks per group: 32768
Fragments per group: 32768
Inodes per group: 8192
Inode blocks per group: 512
RAID stride: 1
Flex block group size: 16
Filesystem created: Tue Jul 26 16:18:18 2016
Last mount time: Wed Aug 3 08:42:19 2016
Last write time: Wed Aug 3 08:42:19 2016
Mount count: 8
Maximum mount count: -1
Last checked: Tue Jul 26 16:18:18 2016
Check interval: 0 (<none>)
Lifetime writes: 14 GB
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 256
Required extra isize: 28
Desired extra isize: 28
Journal inode: 8
First orphan inode: 38666243
Default directory hash: half_md4
Directory Hash Seed: d4449666-888f-4552-aa4d-eccde1fda9e1
Journal backup: inode blocks


blkid命令

另一个和block有关的命令

blkid

blkid
/dev/vda1: UUID="fb1d72cf-8058-40e6-8b25-58f9759e1cf9" TYPE="ext3"
/dev/vdb1: UUID="0169c89a-fe36-4b3d-b0ef-0d11497aca9e" TYPE="ext4"
/dev/vdc1: UUID="2da0e026-dbd5-4c9c-9b0d-3574a3403b2b" TYPE="swap"

 


 

 

lsblk命令

 

lsblk把所有磁盘和分区显示出来,uuid也可以显示出来

 

lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 252:0 0 8G 0 disk
└─vda1 252:1 0 8G 0 part /
vdb 252:16 0 10G 0 disk
└─vdb1 252:17 0 9G 0 part /data
vdc 252:32 0 2G 0 disk
└─vdc1 252:33 0 2G 0 part [SWAP]

 

显示uuid

lsblk -f
NAME FSTYPE LABEL UUID MOUNTPOINT
vda
└─vda1 ext3 fb1d72cf-8058-40e6-8b25-58f9759e1cf9 /
vdb
└─vdb1 ext4 0169c89a-fe36-4b3d-b0ef-0d11497aca9e /data
vdc swap lswap 887348e5-e421-470a-b5e5-e6bed3619e3c
└─vdc1 swap 2da0e026-dbd5-4c9c-9b0d-3574a3403b2b [SWAP]

 

显示所有设备

lsblk -a
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 0 loop
loop1 7:1 0 0 loop
loop2 7:2 0 0 loop
loop3 7:3 0 0 loop
loop4 7:4 0 0 loop
loop5 7:5 0 0 loop
loop6 7:6 0 0 loop
loop7 7:7 0 0 loop
vda 252:0 0 8G 0 disk
└─vda1 252:1 0 8G 0 part /
vdb 252:16 0 10G 0 disk
└─vdb1 252:17 0 9G 0 part /data
vdc 252:32 0 2G 0 disk
└─vdc1 252:33 0 2G 0 part [SWAP]

 

f

本文由澳门新萄京官方网站发布于澳门新萄京官方网站,转载请注明出处:tune2fs调解保留块百分比,Linux下选取tune2fs命令来

关键词: