一、从安装操作系统开始
1、磁盘初始化
服务器在安装操作系统之前,必须先对磁盘做raid初始化。
我们只需要将第一个盘进行raid 0的初始化,其他盘不要进行raid 0。
2、安装CentOS6.2
安装操作系统时,注意勾选修改磁盘分区
给每个盘添加swap分区
和 ext4分区
继续将系统安装完毕
3、配置/etc/fstab
用root用户登录
vim /etc/fstab
修改swap的部分
结果如下:
/dev/mapper/vg_bigtest1-lv_root
/ ext4 defaults 1 1
UUID=fad3e289-5a2a-4acb-8188-accfa24be37f
/boot ext4 defaults 1 2
UUID=94287598-cf1c-433d-9d9e-57a0ffabed9a
/data1 ext4 defaults 1 2
UUID=cf812ae0-98e3-48ff-b301-6e50fbf2c0a3
/data2 ext4 defaults 1 2
UUID=8dd2fe11-7595-47ad-8bdb-8761c327f22e
/data3 ext4 defaults 1 2
UUID=0f229ed0-5049-489b-8957-362a33b8008e
/data4 ext4 defaults 1 2
UUID=d642a0c3-1862-45ee-9447-1b04e226c8d7
/data5 ext4 defaults 1 2
UUID=5972169a-8ed7-4335-be01-ee67a43cdd9f
/data6 ext4 defaults 1 2
UUID=610ff728-7a52-4063-9877-764489522e08
/data7 ext4 defaults 1 2
/dev/mapper/vg_bigtest1-lv_home
/home ext4 defaults 1 2
/dev/mapper/vg_bigtest1-lv_swap
swap swap pri=1 0 0
UUID=5d693fa0-5818-411a-80b7-e819a5b27d3e
swap swap pri=3 0 0
UUID=61aa762e-828a-4bba-8ccc-19c4d446842e
swap swap pri=3 0 0
UUID=c5d03ca4-f858-494e-957f-3edc17f82e0e
swap swap pri=3 0 0
UUID=f027504b-c1c0-489a-bae5-45ad77f2ea34
swap swap pri=3 0 0
UUID=567abb5e-70dc-4fbd-8f92-9b9361fabfc4
swap swap pri=3 0 0
UUID=2de1be3a-1737-402b-bdd1-f31c0574c334
swap swap pri=3 0 0
UUID=289ff5f4-9ec9-45be-a27c-ae1854e07c40
swap swap pri=3 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
修改完毕,保存
reboot 重启服务器
重启完毕后
swapon
-s 查看swap使用情况
[root@bigtest1 /]#
swapon -s
Filename Type Size Used Priority
/dev/dm-4 partition 102392 0 1
/dev/sdb2 partition 5242872 0 3
/dev/sdd2 partition 5242872 0 3
/dev/sdc2 partition 5242872 0 3
/dev/sde2 partition 5242872 0 3
/dev/sdf2 partition 5242872 0 3
/dev/sdh2 partition 5242872 0 3
/dev/sdg2 partition 5242872 0 3
##解释##
swap分区的优先级(Priority)从高到低依次使用,最高32767,最低优先级是0
这样设置使得Linux并行的使用7个优先级相同的swap分区(Priority = 3的分区),这会大幅的提高对swap的读写。当这7个分区满了,就会使用第8块swap分区(Priority = 1的分区)
free
可以看到内存 和 swap的总数
[root@bigtest1 /]#
free
total used free
shared buffers cached
Mem: 32843316 1752924
31090392 0 133100
828632
-/+
buffers/cache: 791192 32052124
Swap: 36802496 0
36802496
二、如果系统已安装完毕,如何修改
在建好分区后,我们还可以更改相关分区的文件系统类型
#如,我们要把第二个主分区改成Linux下的交换分区,操作如下
[root@bigtest3 ~]# fdisk /dev/sde
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/sde: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 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: 0x000646e2
Device Boot Start End Blocks Id System
/dev/sde1 1 242549 1948270592 83 Linux
/dev/sde2 242549 243202 5242880 6 FAT16
Command (m for help): t #更改文件系统类型
Partition number (1-4): 2 #选择第二个分区
Hex code (type L to list codes): L #选择要更改的文件系统编码,可以按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): 82 # Linux swap 分区编码是82
Changed system type of partition 2 to 82 (Linux swap / Solaris)
Command (m for help): p #查看磁盘信息
Disk /dev/sde: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 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: 0x000646e2
Device Boot Start End Blocks Id System
/dev/sde1 1 242549 1948270592 83 Linux
/dev/sde2 242549 243202 5242880 82 Linux swap / Solaris
Command (m for help): w #保存
The partition table has been altered!
Calling ioctl() to re-read partition table.
然后把分区写在/etc/fstab 上,重启服务器 reboot 。
配置完毕。
查看
swapon -s
阅读(1625) | 评论(0) | 转发(0) |