Friday, October 31, 2014

Installing MySQL as the external database for Hive, Impala, etc. in Cloudera Hadoop distribution

I intend on having 2 separate namenode servers, and on each one I will be running a MySQL instance. Hive metastore data, Impala metadata, namenode info, Cloudera Manager, and other roles will all use these DBs. Not sure how it’ll all go yet, but my first attempt last week didn’t go so well.


Read through this, then at each step, read ahead a few steps, as the info is a bit spread out: http://ift.tt/1wPj4BF


Do yourself a favor and disable selinux before installing. Otherwise you’ll likely see this error when mysql fails to start:

Fatal error: Can’t open and lock privilege tables: Table ‘mysql.host’ doesn’t exist

(it’s due to permissions on the /var/lib/mysql folder

– nano /etc/selinux/config

– “enforcing” change to “disabled”

– reboot machine

– yum remove mysql-server

– rm -rf /var/lib/mysql

– yum install mysql-server


1. yum install mysql mysql-server

2. in /etc/my.cnf (maybe make a copy of your original, e.g. cp my.cnf my.cnf.orig)

– paste in the sample my.cnf file contents from here (the paths should match the default install paths, but check just in case): http://ift.tt/1wPj4BF

– uncomment the binlog lines and set it to “mixed” (otherwise it’ll error out when your cluster starts up)

3. service mysqld start

4. chkconfig mysqld on

5. /usr/bin/mysql_secure_installation

6. Install Extra Packages for Enterprise Linux (EPEL repo)

– wget http://ift.tt/1htTSIk

– sudo rpm -Uvh epel-release-6*.rpm

7. Copy in the mysql connector (do this on both machines)

– mkdir /usr/share/java

– cp mysql-connector-java-5.1.33/mysql-connector-java-5.1.33-bin.jar /usr/share/java/mysql-connector-java.jar

– note the filename changes when you copy it (if it’s not exactly that you will get errors when testing DB connections)

8. At this point I installed Cloudera Manager on machine1

– from here: http://ift.tt/1wPj4BJ

– wget http://ift.tt/1eEtSMH

– chmod u+x cloudera-manager-installer.bin

– ./cloudera-manager-installer.bin

– the installer downloads everything you need

9. I’m having it install Java

– later I’ll install the mysql connector

– I had one node fail during installation – just “retry failed hosts” a few times. Likely it was some connectivity thing

10. Now for the Cluster Role Assignments step

– All services that require a DB will be on the hosts that have mysql installed and running

– NameNode – first server

– Secondary NameNode – second server

– Cloudera Management Server Activity Monitor – second server

11. Database setup

– “Use Custom Database”

– Database Type: MySQL

– create databases and users for each service listed at the bottom of this page: http://ift.tt/1wPj4BF

– this page provides another description of this process: http://ift.tt/1qb7xXE

– from inside a mysql client on the host mentioned has storing the activity monitor:

– create database amon DEFAULT CHARACTER SET utf8;

– grant all on amon.* TO ‘amon’@’%’ IDENTIFIED BY ‘amoncrazypassword';

– from inside a mysql client on the host mentioned as storing the hive metadata:

– create database hive DEFAULT CHARACTER SET utf8;

– grant all on hive.* TO ‘hive’@’%’ IDENTIFIED BY ‘hivecrazypassword';

– In the “Database Host Name:” field, mine looked like this:

– “:3306″ since that’s the port mysql was running on

– I’d recommend not explicitly specifying a hostname because there are a lot of configs the installer auto-configures.

12. You should get some nice green check marks indicating successful connections. If not:

– service iptables status

– check the port mysql is configured to listen on (default is 3306)

– service mysqld status

– make sure the right database and user are created on the appropriate host

13. If the install finishes smoothly, make sure to set up backups.

– I’ve seen it fail on the “Creating Hive Metastore Databse Tables” step with an error about there needing to be a hostname configured. Just open up a new tab pointed at your Cloudera manager and then look for the red configuration alert next to the Hive service in your cluster. It should take you directly to the offending config. In my case, I clicked on the button to revert it to default. Then go back to the Cluster Setup tab and click Retry. Things were happy again.

14. I’d suggest the first thing you do is restart your cluster

– there are usually some errors that a restart will clear up

15. Hue creates its own embedded database. If you want to have it run on your mysql instances:

– for Hue: http://ift.tt/1qb7vPy

– from a mysql client on the host running hue:

– create database hue DEFAULT CHARACTER SET utf8;

– grant all on hue.* TO ‘hue’@’%’ IDENTIFIED BY ‘huecrazypassword';

– in Cloudera Manager click on the Hue Service > Configuration tab at the top > look for “Database” configs on the left

– update appropriately

16. Honestly, expect the startup of a new cluster to feel a bit like whack-a-mole with the errors on services. Just click on them, look at the logs, and then restart them a few times. The HDFS and HBase services, if not working right, can cause other services to error out, especially the health checks. All that means is focus on HBase and HDFS first.





Hive Metastore Canary – fails to create a database during test

Thursday, October 30, 2014

Mounting NFS share on Windows 8.1

MapR has a fantastic feature where it exposes the Hadoop file system directly via NFS. So, you can read and write to the Hadoop cluster directly from client machines, rather than having to use other tools you have to learn. Now, to be fair, Hortonworks and Cloudera have NFS share features too. The difference is that they buffer the incoming data before actually writing it to the cluster. With MapR, the data is written as it’s received. MapR should have better performance with NFS shares too.


The use cases for DWH are pretty obvious: if you can export csv files and have them simply write directly to the Hadoop cluster, then you’ve cut out an entire step in the data workflow. No need to use special ODBC drivers in SSIS to write data to Hadoop, no need to move very large files around over your network. You can even mount the NFS share on your web servers and have them log directly to that mount point. As the data is laid down, it is queryable too :)


