Search This Blog

Enabling rack awareness for Hadoop cluster

In this article , We will learn how to enable rack awareness in hadoop clusters. Assume that cluster has large  number of nodes and nodes are placed in more than one rack. If we enable rack awareness , all replicas of block will not be stored in one rack so that we can have at least one replica of block is available for data processing in case of rack failures.

Goal of rack awareness is to improve data availability and decrease network bandwidth.


1) Enabling rack awareness without Apache Ambari.


In old versions of HDP we used to enable rack awareness manually. Latest versions of Apache Ambari  supports rack awareness in GUI.

Check the link on how to enable rack awareness manually , You will not require this as most of the latest versions of Apache Ambari are supporting in GUI.





2) Enabling rack awareness using Apache Ambari

Now we are going to see how to enable rack awareness using Apache Ambari . We have a five node cluster and by default we have got all nodes in default-rack.




Now we will modify rack for datanode3.

go to --> hosts in ambari -----> click on host where you want to modify rack------>go to host actions -----> click set rack




Modify rack name to rack-1 and click OK.



Go back to hosts page in Ambari to see rack name for datanode3 is changed.


You can see that nodes are placed in two different racks they are default-rack and rack-1.

3) Confirm rack awareness enabled

We can also confirm from fsck command and also from hdfs dfsadmin -report  commands.

The picture below is the output of command hdfs fsck / and it shows number of racks is 2.





Let me know if you have any questions on above article.


Creating and configuring home directory for a user in HDFS.

In this article , We will learn how to create home directory in HDFS for a new user.

Every user should have home directory in HDFS if he/she wants to access HDFS. Some hadoop jobs use user's home directory to store intermediate/temporary data . Jobs will fail if no home directory for user.
On Local file system , user's home directory is created under /home directory and On HDFS, User's home directory is created under /user folder.



1) Create a user on local file system 

First we need to create a user on local file system (i.e. Operating System) using useradd command. And user should be created on all nodes in the cluster.

The picture below shows new user nirupam is created and nirupam's home directory in local file system is /home/nirupam.


By default , user does not have a password , You can set password using passwd command if you want.

2) Create a directory in HDFS for new user.

We need to create a directory under /user in HDFS for new user. This directory needs to be created using hdfs user as hdfs user is super user for hadoop cluster.

The picture below shows a new directory is created for nirupam user under /user directory in HDFS.



3) Check the owner 

As new directory is created by hdfs user, hdfs user will be the owner of the directory. We need to change the owner of this directory to new user.

The picture below shows owner of the /user/nirupam directory in HDFS.





4) Change the owner

Change the owner of new directory created in HDFS to new user created in local file system. chown  command can be used to change the owner.

The picture below shows changing the owner of HDFS directory /user/nirupam to nirupam user from hdfs user.




5) Change the permissions 

We need to change the permissions of this newly created so that no other users can have  read,write and execute permissions except owner.

The picture below modifies permissions of /user/nirupam directory to 700 so that only own can have read, write and execute permissions.




6) Test the user's HDFS home directory.

We have successfully created home directory in HDFS for new user. We need to test it now.

We will try to upload a new file to HDFS without specifying destination directory. File will be uploaded to user's home directory if no destination is specified.

The picture below shows new file is uploaded to nirupam's user home directory as destination directory is not specified.



Let me know if you have any questions.



Decommissioning of Node manager in Hadoop cluster

In this article , We will learn how to perform decommissioning of the node managers in Hadoop clusters.

Decommissioning process will ensure running jobs moved to different node managers without failing them.

1) Check Ambari UI

If you are using HDP (Hortonworks Data Platform) , You can check Ambari UI to see how many node managers are present in your cluster.

The picture below shows cluster has 3 node managers. We would like to decommission one node manager from the cluster.




2) Check yarn.resourcemanager.nodes.exclude-path property 

Cluster should have yarn.resourcemanager.nodes.exclude-path property in yarn-site.xml file . If property not present , We should add it.



3) Update exclude file

Update /etc/hadoop/conf/yarn.exclude file with hostname on which you want to perform decommissioning of the node manager.

I have updated the file with master2 hostname to decommission node manager on master2 node.




4) Run refreshNodes command

Run yarn rmadmin -refreshNodes command to initiate decommissioning of nodemanagers.
This command needs to be run as yarn user.

