Thursday, December 19, 2013

Proxmox Virtualiazation

Proxmox Virtualiazation

1. What is Proxmox?
2. Installation
3. Promox Usage
4. VPSs Storage
4.1 Create a Raid storage for VPSs and backup

1. What is Proxmox?

Proxmox is an Open Source Server Virtualization Platform, based on KVM and OpenVZ.

2. Installation
Go to proxmox web site and download the the latest version at: http://www.proxmox.com/downloads
and install,
In this example my harddis size to install Promox is just only 55GB. and I will configure Raid 5 to store the Virtual Private Servers (VPSs) and VPSs Backup in the following steps.

Follow the installations step and fill in by your own information:
Enter to Boot: _
I agree
Next
Next
Next
Wait, 
Next
Reboot, to finish the installation.
We can log in with user "root" with the password that we put during the installation.
Or we can access via web browser with user "root" with the password that we put during the installation.


3. Promox Usage

Proxmox system file and path:
Proxmox has 3 main default configuration paths:
/etc/pve/
It is the important path for global Proxmox configuration such as VMs list, Storage information, Users, etc.
/etc/vz/
It is mainly for the Proxmox repository where we can define the download repository, logs path, log level etc.
/var/lib/vz 
It is the default storage where we can store the IOS, images, dumps and as well as the VPSs. We are currently point all these images and VMs to /storage partition.

4. VPSs Storage
4.1 Create a Raid storage for VPSs and backup

In this example, I am going to configure RAID5 with 50GB with 3 Disks.
Install required softwares:
apt-get update
apt-get install vim
apt-get install mdadm

Now I am going to setup RAID5 on /dev/sdb /dev/sdc /dev/sdd
root@proxmox01:~# fdisk /dev/sdb 
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x98a71f64.
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)

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): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 
Using default value 1
First sector (2048-104857599, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599): 
Using default value 104857599

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): L
 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris        
 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx         
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data    
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility   
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt         
 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access     
 a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O        
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor      
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fs        
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT            
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor      
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor      
14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary  
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS    
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE 
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep        
1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT            
1e  Hidden W95 FAT1 80  Old Minix      
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)

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

Calling ioctl() to re-read partition table.
Syncing disks.
root@proxmox01:~#

and then do the same for other disks (/dev/sdc and /dev/sdd)

RAID-5:
mdadm --create --verbose /dev/md0 --level=5 --raid-devices=3 /dev/sdb1 /dev/sdc1 /dev/sdd1
root@proxmox01:~#mkfs.ext4 /dev/md0 
root@proxmox01:~# mkdir /storage
root@proxmox01:~# mount /dev/md0 /storage/
Now we should see /storage with the size (50GB * 3) - 50GB = 100GB

Add to fstab file
vi /etc/fstab

Create tother 3 folders under /storage
mkdir /storage/proxmox_sys
mkdir /storage/proxmox_data
mkdir /storage/proxmox_backup

Changing default Proxmox configuration and storage path
cd /etc/vz/
vi vz.conf
Change following 
LOCKDIR=/storage/proxmox_sys/lib/vz/lock
DUMPDIR=/storage/proxmox_sys/lib/vz/dump
LOGFILE=/storage/proxmox_sys/log/vzctl.log
TEMPLATE=/storage/proxmox_sys/lib/vz/template
VE_ROOT=/storage/proxmox_sys/lib/vz/root/$VEID
VE_PRIVATE=/storage/proxmox_sys/lib/vz/private/$VEID

Go to -> Data Center -> Storage -> Add -> Directory -> Select (ISO,Images,Containers and Templates) and named the Directory as proxmox_data
Go to -> Data Center -> Storage -> Add -> Directory -> Select (Backups) and named the Directory as proxmox_backup
and all the other required folders will be create automatically in these folders.

Copy the image iso for the distribution that you want to install and put in the correct location.
Example, we want to install a Ubuntu server, so we just copy the image iso of Ubuntu server put in: /storage/proxmox_data/template/iso
So when we create the VPSs we can select the default location or we want to use the path /storage which is the RAID-5 we create.

