Monday, July 16, 2012

How to track down a high server load RedHat/CentOS/Fedora/SuSe


Line 1 - General server information - Current time, uptime (since last restart of server), number of users logged on (other than yourself), and the load average for the last 1, 5, and 15 minutes
Line 2 - Tasks - Number of processes, number of actively running processes, sleeping process, stopped process, and zombie processes
Line 3 - CPU usage info (User, System, Nice, Idle, Waiting, Hardware Interrupts, Software Interrupts).  Just worry about Idle, user, system, and waiting.
Line 4 - Memory usage
Line 5 - Swap usage (used should be almost 0 if not 0)
Table header for process list (Process ID, User, Priority, Nice, Virtual Memory, Resident Size, Shared Size, , State, CPU, Memory, CPU Time used, Command)
The processes themselves



login as: root
Access denied
root@192.168.200.102's password:
Last login: Tue Jul  3 02:47:21 2012 from 192.168.200.1

[root@openstack ~]# top -b -i -n 20 >> ./server-load

[root@openstack ~]# cat server-load
top - 00:55:00 up 4 min,  3 users,  load average: 1.84, 1.09, 0.49
Tasks: 124 total,   1 running, 123 sleeping,   0 stopped,   0 zombie
Cpu(s):  7.5%us, 20.0%sy,  0.0%ni, 58.7%id,  7.0%wa,  6.1%hi,  0.7%si,  0.0%st
Mem:   1027968k total,   488776k used,   539192k free,    23112k buffers
Swap:  2064380k total,        0k used,  2064380k free,   203320k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 1337 root      20   0  2908 1020  796 R  3.7  0.1   0:00.06 top


top - 00:55:03 up 4 min,  3 users,  load average: 1.84, 1.09, 0.49
Tasks: 124 total,   1 running, 123 sleeping,   0 stopped,   0 zombie
Cpu(s):  1.0%us,  8.9%sy,  0.0%ni, 86.8%id,  0.0%wa,  3.0%hi,  0.3%si,  0.0%st
Mem:   1027968k total,   488776k used,   539192k free,    23112k buffers
Swap:  2064380k total,        0k used,  2064380k free,   203336k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 1337 root      20   0  2884 1040  812 R  0.7  0.1   0:00.08 top


top - 00:55:06 up 4 min,  3 users,  load average: 1.85, 1.10, 0.50
Tasks: 124 total,   1 running, 123 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.7%us,  8.7%sy,  0.0%ni, 84.7%id,  3.3%wa,  2.7%hi,  0.0%si,  0.0%st
Mem:   1027968k total,   488776k used,   539192k free,    23120k buffers
Swap:  2064380k total,        0k used,  2064380k free,   203328k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 1337 root      20   0  2884 1040  812 R  0.7  0.1   0:00.10 top


top - 00:55:09 up 4 min,  3 users,  load average: 1.85, 1.10, 0.50
Tasks: 124 total,   1 running, 123 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.7%us,  9.6%sy,  0.0%ni, 86.0%id,  0.0%wa,  3.3%hi,  0.3%si,  0.0%st
Mem:   1027968k total,   488776k used,   539192k free,    23120k buffers
Swap:  2064380k total,        0k used,  2064380k free,   203336k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 1337 root      20   0  2884 1040  812 R  0.7  0.1   0:00.12 top


top - 00:55:12 up 4 min,  3 users,  load average: 1.79, 1.10, 0.50
Tasks: 124 total,   1 running, 123 sleeping,   0 stopped,   0 zombie
Cpu(s):  2.3%us,  9.9%sy,  0.0%ni, 80.9%id,  3.3%wa,  3.3%hi,  0.3%si,  0.0%st
Mem:   1027968k total,   488776k used,   539192k free,    23128k buffers
Swap:  2064380k total,        0k used,  2064380k free,   203328k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 1337 root      20   0  2884 1040  812 R  1.0  0.1   0:00.15 top


top - 00:55:15 up 4 min,  3 users,  load average: 1.72, 1.10, 0.50
Tasks: 124 total,   1 running, 123 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.7%us,  9.3%sy,  0.0%ni, 86.0%id,  0.0%wa,  3.7%hi,  0.3%si,  0.0%st
Mem:   1027968k total,   488776k used,   539192k free,    23128k buffers
Swap:  2064380k total,        0k used,  2064380k free,   203336k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 1337 root      20   0  2884 1040  812 R  0.7  0.1   0:00.17 top