The picture below shows refreshNodes command is run.




5) Check Ambari UI 

Login into Amabri GUI  and click on YARN service to check decommissioned nodemanagers.

The picture below show 1 nodemanager is decommissioned, I have highlighted it in yellow.




Trouble shooting:

Check logs of node manager which you are decommissioning, logs of active resource manager and also logs of the active namenode if decommissioning of node managers is not working.


Decommissioning datanodes in Hadoop cluster

In this article , We will learn how to perform decommissioning of data nodes in a Hadoop cluster.
Decommissioning process of the data node ensures that data is transferred to other nodes so that the existing replication factor is not disturbed.


1) Check NameNode UI for available data nodes and their status.

The picture below shows We have three data nodes in the cluster. All of them have had admin state as In Service that means all of them are in working state.

We will try to decommission the data node on the master2 host.





2) dfs.hosts.exclude property

Ensure dfs.hosts.exclude property there in hdfs-site.xml, If not there please add it. This property is required to perform decommissioning of the data node.

The picture below shows property in Apache Ambari. You can also check the same property in Cloudera Manager if you are using CDH.





3) Update dfs.exclude file

Update dfs.exclude file with hostname where you want to decommission the datanode. We would like to decommission datanode on the host master2. This file name is the value of property dfs.hosts.exclude.

 Perform this step on the host where active name node is running.




4) Run refreshNodes command

Run refreshNodes command on active name node to decommission the data node .

hdfs dfs -refreshNodes.



5) Check decommissioning status.

Check name node UI to see master2 host under decommissioning category.




6) Check Decommissioned status

Check name node UI to see one node is marked as decommissioned.
The picture below shows data node in master2 is decommissioned.





Trouble shooting : 


1)  Check name node logs

 If you are unable to decommission the data node,  Check active namenode logs for errors. These logs will have errors related to decommissioning.


2)  Unable to decommission the data node

In small clusters, It is difficult to perform decommissioning of data nodes if  replication factor is less than number of available  data nodes.

For example :

If you have 3 data nodes  and replication factor is 3, You can not decommission one data node because cluster can not achieved replication factor 3 if one data node is decommissioned.

Reduce replication factor to 2 and perform decommissioning.


Let me know if you have any questions.

Installation and configuration of Ranger using Apache Ambari

In this article , We will learn how to install and configure Apache Ranger using Apache Ambari.Apache Ranger is a security technology that provides policy based security for all hadoop eco system tools.

1) Login into Ambari GUI.

2) Click on Add service

Click on Actions in the bottom of services and choose add service, Ambari will launch add service wizard.




3) Choose Ranger

Choose Ranger in the list of services and click Next. Ranger KMS will also be present in the list of services, do not select it for now.


4) Database setup

Ranger uses database to store it's data, we need to have at least one RDBMS system setup.
Ambari already using Postgres, We can click on I have met all  the requirements above and click proceed.





5) Assign Masters

We have two master components in Ranger called Ranger Usersync and Ranger admin.  We need to select hostnames for Ranger Usersync and Ranger Admin in this step.

Click on next once hostnames are selected.



6) Assign Slaves

Ranger has a slave component called Ranger Tagsync . By default it will be selected, just click next in this step.





7) Customize services

We need to configure the database and Ranger audit in this step. Ambari displays meroon colored circles where user inputs required.




Select the database you are using , I have choosen postgres as I am using postgres .  Enter hostname where your database is installed.

Enter password for database user rangeradmin. I have entered ranger as the password.


Enter user name and password for database administrator. Postgres comes with postgres/postgres user credentials. I have entered postgres as username and postgres as password.

After entering the login credentials , Click on test connection to ensure that all database details provided are working.



Ranger audits are stored in database, HDFS and also in SolR. We do not have SolR installed, So I am disabling audit to SolR. Click Next now.



8) Configure identities

If cluster is Kerberized , You can configure keytabs and principals in this step. If cluster is not Kerberized , this step is skipped automatically.



9) Review

Before installing and configuring Ranger , This step provides last opportunity for reviewing the information provided so far. If you wish , you can go back and modify already provided information.

just click on deploy to continue installation.





10) Install test and start

This step performs three operations .

  • Installing Ranger
  • Starting ranger components
  • Testing ranger components by running service checks



11) Summary

