Monthly Archives: May 2013

How to measure or calculate maximum memory usage of Apache

For Debian:

ps -ylC apache2 | awk '{x += $8;y += 1} END {print "Apache Memory Usage (MB): "x/1024; print "Average Proccess Size (MB): "x/((y-1)*1024)}

For Centos/RedHat:

ps -ylC httpd | awk '{x += $8;y += 1} END {print "Apache Memory Usage (MB): "x/1024; print "Average Proccess Size (MB): "x/((y-1)*1024)}'

The output should be like this.

webserverpage:/etc/init.d# ps -ylC httpd | awk ‘{x += $8;y += 1} END {print “Apache Memory Usage (MB): “x/1024; print “Average Proccess Size (MB): “x/((y-1)*1024)}’
Apache Memory Usage (MB): 223.484
Average Proccess Size (MB): 22.3484

How to install QmailToaster in Centos.

Download & Run Pre-Install Scripts

1. Create a directory for qmailtoaster files.

mkdir -p /usr/src/qtms-install

2. Change directory to the above created directory.

cd /usr/src/qtms-install

3. Download the installation script. (The script is meant for 64 bit).

wget http://www.qmailtoaster.com/centos/cnt5064/cnt5064-deps.sh

4. Run the installation script.

bash cnt5064-deps.sh

5. cnt50-svcs.sh & firewall.sh

wget http://www.qmailtoaster.com/centos/cnt50/cnt50-svcs.sh

6. Rename cnt50-svcs.sh to cnt5064-svcs.sh.

mv cnt50-svcs.sh cnt5064-svcs.sh

7. Edit “cnt50-svcs.sh” with “vi” or your favorite text editor

vi cnt5064-svcs.sh

Find the line that with “MYSQLPW=YOUR_MYSQL_ROOT_PASSWORD” and change “YOUR_MYSQL_ROOT_PASSWORD” to the password you want used for the mysql root account.

8. Run the downloaded script.

sh cnt5064-svcs.sh

It’s time to download and install the qmailtoaster.

1. Change your directory to “/usr/src/qtms-install” created in the above step.

cd /usr/src/qtms-install

2. Download the script “current-download-script.sh” that will download all the QmailToaster packages to be installed on your system.

wget http://www.qmailtoaster.com/info/current-download-script.sh

3. Run the “current-download-script.sh” with the command below.

sh current-download-script.sh

Install QmailToaster Packages

1. For x86_64: Download the “cnt5064-install-script.sh” file which will install all the QmailToaster packages on your system.

wget http://www.qmailtoaster.com/centos/cnt50/cnt50-install-script.sh

2. Run the downloaded script.
sh cnt5064-install-script.sh

/home/vpopmail/bin/vadddomain webserverpage.com
/home/vpopmail/bin/vadduser test@webserverpage.com

Edit /etc/php.ini and set register_globals = On
service httpd restart

Bring up your browser and go to:
http://www.webserverpage.com/admin-toaster/
Username: admin
Password: toaster
Change your password . . .

Edit /etc/php.ini and set register_globals = Off
service httpd restart

Check your mail server:
http://www.webserverpage.com/webmail
login with your full email address and your password
Send yourself an email – should show right away
Send an email to yourself if you have another address
Go to your other email account and reply to the message you sent

How to monitor MySQL process.

rpaco@choi:~$ mytop -uroot -p<mypassword>

Output should be like this.

MySQL on localhost (5.0.45) up 0+05:34:18 [15:50:11]
Queries: 16.6M qps: 869 Slow: 0.0 Se/In/Up/De(%): 20/00/00/00
qps now: 682 Slow qps: 0.0 Threads: 9 ( 1/ 1) 22/00/00/00
Key Efficiency: 99.9% Bps in/out: 0.0/ 1.8 Now in/out: 8.4/ 1.4k

Id User Host/IP DB Time Cmd Query or State
— —- ——- — —- — ———-
5 webserverpage localhost:37034 webserverpage 0 Sleep
243 root localhost test 0 Query show full processlist
3 webserverpage localhost:58948 webserverpage 3 Sleep
8 webserverpage localhost:56914 webserverpage 5 Sleep
2 webserverpage localhost:49081 webserverpage 6 Sleep
6 webserverpage localhost:47071 webserverpage 6 Sleep
1 webserverpage localhost:50606 webserverpage 248 Sleep
7 webserverpage localhost:48746 webserverpage 254 Sleep
4 webserverpage localhost:52620 webserverpage 297 Sleep

How to check the max_connections in MySQL database.

rpaco@choi:~$mysql -uroot -h localhost -p
Enter Password: mypassword

Type the command below.
mysql> show variables like ‘max_connections’;
+—————–+——-+
| Variable_name   | Value |
+—————–+——-+
| max_connections | 100   |
+—————–+——-+

Set temporary values. This values will be reset when mysql service restart.

mysql>set global max_connections = 200;

To set it permanently.

vi /etc/mysql/my.cnf
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address            = 127.0.0.1
#
# * Fine Tuning
#
key_buffer              = 16M
max_allowed_packet      = 16M
thread_stack            = 128K
thread_cache_size       = 8
max_connections        = 250    <— uncommented then I have changed the value to 250

Check RAM Memory Chip Speed and Specification From Within a Linux System

root@choi:~# dmidecode –type memory
# dmidecode 2.11
SMBIOS 2.6 present.

Handle 0x0008, DMI type 16, 15 bytes
Physical Memory Array
Location: System Board Or Motherboard
Use: System Memory
Error Correction Type: None
Maximum Capacity: 8 GB
Error Information Handle: No Error
Number Of Devices: 2

