Tuesday, November 25, 2008

how to change IP in Direct Admin

Steps for changing server ip and creating images.


**** Change server ip ****
Boot the server with the new server ip. (the new one you want to use)
DirectAdmin will not be running, as the license file will be invalid.
Contact DirectAdmin to obtain a new license file. They will change the ip in the license.
Get the new license file:

cd /usr/local/directadmin/scripts
./getLicense.sh UID LID

Where UID and LID are your client ID and your license id.
Ensure the license downloaded properly by making sure the file contains no error messages.
Start DirectAdmin with the new license:

service directadmin restart

(The taskq may have already started it, thus the restart instead of just "start")

Download the ipswap.sh script from directadmin:

wget http://www.directadmin.com/ipswap.sh
chmod 755 ipswap.sh

Execute that script with the old and and the new ip. Example:

./ipswap.sh 1.2.3.4 4.3.2.1

where 1.2.3.4 is your old ip and 4.3.2.1 is the new ip.
This script can be run on any ip, so if you want to change all ips with new ones, just run this script for each old ip with the new ip. Just ensure that you match the new server ip with the old one.

Restart everything:

service httpd restart
service proftpd restart
service exim restart
service vm-pop3d restart
...

Make sure they are correctly binding to the new ports by testing them.

You'll need to update the users list cache so that you see the new results in the show users lists:

echo "action=cache&value=showallusers" >> /usr/local/directadmin/data/task.queue


OR

Updating your DirectAdmin License manually Last Modified: Nov 17, 2005, 10:07 pm
If you need to update your DirectAdmin license manually, you can do so by running the following commands:

cd /usr/local/directadmin/scripts
./getLicense.sh 123 1234
service directadmin restart
Where 123 and 1234 are your Client ID and License ID, respectively. If there are errrors extracting the update.tar.gz file, then run:
head -n 1 /usr/local/directadmin/conf/license.key

to search for an error. If there is an readable error inside the file, double check the IP you are using matches the IP in the license on our system. Also check that it's active in our clients section. Failing that, you'll need to contact sales@directadmin.com to get your license activated or updated.

If you have multiple IPs on your device and wget is binding to the incorrect one, you can specify the IP to bind to by adding it as the last argument:

cd /usr/local/directadmin/scripts
./getLicense.sh 123 1234 1.2.3.4
service directadmin restart

**** Creating an Image ****

Install whatever additional services you want on the server (if you need up2date, this would be a good time)

Install a default copy of DirectAdmin on a server.
Be sure to install the customapache script.

Delete the license (doesn't really matter.. just so that nobody else gets a hold of it)

Create the image using whatever method you would like.


*** copy the image to the new server

Run the scripts you would normally run to setup the image properly.
Instead of manually changing the ip through DirectAdmin (as above), you can use the ipswap.sh script as decribed above to swap all instances of the IPs.

When you need to use the server, contact DirectAdmin, order a license using the new server's ip.
Once activated, use the getLicense.sh (see above) to download the license for this system.

Restart DirectAdmin and you should be up and running.


Special notice for VPS/VDS installs:

After the install, add:

ethernet_dev=devicename

for example, on many vps systems it will be:
ethernet_dev=venet0:0

other systems where the IP is not the base IP on the device, you'd need to simply set the correct number:
ethernet_dev=eth0:1

or other systems with the IP on a different device, it might be:
ethernet_dev=eth1

type: /sbin/ifconfig
to see which device your IP is in.

to /usr/local/directadmin/conf/directadmin.conf.
Replace devicename with the FULL devicename reported by ifconfig. If your VDS/VPS system emulates eth0, then you may skip this step.

Saturday, November 22, 2008

Create xen templates for hypervm

Go to www.jailtime.org to download the desired template. The templates on jailtime.org are generic xen templates and need some modifications before they could be installed in the hypervm server.
we will here make gentoo template available on jailtime.org to make it work on the hypervm server.

First login to your xen main node as -su
# wget "http://www.jailtime.org/lib/exe/fetch.php?cache=cache&media=download%3Agentoo%3Agentoo.2008-0.20080719.img.tar.bz2"

# tar jxf gentoo.2008-0.20080719.img.tar.bz2

mkdir /mnt/tmp
mount -o loop /root/gentoo.2008-0.img /mnt/tmp

nano /mnt/tmp/etc/inittab
1:2345:respawn:/sbin/getty -L xvc0 9600 vt100

nano /mnt/tmp/etc/ssh/sshd_config
PermitRootLogin yes

cd /mnt/tmp
tar czf /home/hypervm/xen/template/gentoo.23nov2008.tar.gz .

You are done :)

