Sunday, October 27, 2013

Setting up WSO2 Governance Registry Partitions

In this brief guide, I'll walk you through setting up, WSO2 Governance registry setup in a remote machine, and another local setup (the node) to share with the remote instance. I'm going to setup the remote instance locally as well, so that it's easy for you to set this up, in the same machine (But the procedure would mostly be the same on to an actual remote setup)

As you may know, WSO2 Governance registry is separated into three sub registries;
  •     Config registry - Stores the configurations and related information of a product
  •     Governance registry - Stores governance artifacts and other related information
  •     Local registry - Stores information that is local to a node in a cluster
Local registry, as its name implies, have to be local to that instance. Other two registries can be shared.
To start of with experimenting this setup with WSO2 Governance Registry, go ahead and download the latest stable WSO2 Governance Registry product from http://wso2.com/products/governance-registry/ After downloading, extract the zip file to a location of your interest, and copy the entire folder to another location to have a perception of the shared instance.

To avoid confusion, let me rename the directory name of the shared instance to wso2greg-4.6.0_remote. The version number of the extracted zip file may be different from this at the time of your download. Follow this with the version and change the procedure accordingly to reflect the version that you have downloaded. Let the local instance directory name be wso2greg-4.6.0. I've placed the two directories in my home directory. Therefore the two directories are, $HOME/wso2greg-4.6.0 and $HOME/wso2greg-4.6.0_remote. I'll refer to these two directories as GREG_HOME in respective contexts.

WSO2 governance registry uses inbuilt H2 database to store data related to above three registries. In a production environment however, it's recommended to use some other RDBMS such as MySQL as the registry DB. Therefore, in this tutorial, we shall use MySQL as the DB for the remote shared partition.

To install MySQL database point to my above blog post "Installing MySQL in Linux" 

Assuming you have installed MySQL DB and running, you can now create the database named registrydb (the name can be anything you like) in MySQL as follows,

mysql> create database registrydb;

Let's first setup our remote shared instance (i.e. the directory named wso2greg-4.6.0_remote)

In fact, there is nothing much to do in this setup except modifying the configuration file named master-datasources.xml which you can find in GREG_HOME/repository/conf/datasources/ to use MySQL, instead of the built-in H2 database. Change the <datasource> of WSO2_CARBON_DB as shown below.

        <datasource>
            <name>WSO2_CARBON_DB</name>
            <description>The datasource used for registry and user manager</description>
            <jndiConfig>
                <name>jdbc/WSO2CarbonDB</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>jdbc:mysql://127.0.0.1:3306/registrydb</url>
                    <username>root</username>
                    <password>root</password>
                    <driverClassName>com.mysql.jdbc.Driver</driverClassName>
                    <maxActive>50</maxActive>
                    <maxWait>60000</maxWait>
                    <testOnBorrow>true</testOnBorrow>
                    <validationQuery>SELECT 1</validationQuery>
                    <validationInterval>30000</validationInterval>
                </configuration>
            </definition>
        </datasource>

Note the <url>. You may use the phrase "localhost" instead of the loopback address 127.0.0.1 IP address. Further, change the port on which your MySQL runs. (3306 is the default configured MySQL port.)
registrydb part of the URL indicates the database we created earlier.

We need to copy the MySQL JDBC driver (a .jar file), which you can download from http://www.mysql.com/products/connector/, to GREG_HOME/components/lib/. And, this step needs to be done in the other node as well.

We can now start this instance of the WSO2 Governance registry by issuing the following command from GREG_HOME/bin

$ ./wso2server.sh -Dsetup

Here the -Dsetup option is to populate the created 'registrydb' in MySQL. We can now access the management console by navigating to the https://localhost:9443/carbon/ URL from your browser.

