Tuesday, December 21, 2010

Doing some works on Load Balancer with Crossroads.

Well, it's finally about time to begins my senior project stuffs.
Let's say I've been doing busy with some jobs earlier, So I didn't have a chance to look at it much.
But It is nearly new year, everybody's going back their home after midterm examinations.
For me, It's time to move on and working on stuffs.
The less people, The more I can concentrate on this work. (I don't like to be surrounded by people much.)

Talk to much, let's see how I install crossroads on ubuntu. It's easy and work fine.

First download the crossroads package from their website.
$cd /
$wget http://crossroads.e-tunity.com/downloads/crossroads-stable.tar.gz
Untar it.
$tar -xzvf crossroads-stable.tar.gz
Then before starting our installation. Make sure that you've already installed the build-essential package.
$sudo apt-get install build-essential
 Let's begin!
$cd crossroads-2.68
$sudo make install
Wait for a moment. Then we done!
Now it's time for configuration.
Crossroads provides two ways of configuration. Using command-line, or using xml.
Let's see the first one. If we need to use command-line, then we use "xr" command for all configuration.
$xr --verbose --server tcp0:80 / #this will tell xr that we use this server as load balancer
-W 10.10.10.1:8001 / #and this will create our web interface on port 8001
-backend 10.10.10.2:80 / #this will create backend according to the ip address and port
-backend 10.10.10.3:80
This will make your server to listen to port 80 and to dispatch traffic to servers 10.10.10.2 and 10.10.10.3
A web interface for the balancer is started on port 8001

Instead of starting XR by hand, we may use xrcrl as preferable. But first, you've to create a configuration.
To do so, put the following in the file /etc/xrctl.xml
<?xml version="1.0" encoding="UTF-8"?>
     <configuration>
        <system>
          <uselogger>true</uselogger>
          <logdir>/tmp</logdir>
        </system>
        <service>
          <name>web</name>
        <server>
          <address>0:80</address>
          <type>tcp</type>
          <webinterface>10.10.10.1:8001</webinterface>
          <verbose>yes</verbose>
        </server>
        <backend>
          <address>10.10.10.2:80</address>
        </backend>
        <backend>
          <address>10.10.10.3:80</address>
        </backend>
        </service>
     </configuration>
Then type these following commands to start the xr
$xrctl start
Or to stop.
$xrctl stop 
That's all for today. Late night again. OMG!!

Credits : Crossroads

Saturday, December 18, 2010

How to install FTP with vsftpd.

Very easy to configure. recommended!!


First install via apt-get
$sudo apt-get install vsftpd
Let's have it back up before doing anything is recommend!
$sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak
Now begin to configure!
Disable anonymous login and enable local users login, give them write permission.
anonymous_enable=NO
# Let local users login
# If you connect from the internet with local users, you should enable TLS/SSL/FTPS
local_enable=YES

# Write permissions
write_enable=YES
To Deny some users to login
userlist_deny=YES
userlist_file=/etc/vsftpd.denied_users
In the file /etc/vsftpd.denied_users add the username of the users that can't login. One username per line.

To Allow some users to login
userlist_deny=NO
userlist_enable=YES
userlist_file=/etc/vsftpd.allowed_users
In the file /etc/vsftpd.allowed_users add the username of the users that can login. One username per line.

TLS/SSL/FTPS
Add these code at the end of file.
ssl_enable=YES
allow_anon_ssl=NO
force_local_data_ssl=YES
force_local_logins_ssl=YES
ssl_tlsv1=YES
ssl_sslv2=YES
ssl_sslv3=YES
Additional Options
# Show hidden files and the "." and ".." folders.
# Useful to not write over hidden files:
force_dot_files=YES

# Hide the info about the owner (user and group) of the files.
hide_ids=YES

# Connection limit for each IP:
max_per_ip=3

# Maximum number of clients:
max_clients=5
Then, have it applied new configuration.
$sudo /etc/init.d/vsftpd restart 
That's all the configurations I've applied to my ftp server.
If you need more option, please kindly visit this site which can provides you for further information.
Ubuntu Forum 


Credits : epimeteo from Ubuntu Forum. Thx :)

Thursday, December 16, 2010

Great book on Servlets & JSP

It's really good to think of reading a textbook instead of a bunch of papers of your class.
In Thailand, Educational system in higher level such Bachelor's Degree in many high-rank University
still using a bunch of papers, which we called "sheet", for teaching during class.
It's just a slide-printed on paper. So, seems like I can't find much of details in there.
For me, to know and understand what I learned from class is to read the whole details of the topics,
not only the topics and some of information that lied around the paper.

On my last exam I took, which is today, about noon. It's the Internet Programming class.
It's about Servlets and JSP. Unfortunately, I've skipped 2 classes, my head's gone empty
until I've found a book which tutor's using as reference. Head First Servlets and JSP
It's really great book! I recommended for this book if you're totally new to Servlets and JSP.
But, it required some of Java Skills. So, you might need to know Java before start reading this one.
Oh, I didn't buy the book actually, I borrowed it from the library at my Institute.
Don't look in the bad way. I don't have that much of money to spend, even I did spend a lot
on many books from Amazon.com