Sunday, November 16, 2008

Fomat hard disk in linux using fdisk

new disk using fdisk command

Following command will list all detected hard disks:
# fdisk -l | grep '^Disk'
Output:

Disk /dev/sda: 251.0 GB, 251000193024 bytes
Disk /dev/sdb: 251.0 GB, 251000193024 bytes

A device name refers to the entire hard disk. For more information see Linux partition naming convention and IDE drive mappings.
To partition the disk - /dev/sdb, enter:
# fdisk /dev/sdb
The basic fdisk commands you need are:

* m - print help
* p - print the partition table
* n - create a new partition
* d - delete a partition
* q - quit without saving changes
* w - write the new partition table and exit

Step#2 : Format the new disk using mkfs.ext3 command

To format Linux partitions using ext2fs on the new disk:
# mkfs.ext3 /dev/sdb1
Step#3 : Mount the new disk using mount command

First create a mount point /disk1 and use mount command to mount /dev/sdb1, enter:
# mkdir /disk1
# mount /dev/sdb1 /disk1
# df -H
Step#4 : Update /etc/fstab file

Open /etc/fstab file, enter:
# vi /etc/fstab
Append as follows:

/dev/sdb1 /disk1 ext3 defaults 1 2

Save and close the file.
Task: Label the partition

You can label the partition using e2label. For example, if you want to label the new partition /backup, enter
# e2label /dev/sdb1 /backup
You can use label name insted of partition name to mount disk using /etc/fstab:
LABEL=/backup /disk1 ext3 defaults 1 2

Saturday, November 15, 2008

How to install xen hypervm in centos

The simple way to install xen is.
FIRST CHECK THE BIOS/CPU IF THEY SUPPORT VIRTUALIZATION (VT) IN INTEL CPU.

First delete all the linux partition if exist on the system.
Create /swap double the size of the RAM on the system.
/boot 500mb
/40000 in ext3
In free space. Make LVM
create /

If you want to use the RAID than use software RAID.

Once completed.