It’s easy enough to mount an NFS share in Linux and OSX, but for Windows you have to either install some third party NFS client, or you can do this:


Enable the NFS client features in Windows – search for Add Features


regedit.exe

HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > ClientForNFS > Default > add 2 DWORDS:

AnonymousGid

AnonymousUid

The values need to be 0, which will be set by default.

from a command line:

"nfsadmin client restart" (or reboot)


Now when you browse to your mapR machine’s IP via Explorer, you will see the shared folders. You can copy stuff in or out, delete, etc. Note, I’ve only ever seen 30MB/s at the fastest.


mapR docs on the subject:


http://ift.tt/1yKUuBn


Notes on security:

I haven’t looked yet, but it’d probably be a good idea to restrict which hosts can hit which folders on the Hadoop cluster. I haven’t yet messed with how mapR exports the NFS shares, but I suppose IP restrictions should be alright.





Wednesday, October 29, 2014

Mapr Install redux

Dynamic Hive table schema based on HBase column family

Goal:

Let data get firehosed into HBase. Then auto-generate and maintain Hive external table schema based on the actual key-value pairs in the HBase column families. It seems nobody’s really doing this too much. However, it seems this would be a general solution for data warehousing (as long as you can get all data into JSON format in an HBase table).


How to generate dynamic Hive tables based on JSON:


http://ift.tt/1n5r1d0


The good JSON serde:


http://ift.tt/1eVPKm1


http://ift.tt/1p3WW62


Generate a Hive schema based on a “curated” representative JSON doc:


http://ift.tt/104aylj


http://ift.tt/1u2Mlp4


In a comment on his own OP, how to create an external table pointed at an HBase table that returns everything as JSON. It may be useful as the source of the “curated” JSON doc:


http://ift.tt/104aylk


I’ll update on progress…





Tuesday, October 28, 2014

MapR – Architectural Overview

I found this video by the CTO of MapR to be very explanatory about now Mapr does things.


In short, there are no NameNodes to die in your Hadoop cluster, their MaprDB seems even better than HBase, their NFS allows for random read-write, and everything on the cluster is HA (not sure still why exactly there are a limited number of control nodes though – more to learn).


https://www.mapr.com/resources/videos/architectural-overview-mapr





Getting data into Hadoop from Windows via SSIS (SSDT) and a DSN

Figured I’d consolidate what I did to get data into a Hadoop cluster with SSIS/SSDT. I used SSDT 2013 – the BI version install. In this case, it was a Hortonworks Hadoop cluster.


1. Install both the 32 and 64 bit versions of the Hortonworks Hive ODBC driver: http://ift.tt/1wsXYrp

– edit the DSNs that should already be in there from the installer to point at whichever node is running a HiveServer2 service (find it in Ambari)

– you have to edit the 32 bit one via the 32 bit ODBC Data Source Administrator and the 64 bit DSN via the 64 bit ODBC Data Source Administrator

– In “Authentication”, I could only get it to work with “username” or “username and password”. “No Authentication” resulted in a test just hanging for a long time. I used the “hive” account creds as defined in Ambari


2. At this point you must have a Hive table schema already existing. Just map columns from the data flow to columns in the Hive table schema and you should be good to go.

– Now, to be honest, I keep getting a permissions issue with writing data to the table. I haven’t solved it yet, but it may be problematic. I’ll try to update later with what works.


How do you create a table in Hive? You can use Hue or HCat or whatever web-based tool may be installed on your Hadoop cluster. But here is how you can do it via the command-line:


1. SSH into one of the nodes on your cluster that’s running Hive

2. change use to a user that has permissions in Hive:

– su hive

3. start hive

– hive

4. Once you’re in hive, it’s just like when you’re logged in to a mysql client – generally the same commands are available)

– show databases;

– use database default;

– create table (Year int, Month);