This is final step in which Ambari displays summary about recent installation. just click on complete to see Ranger in the services section of Ambari.

This step also informs us that we need to restart services  those have restart symbol after this step.




12) Restart required

The picture below shows restart symbol next to services HDFS,YARN,Hive and Knox. We need to restart them. and also we can see new service Ranger is installed.



This is how we can install and configure Ranger using Apache Ambari. Let me know if you have any questions.

HDP (Hortonworks Data Platform) installation using Apache Ambari

HDP (Hortonworks Data Platform) installation using Apache Ambari.

In this article , We will learn how to install HDP (Hortonworks Data Platform) using Apache Ambari. Before HDP installation we need to complete Ambari server installation.

1) Monitor the Ambari-server log

It is recommended to have live amabri-server log to see detailed error if you hit any issues during the HDP installation. So open ambari-server log file and monitor the same.

The picture below shows live ambari-server log.




2) Install Wizard

Login into Ambari GUI using credentials (default :admin/admin) and click on Launch install wizard button to start HDP installation.





3) HDP version

Select the HDP version you want to install. Amabri also shows what are the different components we get in a HDP version.

Currently HDP2.6 is the latest and we are trying to install HDP 2.5 here.



Click Next once HDP version is selected.


4)Name the cluster

Mention the name you want to use for your cluster. I have given myhdp25 as the name to my cluster.



5) Install options

In this step , We will register nodes to be added to the cluster. We will mention hostnames one per line. We can also use patterns, click on pattern expressions to know more.
We are adding single node named secured01 to the cluster.

/etc/hosts file on every node should contain whatever hostnames you add here.


We can register nodes in two ways.

Automatic registration :

Ambari will auto-install ambari-agents on all nodes to register them with ambari-server. We need to specify private key of  Ambari server host.


Check private key file path below.




Manual registration :

In manual registration , we are responsible for installing and configuring ambari-agents to make them report to ambari server.

We are going with automatic registration. click next after entering hostnames and private key.



All hostnames mentioned should be FullyQualifiedDomainNames (FQDN) names. In other words hostnames should be output of hostname -f command.

Ambari will throw warning to check if hostnames are FQDNs, if you are confident click OK.







6)Confirm hosts

In this step , Ambari will check all nodes to see if they meet prerequisites for hadoop installation and also installs and configures ambari-agents.



Ambari will display warnings in the bottom if any of nodes do not meet prerequisites.  Click on the click to see warning link to know more about warnings.

The picture below shows ntpd process is not started on a node.




Go to node and start the ntpd process . If ntp is not installed ,first install (yum install ntp) and then start the ntp.



After fixing warnings click on rerun checks to confirm warning are gone.

The picture below shows no warnings now.



7) Choose services 

In this step, we will choose services required for our cluster. We are selecting HDFS, Mapreduce2 and YARN.





















Ambari will also add services those are mandatory.





8) Assign Masters.

In this step , We will choose nodes for master components. For example , we will choose a node/host to install Namenode.




9) Assign slave and clients

In this step, we will just select select slave components and clients to be installed.



10) Customize Services

In this step , We can modify configurations of the services. Ambari will show us red colored numbers if any inputs are required from us.

For example : ambari-metrics and Smartsense require password for admin user. mention admin password for both and click next.




Ambari will also recommend configuration values as warnings. You can also ignore them and clik proceed anyway or hit cancel to fix them.




11) Review 

Ambari gives us last opportunity to review our HDP installation. At this step , We can go back and modify things.
In this step, Ambari shows installation details like hosts,repositories and services.

Click deploy to continue installation.



12) Install , Start and Test

This step performs three operations .

Installation of services
Starting the services
Performing service checks to see if services are in working state.




It takes some time to complete this step if services are being downloaded from the public repositories.

13) Summary

Ambari will provide us the final summary about our HDP installation. It will also list warnings and errors if any.

The picture below shows one warning and one error.


Click on the complete to go to your new HDP cluster.


14)

The picture below shows New HDP cluster installed with HDFS, Mapreduce2, YARN, Zookeeper, Metrics and Smartsense services.


This is how we install HDP (Hortonqorks Data Platform) using Apache Ambari on single node. This is the same process we can follow for multi node cluster. Few steps like install options and Assign masters will change.

Let me know if you have any questions.