Sunday, May 24, 2015

Creating a New User in Cassandra Database

Introduction...

Hi All,

Recently I was working on user authentication of DSE(DataStax Enterprise[1]) Cassandra and I noticed that any username and password allowed me to access the cassandra cluster. So I looked into the docs and saw that there are several authenticators[2].

By default the used authenticator is the "org.apache.cassandra.auth.AllowAllAuthorizer" authenticator which allowed access with any username and password. So to create a user and grant permissions, you can follow these steps...

Steps...

Shutdown the Cassandra cluster(can use kill -9) if it is already running and the modify the cassandra.yaml file. If you are using DSE cassandra, it will reside in "<DSE_HOME>/resources/cassandra/conf/cassandra.yaml". Else if you are using Apache Cassandra, it will reside in "<APACHE_CASSANDRA_HOME>/conf/cassandra.yaml".

Modify the file in a way that "org.apache.cassandra.auth.AllowAllAuthorizer" authenticator is commented and add "org.apache.cassandra.auth.PasswordAuthenticator" authenticator[3].
#authenticator: AllowAllAuthenticator
authenticator: PasswordAuthenticator

By default, Cassandra has a user with username as "cassandra" and password as "cassandra" which can be used to create a new user using "cqlsh" tool[4]. Login using the "cqlsh" tool by executing the following command.

./cqlsh localhost -u cassandra -p cassandra

After the cqlsh console is opened, to get the current list of users run the following command.

list users;

To create a new user, run the following command. Here the username is "myUserName" and the password is "myPassword".

CREATE USER myUserName WITH PASSWORD 'myPassword' SUPERUSER;

The above user will get created with superuser privileges. The newly created user should be there when running the "list users;" command again.

Goodluck!!!

References...

[1] - http://www.datastax.com/products/products-index
[2] - http://docs.datastax.com/en/cassandra/1.2/cassandra/security/secure_config_native_authorize_t.html
[3] - http://www.datastax.com/dev/blog/a-quick-tour-of-internal-authentication-and-authorization-security-in-datastax-enterprise-and-apache-cassandra
[4] - http://docs.datastax.com/en/cassandra/1.2/cassandra/security/security_config_native_authenticate_t.html

Wednesday, May 20, 2015

View Hazelcast Management Center for WSO2 Message Broker 3.0.0.

WSO2 products allows to use multiple instances to form a cluster and divide up the work to enhance the performance and reliability of their intended processes[1]. WSO2 Message Broker 3.0.0 uses Hazelcast[2] to communicate within the instances of a cluster and is heavily depended on on it when it comes message delivering scenarios and etc. The following post is on how to access the hazelcast management center[3] of the Message Broker(s). The hazelcast management center helps to monitor the overall state of the cluster.

Lets see how we can make it happen. The following prerequisites are needed :
  • A WSO2 Message Broker cluster(clustering enabled).
  • Tomcat to host hazelcast management center.

First we have to modify the axis2.xml file of all the instances. Access the "axis2.xml" file in the following path.
<WSO2_PRODUCT>/repository/conf/axis2/axis2.xml
At the bottom of the file in the "clustering" section, the following commented line can be seen.
<!--<parameter name="mgtCenterURL">http://localhost:8081/mancenter/</parameter>-->
Uncomment the line and modify the port to 8080. This is the default port in tomcat which we will get back later.
<parameter name="mgtCenterURL">http://localhost:8080/mancenter/</parameter>
Startup the Message Broker instance(s) afterwards.

Now lets host the hazelcast management center.

To do this we need to get the "mancenter-3.2.6.war" file from the hazelcast official site. The version of the war file should be the exact hazelcast version that is being used in WSO2 Message Broker. I.E current version is 3.2.6

Download Hazelcast - The war file is included.

After downloading, place the "mancenter-3.2.6.war" file in the "<TOMCAT_HOME>/webapps" folder and rename the war file to "mancenter.war". Start up the tomcat server using "./startup.sh" in the "bin" folder of tomcat.