Anyway, I'm totally like this book. It have great content. Also,the way they represent details on each topic is
like..you know, It's comic, full of pictures and images. It's good for your brain when you've to
remember something so complicated.

That's all for today :)

Tuesday, December 7, 2010

Insertion Sort and Merge Sort in Java

Well it's my homework in DAA (Design and Analysis of Algorithms)
Talking about the algorithms, itself is brought from the book that we've used
which is "Introduction to Algorithms 3rd edition"
It's a good book, but I do weak in maths somehow.
So, probably there is some of them I couldn't understand right away.
It's bad to have a worst logic and maths skill, you know?
whatever, let's see the code that I have written using Java.
(Somebody said that they doesn't like Java because of its performance,
But I don't. I prefer it than C/C++ in some way.)

Insertion Sort
public static void insertionSort_2(int x[]) {
        int i, j, key;
        for (j = 1; j < x.length; j++) {
            key = x[j];  
            i = j - 1; 
            while (i >= 0 && x[i] > key) { 
                x[i + 1] = x[i]; 
                i = i - 1; .
            }
            x[i + 1] = key; 
        }
    }
This one works based on the algorithms of insertion sort. First we find the key.
then we lock the key so we won't get confuse between
the length of array we are caring and the one that is still out of our sight.
after that we just sorting it, by compare the value of an array, one by one.
when it have sorted, we just change the key. moving to the next one until the whole array is sorted.

Merge Sort
public static void merge_sort(int y[], int p, int r) {
        if (r > p) {
            int q = (p + r) / 2;
            merge_sort(y, p, q);
            merge_sort(y, q + 1, r);
            merge(y, p, q, r);
        }
    }
 Merge method
public static void merge(int y[], int p, int q, int r) {
        int n1 = q - p + 2;
        int n2 = r - q + 1;
        int i, j, k;
        int []left = new int[n1];
        int []right = new int[n2];
        //Cp y to left array
        for (i = 0; i < n1 - 1; i++) {
            left[i] = y[p + i];
        }
        left[n1 - 1] = INF;
        //Cp y to right array
        for (i = 0; i < n2 - 1; i++) {
            right[i] = y[q + 1 + i];
        }
        right[n2 - 1] = INF;
        i = 0;
        j = 0;
        for (k = p; k <= r; k++) {
            if (left[i] <= right[j]) {
                y[k] = left[i];
                i++;
            } else {
                y[k] = right[j];
                j++;
            }
        }
    }
For merge sort, there are two method you need.
The first one is for divide an array into separate two of them.
Another one is for merging them together.
I won't explain it clearly because it will take me a while to try to explain it.
As you can see that I'm not English native, so It's quite hard to write.

And It's all for tonight. I'm late for my bed again.

Thanks for reading
:)

Friday, November 19, 2010

Another way to install VMWare Server 2 on Ubuntu 10.04

The first way I've provided is not the only way that you could follow in order to install VMWare Server 2.
 Now Let's consider this method of installation.

1. Download VMware Server (VMware-server-2.0.2-203138.i386.tar.gz).
2. Download the VMware Server 2 update patch #2
$ wget -N http://risesecurity.org/~rcvalle/VMware-server-2.0.2-203138-update-2.patch
3. Extract VMWare Server
$ tar -xzf VMware-server-2.0.2-203138.i386.tar.gz
4. Extract VMWare Server Modules
$cd vmware-server-distrib/lib/modules/source
$tar -xf vmci.tar
$tar -xf vmmon.tar
$tar -xf vmnet.tar
$tar -xf vsock.tar
5. Apply the patch
$cd vmware-server-distrib/
$patch -p1 < ../VMware-server-2.0.2-203138-update-2.patch
6. Archive VMWare Server Modules again
$cd vmware-server-distrib/lib/modules/source
$rm -f vmci.tar
$rm -f vmmon.tar
$rm -f vmnet.tar
$rm -f vsock.tar
$tar -cf vmci.tar vmci-only/
$tar -cf vmmon.tar vmmon-only/
$tar -cf vmnet.tar vmnet-only/
$tar -cf vsock.tar vsock-only/
7. Run the installer script as root
$cd vmware-server-distrib/
$sudo ./vmware-install.pl

Note :
1. Don't forget to add a new administrative user when it asked for.
2. The VMWare Remote Console Plug-in doesn't work properly on Ubuntu 10.04. You can set the environment variable  VMWARE_USE_SHIPPED_GTK before running the VMWare Remote Console Plug-in. You can do this by add the following line to your ~/.profile
export VMWARE_USE_SHIPPED_GTK=yes

Credits : Rise Security

Tuesday, November 16, 2010

Where is my datastore!? (VMWare Server 2 on Ubuntu Lucid)

reJust put your own existing virtual machine in to this place and added it into your datastore with vmware-web console.
/var/lib/vmware/Virtual Machines
That's all :)

when 503 Service Unavailable comes up!! (cause from vmware server2)