Now we can configure the other node (our local instance that's going to share the 'Config' and 'Governance' registries of the remote partition that we have already started). Therefore, what needs to happen is that, to inform this node about the remote 'Config' and 'Governance' registries that we intend to use. This is done in WSO2 Governance Registry by properly configuring the registry.xml and the master-datasources.xml configuration files.

Let's configure the registry.xml file. We need to tell this registry partition that we are going to use a remote 'Config' and 'Governance' registries. This is done by adding the following in the registry.xml file.

    <mount path="/_system/config" overwrite="true">
        <instanceId>mountInstance</instanceId>
        <targetPath>/_system/config</targetPath>
    </mount>

    <mount path="/_system/governance" overwrite="true">
        <instanceId>mountInstance</instanceId>
        <targetPath>/_system/governance</targetPath>
    </mount>

And further, we have to have a way to inform the mount instance location. That's done by adding the following in registry.xml.

    <remoteInstance url="https://x.x.x.x:9443/registry">
        <id>mountInstance</id>
        <dbConfig>mountregistry</dbConfig>
        <readOnly>false</readOnly>
        <enableCache>true</enableCache>
        <registryRoot>/</registryRoot>
        <cacheId>root@jdbc:mysql:@127.0.0.1:3306:registrydb</cacheId>
    </remoteInstance> 

Where x.x.x.x is the IP address of the remote partition. Since, the remote instance that we already started is in localhost that x.x.x.x = 127.0.0.1 (the loopback ip address). If you are setting this up in a true remote setup, change that IP address accordingly. Note that <id> tag matches the <instanceid> tag in the <mount> we configured earlier.

Now the registry partition location is been informed. Now we got to say, where the database of the remote instance resides. That database could ideally be in any location within the reachable network. It has to be configured in the master-datasources.xml file. Before that, we have to add one more addition to registry.xml file. It's listed below.

    <dbConfig name="mountregistry">
        <dataSource>jdbc/WSO2MountRegistryDB</dataSource>
    </dbConfig>

"jdbc/WSO2MountRegistryDB" will be a reference to the relevant <datasource> that we would next configure in the master-datasources.xml file. Now, let's move to master-datasources.xml file. There we would keep the default H2 database for the local registry. Additionally we got to say the DB instance where the 'Config' and 'Governance' registries reside. Add the following <datasource> in master-datasources.xml to achieve that.

        <datasource>
            <name>WSO2_MOUNT_REGISTRY_DB</name>
            <description>The datasource used for registry and user manager</description>
            <jndiConfig>
                <name>jdbc/WSO2MountRegistryDB</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>jdbc:mysql://127.0.0.1:3306/registrydb</url>
                    <username>root</username>
                    <password>root</password>
                    <driverClassName>com.mysql.jdbc.Driver</driverClassName>
                    <maxActive>120</maxActive>
                    <maxWait>900000</maxWait>
                    <testOnBorrow>true</testOnBorrow>
                    <validationQuery>SELECT 1 FROM DUAL</validationQuery>
                    <validationInterval>30000</validationInterval>
                </configuration>
            </definition>
        </datasource>

I guess we are all set, except for one thing. Since we are going to run both the remote and local setup in the local machine itself, if you run the currently configured node, you would see an exception thrown in the console. The reason for this is that, we can't run two WSO2 products at the same time, since both would attempt to run on the same default port 9443. To avoid the conflict, we should set the offset for the next server that we are going to run in the carbon.xml in GREG_HOME/repository/conf. Open up carbon.xml and change the value for <offset> to 1. This will make this instance to start of with the port 9444. If you are running this setup in two different machines you may not need to do this change, though doing so would do no harm either.

Phew!!!. All done. Now we shall start this instance in the same way we started the earlier remote instance. In the console, you should see the following three lines among others, which indicate that two registries; 'Config' and 'Governance' have been mounted in the 'mountregistry'.

 [2013-10-21 16:00:46,379]  INFO {org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService} -  Configured Registry in 116ms
 [2013-10-21 16:00:46,408]  INFO {org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService} -  Connected to mount at mountregistry in 3ms
 [2013-10-21 16:00:46,606]  INFO {org.wso2.carbon.registry.core.jdbc.EmbeddedRegistryService} -  Connected to mount at mountregistry in 0ms

You may access the Management Console by browsing https://localhost:9444/carbon/ URL. In the Management console, click 'Browse' and expand the _system in the tree view. You should see blue arrow in front of 'config' and 'governance' nodes as shown in the following screenshot, indicating that it's mounted in a remote partition.


Saturday, October 19, 2013

Downloading and running WSO2 Governance Registry


WSO2 Governance registry is fully open source, Service Oriented Architecture (SOA) integrated registry for storing and managing artifact metadata.

In this short guide, I'll walk you through the process of how to download the WSO2 Governance Registry and start it in your machine and accessing it with its in-built web based management console (A Web User Interface (UI)), for managing the metadata.

The process is just simple. Download the latest release binary zip file from http://wso2.com/products/governance-registry/

Once you download the zipped archive, extract it to a directory of your liking. Let's assume the extracted directory be $(HOME_DIRECTORY)/wso2greg-4.5.3/ and let me call this directory $(GREG_HOME). You must have Java installed and JAVA_HOME set to successfully start the product. See my previous post "Installing Developer Tools in Linux" to see how to install and configure java in Linux.

Navigate to $(GREG_HOME)/bin and execute the following to run the WSO2 Governance Registry.
 $ ./wso2server.sh                                (In Linux)
 > wso2server.bat                                 (In Windows)
This will start the WSO2 Governance regiatry with all the default configurations, and you should see an output in console. In the end of the output you should see an output like the following.
Mgt Console URL  : https://192.168.2.1:9443/carbon/
Copy and paste the above URL in your favorite browser. You should see the WSO2 Governance Registry management console login screen. You can use the default Admin user credentials of which username and password being 'admin' to access the registry. Once you access you are ready to store and manage different artifacts in WSO2 Governance Registry. Following is a typical screen shot of the first page that you would see when you logged in.



Good Luck in using the product.

Thursday, October 17, 2013

Installing MySQL in Linux

MySQL is a very powerful open source relational database management system (RDBMS). In this short guide we'll get into installing MySQL on Linux.

You can check whether MySQL is already installed by issuing the following command.
$ mysql -V
You should see something similar output as follows if you have MySQL installed.
mysql  Ver 14.14 Distrib 5.5.32, for debian-linux-gnu (x86_64) using readline 6.2
If not, to install MySQL, run the following command from a terminal prompt in apt-get package manager based Linux distributions
$ sudo apt-get install mysql-server
In yum package manager based Linux distributions, issue the following command
$ sudo yum install mysql-server
You will be prompted to enter a password for the MySQL root user in the installation process. It's recommended to use a password for a root account. Now the MySQL server is installed on your Linux machine.

Alternatively, you may download the relevant MySQL package (e.g. rpm package) for your Linux from http://dev.mysql.com/downloads/mysql/#downloads and install according to your distribution. You may need to sign up for an Oracle Web account to download from this site. This article won't go into details of installing with distribution specific packages.

MySQL installation could also be done with the source. You can also download the source distribution from the above URL. Installing from source needs certain tools and libraries pre-installed (such as cmake and ncurses-devel). Other workaround may be required to build from source.

To start the MySQL database, issue the following command.
$ sudo /etc/init.d/mysql start
or in Fedora/RHEL
$ sudo systemctl start mysqld.service
To check whether MySQL is already running, you can issue the following command.
$ mysqladmin -u root -p status
You will be prompted for the password. When entered, you should see somewhat similar output as follows if MySQL is running
Uptime: 28581  Threads: 1  Questions: 111  Slow queries: 0  Opens: 343  Flush tables: 1  Open         tables: 84  Queries per second avg: 0.003
If not running, you would see an output as shown below.
   mysqladmin: connect to server at 'localhost' failed
   error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
   Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
You can edit the settings for the MySQL instance in /etc/mysql/my.cnf file to configure the basic settings like log file and port number.

That's it. You now should have MySQL installed on your system and ready to use it to develop database driven applications.

Saturday, October 5, 2013

Installing Developer Tools in Linux

The first step in developing applications in Linux based computers is mostly to have a setup of your developer tools to be installed properly. This short guide aims to provide you with installation steps required to get started with some of the popular programming languages to develop fascinating software.

This post will provide steps for installing the required tools and provide a classic "Hello World" example to test your installation of the tools. Before attempting to install any of the tools, make sure whether your system already contains the tools. Chances are high, that you, most probably have it installed already.

  • C

To compile a C program in Linux based systems, the most popular tool used is the gcc compiler. This is contained in the GNU Compiler Collection (GCC). To check whether gcc is already installed enter the following command
$ gcc --version
if you see an output like the following, gcc is already installed and you are all set to write C programs.
gcc (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Instead if you see the following or something similar, you will have to install gcc.
bash: gcc: command not found...
Though gcc can be installed separately it's recommended to install a package called 'build-essential', which contains bunch of other useful and related packages. To install it issue the following commands in Debian based Linux.
$ sudo apt-get update
This will update the package list. Now issue the following command in Debian based Linux like Ubuntu.
$ sudo apt-get install build-essential
In Linux systems such as Red Hat Linux or Fedora that has yum based package manager, you can use the following command,
$ sudo yum install gcc
This will install gcc compiler and other development libraries like glibc. You can also use the following command to install whole bunch of development packages which also includes gcc and g++ (for C++)
$ sudo yum groupinstall "Development tools"
Now you can write a sample C program as below to check that everything is working fine. Create a file named HelloWorld.c and type in the following program text.
    #include <stdio.h>

    int main()
    {
        printf("Hello World!\n");
        return 0 ; 
    }
Compile the above program with the following command.
$ gcc -o HelloWorld HelloWorld.c
This will create an executable file named HelloWorld in your current directory. To execute the executable program type ;
$ ./HelloWorld
You should see the following output.
Hello World!
Congratulations!! You are a C guru now.

  • C++

The most popular C++ compiler in Linux is undoubtedly g++. This is also part of the GCC. If you have installed the build-essentials in the Debian or the "Development Tools" in Red hat Linux, you must already have g++. Otherwise, go ahead and install build-essentials or "Development Tools". To check whether g++ is already installed, enter the following command.
$ g++ --version
if you see an output like the following, g++ is already installed and you are all set to write C++ programs.
g++ (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3
    Copyright (C) 2012 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Instead if you see the following or something similar, you will have to install g++ by installing build-essential package or the "Development Tools".
bash: g++: command not found...
If you didn't install "Development Tools", and want to install g++ separately using yum, use the following command,
$ sudo yum install gcc-c++ 

This should install g++ and other development files and libraries.

Let's now write a sample C++ program which prints Hello World! on the standard output. Type the following program in a file named HelloWorld.cpp
    
#include <iostream>     
using namespace std ;     

int main()     
{         
    cout << "Hello World!" << endl ;         
    return 0 ;      
} 
Compile the above program with the following command
$ g++ -o HelloWorld HelloWorld.cpp
This will create an executable file named HelloWorld in your current directory. To execute the executable program, type ;
$ ./HelloWorld
You should see the following output.
Hello World!
Quite similar to what we did for C, right? Voila!!! Now you are a C++ expert too.

  • Java

Next we shall look into setting up Java in Linux. Chances are that you already got Java installed. Most probably the OpenJDK version. If you are willing to work with OpenJDK, everything is fine, and you are ready to develop java applications. But you may have a valid reason to use Oracle java for developments. In that case we can remove OpenJDK and install Oracle Java or keep OpenJDK with Oracle Java. Though there are few ways to install and confugre Java in Linux, the best and easy way is to download the JDK zipped file from http://www.oracle.com/technetwork/java/javase/downloads/index.html. Make sure to download the version you want, which is applicable to your system architecture. Once you have downloaded the zip file, extract it to a location of your interest. Let's say the extracted location is /usr/local/java/jdk1.6.0_43. All you need to do is add the JAVA_HOME (your installation directory; e.g: /usr/local/java/jdk1.6.0_43) as a new environment variable and add the bin directory of JAVA_HOME to the PATH environment variable. This can easily be done by adding the following lines to your .bashrc file in your home directory.
JAVA_HOME=/usr/local/java/jdk1.6.0_43
PATH=$PATH:$HOME/bin:$JAVA_HOME/bin     
export JAVA_HOME     
export PATH

If you add these lines to .bashrc, the changes will be effective only to the current user. If changes need to be applied to all the users, the same set of lines can be added to /etc/profile file. Once you added the line, source the respective file to make changes immediate on the same shell. To do that, issue the following command.
$ source ~/.bashrc
Now java is configured on your Linux box. Issue the following commands to verify your installation and environment variables. Expected outputs should be something similar to the following lines.
$ echo $JAVA_HOME      
/usr/local/java/jdk1.6.0_43     

$ echo $PATH      
/usr/local/java/jdk1.6.0_43    

$ java -version
If you see a similar output as follows you are all set to develop java applications
java version "1.6.0_43"
Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01, mixed mode)
Let's write a simple java program, compile and execute it. Create a file named HelloWorld.java and type in the following text.
public class HelloWorld     
{         
 public static void main(String[] args)         
 {               
  System.out.println("Hello World!");         
 }       
}
Make sure the class name match your file name. To compile this program, type in the following.
$ javac HelloWorld.java
This must generate a class file in your current directory named HelloWorld.class. It contains the bytecode of your program. To execute your class file type
$ java HelloWorld
Make sure you do not type in the .class extension when executing. Following output should be shown in the standard output.
Hello World!
Congratulations!! you have written a simple java program. Ok.. Have we done with everything? Ideally yes. But wait a second. We often come across new java versions. Then the question comes, whether we can have two versions of java installed in the Linux side by side? The answer, as you may have guessed, is a big "YES". So how do we go about making that. Ok.. The process is simple. Download the zip file of your interested version of java. And extract it, say to the same location (e.g. /usr/local/java/jdk1.7.0_07). Next we got to inform the Linux that you have two versions of java. Let's collect a few more details.
$ java -version
This should still print the older java we configured earlier, like the following.
java version "1.6.0_43"
Java(TM) SE Runtime Environment (build 1.6.0_43-b01)
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01, mixed mode)
To find the path of the java that we currently use, issue the following command
$ which java
If you have only the java we set up earlier and followed the instructions above, you would get a similar output as follows.
/usr/local/java/jdk1.6.0_43/bin/java
Ok.. let's make the Linux aware about the two jdk versions we extracted to /usr/local/java. To do that we issue the following commands.
$ sudo update-alternatives --install /usr/bin/java java /usr/local/java/jdk1.7.0_07/bin/java 2
ok... now the Linux knows about the new java, but has set the priority to 2. Issue the following command.
$ java -version
This would print the new java version.
java version "1.7.0_07"
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)     
Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)
    