Then go to the following URL :
http://localhost:8080/mancenter/

Login to the hazelcast management center using username and password as "admin" and "admin". Once logged in, you should see the hazelcast management center.

Following are several images of the hazelcast management center.


This mentioned solution should also work with other WSO2 products which uses hazelcast for clustering. But I have not tested them out. I do not guarantee this solution will work or held responsible.

[1] - https://docs.wso2.com/display/CLUSTER420/Overview
[2] - http://hazelcast.org/
[3] - http://docs.hazelcast.org/docs/latest/manual/html/managementcenter.html

Thanks,
Hemika

Unable to mount ExFat external HDD (' stderr: ERROR:._.com.apple.timemachine.donotpresent' has invalid checksum)

Hi All,

I have an external hard drive(Western Digital My Passport Ultra 1TB) which I keep all my movies, work stuff and etc. Initially I formatted the drive in ExFat format in Mac OS X platform so that I can use it in Windows and Mac. Also Ubuntu seems to have a fix to read ExFat file systems[1].

But recently when I connected this external hard drive to my Ubuntu machine, it gave me this error(something similar) saying that it cannot mount the disk: 
Error mounting /dev/sdb1 at /media/rbuse/My Passport: Command-linemount -t "exfat" -o "uhelper=udisks2,nodev,nosuid,uid=1000,gid=1000,io charset=utf8,namecase=0,e rrors=remount-ro,umask=0077" "/dev/sdb1" "/media/rbuse/My Passport"' exited with non-zero exit status 1: stdout:FUSE exfat 1.0.1

stderr: ERROR:._.com.apple.timemachine.donotpresent' has invalid checksum (0x6634 != 0x4044). '
I was stunned because all my work was in there, especially my VDIs. 

So I started my research and one solution was to plug it back in to my Mac OS X machine and use the "Disk Utility" tool to repair it(Use "Repair Disk" button) [2][3]. When I tried this, the following error came up.
Error: Disk Utility can’t repair this disk. Back up as many of your files as possible, reformat the disk, and restore your backed-up files.
I was like "Huh?!?!?" . I continued my research and found that if I attempt several times to "Repair Disk", it will work at sometime[4]. I tried like 20+ times, it didn't work.

So I googled more and found a command that should fix the broken external hard drive [5][6][7].
sudo fsck_exfat -d <device>
To find the correct value for <device>(eg : disk1s2) use the following command[8] to list down the device IDs.
diskutil list
At the end of the fsck_exfat command, I got the following error[9]. 
fsck_exfat: Could not update main boot region: Bad file descriptor
Sigh!.

As the last attempt to fix, I used the "chkdsk" command of Windows OS[10]. And IT WORKED!!. I ran the following command. It took sometime to complete the task. So be patient.
chkdsk /f <Volume_ID>
Here the Volume_ID refers "C:" or "D:" of the corrupted hard disk. eg : 
chkdsk /f D:

Hope this article helped!,

Thanks,
Hemika

[1] - http://askubuntu.com/questions/451364/how-to-enable-exfat-in-ubuntu-14-04
[2] - https://bbs.archlinux.org/viewtopic.php?pid=1481063#p1481063
[3] - http://osxdaily.com/2014/01/27/verify-disk-command-line-mac-os-x/
[4] - http://beshoy.girgis.us/2013/11/solved-error-disk-utility-cant-repair-disk-backup-many-files-possible/
[5] - https://discussions.apple.com/message/24958301#24958301
[6] - http://craigsmith.id.au/2014/07/06/repairing-a-corrupted-mac-osx-exfat-partition/
[7] - https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man8/fsck_exfat.8.html
[8] - https://discussions.apple.com/thread/4154638?start=30&tstart=0
[9] - https://discussions.apple.com/thread/4154638?start=45&tstart=0
[10] - https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/chkdsk.mspx?mfr=true