For hypervm make sure selinux is disabled
  • $ setenforce 0
  • $ wget http://download.lxlabs.com/download/hypervm/production/hypervm-install-master.sh
  • $ sh ./hypervm-install-master.sh --virtualization-type=xen/openvz/NONE
  • Here we need xen
    Run the installation of hypervm xen. Once completed.

    cd /usr/local/lxlabs/hypervm/httpdocs/

    lphp.exe ../bin/misc/fixcentos5xen.php


    If hyperVM didn't automatically recognize the xen driver, you can run the command below to forcibly set it.

    -------------

    cd /usr/local/lxlabs/hypervm/httpdocs/

    lphp.exe ../bin/common/setdriver.php --server=localhost --class=vps --driver=xen



    What’s LVM? Why using Linux Logical Volume Manager or LVM?
    These questions are not the scope here. But in brief, the most attractive feature of Logical Volume Manager is to make disk management easier in Linux! Basically, LVM allows users to dynamically extend or shrink Linux “partition” or file system in online mode! The LVM can resize volume groups (VG) online by adding new physical volumes (PV) or rejecting those existing PVs attached to VG.

    A visualized concept diagram of the Linux Logical Volume Manager or LVM.

    A visualized concept diagram of the Linux Logical Volume Manager or LVM


    In this 3-minutes Linux LVM guide, let’s assume that

    * The LVM is not currently configured or in used. Having say that, this is the LVM tutorial if you’re going to setup LVM from the ground up on a production Linux server with a new SATA / SCSI hard disk.

    * Without a luxury server hardware, I tested this LVM tutorial on PC with the secondary hard disk dedicated for LVM setup. So, the Linux dev file of secondary IDE hard disk will be /dev/hdb (or /dev/sdb for SCSI hard disk).

    * This guide is fully tested in Red Hat Enterprise Linux 4 with Logical Volume Manager 2 (LVM2) run-time environment (LVM version 2.00.31 2004-12-12, Library version 1.00.19-ioctl 2004-07-03, Driver version 4.1.0)!

    How to setup Linux LVM in 3 minutes at command line?

    1. Login with root user ID and try to avoid using sudo command for simplicity reason.

    2. Using the whole secondary hard disk for LVM partition:

    fdisk /dev/hdb

    At the Linux fdisk command prompt,
    1. press n to create a new disk partition,
    2. press p to create a primary disk partition,
    3. press 1 to denote it as 1st disk partition,
    4. press ENTER twice to accept the default of 1st and last cylinder - to convert the whole secondary hard disk to a single disk partition,
    5. press t (will automatically select the only partition - partition 1) to change the default Linux partition type (0×83) to LVM partition type (0×8e),
    6. press L to list all the currently supported partition type,
    7. press 8e (as per the L listing) to change partition 1 to 8e, i.e. Linux LVM partition type,
    8. press p to display the secondary hard disk partition setup. Please take note that the first partition is denoted as /dev/hdb1 in Linux,
    9. press w to write the partition table and exit fdisk upon completion.


    3. Next, this LVM command will create a LVM physical volume (PV) on a regular hard disk or partition:

    pvcreate /dev/hdb1

    4. Now, another LVM command to create a LVM volume group (VG) called vg0 with a physical extent size (PE size) of 16MB:

    vgcreate -s 16M vg0 /dev/hdb1

    Be properly planning ahead of PE size before creating a volume group with vgcreate -s option!

    5. Create a 400MB logical volume (LV) called lvol0 on volume group vg0:

    lvcreate -L 400M -n lvol0 vg0

    This lvcreate command will create a softlink /dev/vg0/lvol0 point to a correspondence block device file called /dev/mapper/vg0-lvol0.

    6. The Linux LVM setup is almost done. Now is the time to format logical volume lvol0 to create a Red Hat Linux supported file system, i.e. EXT3 file system, with 1% reserved block count:

    mkfs -t ext3 -m 1 -v /dev/vg0/lvol0

    7. Create a mount point before mounting the new EXT3 file system:

    mkdir /mnt/vfs

    8. The last step of this LVM tutorial - mount the new EXT3 file system created on logical volume lvol0 of LVM to /mnt/vfs mount point:

    mount -t ext3 /dev/vg0/lvol0 /mnt/vfs

    To confirm the LVM setup has been completed successfully, the df -h command should display these similar message:


    vgdisplay vg0

    To check or display volume group setting, such as physical size (PE Size), volume group name (VG name), maximum logical volumes (Max LV), maximum physical volume (Max PV), etc.

    pvscan

    To check or list all physical volumes (PV) created for volume group (VG) in the current system.

    vgextend

    To dynamically adding more physical volume (PV), i.e. through new hard disk or disk partition, to an existing volume group (VG) in online mode. You’ll have to manually execute vgextend after pvcreate command that create LVM physical volume (PV).



    Now login to the hypervm as admin
    http://192.168.1.1:8888 (This should be your IP address)
    Go to server > Home > Location >

    lvm:vg0 <------------------ This VGO is the partition we created above.
    Now it's all set for ready to GO!!!!

    :)