Ooops!!. Where the hell my old java went? Ok don't panic. What has happened here is that you have created a symbolic link to /usr/local/java/jdk1.7.0_07/bin/java from /etc/alternatives/java and another symbolic link to /etc/alternatives/java to /usr/bin/java. When you issue the above java command, the system path /usr/bin/java overrides the path we earlier set. You can check this by issuing the following commands.
$ ls -l /usr/bin/java     
lrwxrwxrwx 1 root root 22 Oct  5 11:14 /usr/bin/java -> /etc/alternatives/java     

$ ls -l /etc/alternatives/java     
lrwxrwxrwx 1 root root 36 Oct  5 11:14 /etc/alternatives/java -> /usr/local/java/jdk1.7.0_07/bin/java
We shall now do the same to the old java we had. To do that, issue the following command
$ sudo update-alternatives --install /usr/bin/java java /usr/local/java/jdk1.6.0_43/bin/java 1

If you issue the following command, we should still see the jdk7 is used.
$ java -version     

java version "1.7.0_07"     
Java(TM) SE Runtime Environment (build 1.7.0_07-b10)     
Java HotSpot(TM) 64-Bit Server VM (build 23.3-b01, mixed mode)

Ok. We shall change to the earlier version by issuing following command and selecting 1.
$ sudo update-alternatives --config java