Handle 0x0009, DMI type 17, 28 bytes
Memory Device
Array Handle: 0x0008
Error Information Handle: 0x000A
Total Width: 64 bits
Data Width: 64 bits
Size: 1024 MB
Form Factor: DIMM
Set: None
Locator: Slot 1
Bank Locator: BANK 0
Type: DDR2
Type Detail: Synchronous
Speed: 800 MHz
Manufacturer: Hynix
Serial Number: AD0000000000000001095049723169
Asset Tag: Unknown
Part Number: HYMP112S64CP6-S6
Rank: Unknown

Handle 0x000C, DMI type 17, 28 bytes
Memory Device
Array Handle: 0x0008
Error Information Handle: Not Provided
Total Width: Unknown
Data Width: Unknown
Size: No Module Installed
Form Factor: DIMM
Set: None
Locator: Slot 2
Bank Locator: BANK 0
Type: DDR2
Type Detail: None
Speed: Unknown
Manufacturer: Not Specified
Serial Number: Not Specified
Asset Tag: Unknown
Part Number: Not Specified
Rank: Unknown

How to update vzkernel in host OS running OpenVZ

This is how you can update your kernel in your host OS.

1. Check the installed kernel first.

[root@choi ~]# rpm -qa | grep vzkernel
vzkernel-2.6.32-042stab057.1.x86_64

2. Search for available vzkernel

[root@choi ~]# yum search vzkernel
Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
* base: mirror.usonyx.net
* extras: mirror.usonyx.net
* openvz-kernel-rhel6: mirror.secureax.com
* openvz-utils: mirror.secureax.com
* updates: mirror.smartmedia.net.id
base | 3.7 kB
00:00
extras | 3.5 kB
00:00
openvz-kernel-rhel6 | 951 B
00:00
openvz-utils | 951 B
00:00
updates | 3.5 kB
00:00
============================ N/S Matched: vzkernel
=============================
vzkernel.x86_64 : The Linux kernel

3. You may now update the vzkernel.

[root@choi ~]# yum update vzkernel.x86_64
Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
* base: mirror.usonyx.net
* extras: mirror.usonyx.net
* openvz-kernel-rhel6: mirror.secureax.com
* openvz-utils: mirror.secureax.com
* updates: mirror.smartmedia.net.id
Setting up Update Process
Resolving Dependencies
–> Running transaction check
—> Package vzkernel.x86_64 0:2.6.32-042stab076.8 will be installed
–> Processing Dependency: kernel-firmware >= 2.6.32-279.22.1.el6 for
package: vzkernel-2.6.32-042stab076.8.x86_64
–> Running transaction check
—> Package kernel-firmware.noarch 0:2.6.32-220.23.1.el6 will be obsoleted
—> Package vzkernel-firmware.noarch 0:2.6.32-042stab076.8 will be
obsoleting
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository
Size
================================================================================
Installing:
vzkernel x86_64 2.6.32-042stab076.8 openvz-kernel-rhel6
27 M
vzkernel-firmware noarch 2.6.32-042stab076.8 openvz-kernel-rhel6
10 M
replacing kernel-firmware.noarch 2.6.32-220.23.1.el6

Transaction Summary
================================================================================
Install 2 Package(s)

Total download size: 37 M
Is this ok [y/N]: Y

4. Reboot the server.

Create Partition and Format Partition in Centos 6.4

In this notes, I have inserted two HDD on a 1U server which have 2 existing HDD (raid 1) setup and currently running. I have inserted 2x 1TB HDD in the 3rd and 4th slot of the server.

1. To check if the disk have been detected, you may type the command below “fdisk -l”

[root@choi ~]# fdisk -l

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 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: 0x00093eed

Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2550    20480000   fd  Linux raid autodetect
/dev/sda2            2550        3570     8192000   82  Linux swap / Solaris
/dev/sda3            3570      121602   948088832   fd  Linux raid autodetect

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 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: 0x0005825f

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1        2550    20480000   fd  Linux raid autodetect
/dev/sdb2            2550        3570     8192000   82  Linux swap / Solaris
/dev/sdb3            3570      121602   948088832   fd  Linux raid autodetect

Disk /dev/md0: 21.0 GB, 20971446272 bytes
2 heads, 4 sectors/track, 5119982 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/md1: 970.8 GB, 970841780224 bytes
2 heads, 4 sectors/track, 237021919 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdc: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 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: 0x00000000

Disk /dev/sdd: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 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: 0x00000000

2. The two HDD have been detected which are /dev/sdc and /dev/sdd. We have two create a partition so that we can use the HDD.

[root@lead ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xf0446563.
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)

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): m
Command action
a   toggle a bootable flag
b   edit bsd disklabel
c   toggle the dos compatibility flag
d   delete a partition
l   list known partition types
m   print this menu
n   add a new partition
o   create a new empty DOS partition table
p   print the partition table
q   quit without saving changes
s   create a new empty Sun disklabel
t   change a partition’s system id
u   change display/entry units
v   verify the partition table
w   write table to disk and exit
x   extra functionality (experts only)

Command (m for help):

[root@choi~]# fdisk /dev/sdc

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): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-121601, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-121601, default 121601):
Using default value 121601

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

[root@choi~]# fdisk /dev/sdd
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x00edcde8.
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)

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): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-121601, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-121601, default 121601):
Using default value 121601

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

3. Check if it appear in fdisk -l.
[root@choi ~]# fdisk -l
Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1      121601   976760001   83  Linux

Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1      121601   976760001   83  Linux

4. Now we are ready to format the two HDD that has been added.

[root@choi ~]# mkfs.ext3 /dev/sdc1
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
61054976 inodes, 244190000 blocks
12209500 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
7453 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@choi ~]# mkfs.ext3 /dev/sdd1
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
61054976 inodes, 244190000 blocks
12209500 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
7453 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

ENJOY! ^ ^