Saturday, January 26, 2013

Setting up Cassandra Database on Windows 7

  1. Download Cassandra from http://cassandra.apache.org/
  2. Cassandra is build with java, so it needs java to be installed.
  3. Setup environment variables;
    •  JAVA_HOME : C:\Program Files\Java\jdk1.7.0_11
    • CASSANDRA_HOME : C:\cassandra\apache-cassandra-1.2.0
    • CLASSPATH : %JAVA_HOME%\jre\lib; %CASSANDRA_HOME%
  4. Check in CMD whether environment variables are set;
    • echo %JAVA_HOME%  
  5.  Copy the downloaded Cassandra files to C:\cassandra\apache-cassandra-1.2.0
  6. Create commitlog, data, saved_caches folders inside C:\cassandra\storage 
  7. Open cassandra.yml file in C:\cassandra\apache-cassandra-1.2.0\conf
  8. Change the following;
    • data_file_directories:
        - C:\cassandra\storage\data
    • commitlog_directory: C:\cassandra\storage\commitlog
    • saved_caches_directory: C:\cassandra\storage\saved_caches
  9.  Open CMD and go to C:\cassandra\apache-cassandra-1.2.0\bin, to start the server;
    •  C:\cassandra\apache-cassandra-1.2.0> cassandra -f
  10.  Open another CMD and go to C:\cassandra\apache-cassandra-1.2.0\bin, to start the client;
    •  C:\cassandra\apache-cassandra-1.2.0> cassandra-cli.bat 
  11.  If the client is running properly following output will come;
            C:\cassandra\apache-cassandra-1.2.0\bin>cassandra-cli.bat
            Starting Cassandra Client
            Connected to: "Test Cluster" on 127.0.0.1/9160
            Welcome to Cassandra CLI version 1.2.0

             Type 'help;' or '?' for help.
             Type 'quit;' or 'exit;' to quit.


             [default@unknown]



First command on client !

[default@unknown] show cluster name;  
Test Cluster



If you forget the semicolon (;) it will not communicate with the server

[default@unknown] show cluster name
...
 








 

       

Tuesday, January 1, 2013

Ubuntu 12.10 + Apache + Perl + PHP



 Apache


Install Apache
  • sudo apt-get install apache2
Start Apache
  • sudo /etc/init.d/apache2 start
Stop Apache
  •  sudo /etc/init.d/apache2 stop
Restart Apache
  • sudo /etc/init.d/apache2 restart

Main Configuration File
  • sudo nano /etc/apache2/apache2.conf
Set the Virtual Hosts here;
  • sudo nano /etc/apache2/sites-available/default
Apache Error Log
  • sudo nano /var/log/apache2/error.log
Location of Web Server Files
  • /var/www/ 

 

PHP

Install PHP
  • sudo apt-get install php5 libapache2-mod-php5

PERL 

  • Perl is pre-installed.
  • whereis perl to see the location where perl is installed.
  • perl-v check the version which is in use.
  • Use /usr/lib/cgi-bin to put perl files.
  • Make the changes in BOLD in the Virtual host (/etc/apache2/sites-available/default)
      ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                AddHandler cgi-script cgi pl
                Order allow,deny
                Allow from all
        </Directory>

  • Change the permission in the perl script to 755 (sudo chmod 755 test.pl)
  • Now run http:localhost/cgi-bin/test.pl

  • Sample perl script test.pl 
        #!/usr/bin/perl -w  -> location of perl  
       print "Content-type: text/html\r\n\r\n";     -> without this line it will give an internal server error 
       print "Hello there";

  • Running Perl in Terminal
                perl filename.pl