You will be prompted as shown below.
Selection    Path                                  Priority   Status     
------------------------------------------------------------     
* 0          /usr/local/java/jdk1.7.0_07/bin/java   2         auto mode       
  1          /usr/local/java/jdk1.6.0_43/bin/java   1         manual mode       
  2          /usr/local/java/jdk1.7.0_07/bin/java   2         manual mode     

Press enter to keep the current choice[*], or type selection number: 1
      
By selecting 1, you can switch back to the earlier version. To verify, again issue the following.
$ java -version     

java version "1.6.0_43"     
Java(TM) SE Runtime Environment (build 1.6.0_43-b01)     
Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01, mixed mode)
  
Further you have to do the same thing for javac and javaws commands for both the versions like the following.
$ sudo update-alternatives --install /usr/bin/javac javac /usr/local/java/jdk1.7.0_07/bin/javac 2     
$ sudo update-alternatives --install /usr/bin/javaws javaws /usr/local/java/jdk1.7.0_07/bin/javaws 2     
$ sudo update-alternatives --install /usr/bin/javac javac /usr/local/java/jdk1.6.0_43/bin/javac 1     
$ sudo update-alternatives --install /usr/bin/javaws javaws /usr/local/java/jdk1.6.0_43/bin/javaws 1
    
Now you can select your preferred javac version as below.
$ sudo update-alternatives --config javac

