msgbartop
Server Management Knowledge Base
msgbarbottom

02 Jan 09 Expanding LVM logical volume

The e2fsprogs and lvm2 packages are required to follow these steps, but these packages are mandatory on systems that use ext2/ext3 on a LVM2 logical volume.

Determine the size of the extended volume

Get the site of the expanded volume group first:

# lvm vgdisplay

— Volume group —
VG Name               VolGroup00
System ID
Format                lvm2
Metadata Areas        2
Metadata Sequence No  4
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                2
Open LV               2
Max PV                0
Cur PV                2
Act PV                2
VG Size               72.59 GB
PE Size               32.00 MB
Total PE              2323
Alloc PE / Size       1129 / 35.28 GB
Free  PE / Size       1194 / 37.31 GB
VG UUID               6OXHId-sean-ZBR2-wuOy-yjVR-cQeB-PJIvrD

We can see here that 1129 of 2323 physical extends (PE) are in use. But there are two logical volumes, so we have to look up the size of the volume that we would like to extend:

# lvm lvdisplay /dev/mapper/VolGroup00-LogVol00

— Logical volume —
LV Name                /dev/VolGroup00/LogVol00
VG Name                VolGroup00
LV UUID                ILc0A4-Ku4W-ws3U-6dk5-WJlc-EKVp-UCxCfK
LV Write Access        read/write
LV Status              available
# open                 1
LV Size                33.34 GB
Current LE             1067
Segments               1
Allocation             inherit
Read ahead sectors     0
Block device           253:0

The current size is 1067 PEs, and we have 1194 free extends, so the new volume size will be 1067 + 1194 = 2261.

Extending the volume

We can now easily extend the volume, by specifying the new number of PEs:

# lvm lvresize -l 2261 lvm lvdisplay /dev/mapper/VolGroup00-LogVol00
Extending logical volume LogVol00 to 70.66 GB
Logical volume LogVol00 successfully resized

Resizing the filesystem

The volume is now expanded, but the filesystem still has its old size. You have 2 solutions to expand the filesytem You can either umount the volume , use resize2fs and then mount it back :

# umount /dev/mapper/VolGroup00-LogVol00
# resize2fs /dev/mapper/VolGroup00-LogVol00
# mount /dev/mapper/VolGroup00-LogVol00

Or you can resize the filesystem without umounting the device (applications can still write/read datas on disk), a.k.a online resizing :

CentOS 4

# ext2online /dev/mapper/VolGroup00-LogVol00

CentOS 5

# resize2fs /dev/mapper/VolGroup00-LogVol00

(In CentOS 5 the ext2online command has been removed and the online resizing code has been merged into resize2fs)

Share/Save/Bookmark

02 Jan 09 Virtual IP addresses

You can add several virtual IP addresses to a physical network interface. A good starting point is to copy the interface definition file of the device you want to add a virtual IP address to.

cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0

You may have to modify ifcfg-eth0 to match your physical interface name.

Now you can edit the new file ifcfg-eth0:0 and specify the network settings of the virtual interface.

To make the changes take effect please restart the network services using:

service network restart

Share/Save/Bookmark

02 Jan 09 Enable IP forwarding

To enable IP packet forwarding please edit /etc/sysctl.conf with your editor of choice and set:

# Controls IP packet forwarding

net.ipv4.ip_forward = 1

You can then verify your settings with:

/sbin/sysctl -p

Share/Save/Bookmark

02 Jan 09 Resizing Ext3

Before resizing a file system it must be unmounted, so you’ll need to create working standalone boot disks.
A few ways you can do it:

1. resize2fs
2. parted
3. Partition Magic 7.x

In all cases, first convert ext3 –> ext2:

tune2fs -O ^has_journal /dev/hdax
e2fsck -v -f /dev/hdax

Resize the partitions with tool of choice.
Convert back to ext3

tune2fs -j /dev/hdax
e2fsck -v -f /dev/hdax

Share/Save/Bookmark

02 Jan 09 Repair mysql databases

Cpanel provides tools to fix corrupt mysql tables. But if you server does not have control panel here are the commands that you need to check to fix your databases tables.

Repairing MyISAM mySQL Tables/Databases:

cd /var/lib/mysql/DBNAME
#Please note that we assume your mySQL data directory is /var/lib/mysql

myisamchk *.MYI

Repairing ISAM mySQL Tables/Databases:

cd /var/lib/mysql/DBNAME
#Please note that we assume your mySQL data directory is /var/lib/mysql

isamchk *.MYI

The second method is to run the mysqlcheck command-line utility. The syntax is:

mysqlcheck [options] dbname tablename [tablename2... ].

The following options pertain to checking (mysqlcheck can also repair, as well as analyze and optimize)

For ex.

mysqlcheck -r databasename
mysqlcheck -o databasename

Share/Save/Bookmark

01 Jan 09 Install Zend Optimizer

- log in to your server or VPS in SSH
- cd /usr/local/directadmin/custombuild/
- At the command prompt type the following
./build clean
- and then type
./build zend

