March 16, 2018

Hyperledge Sawtooth Installation as PEER – on single machine node

This post will help readers in setting up and running sawtooth as peers. Again there are not much guides availabel (to the time I write this) hence writing the same.

For peering , we can set up as dynamic/static . I am using dynamic peering with main validator as validator-0 . the idea here is to provide an endpoint address and specify network and component port .the second or subsequent nodes to setup validator-1 and next to use dynamic peering with peer as endpoint of validator-0..

 

Prerequisites –

  1. Ubuntu APT installs for SAWTOOTH
  2. Create  genesis block and keys.

Setup main validator node – We’ll run them on standard port 8008 and 4004.

$dev@dev-thinkcentre-a63:~/sawtooth-1$ sudo sawtooth-validator -vv –bind network:tcp://10.34.14.29:8800 –bind component:tcp://10.34.14.29:4004 –peering dynamic –endpoint tcp://10.34.14.29:8800 –scheduler serial –network trust

Start/Install settings TP

dev@dev-thinkcentre-a63:~$ settings-tp -vv -C tcp://10.34.14.29:4004

Start / Intall intkey TP

dev@dev-thinkcentre-a63:~/sawtooth-2$ intkey-tp-python -vv -C tcp://10.34.14.29:4004

Start / Install REST API

dev@dev-thinkcentre-a63:~$ sawtooth-rest-api -C tcp://10.34.14.29:4004 -v

Till now there will be 1 node that has started the validator with a genesis block

 

For setting up subsequent PEER , you need to specify the endpoint for PEER-0 in the command , as

dev@dev-thinkcentre-a63:~/sawtooth-2$ sudo sawtooth-validator -v –bind network:tcp://10.34.14.29:8801 –bind component:tcp://10.34.14.29:4005 –peering dynamic –endpoint tcp://10.34.14.29:8801 –seeds tcp://10.34.14.29:8800 –scheduler serial –network trust

 

The node shoudl be same as the peer node so that it has all TP installed , otherwise its not worth.Note that I am regfisterig all TP on the PEER-1 at port 4005.

Start/Install settings TP

dev@dev-thinkcentre-a63:~$ settings-tp -vv -C tcp://10.34.14.29:4005

Start / Intall intkey TP

dev@dev-thinkcentre-a63:~/sawtooth-1$ intkey-tp-python -vv -C tcp://10.34.14.29:4005

 

Alternatively , start the REST API.

dev@dev-thinkcentre-a63:~/sawtooth-2$ sawtooth-rest-api -C tcp://10.34.14.29:4005 -B localhost:8081 -v

 

note that the bind address is different.

 

Testing the network

 

  1. Check peers are runnign.

$ sudo sawtooth peer list –url tcp://10.34.14.29:8800

2. Test the intekey

when runnning the intkey both validator logs should be onserver to be rolled. and you can checn the /batches and /state to eb changes int both URLs for REST

March 16, 2018

HyperLedge Sawtooth Java help

HyperLedger recently releases the enterprise grade blockchain (as claimed by HL) called as Sawtooth. I was evaluating HyperLedger post its release in Mar’18. Since it was initial phase it was difficult and challenging to findout a guide and not few blogs were available.I though o f writing this blog summarising and guiding follower on Sawtooth specifically from Java background. I have been working on java for long and its huge enterprise presence let me evaluate Sawtooth acc   ordingly. I had to work a lot, while evaluating,  in terms of setting up Hyper Ledger Sawtooth  and evaluating implementation  wr.t. Java. While the installation and devops operations are common the programming and solutions development using Java language wasn’t documented well anywhere . Thus I created this blog.

First things first, in order for a developer to set up things below is the best I see and favourable with the kind of approach i took for developer  machine. I believe that developers should focus on development and want everything on their machines to further support development. But, these days since containerisation for devops is talked and used much , traditional setups are rather discouraged due to their lack of usability. While evaluating I took the docker and ubuntu apt approach for installation , but finally I derived a way to do it without the support of apt or docker, as a plain old standalone way. I like the way as it exposes internals, and is good for evaluation. But, I would support devops using docker for prod and maturity on projects.

Installation or Setup of Sawtooth –

This setup is via module by module without docker/apt. The Hyper Leger Sawtooth document will help you on the docker and ubuntu based installations at this link.

I am using Ubuntu 16.4 LTS and installed basic java sdk , maven etc. For items you require use apt-get installations accordingly.

  1. Checkout  – the first step is to get the latest code cloned on your machine
    1. Sawtooth Core = Hyper Ledger Sawtooth is written in Python , and the code could be checked out / cloned from GIT – https://sawtooth.hyperledger.org/docs/core/ 
    2. Lets look at what all is available
      1. bin   – contains all the build files that would support run,build and deployments for modules.
      2. docker – contains all dockerized images , you can directly use the to set things up.
      3. sdk  – contains the SDK in different language, this adds extensions to the way sawtooth allows its users to write their own implementations. I use JAVA. Also contain examples that you can reference.
      4. Other- all other are specific to the Sawtooth core implementation in python. Lets leave the,
  2. Build – Start building the whole project once so all libraries / dependencies are freshly available locally.  Note – keep this core in sync with remote on releases.
    1. build_all  – run this script as $SAWTOOTH_CORE> bin/build_all (This will take some time to build).
    2. Build and Install JAVA SDK for sawtooth
      1. build_java_sdk
    3. Build sample Transaction Processors for XO and INT KEY by using build_java_xo and 