and select the appropriate number. That's it. We can now have as many java versions as we need in our system and switch back and forth easily to experiment with.

  • Python

Most probably python is installed on your Linux. You can check for python version by entering following command
$ python -V     

Python 2.7.4
If python is available you should see a similar output as above. If not install python with the following command, whichever is applicable,    $
sudo apt-get install python        or   
$ sudo yum install python
Ok.. Now let's start writing a sample program. Create a file called HelloWorld.py in your current directory. Enter the following text in it.
#!/usr/bin/python     
print("Hello World!")
Save the file and execute the code using python interpreter as follows
$ python HelloWorld.py     

Hello World!
Great.. Now you know how to program in Python too.

  • Perl

Most probably perl is also installed on your Linux. You can check for perl version by entering following command
$ perl -v
You should see a somewhat similar output as follows.
This is perl 5, version 14, subversion 2 (v5.14.2) built for x86_64-linux-gnu-thread-multi
(with 80 registered patches, see perl -V for more detail)

Copyright 1987-2011, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
    
If not, install perl using the following command, whichever applicable
$ sudo apt-get install perl        or     
$ sudo yum install perl
Done.. Now let's start writing a sample program. Create a file called HelloWorld.pl in your current directory. Enter the following text in it.
#!/usr/bin/perl     
print "Hello World!\n";
Save the file and execute the code using python interpreter as follows
$ perl HelloWorld.pl   
  