Follow the on screen instructions and you are done! Make sure you have set zend=yes in option.conf file.

Manual installation instructions

For PHP 4.0.5 or above you’ll want to install Zend Optimizer 2.6.2

For PHP 5.x you want to install Zend Optimizer 3.0.1

# cd /root

Download Zend:

# wget http://downloads.zend.com/url/to/your/version

Of course changing the above with the corresponding link. The i386 versions will work fine. Now untar/gunzip the Optimizer

# tar zxvf Zend

Because of the different versions, I find it easier to just hit tab after typing in Zend

Then cd up to Zend’s directory:

# cd Zend

Now to install.

# ./install

Share/Save/Bookmark

30 Dec 08 Change the IP of my server in Helm

Firstly in Helm you’ll need to add the new IP address, and assign it to a server. You can do this here:

Home > System Settings > IP Address Manager

Once done, you need to update the communication IP for your server:

Home > System Settings > Servers > YOUR SERVER

The communication IP is the IP at the top, under your server name.  Change this IP to the new IP and click “Save”.

If this IP was also used for your websites then you’ll also need to update the Host Header for all the sites and the DNS zones on your DNS server too. From version 3.2.4 onwards, you can use the Helm Restore Tool to change from the old IP to the new IP on all domains. Before you use this though, you will need to go into the Web Service:

Home > System Settings > Servers > YOUR SERVER > Web Service

Choose the new IP from the drop down box and click Save. Repeat this for any other service that uses that IP (FTP, Mail, etc). You can then run the Helm Restore Tool on each service and this will assign the new IP to all domains.

The Helm Restore Tool can be found in the Tools folder of the Helm installation folder.

Share/Save/Bookmark

29 Dec 08 Incorrect disk usage on DirectAdmin Panel

DirectAdmin panel is showing wrong disk usage. In such cases we need to update the disk usage manually. Run the following command in the server to update the disk usage.

# echo “action=tally&value=all” >> /usr/local/directadmin/data/task.queue

We can verify the disk usage shown in the directAdmin panel is correct or not as the directAdmin will list the quota information based on the output of the following command.

#/usr/sbin/repquota -a

Share/Save/Bookmark

29 Dec 08 Installing Apache 2 in Debian with PHP5

By Default you will be given the package apache2-mpm-worker

apache2-mpm-worker

The worker MPM provides a threaded implementation for Apache2. It is considerably faster than the traditional model, and is the recommended MPM.

apache2-mpm-prefork

This Multi-Processing Module (MPM) implements a non-threaded, pre-forking web server that handles requests in a manner similar to Apache 1.3. It is appropriate for sites that need to avoid threading for compatibility with non-thread-safe libraries.

#apt-get instal install apache2

#apt-get install apache2-mpm-prefork

That’s it  basic apache2 installation finished. If you want to test your installation go to your browser and type the following

http://youripaddress/apache2-default/

This should display welcome message then your installation is correct.

Default document root directory for apache2 is /var/www

If you want to change the default document root directory in apache2 you have  to modify /etc/apache2/sites-available/default file.Edit this file and change the path to where ever you want to change.

PHP Support For Apache2

If you want to add support of php and cgi scripts install the following packages libapache2-mod-php5,php5-cli,php5-common,php5-cgi

# apt-get install libapache2-mod-php5 php5-cli php5-common php5-cgi

Make sure you have all the following lines need to uncomment somewhere in your apache2.conf (or in your conf.d/php.ini) file:

LoadModule php5_module modules/libphp5.so

# Cause the PHP interpreter to handle files with a .php extension.

AddType application/x-httpd-php .php

If you want to allow the different index files types check for the following line in /etc/apache2/apache2.conf file

DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.shtml

Restart the apache server

/etc/init.d/apache2 restart

Share/Save/Bookmark

Tags: , , ,

27 Dec 08 mount /tmp partition with ‘noexec’ option

It is recommended to create /tmp as separate partition and mount it with ‘noexec’ and ‘nosuid’ options.

‘noexec’ disables the executable file attribute within an entire filesystem, effectively preventing any files within that filesystem from being executed.

‘nosuid’ disables the SUID file-attribute within an entire filesystem. This prevents SUID attacks on, say, the /tmp filesystem.

If /tmp is a separate partition on the server, you only need to edit /etc/fstab and add ‘noexec’ and ‘nosuid’ options for /tmp. Then remount the partition.

If /tmp directory resides on / partition, it is better to create new partition for /tmp,  for example with size
512 MB:

# mkdir /filesystems
# dd if=/dev/zero of=/filesystems/tmp_fs seek=512 count=512 bs=1M
# mkfs.ext3 /filesystems/tmp_fs

Add the string into /etc/fstab:

/filesystems/tmp_fs /tmp ext3 noexec,nosuid,loop 1 1

Move current /tmp directory content to another location.

Mount new /tmp partition:

# mount /tmp

Share/Save/Bookmark