top - 00:55:18 up 4 min,  3 users,  load average: 1.72, 1.10, 0.50
Tasks: 124 total,   1 running, 123 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.7%us,  9.0%sy,  0.0%ni, 86.0%id,  1.0%wa,  3.0%hi,  0.3%si,  0.0%st
Mem:   1027968k total,   488776k used,   539192k free,    23136k buffers
Swap:  2064380k total,        0k used,  2064380k free,   203336k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 1337 root      20   0  2884 1040  812 R  0.7  0.1   0:00.19 top


top - 00:55:21 up 4 min,  3 users,  load average: 1.66, 1.10, 0.50
Tasks: 124 total,   1 running, 123 sleeping,   0 stopped,   0 zombie
Cpu(s):  1.0%us,  8.6%sy,  0.0%ni, 87.1%id,  0.0%wa,  3.0%hi,  0.3%si,  0.0%st
Mem:   1027968k total,   488776k used,   539192k free,    23136k buffers
Swap:  2064380k total,        0k used,  2064380k free,   203344k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 1337 root      20   0  2884 1040  812 R  1.0  0.1   0:00.22 top


top - 00:55:24 up 4 min,  3 users,  load average: 1.66, 1.10, 0.50
Tasks: 124 total,   1 running, 123 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.7%us,  9.3%sy,  0.0%ni, 85.7%id,  1.0%wa,  3.0%hi,  0.3%si,  0.0%st
Mem:   1027968k total,   488776k used,   539192k free,    23144k buffers
Swap:  2064380k total,        0k used,  2064380k free,   203348k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 1337 root      20   0  2884 1040  812 R  0.7  0.1   0:00.24 top


top - 00:55:27 up 4 min,  3 users,  load average: 1.61, 1.10, 0.51
Tasks: 124 total,   1 running, 123 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.7%us,  8.6%sy,  0.0%ni, 87.5%id,  0.0%wa,  3.0%hi,  0.3%si,  0.0%st
Mem:   1027968k total,   488776k used,   539192k free,    23144k buffers
Swap:  2064380k total,        0k used,  2064380k free,   203348k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 1337 root      20   0  2884 1040  812 R  0.7  0.1   0:00.26 top


top - 00:55:30 up 5 min,  3 users,  load average: 1.48, 1.08, 0.50
Tasks: 124 total,   1 running, 123 sleeping,   0 stopped,   0 zombie
Cpu(s):  1.0%us,  8.9%sy,  0.0%ni, 85.5%id,  1.7%wa,  2.6%hi,  0.3%si,  0.0%st
Mem:   1027968k total,   488776k used,   539192k free,    23152k buffers
Swap:  2064380k total,        0k used,  2064380k free,   203348k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 1337 root      20   0  2884 1040  812 R  1.0  0.1   0:00.29 top


top - 00:55:33 up 5 min,  3 users,  load average: 1.48, 1.08, 0.50
Tasks: 119 total,   1 running, 118 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.3%us,  9.6%sy,  0.0%ni, 86.8%id,  0.0%wa,  3.0%hi,  0.3%si,  0.0%st
Mem:   1027968k total,   488744k used,   539224k free,    23152k buffers
Swap:  2064380k total,        0k used,  2064380k free,   203348k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 1337 root      20   0  2884 1040  812 R  0.7  0.1   0:00.31 top


top - 00:55:36 up 5 min,  3 users,  load average: 1.44, 1.08, 0.51
Tasks: 120 total,   1 running, 119 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.7%us,  8.7%sy,  0.0%ni, 86.0%id,  1.7%wa,  3.0%hi,  0.0%si,  0.0%st
Mem:   1027968k total,   488744k used,   539224k free,    23160k buffers
Swap:  2064380k total,        0k used,  2064380k free,   203340k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 1337 root      20   0  2884 1040  812 R  0.7  0.1   0:00.33 top


top - 00:55:40 up 5 min,  3 users,  load average: 1.44, 1.08, 0.51
Tasks: 120 total,   1 running, 119 sleeping,   0 stopped,   0 zombie
Cpu(s):  0.7%us,  9.6%sy,  0.0%ni, 86.5%id,  0.0%wa,  3.0%hi,  0.3%si,  0.0%st
Mem:   1027968k total,   488744k used,   539224k free,    23160k buffers
Swap:  2064380k total,        0k used,  2064380k free,   203348k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 1337 root      20   0  2884 1040  812 R  1.0  0.1   0:00.36 top

[root@openstack ~]#

Friday, June 8, 2012

