分类目录归档:Linux

云端Xen/LinuxVPS 挂载未使用硬盘教程

原文地址:http://blog.aoyohost.com/mount-lvm-formatted-disk.html

[root@MyVPS ~]# fdisk -l //*查看硬盘分区情况*//

Disk /dev/xvda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          13      104391   83  Linux
/dev/xvda2              14        1044     8281507+  8e  Linux LVM
/dev/xvda3            1045        1305     2096482+  8e  Linux LVM

Disk /dev/xvdb: 7516 MB, 7516192768 bytes
255 heads, 63 sectors/track, 913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/xvdb doesn’t contain a valid partition table
[root@MyVPS ~]#df -hal //*查看已划分区空间使用情况*//
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
9.3G  1.2G  7.7G  13% /
proc                     0     0     0   –  /proc
sysfs                    0     0     0   –  /sys
devpts                   0     0     0   –  /dev/pts
/dev/xvda1             99M   29M   66M  31% /boot
tmpfs                 151M     0  151M   0% /dev/shm
none                     0     0     0   –  /proc/sys/fs/binfmt_misc
sunrpc                   0     0     0   –  /var/lib/nfs/rpc_pipefs
[root@MyVPS ~]#fdisk /dev/xvdb //*对硬盘/dev/xvdb进行增加分区操作*//
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.

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

Command (m for help):n //*输入n新建分区*//
Command action
e   extended
p   primary partition (1-4)
p //*输入p,主分区*//
Partition number (1-4): 1 //*由于xvdb还没有分区.我们这里输入1.第1个分区*//
First cylinder (1-913, default 1)://*回车跳过*//
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-913, default 913)://*回车跳过*//
Using default value 913

Command (m for help): t //*通过t来指定分区系统格式*//
Selected partition 1
Hex code (type L to list codes):8e //*输入8e LVM系统格式*//
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help):w //*输入w保存退出*//
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@MyVPS ~]#reboot //*重启使之生效*//

Broadcast message from root (pts/0) (Mon Aug 15 00:43:03 2011):

The system is going down for reboot NOW!
[root@MyVPS ~]#
Connection closed by foreign host.