Above will install all the libraries that are required for development.

  1. Run – run all below commands in separate terminal window.
    1. Validator – dev@dev-thinkcentre-a63:~/work/code/sawtooth-core$ sudo bin/sawtooth-validator -vv
    2. Settings TP – dev@dev-thinkcentre-a63:~/work/code/sawtooth-core$ sudo bin/settings-tp -vv
    3. Rest API – dev@dev-thinkcentre-a63:~/work/code/sawtooth-core$ sudo bin/sawtooth-rest-api -vv
    4. IntKey Python – dev@dev-thinkcentre-a63:~/work/code/sawtooth-core$ sudo bin/intkey-tp-python -vv
    5. Testing IntKey -dev@dev-thinkcentre-a63:~/work/code/sawtooth-core$ sudo bin/intkey set nishant 10 –keyfile /home/dev/.sawtooth/keys/prashant.priv

The response from command is  status of transaction , which you can paste on a browser and see status of the transactions. Alternatively, you should also look at the log output got int key TP we installaed in step step 4.

 

Implementing Sawtooth Solution in Java

  1. Wring the client for Int Key TO in Java – https://github.com/nissshh/samples-blockchain/tree/master/sawtooth/sample-sawtooth-java
  2. Writing your own transaction family – https://github.com/nissshh/samples-blockchain/tree/master/sawtooth-idempotent-tp
  3. Writing you transaction sender – https://github.com/nissshh/samples-blockchain/tree/master/sawtooth/sample-sawtooth-java

https://platform.linkedin.com/badges/js/profile.js

March 20, 2014

Mule Studio cross Mule ESB Runtime testing.

Many times you might need to check if a mule application is backward of forward compatible.One way would be to install separate mule runitmes and test it , by deploying on each. this orpcess is lengthy that implies change,build and deployment.  Mule Studio from Version 3.4.0 onwards has provides a better  way feature to do the testing in the Studio IDE itself . We are going to cover how we can do this.

Prerequisites:

  • Mule Studio 3.4.0 or higher
  • Mule Runtimes 3.3.2,3.4.0,3.4.1,3.4.2

I am testing this in the enterprise version, commuinity version will be only 3.4.0 and highers

You need to have access to the IDE installations folders and specifically the plugin folders.

Steps:1. Locate your ESB Project’ mule project XML file typically mule-project.xml

2. Choose Service Run-time .When you perform this step you might not have all run-times . So follow below steps to install rest of the run-times.

Installing Mule Run-times

2.1. Goto Help menu in Studio and choose Install New Software.

2.2 Add below in you software URL

“Mule ESB Runtimes for Studio – http://studio.mulesoft.org/studio-runtimes/”  . You should see something like below.

2.3. Now Choose the run times you would like and install as if you install other plugins.

 

3. Whenever you want to run the ESB application against a particular run-time, you just have to choose the run-time in mule-project.xml and save it.

4. Then Run as mule applicaiton . Viola!

Behind the scenes , Mule picks tup teh runtime from below directories

C:\work\install\ide\MuleStudio\plugins\org.mule.tooling.server.X.X.X.ee_XXXXX\   where X.X.X is version for mule release and XXXX is stamp.

 

 

 

 

 

 

 

 

Alternative Way

You can also do cross version testing by setting the default runtime  in  Window>Preferences>Mule Studio

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

But changing mule-project.xml is flexible and quick

 

 

Hope the posts helps.

 

 

 

 

 

 

October 23, 2012

Monitoring HornetQ – How to

I am going to share a step/step guide to monitor HornetQ. I have recently read a post with details about the performance of HornetQ and quickly it attracted me to test out and start using it. You can get the installation details from their site.

HornetQ can be hosted in 2 ways 1)Standalone 2) jBoss App Server. When you go for option 2) lot of things are provided out of the box by the app server itself , but the pain is when we got for standalone. One of the aspects which I did not get any help was on monitoring hornetq, and thus I have to figure out. There is a Management API provided by HornetQ but again you need to add an interface or write you own client to do it, which is not readily available till date of this post. In below post we are going to monitor the HornetQ using jConsole remote monitoring, and believe me its easy. So here we go.

Prerequisites

  • HorentQ should be installed already in standalone mode. Please follow the guide from HornetQ.
  • Check that the port 3333 (or of your choice) is open and free.
  • Configure the hornet hornetq-beans.xml and hornetq-configuration.xml bye replacing localhost with remote IP/DNS for the HornetQ server.

Steps

Provide remote monitoring capabilities for the HornetQ server in run.sh

You need to add below parameters to run.sh by changing the last line , which is

java $JVM_ARGS -classpath $CLASSPATH -Dcom.sun.management.jmxremote org.hornetq.integration.bootstrap.HornetQBootstrapServer $FILENAME
to
java $JVM_ARGS -classpath $CLASSPATH -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=3333 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false org.hornetq.integration.bootstrap.HornetQBootstrapServer $FILENAME
Note that we have add 2 system variables
-Dcom.sun.management.jmxremote.port=3333
-Dcom.sun.management.jmxremote.authenticate=false

Secured access (SSL) is optional and is out of scope for this post, but at the end of this post you can find a little bit on authenticated access.
At this point we have arranged monitoring for hornetQ.

Hook Up jconsole

run ‘jconsole’ from command line at your client machine . This will pop up jconsole UI.

Note – for linux users , you need to have a GUI environment running like KDE/GNOME.

Monitoring

Below are some images that will help you manage the hornetq

    1. Starting the session with HornetQ
  1. Queue Details to monitor
  2. Creating the queue.
  3. Queue created

If you want to further manage the hornet Queues/Server use the MBeans to do that.

Secured Access

To Enable authentication you need to add below details for jmx management in server’s JDK installations.

      • Copy JRE_HOME/lib/management/jmxremote.password.template this template to JRE_HOME/lib/management/management.jmxremote.password
      • Set the user/password entries in management.jmxremote.password for roles

monitorRole hornet
controlRole superhornet

  • Change the permission of jmxremote.password to read-only # by the owner.

Now we have added authentication credentials for remote service with username and password , you’ll need this in jconsole.