Hello World!
That's great... Now you are a perl expert as well.

  • Ruby

To check whether ruby is installed on you Linux, enter the following command.
$ ruby -v
If you have ruby installed, you should see somewhat similar output as below.    
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
If you can't see an output like this, you will have to install ruby by issuing the following command, whichever is applicable
$ sudo apt-get install ruby            or      
$ sudo yum install ruby
Ok. Let's write the same HelloWorld program in ruby. Create a file called HelloWorld.rb and enter the following.
#!/usr/bin/ruby      
puts "Hello World!"
Now you can execute the program by entering following.
$ ruby HelloWorld.rb

Hello World!

  • C#

We finally have come to our last section. C# is a Microsoft developed programming language. Hence you should typically be programming in Windows using the .Net framework. But if you still want to develop C# or any .Net application in Linux, you are not to be made worry. You can install the 'mono', which is an open source implementation of the Microsoft .Net framework. To install mono on your Linux type in the following commands. whichever is applicable.
$ sudo apt-get install mono-complete    or     
$ sudo yum install mono-core.x86_64
When this is done, you are ready to develop .Net applications in Linux. To see the mono version installed, type in the following.
$ mono -V
you should see something similar to the following.
Mono JIT compiler version 2.10.8.1 (Debian 2.10.8.1-5ubuntu1)
Copyright (C) 2002-2011 Novell, Inc, Xamarin, Inc and Contributors. www.mono-project.com
 TLS:           __thread
 SIGSEGV:       altstack
 Notifications: epoll
 Architecture:  amd64
 Disabled:      none
 Misc:          softdebug 
 LLVM:          supported, not enabled.
 GC:            Included Boehm (with typed GC and Parallel Mark)
Let's write a small C# program. Create a file called HelloWorld.cs and type in the following.
using System;     

public class HelloWorld     
{         
 static void Main()         
 {               
  Console.WriteLine("Hello World!");        
 }       
}
We can compile the program by issuing the following command.
$ gmcs HelloWorld.cs
This should create a file called HelloWorld.exe in you current directory. (Note : In Microsoft Visual C# in Windows, we use 'csc' command in the command prompt to compile a C# program). To execute the executable we can type in the following.
$ mono HelloWorld.exe     

Hello World!
Voila!!! Now we can develop any .Net application in Linux as well. Here we are. This post explained you to set up development tools (or rather to see whether it's installed) in your Linux box and walked you in creating sample programs to get started. I hope the article has been easy to follow and fun to read. Flourish in the development world!! Good luck.