Showing posts with label Apache Tomcat. Show all posts
Showing posts with label Apache Tomcat. Show all posts

Quick Apache Hadoop Admin Command Reference Examples

If you are working on Hadoop, you’ll realize there are several shell commands available to manage your hadoop cluster.
This article provides a quick handy reference to all Hadoop administration commands.

If you are new to big data, read the introduction to Hadoop article to understand the basics.

1. Hadoop Namenode Commands

Command Description
hadoop namenode -format Format HDFS filesystem from Namenode
hadoop namenode -upgrade Upgrade the NameNode
start-dfs.sh Start HDFS Daemons
stop-dfs.sh Stop HDFS Daemons
start-mapred.sh Start MapReduce Daemons
stop-mapred.sh Stop MapReduce Daemons
hadoop namenode -recover -force Recover namenode metadata after a cluster failure (may lose data)   

2. Hadoop fsck Commands

Command Description
hadoop fsck / Filesystem check on HDFS
hadoop fsck / -files Display files during check
hadoop fsck / -files -blocks Display files and blocks during check
hadoop fsck / -files -blocks -locations Display files, blocks and its location during check
hadoop fsck / -files -blocks -locations -racks Display network topology for data-node locations
hadoop fsck -delete Delete corrupted files
hadoop fsck -move Move corrupted files to /lost+found directory

3. Hadoop Job Commands

Command Description
hadoop job -submit <job-file> Submit the job
hadoop job -status <job-id> Print job status completion percentage
hadoop job -list all List all jobs
hadoop job -list-active-trackers List all available TaskTrackers
hadoop job -set-priority <job-id> <priority> Set priority for a job. Valid priorities: VERY_HIGH, HIGH, NORMAL, LOW, VERY_LOW
hadoop job -kill-task <task-id> Kill a task
hadoop job -history Display job history including job details, failed and killed jobs

4. Hadoop dfsadmin Commands

Command Description
hadoop dfsadmin -report Report filesystem info and statistics
hadoop dfsadmin -metasave file.txt Save namenode’s primary data structures to file.txt
hadoop dfsadmin -setQuota 10 /quotatest Set Hadoop directory quota to only 10 files
hadoop dfsadmin -clrQuota /quotatest Clear Hadoop directory quota
hadoop dfsadmin -refreshNodes Read hosts and exclude files to update datanodes that are allowed to connect to namenode. Mostly used to commission or decommsion nodes
hadoop fs -count -q /mydir Check quota space on directory /mydir
hadoop dfsadmin -setSpaceQuota /mydir 100M Set quota to 100M on hdfs directory named /mydir
hadoop dfsadmin -clrSpaceQuota /mydir Clear quota on a HDFS directory
hadooop dfsadmin -saveNameSpace Backup Metadata (fsimage & edits). Put cluster in safe mode before this command.

5. Hadoop Safe Mode (Maintenance Mode) Commands

The following dfsadmin commands helps the cluster to enter or leave safe mode, which is also called as maintenance mode. In this mode, Namenode does not accept any changes to the name space, it does not replicate or delete blocks.
Command Description
hadoop dfsadmin -safemode enter Enter safe mode
hadoop dfsadmin -safemode leave Leave safe mode
hadoop dfsadmin -safemode get Get the status of mode
hadoop dfsadmin -safemode wait Wait until HDFS finishes data block replication

6. Hadoop Configuration Files

File Description
hadoop-env.sh Sets ENV variables for Hadoop
core-site.xml Parameters for entire Hadoop cluster
hdfs-site.xml Parameters for HDFS and its clients
mapred-site.xml Parameters for MapReduce and its clients
masters Host machines for secondary Namenode
slaves List of slave hosts

7. Hadoop mradmin Commands

Command Description
hadoop mradmin -safemode get Check Job tracker status
hadoop mradmin -refreshQueues Reload mapreduce configuration
hadoop mradmin -refreshNodes Reload active TaskTrackers
hadoop mradmin -refreshServiceAcl Force Jobtracker to reload service ACL
hadoop mradmin -refreshUserToGroupsMappings Force jobtracker to reload user group mappings

8. Hadoop Balancer Commands

Command Description
start-balancer.sh Balance the cluster
hadoop dfsadmin -setBalancerBandwidth <bandwidthinbytes> Adjust bandwidth used by the balancer
hadoop balancer -threshold 20 Limit balancing to only 20% resources in the cluster

9. Hadoop Filesystem Commands

Command Description
hadoop fs -mkdir mydir Create a directory (mydir) in HDFS
hadoop fs -ls List files and directories in HDFS
hadoop fs -cat myfile View a file content
hadoop fs -du Check disk space usage in HDFS
hadoop fs -expunge Empty trash on HDFS
hadoop fs -chgrp hadoop file1 Change group membership of a file
hadoop fs -chown huser file1 Change file ownership
hadoop fs -rm file1 Delete a file in HDFS
hadoop fs -touchz file2 Create an empty file
hadoop fs -stat file1 Check the status of a file
hadoop fs -test -e file1 Check if file exists on HDFS
hadoop fs -test -z file1 Check if file is empty on HDFS
hadoop fs -test -d file1 Check if file1 is a directory on HDFS