Type `help’ to learn how to use Xshell prompt.
Xshell:>

Connecting to            :22…
Connection established.
Escape character is ‘^@]’.

Last login: Mon Aug 15 00:41:06 2011 from
[root@MyVPS1280 ~]#fdisk -l //*查看硬盘分区情况*//

Disk /dev/xvda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/xvda1   *           1          13      104391   83  Linux
/dev/xvda2              14        1044     8281507+  8e  Linux LVM
/dev/xvda3            1045        1305     2096482+  8e  Linux LVM

Disk /dev/xvdb: 7516 MB, 7516192768 bytes
255 heads, 63 sectors/track, 913 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/xvdb1               1         913     7333641   8e  Linux LVM
[root@MyVPS1280 ~]#pvcreate /dev/xvdb1 //*创建物理卷*//
Physical volume “/dev/xvdb1” successfully created
[root@MyVPS1280 ~]#vgextend VolGroup00 /dev/xvdb1 //*将物理卷加入到组VolGroup2011*//
Volume group “VolGroup00” successfully extended
[root@MyVPS1280 ~]# vgdisplay //*查看物理卷组情况.可以看到我们有6.97G的容量可以扩展*//
— Volume group —
VG Name               VolGroup00
System ID
Format                lvm2
Metadata Areas        3
Metadata Sequence No  6
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                2
Open LV               2
Max PV                0
Cur PV                3
Act PV                3
VG Size               16.81 GB
PE Size               32.00 MB
Total PE              538
Alloc PE / Size       315 / 9.84 GB
Free  PE / Size       223 / 6.97 GB
VG UUID               ONGPxy-HBvY-xrrQ-IjEW-PIiO-2cX7-tg6tuI

[root@MyVPS1280 ~]# lvresize -L +6G /dev/VolGroup00/LogVol00 //*扩容6G(我们第一次加6G)*//
Extending logical volume LogVol00 to 15.59 GB
Logical volume LogVol00 successfully resized
[root@MyVPS1280 ~]#resize2fs /dev/VolGroup00/LogVol00 //*动态扩容分区大小*//
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 4087808 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 4087808 blocks long.

[root@MyVPS1280 ~]# vgdisplay //*查看物理卷组情况.可以看到我们还有992M的容量可以扩展*//
— Volume group —
VG Name               VolGroup00
System ID
Format                lvm2
Metadata Areas        3
Metadata Sequence No  7
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                2
Open LV               2
Max PV                0
Cur PV                3
Act PV                3
VG Size               16.81 GB
PE Size               32.00 MB
Total PE              538
Alloc PE / Size       507 / 15.84 GB
Free  PE / Size       31 / 992.00 MB
VG UUID               ONGPxy-HBvY-xrrQ-IjEW-PIiO-2cX7-tg6tuI

[root@MyVPS1280 ~]# lvresize -L +992M /dev/VolGroup00/LogVol00 //*扩容992M(我们第2次加992M)*//
Extending logical volume LogVol00 to 16.56 GB
Logical volume LogVol00 successfully resized
[root@MyVPS1280 ~]# resize2fs /dev/VolGroup00/LogVol00 //*动态扩容分区大小*//
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 4341760 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 4341760 blocks long.

[root@MyVPS1280 ~]#vgdisplay //*最后再查看扩容完没有 可以看到已经扩容完毕*//
— Volume group —
VG Name               VolGroup00
System ID
Format                lvm2
Metadata Areas        3
Metadata Sequence No  8
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                2
Open LV               2
Max PV                0
Cur PV                3
Act PV                3
VG Size               16.81 GB
PE Size               32.00 MB
Total PE              538
Alloc PE / Size       538 / 16.81 GB
Free  PE / Size       0 / 0
VG UUID               ONGPxy-HBvY-xrrQ-IjEW-PIiO-2cX7-tg6tuI

[root@MyVPS1280 ~]# df -hal //*查看已划分区空间使用情况 可以看到我们挂载成功*//
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
17G  1.2G   15G   8% /
proc                     0     0     0   –  /proc
sysfs                    0     0     0   –  /sys
devpts                   0     0     0   –  /dev/pts
/dev/xvda1             99M   29M   66M  31% /boot
tmpfs                 151M     0  151M   0% /dev/shm
none                     0     0     0   –  /proc/sys/fs/binfmt_misc
sunrpc                   0     0     0   –  /var/lib/nfs/rpc_pipefs
//*S4 Did For AoyoHost*//

linux top命令详解

top命令是Linux下常用的性能分析工具,能够实时显示系统中各个进程的资源占用状况,类似于Windows的任务管理器。下面详细介绍它的使用方法。

top – 01:06:48 up 1:22, 1 user, load average: 0.06, 0.60, 0.48
Tasks: 29
total, 1 running, 28 sleeping, 0 stopped, 0 zombie
Cpu(s): 0.3% us, 1.0% sy,
0.0% ni, 98.7% id, 0.0% wa, 0.0% hi, 0.0% si
Mem: 191272k total, 173656k
used, 17616k free, 22052k buffers
Swap: 192772k total, 0k used, 192772k free,
123988k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
1379 root 16 0 7976
2456 1980 S 0.7 1.3 0:11.03 sshd
14704 root 16 0 2128 980 796 R 0.7 0.5
0:02.72 top
1 root 16 0 1992 632 544 S 0.0 0.3 0:00.90 init
2 root 34 19 0
0 0 S 0.0 0.0 0:00.00 ksoftirqd/0
3 root RT 0 0 0 0 S 0.0 0.0 0:00.00
watchdog/0

统计信息区
前五行是系统整体的统计信息。第一行是任务队列信息,同 uptime 命令的执行结果。其内容如下:

01:06:48 当前时间
up 1:22 系统运行时间,格式为时:分
1 user 当前登录用户数
load average:
0.06, 0.60, 0.48 系统负载,即任务队列的平均长度。
三个数值分别为 1分钟、5分钟、15分钟前到现在的平均值。

继续阅读

利用LVM为服务器实现扩容

作者:llk726  原始连接: http://llk726.blog.51cto.com/622293/166536
公司的FTP服务器经过几年的运行,现在出现了空间不足的情况,决定用LVM方式实现扩容工作。
思路:先拷贝数据,再购置一块大容量硬盘添加到服务器上,然后将己有的普通分区转换为物理卷,最后通过物理卷创建逻辑卷组来实现容量的扩充。
实现过程:
A、检查系统中是否安装了LVM工具,如果没有安装就下载安装。
[root@linuxas ~]# rpm -qa | grep lvm
system-config-lvm-1.0.22-1.0.el5
lvm2-2.02.16-3.el5
B、 创建和管理LVM
1、创建或转换分区
[root@linuxas ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 1044.
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)
Command (m for help): p(查看分区情况)
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 25 200781 83 Linux
/dev/sda2 26 535 4096575 83 Linux
/dev/sda3 536 854 2562367+ 83 Linux
/dev/sda4 855 1044 1526175 5 Extended
/dev/sda5 855 905 409626 82 Linux swap / Solaris
/dev/sda6 906 1044 1116486 83 Linux
Command (m for help): t (更改分区类型)
Partition number (1-6): 6 (将第6个分区转换成LVM)
Hex code (type L to list codes): 8e(将分区类型指定为“8e”就是LVM)
Changed system type of partition 6 to 8e (Linux LVM)
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 16: 璁惧鎴栬祫婧愬繖.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.