Archive for the ‘Hosting’ Category

7 November, 2013 — Hosting

How to Extended a Linux Logical Volume

I recently upgraded the disk space on one of my Linux VPS servers and once the upgrade was done the space was still not added to the server… after a search around on the internet I found that I needed to Extend the Logical Volume of the VPS to add the extra 40GB of HDD space.

Below is a step by step guide of how to do this. Extending your LV should not delete any data however I can’t be held responsible if this does happen. However removing space from your LV will result in data loss. This guide is only extending the LV so you shouldn’t run into any trouble.

Please comment below if you have any questions regarding this!

Show Me How!

First, check the drives on the server with fdisk -l:

# fdisk -l
Disk /dev/hda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
  Device Boot      Start        End      Blocks  Id  System
/dev/hda1  *          1          33      265041  83  Linux
/dev/hda2              34        164    1052257+  82  Linux swap / Solaris
/dev/hda3            165        5221    40620352+  8e  Linux LVM
Disk /dev/sda: 85.8 GB, 85899345920 bytes
16 heads, 63 sectors/track, 166440 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
  Device Boot      Start        End      Blocks  Id  System
/dev/sda1              1      83220    41942272+  8e  Linux LVM
We will first add the extra 40GB from the system drive (hda). Start to modify the partition table with fdisk, specifying the drive “hda”
# fdisk /dev/hda
The number of cylinders for this disk is set to 10443.
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):
 At this prompt, you can type “p” to display the current partitioning:
Command (m for help): p
Disk /dev/hda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
  Device Boot      Start        End      Blocks  Id  System
/dev/hda1  *          1          33      265041  83  Linux
/dev/hda2              34        164    1052257+  82  Linux swap / Solaris
/dev/hda3            165        5221    40620352+  8e  Linux LVM
Command (m for help):
We want to add another partition so type “n” then “p” and specify partition “4” as 1, 2 and 3 are used. The next two prompts can be left blank to use the default.
Command (m for help): n
Command action
  e  extended
  p  primary partition (1-4)
p
Selected partition 4
First cylinder (5222-10443, default 5222):
Using default value 5222
Last cylinder or +size or +sizeM or +sizeK (5222-10443, default 10443):
Using default value 10443
Command (m for help):
Now, we change the partition we created to LVM. Type “t” at the prompt, specify partition 4 and then put in the code “8e” to set it to Linux LVM.
Command (m for help): t
Partition number (1-4): 4
Hex code (type L to list codes): 8e
Changed system type of partition 4 to 8e (Linux LVM)
Command (m for help):
Type “p” to make sure the partition is there and set to Linux LVM.
Command (m for help): p
Disk /dev/hda: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
  Device Boot      Start        End      Blocks  Id  System
/dev/hda1  *          1          33      265041  83  Linux
/dev/hda2              34        164    1052257+  82  Linux swap / Solaris
/dev/hda3            165        5221    40620352+  8e  Linux LVM
/dev/hda4            5222      10443    41945715  8e  Linux LVM
Command (m for help):
Type “w” at the prompt to write the changes. This may give you a notice that you need to reboot. If this is the case, simply type “reboot” at the command line.
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: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
# reboot
Broadcast message from root (pts/0) (Thu Oct 31 13:47:39 2013):
The system is going down for reboot NOW!
When the server has come back up, log back in and at the command prompt, check the Physical Volume by typing “pvdisplay”
# pvdisplay
  — Physical volume —
  PV Name              /dev/hda3
  VG Name              VolGroup00
  PV Size              38.74 GB / not usable 20.31 MB
  Allocatable          yes (but full)
  PE Size (KByte)      32768
  Total PE              1239
  Free PE              0
  Allocated PE          1239
  PV UUID              OEY2Ya-0SCL-t8M6-n3yR-lWs7-Kr1z-8UraBM
  — Physical volume —
  PV Name              /dev/sda1
  VG Name              VolGroup00
  PV Size              40.00 GB / not usable 31.25 MB
  Allocatable          yes (but full)
  PE Size (KByte)      32768
  Total PE              1279
  Free PE              0
  Allocated PE          1279
  PV UUID              lXOcRG-1TLW-rpHj-Xzwb-3W9o-49jV-MLMf8N
We now want to add the new partition with pvcreate and specifying the new partition:
# pvcreate /dev/hda4
  Writing physical volume data to disk “/dev/hda4”
  Physical volume “/dev/hda4” successfully created