Run you OWNCLOUD on CentOS/REDHAT/FEDORA

  1. Install the following packages:    yum -y install httpd php php-mysql php-mbstring php-devel mysql mysql-server zlib zlib-devel pcre-devel phpmyadmin 
  2. Download ownCloud3 sources from here
  3. Extract and copy the resultant owncloud/ directory to /var/www/html
  4. ‘cd’ to /var/www/html and set appropriate permission to owncloud directory so that apache can read/write from/to it: $sudo  chown -R apache:apache owncloud/
  5. Start Apache server: $ sudo service httpd start
  6. Start MySQL server: $ sudo service mysql start and change the root password using $mysqladmin -u root password PASSWORD
  7. Create a MySQL database that you want ownCloud to use by going to: http://localhost/phpmyadmin
  8. Start ownCloud: http://localhost/owncloud and setup other users or simply start using for storing files
  9. Use PageKite to make your cloud publicly accessible as detailed here

Wednesday, May 30, 2012

Bandwidth limitation using "TC Command" RedHat /CentOS/Fedora/Ubuntu/SuSe

Use "tc" command.

# tc qdisc add dev eth0 root tbf limit 15Kb buffer 10Kb/8 rate 10Kbps

Check the configuration.

# tc -s qdisc
qdisc tbf 8001: dev eth0 root refcnt 2 rate 80000bit burst 10Kb lat 512.0ms
 Sent 994 bytes 14 pkt (dropped 0, overlimits 0 requeues 0)
 rate 0bit 0pps backlog 0b 0p requeues 0
qdisc pfifo_fast 0: dev eth1 root refcnt 2 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
 Sent 10861 bytes 156 pkt (dropped 0, overlimits 0 requeues 0)
 rate 0bit 0pps backlog 0b 0p requeues 0
qdisc pfifo_fast 0: dev eth2 root refcnt 2 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
 Sent 15932 bytes 100 pkt (dropped 0, overlimits 0 requeues 0)
 rate 0bit 0pps backlog 0b 0p requeues 0
qdisc pfifo_fast 0: dev eth3 root refcnt 2 bands 3 priomap  1 2 2 2 1 2 0 0 1 1 1 1 1 1 1 1
 Sent 1836 bytes 10 pkt (dropped 0, overlimits 0 requeues 0)
 rate 0bit 0pps backlog 0b 0p requeues 0



If you want to delete the configuration, execute the following command.

# tc qdisc del dev eth0 root

Using dump/restore command do the backup and restore whole CentOS/RedHat/Fedore/SUSE/Ubuntu.


Using dump/restore command do the backup and restore whole CentOS/RedHat/Fedore/SUSE/Ubuntu.

http://dump.sourceforge.net/isdumpdeprecated.html

# cat /etc/fstab
LABEL=/                 /                       ext3    defaults        1 1
LABEL=/boot1            /boot                   ext3    defaults        1 2
LABEL=/data             /data                   ext3    defaults        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
LABEL=SWAP-sda5         swap                    swap    defaults        0 0


# fdisk -l
   Device Boot    Start      End    Blocks      Id  System
/dev/sda1 *           1       13    104391      83  Linux
/dev/sda2            14      1925   15358140    83  Linux
/dev/sda3          1926      3200   10241437+   83  Linux
/dev/sda4          3201      4864   13366080    5   Extended
/dev/sda5          3201      3391   1534176     82  Linux swap / Solaris


# dump -0uf - /dev/sda1 | ssh root@192.168.0.14 dd of=/tmp/sda1.dump
# dump -0uf - /dev/sda2 | ssh root@192.168.0.14 dd of=/tmp/sda2.dump
# dump -0uf - /dev/sda3 | ssh root@192.168.0.14 dd of=/tmp/sda3.dump
# dump -0uf - /dev/sda4 | ssh root@192.168.0.14 dd of=/tmp/sda4.dump
# dump -0uf - /dev/sda5 | ssh root@192.168.0.14 dd of=/tmp/sda5.dump

Restore the data

# restore -rf /sda1.dump
# restore -rf /sda2.dump
# restore -rf /sda3.dump
# restore -rf /sda4.dump
# restore -rf /sda5.dump

Live CD/rescue mode first and use fdisk to create partitions and give ip address

Create a partitions on new disk

Fdisk /dev/sda

format sda1/sda2/sda3/sda5 by using the mkfs command
# mkfs.ext3 /dev/sda1
# mkfs.ext3 /dev/sda2
# mkfs.ext3 /dev/sda3
# mkfs.ext3 /dev/sda4
# mkfs.ext3 /dev/sda5

Re-label all the partitions
# e2label /dev/sda1 /boot1
# e2label /dev/sda2 /
# e2label /dev/sda3 /data
# mkswap -L SWAP-sda5 /dev/sda5

login into 192.168.0.187, and restore sda1 from a remote 192.168.0.14 sda1.dump

# ssh 192.168.0.187 "cd /mnt/sda1 && RSH=/usr/bin/ssh restore -r -f 192.168.0.14:/tmp/sda1.dump"

Please run grub-install in rescue mode first. Install grub on /dev/sda1*