make sure that you set the system property to true for hornetq/bin/run.sh.
-Dcom.sun.management.jmxremote.authenticate=true

May 15, 2012

Installing hive – Cookbook

In this blog I am going to list out installation guide through the hive installation , sort of cook book recipe.

Installation of Hive.

This blog runs everything on single machine hive server, meta-store and the client in form of CLI. You can write your client that can understand thrift and your hive server is accessible through TCP .

Ingredients/Requirements

Installation Steps

  • Download TAR ball for hive.
  • Extract TAR ball to your Users home directory ,preferable the same user for hadoop.
  • Make a soft link
  • ~:ln -s hive-0.8.1/ hive

    *Making soft links works best in scenario when you want to upgrade , just change the link 😉

  • Configuring Hive
  • hive relies on underlying hadoop infrastructure, in this blog we are utilizing only local instance. Hence its important to install hadoop first.

    • Add HADOOP_HOME to system variable.
    • ~:sudo cat "HADOOP_HOME=~/hadoop" >> ~/.bashrc
      *You should be a sudoer or have write permission on profile for hadoop user.

    • Make a Copy of file ~/hive/conf/hive-default.xml.template
    • ~:cp ~/hive/conf/hive-default.xml.template ~/hive/conf/hive-default.xml

      The above file is a config file , for hive fine tuning we override the properties , for a list of properties and there usage please visit.

    • Add configuration properties as below to the end of file

    • <!-- Nishant -->
      <property>
      <name>mapred.job.tracker</name>
      <value>local</value>
      <description>Hive fully supports local mode execution</description>
      </property>

      Metastore
      Hive depends on a Meta information which it maintains b/w Hive tables/partitions and actual data on HDFS. This can be stored in a persistent store like a DB. I am using Derby here as it gives an in memory advantage. Its a tradeoff that an architect has to make. It can be Embedded,Local,Remote. The advantage of one over the other are driven by
      – Performance (for embedded)
      – Redundancy (for remote)
      – Other db features
      In this example we are going with Local with derby (you can use embedded as well).

      <property>
      <name>javax.jdo.option.ConnectionURL</name>
      <value>jdbc:derby://localhost:1527/metastore_db;create=true</value>
      <description>JDBC connect string for a JDBC metastore</description>
      </property>
      <property>
      <name>javax.jdo.option.ConnectionDriverName</name>
      <value>org.apache.derby.jdbc.ClientDriver</value>
      <description>Driver class name for a JDBC metastore</description>
      </property>
      <property>
      <name>hive.metastore.warehouse.dir</name>
      <value>/user/nishant/hive/warehouse</value>
      <description>location of default database for the warehouse</description>
      </property>

      Web Interface
      Hive Provides you a web interface so you can do browsing of schema and multi query execution. This comes handy when multiple hive clients are running queries on hive server.

      <!-- Nishant -->
      <property>
      <name>hive.hwi.war.file</name>
      <value>lib/hive-hwi-0.6.0.war</value>
      <description>This sets the path to the HWI war file, relative to ${HIVE_HOME}. </description>
      </property>
      <property>
      <name>hive.hwi.listen.host</name>
      <value>127.0.0.1</value>
      <description>This is the host address the Hive Web Interface will listen on</description>
      </property>
      <property>
      <name>hive.hwi.listen.port</name>
      <value>9999</value>
      <description>This is the port the Hive Web Interface will listen on</description>
      </property>

  • Starting hive Hive server
  • ~/hive: bin/hive --service hiveserver
    *Hive runs on 10000 port on the server.

    That’s it , the above will start the hive server.

  • Client CLI
  • ~/hive: bin/hive
    The above will start CLI , but to run queries or any other hive operation , the metastore should be existing.
    Hive Clients can be any which can work using ODBC/JDBC connection with hive on URL jdbc:hive://<HOST>:<PORT:/default

  • Starting metastore.
  • Since I user a local derby server I am starting the metastore.
    ~/derby/bin/startNetworkServer

  • Starting Hadoop
  • ~/hadoop:bin/start-all.sh

    Testing Hive

    TBD
    A Atypical Hive Deployment might run like

    Typical Deployment for Hive

    Migtation Issue

    We faced on issue when migrating the underlying Hadoop and changing its configurations.We changed the port for the Hadoop from 60000 to 54310(default) . Reason being our hbase was runnign default on 60000 . So doing this our hive failed because it was again trying to hit the previos case, with error as below

    hive> select * from pokes;
    OK
    Failed with exception java.io.IOException:java.net.ConnectException: Call to localhost/127.0.0.1:60000 failed on connection exception: java.net.ConnectException: Connection refused
    Time taken: 10.507 seconds

    The reason is that the metadata stores all information for the location of the file on hadoop , hence when i saw the extended description of table i got something as

    hive> describe extended pokes;
    OK
    foo int
    bar string
    new_col int

    Detailed Table Information Table(tableName:pokes, dbName:default, owner:sysadminn, createTime:1337064947, lastAccessTime:0, retention:0, sd:StorageDescriptor(cols:[FieldSchema(name:foo, type:int, comment:null), FieldSchema(name:bar, type:string, comment:null), FieldSchema(name:new_col, type:int, comment:null)], location:hdfs://localhost:60000/user/hive/warehouse/pokes, inputFormat:org.apache.hadoop.mapred.TextInputFormat, outputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat, compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, parameters:{serialization.format=1}), bucketCols:[], sortCols:[], parameters:{}), partitionKeys:[], parameters:{last_modified_by=sysadminn, last_modified_time=1337065255, transient_lastDdlTime=1337065459}, viewOriginalText:null, viewExpandedText:null, tableType:MANAGED_TABLE)

    which still points to olded info . So I altered the table with command as below

    ALTER TABLE pokes SET LOCATION "hdfs://localhost:54310/user/hive/warehouse/pokes";

    And thus the table restored its metatdata and hadoop links. It is important to note that the URL is for the Hadoop location (hdfs) and not he jobtracker. Otherwise you’ll get this error.

    hive> select * from pokes;
    OK
    Failed with exception java.io.IOException:org.apache.hadoop.ipc.RemoteException: java.io.IOException: Unknown protocol to job tracker: org.apache.hadoop.hdfs.protocol.ClientProtocol
    at org.apache.hadoop.mapred.JobTracker.getProtocolVersion(JobTracker.java:222)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:508)
    at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:959)
    at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:955)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.security.auth.Subject.doAs(Subject.java:396)
    at org.apache.hadoop.ipc.Server$Handler.run(Server.java:953)

    The above is also equally and extensible applicable in case of partitions. We need to individually override location invormation for partitins as below, along with table.

    Altering Table
    hive> describe extended invites;
    OK
    foo int
    bar string
    new_col2 int a comment
    ds string

    Detailed Table Information Table(tableName:invites, dbName:default, owner:sysadminn, createTime:1337065237, lastAccessTime:0, retention:0, sd:StorageDescriptor(cols:[FieldSchema(name:foo, type:int, comment:null), FieldSchema(name:bar, type:string, comment:null), FieldSchema(name:new_col2, type:int, comment:a comment), FieldSchema(name:ds, type:string, comment:null)], location:hdfs://localhost:60000/user/hive/warehouse/invites, inputFormat:org.apache.hadoop.mapred.TextInputFormat, outputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat, compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, parameters:{serialization.format=1}), bucketCols:[], sortCols:[], parameters:{}), partitionKeys:[FieldSchema(name:ds, type:string, comment:null)], parameters:{last_modified_by=sysadminn, last_modified_time=1337065270, transient_lastDdlTime=1337065270}, viewOriginalText:null, viewExpandedText:null, tableType:MANAGED_TABLE)

    hive> ALTER TABLE invites SET LOCATION "hdfs://localhost:54310/user/hive/warehouse/invites";

    hive> describe extended invites;
    OK
    foo int
    bar string
    new_col2 int a comment
    ds string

    Detailed Table Information Table(tableName:invites, dbName:default, owner:sysadminn, createTime:1337065237, lastAccessTime:0, retention:0, sd:StorageDescriptor(cols:[FieldSchema(name:foo, type:int, comment:null), FieldSchema(name:bar, type:string, comment:null), FieldSchema(name:new_col2, type:int, comment:a comment), FieldSchema(name:ds, type:string, comment:null)], location:hdfs://localhost:54310/user/hive/warehouse/invites, inputFormat:org.apache.hadoop.mapred.TextInputFormat, outputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat, compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, parameters:{serialization.format=1}), bucketCols:[], sortCols:[], parameters:{}), partitionKeys:[FieldSchema(name:ds, type:string, comment:null)], parameters:{last_modified_by=sysadminn, last_modified_time=1337158863, transient_lastDdlTime=1337158863}, viewOriginalText:null, viewExpandedText:null, tableType:MANAGED_TABLE)

    Listing Partition information for table
    hive> SHOW PARTITIONS invites;
    OK
    ds=2008-08-08
    ds=2008-08-15

    Altering Partitions

    hive> DESCRIBE EXTENDED invites PARTITION (ds='2008-08-08');
    OK
    foo int
    bar string
    new_col2 int a comment
    ds string

    Detailed Partition Information Partition(values:[2008-08-08], dbName:default, tableName:invites, createTime:1337065605, lastAccessTime:0, sd:StorageDescriptor(cols:[FieldSchema(name:foo, type:int, comment:null), FieldSchema(name:bar, type:string, comment:null), FieldSchema(name:new_col2, type:int, comment:a comment)], location:hdfs://localhost:60000/user/hive/warehouse/invites/ds=2008-08-08, inputFormat:org.apache.hadoop.mapred.TextInputFormat, outputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat, compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, parameters:{serialization.format=1}), bucketCols:[], sortCols:[], parameters:{}), parameters:{transient_lastDdlTime=1337065605})

    hive> ALTER TABLE invites PARTITION (ds='2008-08-08') SET LOCATION "hdfs://localhost:54310/user/hive/warehouse/invites/ds=2008-08-08";
    OK

    hive> DESCRIBE EXTENDED invites PARTITION (ds='2008-08-08');
    OK
    foo int
    bar string
    new_col2 int a comment
    ds string

    Detailed Partition Information Partition(values:[2008-08-08], dbName:default, tableName:invites, createTime:1337065605, lastAccessTime:0, sd:StorageDescriptor(cols:[FieldSchema(name:foo, type:int, comment:null), FieldSchema(name:bar, type:string, comment:null), FieldSchema(name:new_col2, type:int, comment:a comment)], location:hdfs://localhost:54310/user/hive/warehouse/invites/ds=2008-08-08, inputFormat:org.apache.hadoop.mapred.TextInputFormat, outputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat, compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, parameters:{serialization.format=1}), bucketCols:[], sortCols:[], parameters:{}), parameters:{last_modified_by=sysadminn, last_modified_time=1337159527, transient_lastDdlTime=1337159527})


    And for another partition

    hive> DESCRIBE EXTENDED invites PARTITION (ds='2008-08-15');
    OK
    foo int
    bar string
    new_col2 int a comment
    ds string

    Detailed Partition Information Partition(values:[2008-08-15], dbName:default, tableName:invites, createTime:1337065580, lastAccessTime:0, sd:StorageDescriptor(cols:[FieldSchema(name:foo, type:int, comment:null), FieldSchema(name:bar, type:string, comment:null), FieldSchema(name:new_col2, type:int, comment:a comment)], location:hdfs://localhost:60000/user/hive/warehouse/invites/ds=2008-08-15, inputFormat:org.apache.hadoop.mapred.TextInputFormat, outputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat, compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, parameters:{serialization.format=1}), bucketCols:[], sortCols:[], parameters:{}), parameters:{transient_lastDdlTime=1337065580})

    hive> ALTER TABLE invites PARTITION (ds='2008-08-15') SET LOCATION "hdfs://localhost:54310/user/hive/warehouse/invites/ds=2008-08-15";
    OK

    hive> DESCRIBE EXTENDED invites PARTITION (ds='2008-08-15');
    OK
    foo int
    bar string
    new_col2 int a comment
    ds string

    Detailed Partition Information Partition(values:[2008-08-15], dbName:default, tableName:invites, createTime:1337065580, lastAccessTime:0, sd:StorageDescriptor(cols:[FieldSchema(name:foo, type:int, comment:null), FieldSchema(name:bar, type:string, comment:null), FieldSchema(name:new_col2, type:int, comment:a comment)], location:hdfs://localhost:54310/user/hive/warehouse/invites/ds=2008-08-15, inputFormat:org.apache.hadoop.mapred.TextInputFormat, outputFormat:org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat, compressed:false, numBuckets:-1, serdeInfo:SerDeInfo(name:null, serializationLib:org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, parameters:{serialization.format=1}), bucketCols:[], sortCols:[], parameters:{}), parameters:{last_modified_by=sysadminn, last_modified_time=1337159560, transient_lastDdlTime=1337159560})

May 11, 2012

SVN Server Quick

This post is a guide to set up SVN server quickly

Prerequieites :

Linux : Ubuntu with APT tool kit installed

Steps:

  1. Create a directory that will be svn root.
  2. svn-server:$~mkdir svn-root

  3. Set read write permission to all
  4. svn-server:$~sudo chmod -R 0777 svn-root/

  5. Install Subversion client+server
  6. svn-server:$~sudo apt-get install subversion

    This should install svn on the machine

  7. Test svn
  8. svn-server:$~svn help

    svn-server:$~svnadmin help

    Both should display a list of commands

  9. Create repository
  10. svn-server:$~/svnroot$ svnadmin create sample

    The above command will create a project or repo for you

  11. Test the project using file:///
  12. svn-server:$~svn co file://~/sample sample
    This will checkout the sample project to local

    The file:/// protocol will work only on local machine(server) , you need to set up alternate way to access the project/repo . This can be http://,svn:// etc..

    I am configuring a simple, quick and LAN based access using SVN.For this we need to enable and start svn as a service.

  13. Run below command to start service in background mode
  14. svn-server:$~svnserve -d --foreground -r ~/svn-root --log-file ~/svn-server.log --pid-file ~/svn-server.pid

    The above command will start listening on default port (3690).

  15. User Management :
  16. You need to provide Username and Passwords to be used by client for each project. Alternative is to have softlink for a command file for all project

      Override the file inside project direcroty ([project]/conf/) using your own tool

    1. File : svnserve.conf
    2. Enable by adding (or uncommenting) the lines telling on default user management file.
      password-db = passwd

    3. File : passwd
    4. Override by adding UN=PW pairs eg.
      developer=slashdot
      tester=bugsworld

  17. Testing from client machine
  18. Prequisites: The client should have svn client installed and teh svn client (like tortoise) should be able to decode svn://protocol

    svn-client:~svn co svn://svn-server/sample sample

    The above should check out the folder.

    Thanks

April 3, 2012

Ruby 1.9.2 installation issues on Linux (Ubuntu)

Today I was trying to install Ruby on Rails (ROR) as specified in from the Installing Ruby on Rails . From the page it looked like a piece of cake but not to mention there were issues when I actually went for instllation . So here is the excerpt on the installation.

1. Use apt-get install for installing ruby. This should install the released version , as in my case it was 1.9.2.
sudo apt-get install ruby

The above code will automatically install gem installer as well.So no need to do extra bit.

The Ruby runtime gets installed in /usr/bin/ruby-x.x.x directory.

2. Install the gem for rails . Use command
sudo gem i rails -V
the -V option will not stall the command line output and you can easily see what’s going on behind the scenes.

Issues: mkmf module installation problem.
Error:

This is because the lower level code for ruby depends on compilers for C hence you gotto install the necessary module for the same. Hence use
sudo apt-get install build-essential libopenssl-ruby ruby1.9.1-dev

3. Install the gem for rails again
sudo gem i rails -V

This will install the ruby rails gem.

4. Use the new Rails gem Create an application
rails new myproject

The o/p was as below

create
create README.rdoc
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/assets/images/rails.png
create app/assets/javascripts/application.js
create app/assets/stylesheets/application.css
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/mailers
create app/models
create app/views/layouts/application.html.erb
create app/mailers/.gitkeep
create app/models/.gitkeep
create config
create config/routes.rb
create config/application.rb
create config/environment.rb
create config/environments
create config/environments/development.rb
create config/environments/production.rb
create config/environments/test.rb
create config/initializers
create config/initializers/backtrace_silencers.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/secret_token.rb
create config/initializers/session_store.rb
create config/initializers/wrap_parameters.rb
create config/locales
create config/locales/en.yml
create config/boot.rb
create config/database.yml
create db
create db/seeds.rb
create doc
create doc/README_FOR_APP
create lib
create lib/tasks
create lib/tasks/.gitkeep
create lib/assets
create lib/assets/.gitkeep
create log
create log/.gitkeep
create public
create public/404.html
create public/422.html
create public/500.html
create public/favicon.ico
create public/index.html
create public/robots.txt
create script
create script/rails
create test/fixtures
create test/fixtures/.gitkeep
create test/functional
create test/functional/.gitkeep
create test/integration
create test/integration/.gitkeep
create test/unit
create test/unit/.gitkeep
create test/performance/browsing_test.rb
create test/test_helper.rb
create tmp/cache
create tmp/cache/assets
create vendor/assets/javascripts
create vendor/assets/javascripts/.gitkeep
create vendor/assets/stylesheets
create vendor/assets/stylesheets/.gitkeep
create vendor/plugins
create vendor/plugins/.gitkeep
run bundle install
Fetching gem metadata from https://rubygems.org/……&#8230;
Using rake (0.9.2.2)
Using i18n (0.6.0)
Using multi_json (1.2.0)
Using activesupport (3.2.3)
Using builder (3.0.0)
Using activemodel (3.2.3)
Using erubis (2.7.0)
Using journey (1.0.3)
Using rack (1.4.1)
Using rack-cache (1.2)
Using rack-test (0.6.1)
Using hike (1.2.1)
Using tilt (1.3.3)
Using sprockets (2.1.2)
Using actionpack (3.2.3)
Using mime-types (1.18)
Using polyglot (0.3.3)
Using treetop (1.4.10)
Using mail (2.4.4)
Using actionmailer (3.2.3)
Using arel (3.0.2)
Using tzinfo (0.3.32)
Using activerecord (3.2.3)
Using activeresource (3.2.3)
Using bundler (1.1.3)
Using coffee-script-source (1.2.0)
Using execjs (1.3.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.2)
Using json (1.6.6)
Using rdoc (3.12)
Using thor (0.14.6)
Using railties (3.2.3)
Using coffee-rails (3.2.2)
Using jquery-rails (2.0.1)
Using rails (3.2.3)
Using sass (3.1.15)
Using sass-rails (3.2.5)
Using sqlite3 (1.3.5)
Using uglifier (1.2.4)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

5. Start the application
cd myproject
rails server

Error :

/var/lib/gems/1.9.1/gems/execjs-1.3.0/lib/execjs/runtimes.rb:50:in `autodetect’: Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)
from /var/lib/gems/1.9.1/gems/execjs-1.3.0/lib/execjs.rb:5:in `’
from /var/lib/gems/1.9.1/gems/execjs-1.3.0/lib/execjs.rb:4:in `’
from /var/lib/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `require’
from /var/lib/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee_script.rb:1:in `’
from /var/lib/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `require’
from /var/lib/gems/1.9.1/gems/coffee-script-2.2.0/lib/coffee-script.rb:1:in `’
from /var/lib/gems/1.9.1/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `require’
from /var/lib/gems/1.9.1/gems/coffee-rails-3.2.2/lib/coffee-rails.rb:1:in `’
from /var/lib/gems/1.9.1/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `require’
from /var/lib/gems/1.9.1/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `block (2 levels) in require’
from /var/lib/gems/1.9.1/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `each’
from /var/lib/gems/1.9.1/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `block in require’
from /var/lib/gems/1.9.1/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `each’
from /var/lib/gems/1.9.1/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `require’
from /var/lib/gems/1.9.1/gems/bundler-1.1.3/lib/bundler.rb:119:in `require’
from /home/kunal/work/nishant/config/application.rb:7:in `’
from /var/lib/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:53:in `require’
from /var/lib/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:53:in `block in ‘
from /var/lib/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:50:in `tap’
from /var/lib/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:50:in `’
from script/rails:6:in `require’
from script/rails:6:in `’

This issue is because the javascript runtime gem (execjs) is not installed or N/A for this project hence we need to add this as a dependency for our bundle .

bundle show
Gems included by the bundle:
* actionmailer (3.2.3)
* actionpack (3.2.3)
* activemodel (3.2.3)
* activerecord (3.2.3)
* activeresource (3.2.3)
* activesupport (3.2.3)
* arel (3.0.2)
* builder (3.0.0)
* bundler (1.1.3)
* coffee-rails (3.2.2)
* coffee-script (2.2.0)
* coffee-script-source (1.2.0)
* erubis (2.7.0)
* execjs (1.3.0)
* hike (1.2.1)
* i18n (0.6.0)
* journey (1.0.3)
* jquery-rails (2.0.1)
* json (1.6.6)
* mail (2.4.4)
* mime-types (1.18)
* multi_json (1.2.0)
* polyglot (0.3.3)
* rack (1.4.1)
* rack-cache (1.2)
* rack-ssl (1.3.2)
* rack-test (0.6.1)
* rails (3.2.3)
* railties (3.2.3)
* rake (0.9.2.2)
* rdoc (3.12)
* sass (3.1.15)
* sass-rails (3.2.5)
* sprockets (2.1.2)
* sqlite3 (1.3.5)
* thor (0.14.6)
* tilt (1.3.3)
* treetop (1.4.10)
* tzinfo (0.3.32)
* uglifier (1.2.4)

6. Add the javascript runtime ‘therubyracer’ gem to bundle

sudo nano Gemfile

cat Gemfile
source ‘https://rubygems.org&#8217;

gem ‘rails’, ‘3.2.3’

# Bundle edge Rails instead:
# gem ‘rails’, :git => ‘git://github.com/rails/rails.git’

gem ‘sqlite3’

gem ‘therubyracer’

# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem ‘sass-rails’, ‘~> 3.2.3’
gem ‘coffee-rails’, ‘~> 3.2.1’

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem ‘therubyracer’, :platform => :ruby

gem ‘uglifier’, ‘>= 1.0.3’
end

gem ‘jquery-rails’

# To use ActiveModel has_secure_password
# gem ‘bcrypt-ruby’, ‘~> 3.0.0’

# To use Jbuilder templates for JSON
# gem ‘jbuilder’

# Use unicorn as the app server
# gem ‘unicorn’

# Deploy with Capistrano
# gem ‘capistrano’

# To use debugger
# gem ‘ruby-debug19’, :require => ‘ruby-debug’

7. Start server agian with no issue.

Appreciate you response.
Happy Coding and reading.

April 3, 2012

IE8 IE9 Privacy Policy Blocking Issue

Hello Readers

The other day I was working on making a site live for and FB page. So we guys were through with QA and then client reported that all users are facing a Privacy Policy Issue with our actual Website URL being blocked. The sites were shown in Privacy Policy Blocked list.

Issue was that we could not replicate it at our end but client was facing it readily. There could be 3 reasons

1- Proxy Server blocking the website locally.
2- Internet options added the sites as blocked.

We could not realize what was the issue until we refereed that the cookies accessed by our web page are making a scene to stop the IE Browser block it. This was the P3P header issue P3P Header.

We the set the header from our server side only using below.

response.setHeader("P3P","CP='IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT'")

This often happens when a 3rd party source/page is hosted in an IFRAME and this source is trying to set cookies that can attract a bit private information from browser agent (in our and most cases IE)thus browser blocks the website.

The above solution worked for us and sure it will for other’s too. One thing I could not understand is , if at all the browsers wanted to block sites that are controlled by server then any server serving content can add header and mark these web pages as no harm.This should be completely on the client/users hand to mark the pages as secured or privacy protected.

Happy coding!

March 14, 2012

Security Issue on IE for Facebook pages [ SEC7111: HTTPS security is compromised by]

Hello Readers,

Today I want to talk about the issues we faced for a Facebook Page/ Facebook App HTTPS access issue in IE. The typical error was –

SEC7111: HTTPS security is compromised by http://myapphost/mypage.html
123456789012345?sk=app_123456789012345

The problem

When a user tries to access our Facebook App/Page using a Secured profile (https enabled in Facebook User’s security settings) , automatically https: is prefixed in its URL. Doing so all request to Facebook henceforth will use HTTPS. But our Facebook App/Page, which are yet HTTP, are still accessed and thus IE throws this error for accessing our unsecured HTTP page. The above error is generated whenever an unsecured content is accessed from secured content and the user is intimated by the browser (IE) for this. It can easily be resolved by accepting the access but still annoying at the first place itself. Any big brand wont like this as it will divert the prospective Facebook Page visitor.This solution is of unsecured access by the FB user , but that’s out of our control so not a recommended.

The solution

Add trusted certificates to our domain.So that HTTPS access is enabled for our domain and its trusted. If the certs are not trusted IE will again prompt for adding the untrusted certificated.

You can refer to Trusted SSL Certificate providers for a list of Trusted SSL Certificate providers and purchase a certificate.

Thanks
Nissshh

Pin It

February 29, 2012

Dynamic Datanode attached to Namenode

Hello Readers

In this post we are going to see how to attach a datanode to a hadoop cluster during runtime. This also shows how can we achieve runtime elasticity within a hadoop cluster. Follow me.

Here we are going to attach a new Slave (hadoop-slave2) to an existing cluster with 1 Namenode (NN) on hadoop-master and 1 Datanode (DN) on hadoop-slave1.

    Prerequisites

    We need to make slave elligible for attaching to cluster so for new Slave

  1. Install SSH client and server
    sudo apt-get install openssh-server openssh-client
    *make sure that the ssh service is enabled for all users.
  2. Create a common user for SSH shell e.g. hduser
    adduser hduser

    Complete all formalities
  3. Enable Password Less comminication.
    Create a public key for hduser
    ssh-keygen -t rsa
    ssh-dd
  4. Install Java using apt-get
    sudo apt-get install java-6-openjdk
    * this should install jdk to /usr/lib/jvm/java-6-openjdk

The above should prepare for the new client, follow below steps for the action of attaching this slave dynamically without changing the configuration on master.Readers should note that the new slave is temporary and not a registered data node for the cluster, as the next time you restart the whole cluster the new slave might not be visible.

  1. Step -1
    Update /etc/hosts for Namenode (Master)
    * this case doesn’t use another DNS service for name resolution.
    eg.
    172.20.20.111 hadoop-slave2
    * use the same name for the hostname for the client.
  2. Step – 2
    Establish SSH b/w new slave and master follow below steps.This will enable password less entry.
    ssh-copy-id -i .ssh/id_rsa.pub hduser@hadoop-slave2
  3. Step – 3
    1. Push all from master hadoop jar and configs to slave
      scp /home/hduser/hadoop-0.20.203.0rc1.tar.gz hduser@hadoop-slave2:~/
      ssh hadoop-slave2

      *make sure that master is logged in as hduser only other wise use
    2. Extract the Tarball to slave
      ssh hduser@hadoop-slave2 'tar -xvf hadoop-0.20.203.0rc1.tar.gz'
    3. Make a softlink for easy typing
      ssh hduser@hadoop-slave2 'ln -s /home/hduser/hadoop-0.20.203.0/ hadoop'
    4. Copy all configs from Master to slave.
      scp hadoop/conf/*-site.xml hadoop-slave2:/home/hduser/hadoop/conf/.
      scp hadoop/conf/hadoop-env hadoop-slave2:/home/hduser/hadoop/conf/.

      * make sure that JAVA_HOME is pointing to /usr/lib/jvm/java-6-openjdk
  4. Step -4
    On Slave Export HADOOP_HOME and override PATH as below

    export HADOOP_HOME=/home/hduser/hadoop
    export PATH=$PATH:$HADOOP_HOME/bin

  5. Step -5
    Goto Slave and run datanode

    hduser@hadoop-slave2:~$ hadoop datanode

You will get below as o/p

12/02/29 12:16:53 INFO datanode.DataNode: STARTUP_MSG:
/************************************************************
STARTUP_MSG: Starting DataNode
STARTUP_MSG: host = hadoop-slave2/127.0.1.1
STARTUP_MSG: args = []
STARTUP_MSG: version = 0.20.203.0
STARTUP_MSG: build = http://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security-203 -r 1099333; compiled by 'oom' on Wed May 4 07:57:50 PDT 2011
************************************************************/
12/02/29 12:16:54 INFO impl.MetricsConfig: loaded properties from hadoop-metrics2.properties
12/02/29 12:16:54 INFO impl.MetricsSourceAdapter: MBean for source MetricsSystem,sub=Stats registered.
12/02/29 12:16:54 INFO impl.MetricsSystemImpl: Scheduled snapshot period at 10 second(s).
12/02/29 12:16:54 INFO impl.MetricsSystemImpl: DataNode metrics system started
12/02/29 12:16:54 INFO impl.MetricsSourceAdapter: MBean for source ugi registered.
12/02/29 12:16:54 WARN impl.MetricsSystemImpl: Source name ugi already exists!
12/02/29 12:16:54 INFO common.Storage: Storage directory /tmp/hduser/dfs/data is not formatted.
12/02/29 12:16:54 INFO common.Storage: Formatting ...
12/02/29 12:16:54 INFO datanode.DataNode: Registered FSDatasetStatusMBean
12/02/29 12:16:54 INFO datanode.DataNode: Opened info server at 50010
12/02/29 12:16:54 INFO datanode.DataNode: Balancing bandwith is 1048576 bytes/s
12/02/29 12:17:00 INFO mortbay.log: Logging to org.slf4j.impl.Log4jLoggerAdapter(org.mortbay.log) via org.mortbay.log.Slf4jLog
12/02/29 12:17:00 INFO http.HttpServer: Added global filtersafety (class=org.apache.hadoop.http.HttpServer$QuotingInputFilter)
12/02/29 12:17:00 INFO http.HttpServer: Port returned by webServer.getConnectors()[0].getLocalPort() before open() is -1. Opening the listener on 50075
12/02/29 12:17:00 INFO http.HttpServer: listener.getLocalPort() returned 50075 webServer.getConnectors()[0].getLocalPort() returned 50075
12/02/29 12:17:00 INFO http.HttpServer: Jetty bound to port 50075
12/02/29 12:17:00 INFO mortbay.log: jetty-6.1.26
12/02/29 12:17:00 INFO mortbay.log: Started SelectChannelConnector@0.0.0.0:50075
12/02/29 12:17:00 INFO impl.MetricsSourceAdapter: MBean for source jvm registered.
12/02/29 12:17:00 INFO impl.MetricsSourceAdapter: MBean for source DataNode registered.
12/02/29 12:17:06 INFO ipc.Server: Starting SocketReader
12/02/29 12:17:06 INFO impl.MetricsSourceAdapter: MBean for source RpcDetailedActivityForPort50020 registered.
12/02/29 12:17:06 INFO impl.MetricsSourceAdapter: MBean for source RpcActivityForPort50020 registered.
12/02/29 12:17:06 INFO datanode.DataNode: dnRegistration = DatanodeRegistration(hadoop-slave2:50010, storageID=, infoPort=50075, ipcPort=50020)
12/02/29 12:17:16 INFO datanode.DataNode: New storage id DS-485708509-127.0.1.1-50010-1330498036901 is assigned to data-node hadoop-slave2:50010
12/02/29 12:17:16 INFO datanode.DataNode: DatanodeRegistration(hadoop-slave2:50010, storageID=DS-485708509-127.0.1.1-50010-1330498036901, infoPort=50075, ipcPort=50020)In DataNode.run, data = FSDataset{dirpath='/tmp/hduser/dfs/data/current'}
12/02/29 12:17:16 INFO ipc.Server: IPC Server Responder: starting
12/02/29 12:17:16 INFO ipc.Server: IPC Server listener on 50020: starting
12/02/29 12:17:16 INFO ipc.Server: IPC Server handler 0 on 50020: starting
12/02/29 12:17:16 INFO ipc.Server: IPC Server handler 1 on 50020: starting
12/02/29 12:17:16 INFO ipc.Server: IPC Server handler 2 on 50020: starting
12/02/29 12:17:16 INFO datanode.DataNode: using BLOCKREPORT_INTERVAL of 3600000msec Initial delay: 0msec
12/02/29 12:17:16 INFO datanode.DataNode: BlockReport of 0 blocks took 0 msec to generate and 2 msecs for RPC and NN processing
12/02/29 12:17:16 INFO datanode.DataNode: Starting Periodic block scanner.
12/02/29 12:17:21 INFO datanode.DataNode: Receiving block blk_1167069880619983991_1051 src: /hadoop-master:47627 dest: /hadoop-slave2:50010
12/02/29 12:17:21 INFO datanode.DataNode: Receiving block blk_-122434886027464979_1079 src: /hadoop-master:47626 dest: /hadoop-slave2:50010
12/02/29 12:17:21 INFO datanode.DataNode: Received block blk_-122434886027464979_1079 src: /hadoop-master:47626 dest: /hadoop-slave2:50010 of size 142469
12/02/29 12:17:21 INFO datanode.DataNode: Received block blk_1167069880619983991_1051 src: /hadoop-master:47627 dest: /hadoop-slave2:50010 of size 142469
12/02/29 12:22:42 INFO datanode.DataBlockScanner: Verification succeeded for blk_1167069880619983991_1051
12/02/29 12:25:03 INFO datanode.DataBlockScanner: Verification succeeded for blk_-122434886027464979_1079

Verify Datanodes on Namenode UI as below
http://hadoop-master:50070/

Caution

The hosts entry should contain the mapping with proper hostname of slaves.

e.g. /etc/hosts entry on master
XXX.XXX.XXX.XXX hadoop-slave2
/etc/hostname on slave
hadoop-myslave

This will create conflicts.