We can confirm this is added with pvdisplay.
# pvdisplay
  — Physical volume —
  PV Name              /dev/hda3
  VG Name              VolGroup00
  PV Size              38.74 GB / not usable 20.31 MB
  Allocatable          yes (but full)
  PE Size (KByte)      32768
  Total PE              1239
  Free PE              0
  Allocated PE          1239
  PV UUID              OEY2Ya-0SCL-t8M6-n3yR-lWs7-Kr1z-8UraBM
  — Physical volume —
  PV Name              /dev/sda1
  VG Name              VolGroup00
  PV Size              40.00 GB / not usable 31.25 MB
  Allocatable          yes (but full)
  PE Size (KByte)      32768
  Total PE              1279
  Free PE              0
  Allocated PE          1279
  PV UUID              lXOcRG-1TLW-rpHj-Xzwb-3W9o-49jV-MLMf8N
  “/dev/hda4” is a new physical volume of “40.00 GB”
  — NEW Physical volume —
  PV Name              /dev/hda4
  VG Name
  PV Size              40.00 GB
  Allocatable          NO
  PE Size (KByte)      0
  Total PE              0
  Free PE              0
  Allocated PE          0
  PV UUID              rHvm5B-MA1d-shpx-3dxp-QCoq-Xhhl-x8KWax
You can view the current volume group with “vgdisplay” to get the VG name
# vgdisplay
  — 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                1
  Open LV              1
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size              78.69 GB
  PE Size              32.00 MB
  Total PE              3798
  Alloc PE / Size      3798 / 78.69 GB
  Free  PE / Size      0 / 0
  VG UUID              H7RyAi-ZTUo-hH0t-nnGi-IBRN-qeMl-umrblW
Extend the Volume Group to include the new partition
# vgextend VolGroup00 /dev/hda4
  Volume group “VolGroup00” successfully extended
Next, we want to check the Logical Volume with lvdisplay. (Note that I had gone back and added the other partition before continuing here),
# lvdisplay
  — Logical volume —
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                sorbDy-tdpk-dqdp-YAfe-OSrs-zDHS-PUvG4K
  LV Write Access        read/write
  LV Status              available
  # open                1
  LV Size                118.69 GB
  Current LE            3798
  Segments              3
  Allocation            inherit
  Read ahead sectors    auto
  – currently set to    256
  Block device          253:0
Take note of the “LV Name” and then we can extend the logical volume using “lvextend”. We can specify the size however by using 100%FREE, it will use all available space.
# lvextend -l +100%FREE /dev/VolGroup00/LogVol00
  Extending logical volume LogVol00 to 158.69 GB
  Logical volume LogVol00 successfully resized
Finally, we resize to the file system so the space is usable with “resize2fs” which can take a few minutes to complete
# 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 41598976 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 41598976 blocks long.
You can confirm the space is usable by running “df -h” again.
# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                      154G  69G  78G  47% /
/dev/hda1            251M  86M  153M  36% /boot
tmpfs                500M    0  500M  0% /dev/shm
/usr/tmpDSK          549M  21M  500M  4% /tmp
The extra space is now usable on your server.
Comment below if you have any questions regarding this!
.
Server Rack
3 June, 2013 — Hosting, Tech

How To Transfer / Migrate cPanel Accounts With No Downtime

Before The Move

Before we even think about moving accounts we need to think about a few other things that need sorting first.

Purchasing A New Server

First things first, if you haven’t already you need to have your new server set-up, have cPanel installed, installed your Firewall and then leave it… just leave it for 4-5 days. This is so you can make sure a. the server is stable and b. the new companies network is stable. The last thing you need is to move all your accounts over and find out the new network is rubbish and your server crashes every five minuets.

Update DNS TTL (Time to Live)

This step has to be done 48-72 hours prior to migration. Changing the TTL (Time To Live) from 14400 (4 hours) to 300 (5 minutes) means that as soon as we make a change to a DNS zone, it will take affect everywhere within 5 minutes as opposed to 4 hours.

To do so you need to run the following commands in your SSH console.

