Wednesday 30 May 2012

Installing Cassandra on windows xp

First we need to download Cassandra.For Download Cassandra Click this link Download. Now unzip the file and put it into a drive where you want to install Cassandra.you can change the folder name cause deafult name is "apache-cassandra-0.5.1".its to long to remember easily.So i change my unzip folder name to "cassandra". Now we have our Cassandra in a spacific drive.Lets go install and configur Cassandra database on windowsXP.You need to install java 1.6.for JAVA download
i) First Step :
First we need to add Two Environment Variables. One for java and other for Cassandra home Directory.Bellow show how to set the Environment Variables on WindowsXp.


Click start then select My Computer and Click Right button on mouse.After that it show System properties Tab manu.Now Select Advanced Tab.


 Now select Environment Variables button.Its open Environment Variables set window like bellow.


Now Select New From System Variables Section.its open a new window like bellow.


Fill Variable name section to "JAVA_HOME" and Variable value to java jdk path. I install java to my C:\program files folder for this my java jdk path is "C:\program Files\java\jdk1.6.0_18" please change this path with your java installation path. same way set CASSANDRA_HOME path.my Cassandra is "F:\cassandra" casue i put Cassandra unzip folder to f drive and i change it to cassandra.please change it with your cassandra dirve.



Now click ok->apply and your Environment Variables setting is completed.Now lest go to run Cassandra and connect with database.Again Click Start then click run and type cmd in text box on run window and Enter .it open commend mode on windows.Like this.
Now type f: then enter and then type cd cassandra\bin and enter.here f is the drive where my cassandra folder is.now its look like this

First you need some change in configuration file . for edit configuration file please open "storage-conf.xml" file on any txt editor and write this line under

<replicationfactor>1</replicationfactor> tag.

<commitlogdirectory>F:/cassandra/data/commitlog</commitlogdirectory>
<datafiledirectories>
<datafiledirectory>F:/cassandra/data/data</datafiledirectory></datafiledirectories>
<calloutlocation>F:/cassandra/data/callouts</calloutlocation>
<stagingfiledirectory>F:/cassandra/data/staging</stagingfiledirectory>

you find this configuration file on F:\cassandra\conf this location. please change Directory with your Cassandra Directory. Now type cassandra.bat and Enter.if it run correctly the commend prompt show like this
Its mean the Cassandra server run correctly.if you check your my computer then you found there is a extra drive created with same name where your Cassandra folder is.Now type cassandra-cli.bat on your commend and Enter.it will show a welcome message.now connect with Thrift.type connect / its mean connect localhost/9160 and enter.here 9160 is your ThriftPort that define in configuration file in defult.after run this commend your commend prompt look like this

its show connected to localhost/9160 it means you are connect to Thrift.If you want to check your connection is ok or not, type show keyspaces and press enter,it shows your default Keyspace name like this



To create Column need to add some code in storage-conf.xml.The next thing we need to do is to locate and configure the database storage-conf.xml file.which is found in conf folder.Open the storage-conf.xml in your favorite text editor.now Add the following code under tag.




<Keyspace Name="Blog">
        <ColumnFamily Name="Post"
                      ColumnType="Super"
                      CompareWith="UTF8Type"
                      CompareSubcolumnsWith="UTF8Type"
                      Comment="A column family with supercolumns, whose column and subcolumn names are UTF8 strings"                      />
    </Keyspace>



save it.The above configuration creates one Column Family(or table).called Posts in a Keyspace (or database ) called Blog. 

No comments:

Post a Comment