10. Additional Hadoop Filesystem Commands

Command Description
hadoop fs -copyFromLocal <source> <destination> Copy from local fileystem to HDFS
hadoop fs -copyFromLocal file1 data e.g: Copies file1 from local FS to data dir in HDFS
hadoop fs -copyToLocal <source> <destination> copy from hdfs to local filesystem
hadoop fs -copyToLocal data/file1 /var/tmp e.g: Copies file1 from HDFS data directory to /var/tmp on local FS
hadoop fs -put <source> <destination> Copy from remote location to HDFS
hadoop fs -get <source> <destination> Copy from HDFS to remote directory
hadoop distcp hdfs://192.168.0.8:8020/input hdfs://192.168.0.8:8020/output Copy data from one cluster to another using the cluster URL
hadoop fs -mv file:///data/datafile /user/hduser/data Move data file from the local directory to HDFS
hadoop fs -setrep -w 3 file1 Set the replication factor for file1 to 3
hadoop fs -getmerge mydir bigfile Merge files in mydir directory and download it as one big file

Install Apache Tomcat 7.0 on RHEL 6 / CentOS 6

Apache Tomcat is an open source web server and servlet container developed by the Apache Software Foundation (ASF).

Tomcat implements the Java Servlet and the JavaServer Pages (JSP) specifications from Oracle and provides a “pure Java” HTTP web server environment for running the Java codes.  Apache Tomcat includes tools for configuration and management, but can also be configured by editing XML configuration files.

Here is the step by step guide to install Apache Tomcat 7.0 on RHEL 6 / CentOS 6.
Open Terminal.

Switch to root user.

Install OpenJDK:

Tomcat requires to have java installed on your machine, you can either have Oracle JDK or OpenJDK installed on your machine. Here i used the openjdk, lets install openjdk by issuing the following command.
[root@server ~]# yum install java-1.7.0
You can also verify it, by issuing the following command.
[root@server ~]#  java -version
java version “1.7.0_51″
OpenJDK Runtime Environment (rhel-2.4.4.1.el6_5-x86_64 u51-b02)
OpenJDK 64-Bit Server VM (build 24.45-b08, mixed mode)

Download & Setup Apache Tomcat:

Download the latest version of the Apache Tomcat from the website and save it on your home directory.
[root@server ~]# wget http://mirror.nexcess.net/apache/tomcat/tomcat-7/v7.0.52/bin/apache-tomcat-7.0.52.tar.gz
Download the MD5 file.
[root@server ~]# wget --no-check-certificate https://www.apache.org/dist/tomcat/tomcat-7/v7.0.52/bin/apache-tomcat-7.0.52.tar.gz.md5
Verify the md5 check sum of the downloaded Tomcat archive with check sum provided by Apache Tomcat.
[root@server ~]# cat apache-tomcat-7.0.52.tar.gz.md5
3d780939cc4fce1661e7411bbd640c09 *apache-tomcat-7.0.52.tar.gz
 
[root@server ~]# md5sum apache-tomcat-7.0.52.tar.gz
3d780939cc4fce1661e7411bbd640c09  apache-tomcat-7.0.52.tar.gz
If both matches, extract the the tomcat on to your desired (/var/local) directory.
 tar -zxvf apache-tomcat-7.0.26.tar.gz -C /var/local/

Controlling Apache Tomcat:

Apache Tomcat can be  started and stopped by the script which comes with package, start the Apache Tomcat.
[root@server ~]# /var/local/apache-tomcat-7.0.26/bin/startup.sh
you will get the following out.
[root@server ~]# /var/local/apache-tomcat-7.0.52/bin/startup.sh
Using CATALINA_BASE:   /var/local/apache-tomcat-7.0.52
Using CATALINA_HOME:   /var/local/apache-tomcat-7.0.52
Using CATALINA_TMPDIR: /var/local/apache-tomcat-7.0.52/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /var/local/apache-tomcat-7.0.52/bin/bootstrap.jar:/var/local/apache-tomcat-7.0.52/bin/tomcat-juli.jar
Tomcat started.
You can verify the service running, by default tomcat runs on port no 8080
[root@server ~]# netstat -antup | grep 8080
tcp        0      0 0.0.0.0:8080                0.0.0.0:*                   LISTEN      2476/java
Open the web browser and point to http://ipaddress:8080
Tomcat Home
Stop the Apache Tomcat.
[root@server ~]# /var/local/apache-tomcat-7.0.26/bin/shutdown.sh

Managing the Apache Tomcat:

Tomcat can be managed through the web-manager, the following can be done through that.
Deploy new application, deploy new application on specified context, list the active or in active applications, start and stop the web applications.
Web manager is password protected, requires user name and password to access. Only the user with the “manager-gui” role is allowed to access, these users and roles are defined in tomcat-users.xml. By default “manager-gui” role not defined that file, we need to add it manually.
vi /var/local/apache-tomcat-7.0.52/conf/tomcat-users.xml
Place the following two lines just above the last line.
<role rolename=”manager-gui”/>
<user username=”tomcat” password=”tomcat” roles=”manager-gui”/>
Stop and Start the tomcat, now tomcat user have access to the web manager.
Tomcat  Manager
same like, you can define the other roles.
That’s All.