mkdir -p /backup/named-baka ; cp /var/named/*.db /backup/named-baka
perl -pi -e 's/\$TTL 300/\$TTL 14400/g' /var/named/*.db

Once you have done this its just a waiting game… Leave it for a while just to make sure its populated though out the world (24 hours).

Migration Day

Once a day has gone by its d-day… The day of migration. First we need to stop all services on the old server other than Apache and MySQL (to avoid loosing any emails or files people upload) You can do this by running the following commands in SSH

/etc/init.d/cpanel stop
/etc/init.d/exim stop
/etc/init.d/pure-ftpd stop;/scripts/ckillall -9 pure-ftpd;/scripts/ckillall -9 pure-authd
/etc/init.d/proftpd stop

Let The Copying Begin

After that login to WHM on the new server as root then do the following steps:

  1. Click on “Copy Multiple Accounts/Packages From Another Server” (under Transfers)
  2. Fill out the old server data
  3. Select the accounts to transfer
  4. Start the transfer process (this can take some time)

Update DNS

Once the transfer has finished make sure everything is copied across ok and nothing is missing, if you run into any trouble comment below and I will try to help. Once you are happy everything is there SSH into the old server and run the following commands:

mkdir -p /backup/named-bak ; cp /var/named/*.db /backup/named-bak
sed -i 's/[OLD_SERVER_IP]/[NEW_SERVER_IP]/g' *.db
/etc/init.d/named restart

The above commands first make a backup of your DNS databases for each account. Then goes through all of the accounts and updates the DNS records from the old IP to the new IP forcing the DNS servers to send all traffic to the new server! (note this can take anything from 15 – 60 minuets to take effect).

For sites not on a shared IP you will need to edit these DNS records separately to reflect the new IP. Well Done! – All the websites are functioning on the new server, now transfer your Nameservers! Don’t forget to give it 48 hours for the DNS to settle down. DNS can be a pain and take longer to update than other peoples DNS its all different. Once you have waited 48 hours you can shutdown your old server and cancel your account with that host you couldn’t wait to leave!

Resellers?

Note: If you have resellers, we have to copy all the files in /var/cpanel that reference resellers and anything ending in .accts to the new server.

Photo By: Getbutterfly

Amazon Web Services
30 April, 2013 — Development, Hosting, Reviews, Tech

Amazon S3 Review 2013

Below is my Amazon S3 Review for 2013.

What is Amazon S3

S3 stands for Simple Storage Service and is exactly that. S3 is storage that is located in Amazons large data centres across the world, designed to make web-scale computing easier for developers. Amazon S3 provides a simple web services interface that can be used to store and retrieve any amount of data, at any time, from anywhere on the web.

I was sceptical when I first started looking into S3 as I didn’t believe it was as cheap as people said it was. After using it for the past 4 months I know now why people love it! The clue really is in the name “Simple”. The user interface is easy to use and is clean, the pricing again is simple and easy to understand. Keep on reading below, where I will go into more detail about why I love S3.

Amazon S3 Dashboard

Amazon S3 Dashboard

S3 Pricing

S3 operates on a basis of paying only for what you use, with separate fees for storage and data requests. The fees break down as follows:

Storage

5GB FREE (for the first year), then $0.095/GB per month (100GB = $9.50)

Data Transfer (Upload)

$0.00/GB Yes FREE for the first 1TB of data

Data Transfer (Download)

$0.00/GB Yes FREE for the first 1TB of data

PUT, COPY, POST, or LIST Requests

$0.005/1000 Requests

Find out more about the prices here.

No-one can really argue with these prices, and yet Amazon keeps dropping there prices! Only a few years ago S3 storage was priced at $0.15/GB and people thought that was cheap, now with it at an all time low of $0.095/GB people are wondering just how cheaper it can go.

Glacier

I know this is an S3 review but I wanted to bring your attention to a similar service as part of Amazons Web Services and almost a brother to S3 – Glacier.

Glacier is one of Amazons other 25 web service products that is designed to be used for large amounts of data you want to archive away and not touch very often. This is known as Cold Storage. This is because the data is stored deep inside Amazon’s servers where you know its safe but unlike S3 you have less of a need to keep dipping into your data. If you suddenly have the need to access your data you can, however it takes anywhere between 3 to 5 hours to retrieve your data from the Glacier servers. Almost think of Glacier like storing something in a freezer for years until that one day when you need it and you have to wait for it to defrost before using it.

Amazons Glacier’s pricing is as little as $0.01 per GB / month!

Conclusion

Its very hard to find something wrong to write about Amazon S3 because its just so easy and simple to use. You know how much your bill will be at the end of each month and you know the bill will be lower than you think it will be (I know I did). I even managed to not pay a penny for 3 of the 4 months I have been using S3.

Give Amazon S3 a go, I think you will be surprised.
If you already use S3 or any other often Amazon’s web services I’d love to hear your experience.

Easy Apache Error
15 April, 2013 — Hosting

!! Failed to install CPAN Perl module(s) Crypt::PasswdMD5 !! – Easy Apache

cPanel 11.36 is shipped with perl 5.14.3. that might make some problems for your cpan. Some of you might face an error while trying to run easyapache which says:

!! Failed to install CPAN Perl module(s) Crypt::PasswdMD5 !!

Well to fix this issue just run following command to install Crypt::PasswdMD5

# /usr/local/cpanel/bin/cpanm -n Digest::SHA1 Crypt::PasswdMD5

Once you have run the above code in SSH try Easy Apache again.

That didn’t work…

If the above code didn’t work run the following in SSH

# cpan
# install Digest::SHA1 Crypt::PasswdMD5
# exit

After running this try Easy Apache in WHM again and eveything should be working just fine!