Here We go, Enjoy.

Error:

Go to -> Option -> KVM hardware virtualization -> Untick -> OK

That all for now about this Virtualize environments that I want to mention...! 

I am going to test more with the Cluster and Move a VPSs without downtime. ;) for the next post.





Friday, December 13, 2013

Unison File Synchronizer

Unison File Synchronizer

There are many tools use to sync file from one server to other server or two way synchronization.
In my previous artical I use to mentions one tool call CSYNC2 (Cluster Synchronization Tool).
After using this tool for a while there are some more features that I need but this tool could not show it up.

For I now I try to set and other tool up call: Unison File Synchronizer

Which is an other File Synchronizer tool, That I going to mention and show what I tried and work as what I exspected:
That provide 2 ways synchroinzations between nodes and we also could exclude (ignore) the folder that we don't want to sync also.
Here is a sample structure sync:


Install in Ubuntu server:
apt-get install unison

There are many different ways of using this tool. In this purpose I am going to sync between 2 servers. (they are cluster-servers)

After Installed,
Make sure these 2 node can automatically log in into each other with using password:
by using key. If you not sure how to check it out from here:
After complete this step,
1. Log in as root on server1 and edit a default profile file:
vi /root/.unison/default.prf
with content:
---------------------------------------------------
# Unison preferences file
include userone
include usertwo

root = /home
root = ssh://server2//home

auto=true
batch=true
confirmbigdel=true
fastcheck=true
group=true
owner=true
prefer=newer
silent=true
times=true

2. Edit file userone
vi /root/.unison/userone
with content:
---------------------------------------------------
# Paths to synchronize
path = userone/public_html

# Ignore
ignore = Path userone/public_html/foldertemp/*

3. Edit file usertwo
vi /root/.unison/usertwo
with content:
---------------------------------------------------
# Paths to synchronize
path = usertwo/public_html

# Ignore
ignore = Path usertwo/public_html/foldertemp/*
---------------------------------------------------

Now that we have put all settings in a preferences file (especially the root (and optionally the path) directives), we can run Unison without any arguments:
unison 
Or,
We should run this in cron in every 2 minutes:
crontab -e
*/2 * * * * /usr/bin/unison &> /dev/null

In this example will sync 2 ways between public_html and ignore /public_html/foldertemp in home users:
userone and usertwo between server1 and server2.

Note:
* Unison will check configurations in its users run the command, in folder name ~/.unison
* In file /root/.unison/default.prf has the option include filename
(we can include as many files as we one with those filename that contain the path we want to sync.)
* We can include the path as many as we want.

For more info: http://www.cis.upenn.edu/~bcpierce/unison/lists.html

Thursday, December 12, 2013

Linux Professional Institute Candidate in Cambodia

Linux Professional Institute Candidate in Cambodia

#Linux #Professional #Institute #Cambodia 
#LPI



Monday, December 2, 2013

Use Your Own Domain With Blog

Use Your Own Domain With Blog

What we need:
- Domain name registrations (vannakk.net)
- Blogger Site (vannakk.blogspot.com)

1. Own a domain with DNS. so register your domain with DNS

2. Add a record
Name TTL Class TYPE Record
www.vannakk.net. 3600 IN CNAME ghs.google.com


3. Change on your Blog
Go to Setting --> Publishing --> Advanced settings --> Add a custome domain
- Enter your domain name.
- Tick Redirect none www. to www.
- Save.

4. TIPs
If you are setting sub domain like www.mydomain.com instead of my domain.com
and if you want to point your nick domain i.e.mydomain.com to your blog,
you also have to add four A records to dns settings of your domain to these ip address as follows :
* 216.239.32.21
* 216.239.34.21
* 216.239.36.21
* 216.239.38.21

After a while you blog should be redirect to http://www.vannakk.net/  . Depend on TTL settings.
Done,