磁盘配额管理
先划分分区,使用fdisk划分分区
创建文件系统
迁移用户家目录
- [root@centos6 rf]# mkfs.ext4 /dev/sdc1 创建文件系统这里以ext4文件系统为例
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655776 inodes, 2622603 blocks
131130 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2688548864
81 block groups
32768 blocks per group, 32768 fragments per group
8096 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Writing inode tables: 16done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override
- 创建一个临时挂载点,并挂载
- mkdir /chxi
- mount /dev/sdc1 /chenxi
编辑/etc/fstab添加“UUID=9bf7fc97-fbb4-458c-9fda-02d410aa342a /home ext4 defaults,usrquota,grpquota 1 0 ” 注意挂载选项后面跟urquota表示支持用户磁盘配额 - 查看指定设备的UUID
- [root@centos6 ~]# blkid /dev/sdc1
/dev/sdc1: UUID="9bf7fc97-fbb4-458c-9fda-02d410aa342a" TYPE="ext4" 查看指定设备的UUID - 默认选项后加,usrquota 表示支持用户磁盘配额 grpquota表示持 组配额
- mkdir /chxi 创建挂载点
- mount /dev/sdc1 /chxi/ 把/dev/sdc1 挂载至chxi
- cp -a /home/* /chxi/ 拷贝home 下所有数据到chxi目录下
- mount -a 挂载在/etc/fstab 文件中未挂载的设备
- cp -a /chxi/* /home/ 拷贝chxi目录下所有数据到home目录下
- quotacheck -cug /home 初始化磁盘配额数据库指定目录
- setenforce 0 关闭seLinux
- quotaon /home 创建磁盘配额数据库指定目录
- quotaon -p /home 查看是否启用磁盘配额数据库
- edquota cx 对用户做限额 或者 在shell 中直接编辑 setquota usename 4096 5120 40 50 目录;再者edquota -p user1 user2
edquota: Cannot open quotafile /home/aquota.user: Permission denied
Disk quotas for user cx (uid 501):
Filesystem blocks 以用的空间 soft 软的空间大小设置 hard 硬限制的空间大小 inodes inodes节点的使用 soft节点的软设置 hard节点的硬设置
/dev/sdc1 36 0 0 9 0 0
/dev/sdd1 0 0 0 0 0 0
- edquota -g 指定的组名
- 注意这里不对用户的附加组生效,可以把用户的附加组切换成主组
- 用户调查:quota username
- 配额概述:repquota /mountpoint
- 其它工具:warnquota
RAID 管理
什么是RAID
RAID:Redundant Arrays of Inexpensive( (Independent) ) Disks
1988 年由加利福尼亚大学伯克利分校(University ofCalifornia-Berkeley))“ “A Case for RedundantArrays of Inexpensive Disks”
多个磁盘合成一个“阵列”来提供更好的性能、冗余,或者两者都提供
RAID
提高IO 能力:
磁盘并行读写
提高耐用性;
磁盘冗余来实现
级别:多块磁盘组织在一起的工作方式有所不同
RAID 实现的方式:
外接式磁盘阵列:通过扩展卡提供适配能力
内接式RAID :主板集成RAID 控制器
安装OS 前在BIOS 里配置
软件RAID :通过OS
RAID级别
RAID-0 :条带卷,strip
RAID-1: 镜像卷,mirror
RAID-2
RAID-5
RAID-10
RAID-01
RAID-0:
- 读、写性能提升;
- 可用空间:N*min(S1,S2,...)
- 无容错能力
- 最少磁盘数:2, 2
RAID-1:
- 读性能提升、写性能略有下降;
- 可用空间:1*min(S1,S2,...)
- 有冗余能力
- 最少磁盘数:2, 2N
RAID-4:
- 多块数据盘异或运算值,存 于
RAID-5:
- 读、写性能提升
- 可用空间:(N-1)*min(S1,S2,...)
- 有容错能力:允许最多1 块磁盘损坏
- 最少磁盘数:3, 3+
RAID-6:
- 读、写性能提升
- 可用空间:(N-2)*min(S1,S2,...)
- 有容错能力:允许最多2 块磁盘损坏
- 最少磁盘数:4, 4+
RAID-10:
- 读、写性能提升
- 可用空间:N*min(S1,S2,...)/2
- 有容错能力:每组镜像最多只能坏一块
- 最少磁盘数:4, 4+
RAID-01 、RAID-50
RAID7: 可以理解为一个独立存储计算机,自身带有操作系统和管理工具,可以独立运行,理论上性能最高的RAID 模式
JBOD :Just a Bunch Of Disks
功能:将多块磁盘的空间合并一个大的连续空间使用
- 可用空间:sum(S1,S2,...)
常用级别:RAID-0, RAID-1, RAID-5, RAID-10,RAID-50, JBOD
软RAID
- mdadm :为软RAID
- 为空余磁盘添加冗余
- 结合内核中的md(multi devices)
- RAID 设备可命名为/dev/md0 、/dev/md1 、/dev/md2、/dev/md3等
RAID的实现
查看磁盘分区情况
- [root@centos6 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 10G 0 part /boot
├─sda2 8:2 0 97.7G 0 part /
├─sda3 8:3 0 48.8G 0 part
├─sda4 8:4 0 1K 0 part
├─sda5 8:5 0 2G 0 part [SWAP]
├─sda6 8:6 0 10G 0 part
└─sda7 8:7 0 10G 0 part
sdb 8:16 0 200G 0 disk
├─sdb1 8:17 0 30G 0 part
├─sdb2 8:18 0 30G 0 part
├─sdb3 8:19 0 30G 0 part
└─sdb4 8:20 0 30G 0 part
sdc 8:32 0 20G 0 disk
└─sdc1 8:33 0 10G 0 part /home
sdd 8:48 0 60G 0 disk
└─sdd1 8:49 0 20G 0 part
sde 8:64 0 20G 0 disk
sdf 8:80 0 20G 0 disk
sr0 11:0 1 3.7G 0 rom
[root@centos6 ~]# 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): t
Partition number (1-4): 1
Hex code (type L to list codes): l
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 39 Plan 9 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 3c PartitionMagic 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 40 Venix 80286 84 OS/2 hidden C: c6 DRDOS/sec (FAT-
4 FAT16 <32M 41 PPC PReP Boot 85 Linux extended c7 Syrinx
5 Extended 42 SFS 86 NTFS volume set da Non-FS data
6 FAT16 4d QNX4.x 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS 4e QNX4.x 2nd part 88 Linux plaintext de Dell Utility
8 AIX 4f QNX4.x 3rd part 8e Linux LVM df BootIt
9 AIX bootable 50 OnTrack DM 93 Amoeba e1 DOS access
a OS/2 Boot Manag 51 OnTrack DM6 Aux 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 52 CP/M 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 53 OnTrack DM6 Aux a0 IBM Thinkpad hi eb BeOS fs
e W95 FAT16 (LBA) 54 OnTrackDM6 a5 FreeBSD ee GPT
f W95 Ext'd (LBA) 55 EZ-Drive a6 OpenBSD ef EFI (FAT-12/16/
10 OPUS 56 Golden Bow a7 NeXTSTEP f0 Linux/PA-RISC b
11 Hidden FAT12 5c Priam Edisk a8 Darwin UFS f1 SpeedStor
12 Compaq diagnost 61 SpeedStor a9 NetBSD f4 SpeedStor
14 Hidden FAT16 <3 63 GNU HURD or Sys ab Darwin boot f2 DOS secondary
16 Hidden FAT16 64 Novell Netware af HFS / HFS+ fb VMware VMFS
17 Hidden HPFS/NTF 65 Novell Netware b7 BSDI fs fc VMware VMKCORE
18 AST SmartSleep 70 DiskSecure Mult b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 75 PC/IX bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 80 Old Minix be Solaris boot ff BBT
1e Hidden W95 FAT1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)
Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): fd
Changed system type of partition 2 to fd (Linux raid autodetect)
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): fd
Changed system type of partition 3 to fd (Linux raid autodetect)
Command (m for help): t
Partition number (1-4): 4
Hex code (type L to list codes): fd
Changed system type of partition 4 to fd (Linux raid autodetect)
Command (m for help): p
Disk /dev/sdb: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 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: 0x41d1e5dc
Device Boot Start End Blocks Id System
/dev/sdb1 1 3917 31463271 fd Linux raid autodetect
/dev/sdb2 3918 7834 31463302+ fd Linux raid autodetect
/dev/sdb3 7835 11751 31463302+ fd Linux raid autodetect
/dev/sdb4 11752 15668 31463302+ fd Linux raid autodetect
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
- mdadm -C /dev/md0 -a yes -l 5 -n 3 /dev/sdb{1,2,3} 创建RAID5 -n #指定几块盘 后面跟设备
- mdadm -D /dev/md0 查看RAID
- mdadm –D –s >> /etc/mdadm.conf 生成配置文件
- mkfs.ext4 /dev/md0 格式化文件系统
- mount 挂载