Ok after last night I've recently finished my vmware server 2 installation.
I came back this evening and found that I couldn't connect to my vmware web console.
And it keeps telling me that 503 service unavailable thing. so I google and found some interesting solution.

Let's start with stopping all of its services.
$/etc/init.d/vmware stop
If it resulted in something like this. (Something just resulted in "Failed")
Stopping VMware services:
Virtual machine monitor failed
Bridged networking on /dev/vmnet0 done
DHCP server on /dev/vmnet1 done
Host-only networking on /dev/vmnet1 done
DHCP server on /dev/vmnet8 done
NAT service on /dev/vmnet8 done
Host-only networking on /dev/vmnet8 done
Virtual ethernet failed
or when you try to start your vmware and you resulted in
$sudo /etc/init.d/vmware start
vmware is installed, but it has not been (correctly) configured
for this system. To (re-)configure it, invoke the following command:
/usr/bin/vmware-config.pl.
It's telling you to run vmware-config.pl again. So I try to do as it said. It resulted in this.
The following VMware kernel modules have been found on your system that were
not installed by the VMware Installer.  Please remove them then run this
installer again.

vmmon
vmci
vmnet

I.e. - 'rm /lib/modules/2.6.28-11-generic/misc/<ModuleName>.{o,ko}'

Execution aborted.
Then you need to remove the 3 mods that it mentioned with rmmod.
For me "rmmod" doesn't work. So I use hard remove (just delete it where they are.)
How to find it? easy!
$locate [THINGS YOU WANT TO FIND]
mine is in the /lib/modules/2.6.32-24-server/misc/
So I removed all of them
$rm /lib/modules/2.6.32-24-server/misc/*
There you go! now you can stop vmware services and reconfigure your vmware-config.pl
$/etc/init.d/vmware stop
$/usr/bin/vmware-config.pl
 Credits : Ubuntu forum 

Installing VMWare Server 2 on Ubuntu Lucid Lynx (10.04)

After conversion those files, now it's time for a new clean install ubuntu and vmware server 2.
I'll skip the ubuntu installation, it's the thing you gotta do by your own, not so hard.

Let's take a look in the first step before install vmware server 2 after clean installed of ubuntu.

1. Don't forget to update and upgrade all the necessary packages.
sudo apt-get update 
sudo apt-get upgrade 
2. Build essential packages
sudo apt-get install buil-essential
3. If you don't have gcc, you might want to install this package before the installation.
sudo apt-get install gcc 
 4. Download the vmware package and put in somewhere you want to.
 5. Because the ubuntu 10.04 has update its kernel to 2.6.32 so you need to patch you vmware package before apply the installation. Go download script from here
 6. Run the script with super user rights either in the same folder where you have downloaded the server archive (mine is /home/mazaruz/VMware-server-2.0.2-203138.x86_64.tar.gz.gz So I put the scripts in /home/mazaruz/ )
chmod +x vmware-server.2.0.1_x64-modules-2.6.30.4-fix.sh
sudo ./vmware-server.2.0.1_x64-modules-2.6.30.4-fix.sh [PATH_TO_VMWARE_ARCHIVE]
 7. Then it'll lead you to the installation of vmware itself. just do as it said. Don't forget to add your new user for administration your vmware server. 
 8. the license key can be found in vmware website when you registered there. just copy it.
 9. All is finish!!

Credits : Radu Thank you for a nice script :)

Sunday, November 14, 2010

Migration back from Esxi4 to Server2

It looks like my server can't handle this esxi anymore.
All of the virtual machines slow down for weeks.
So, I've been trying to do migration for 3 days.
And Today I've found a way to do it easily.

First you gotta have a VMware vCenter Converter Standalone Product
you can download it for free at vmware.com

Now you got installed, It will be like this.



Then just select Convert Machine on the left side of the panel.
It will ask you whether type you want to convert. I choose the first one
"VMware Infrastructure virtual machine"
Don't forget to enter your esxi's address and username with password.


Then choose the virtual machine you'd like to convert.




 Wait until it completed converting. Then it's all done!!

Saturday, October 9, 2010

Monday, September 27, 2010

Allow root to ftp into your Ubuntu-server

Not recommend.
Just go to your /etc/ftpuser file.
then comment to line says "root"

that's all

Sunday, September 26, 2010

Ubuntu-Server GUI

Don't forget to update&upgrade your ubuntu-server!
# apt-get update
# apt-get upgrade
# apt-get dist-upgrade
I only want GUI to run in my ubuntu-server coz I want to use firefox to browsing website.
# apt-get install update-manager gnome-core xorg firefox

Enable mod_rewrite for apache in Ubuntu.

sudo a2enmod rewrite
sudo /etc/init.d/apache2 restart
cd /etc/apache2/mods-enabled
grep mod_rewrite *


Fix these things


#sudo vi /etc/apache2/site-avaliable/default

then find the following
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
Change it to
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
Then restart your vsftp.

First Blogging !!!

How comes this one?
Since I've through many many jobs, I always forget how to done it!
Of cause, I might document it all, but It's hard to find the title
and it's really hard to keep them all.
So, I think this will be another solution.

Have Fun!!