Showing posts with label apache. Show all posts
Showing posts with label apache. Show all posts

Saturday, June 7, 2014

Installing and Running Apache Pig on Hadoop 2.x versions

Pig is a high-level platform for creating MapReduce programs used with Hadoop. The language for this platform is called Pig Latin. Pig Latin abstracts the programming from the Java MapReduce idiom into a notation which makes MapReduce programming high level, similar to that of SQL for RDBMS systems. Pig Latin can be extended using UDF (User Defined Functions) which the user can write in Java, Python, JavaScript, Ruby or Groovy and then call directly from the language.
Installing Pig is just as simple. What you will have to do is:
  1. Download the desired pig distribution from any one of the Apache Mirrors. It is best if you choose the latest version of Pig. Also, download the file whose name is like pig-0.12.1.tar.gz, where "0.12.1"is the version number. 
  2. Extract Pig to a desired directory.
    1.  Simple way is to copy the tar.gz to the root directory where you want your installation to reside.
    2. Now, execute the following code in Linux bash at the directory
      tar -xzf pig-0.12.1.tar.gz
    3. You will have the installation ready.
  3. Editing Path
    1. To access the pig installation easily and run your scripts from anywhere, make sure to add the pig's bin in your path.
    2. To do this, open the file /home/user/.bashrc in your favorite editor and copy the following line at the end of the file. 
      export PATH=/<my path to pig>/pig-n.n.n/bin:$PATH
      
    3. After doing all this, your Pig installation is ready for further configuration.
You might get the following error when running Pig scripts with Apache Hadoop 2.x. Here is a highlight of the error:
Found interface org.apache.hadoop.mapreduce.JobContext, but class was expected

Now, that's a problem. Don't worry, solving it is unbelievably simple. This is what you will have to do:
  • cd  to your pig installation directory. Yes, inside the Pig directory.
  • And run this code:
    ant clean jar-withouthadoop -Dhadoopversion=23
    

After that, try running your Pig script again. You will find that everything is alright now.
Any problems working this around or have any suggestions? Just comment it below :)


Thursday, June 20, 2013

Set up the best web development environment - Netbeans + Apache + PHP + MySQL + jQuery and lots more!


Well, PHP, MySQL, jQuery - the three most essential tools we need to create the next gen websites or develop interactive content in the world of HTML5.
jQuery will run client side, but PHP and MySQL require server side programming. Hence we need to set up a similar environment on PC, and also we need something to code our thoughts and ideas using our knowledge. Netbeans is one of the best IDE(Integrated Development Environment) that can let you do this with much ease, and basically its free. Everything that you will need to complete this tutorial will be free.

Step 1: Set up a server

There are various apps that let you create an Apache+PHP+MySQL environment of your Windows PC. My favorites are:
Software Download Link Extra notes
Zend Server Click here More secure, High level server administration, might not have the latest version of PHP, MySQL and other modules
EasyPHP Click here Less Secure, Easy administration and installation of modules. Fast updates to PHP and MySQL << Recommended 
WampServer Click here Less secure,option to convert to web server, might not have the latest version of technologies(Apache, PHP, MySQL)

Well, just install these apps like you install any other Windows Software and your server will be up and running in no time.
This was easy, wasn't it?
Now comes the coding part..

Step 2: Install Netbeans

Why Netbeans?
Well, its fully featured, easy to use and has support for lots of languages and is FREE! You will also need JDK(Java SE) latest version. Here is the link.

Step 3: To create projects using NetBeans

Well, creating projects is easy. Now what you need is a simple selection to make when you are kick starting your development. In the New Project Wizard, choose PHP>PHP Application.

If you are creating a PHP project for the first time, Netbeans will take few seconds to activate the PHP Module.
 When you are in this screen when going through the New Project wizard, make sure you check the box copy files to a folder option as mentioned below. 
Now, select the path according to the location of your public www folder(also called document root). If you have downloaded any of the above softwares that I have mentioned, here is a guide to those folders:
ZendServer - <path to Zend Server installation directory>\Apache2.2\htdocs
EasyPHP - <path to EasyPHP installation directory>\data\localweb
WampServer - <path to WampServer installation directory>\www

Thats it! You are done!

Additional Notes:

  1. I prefer EasyPHP as they have latest technologies, so less or no bugs will be encountered when developing.
  2. Do set up root password for your MySQL databases. This makes your server quite secure, in case you decide to make the same server live.
  3. Copy the jQuery script into the folder where you can use it properly. For less amount of code, I prefer to save the .js file into the same directory as the main web page is.
  4. It is always better to choose a proper web host, rather than hosting the scripts yourself. Sure this is a DIY package for creating a web server, but its not secure enough.
  5. WAMPServer comes with phpMyAdmin by default, to access it use localhost\phpmyadmin. For ZendServer and EasyPHP you will have to install the modules.For tutorial on Zend Server, visit this link and for EasyPHP, just activate the phpMyAdmin module in the server administration GUI.
Now that you have set up a complete web Development server, how about kickstarting to learn web development? Check out one of the best books I recommend for beginners to start learning web development by clicking here!