--Private DNS
ip-10-10-10-10.ec2.internal (Master)
ip-20-20-20-20.ec2.internal (Agent 1)
ip-30-30-30-30.ec2.internal (Agent 2)
ip-40-40-40-40.ec2.internal (Agent 3)
--Create module tomcat
cd /etc/puppetlabs/code/environments/production/modules
mkdir tomcat
--Create manifest folder
cd tomcat
mkdir manifests
--Create init.pp (class name should match the name of the module)
vi init.pp
class tomcat {
}
--Create install.pp
vi install.pp
class tomcat::install {
package{'tomcat8':
ensure => installed
}
package{'tomcat8-admin':
ensure => installed
}
}
--Create start.pp
vi start.pp
class tomcat::start{
service{'tomcat8' :
ensure => running
}
}
--Node assignments
cd /etc/puppetlabs/code/environments/production/manifests
vi tomcat.pp
node 'ip-20-20-20-20.ec2.internal' {
include tomcat::install
include tomcat::start
}
--To run agent "pull" on as needed basis
sudo /opt/puppetlabs/bin/puppet agent --test
--Create config.pp
cd /etc/puppetlabs/code/environments/production/modules/tomcat/manifests
vi config.pp
class tomcat::config {
file { '/etc/tomcat8/tomcat-users.xml':
source => 'puppet:///modules/tomcat/tomcat-users.xml',
owner => 'tomcat8',
group => 'tomcat8',
mode => '0600',
notify => Service['tomcat8']
}
}
--Copy tomcat-users.xml file
--Add config to tomcat.pp
cd /etc/puppetlabs/code/environments/production/manifests
vi tomcat.pp
node 'ip-20-20-20-20.ec2.internal' {
include tomcat::install
include tomcat::config
include tomcat::start
}
The blog covers various articles and posts on Cloud, Big Data Analytics, Data Science, Machine Learning, DevOps, Full Stack Development, Java and Middleware Technologies
Saturday, March 2, 2019
Puppet Concepts with Tomcat Installation
Haddop Working with HDFS
### LOCAL FILE SYSTEM ###
ls
mkdir
cp
mv
rm
### LISTING ROOT DIRECTORY ###
hadoop fs -ls /
### LISTING DEFAULT TO HOME DIRECTORY ###
hadoop fs -ls
hadoop fs -ls /user/deepakdubey
### CREATE A DIRECTORY IN HDFS ###
hadoop fs -mkdir hadoop-file-system-test1
### COPY FROM LOCAL FS TO HDFS ###
hadoop fs -copyFromLocal /deepakdubey-starterkit/hdfs/commands/stocks-exchange.cvs hadoop-file-system-test1
### COPY TO HDFS TO LOCAL FS ###
hadoop fs -copyToLocal hadoop-file-system-test1/stocks-exchange.cvs .
hadoop fs -ls hadoop-file-system-test1
### CREATE 2 MORE DIRECTORIES ###
hadoop fs -mkdir hadoop-file-system-test2
hadoop fs -mkdir hadoop-file-system-test3
### COPY A FILE FROM ONE FOLDER TO ANOTHER ###
hadoop fs -cp hadoop-file-system-test1/stocks-exchange.cvs hadoop-file-system-test2
### MOVE A FILE FROM ONE FOLDER TO ANOTHER ###
hadoop fs -mv hadoop-file-system-test1/stocks-exchange.cvs hadoop-file-system-test3
### CHECK REPLICATION ###
hadoop fs -ls hadoop-file-system-test3
### CHANGE OR SET REPLICATION FACTOR ###
hadoop fs -Ddfs.replication=2 -cp hadoop-file-system-test2/stocks-exchange.cvs hadoop-file-system-test2/test-with-replication-factor-2.csv
hadoop fs -ls hadoop-file-system-test2
hadoop fs -ls hadoop-file-system-test2/test-with-replication-factor-2.csv
### CHANGING PERMISSIONS ###
hadoop fs -chmod 777 hadoop-file-system-test2/test-with-replication-factor-2.csv
### FILE SYSTEM CHECK - REQUIRES ADMIN PREVILEGES ###
sudo -u hdfs hdfs fsck /user/deepakdubey/hadoop-file-system-test2 -files -blocks -locations
sudo -u hdfs hdfs fsck /user/deepakdubey/hadoop-file-system-test3 -files -blocks -locations
sudo -u hdfs hdfs fsck /user/ubuntu/input/yelp/academic_dataset_review.json -files -blocks -locations
vi /etc/hadoop/conf/hdfs-site.xml
/data/1/dfs/dn/current/BP-2125152513-172.31.45.216-1410037307133/current/finalized
### DELETE DIR/FILES IN HDFS ###
hadoop fs -rm hadoop-file-system-test2/test-with-replication-factor-5.csv
hadoop fs -rm -r hadoop-file-system-test1
hadoop fs -rm -r hadoop-file-system-test2
hadoop fs -rm -r hadoop-file-system-test3
ls
mkdir
cp
mv
rm
### LISTING ROOT DIRECTORY ###
hadoop fs -ls /
### LISTING DEFAULT TO HOME DIRECTORY ###
hadoop fs -ls
hadoop fs -ls /user/deepakdubey
### CREATE A DIRECTORY IN HDFS ###
hadoop fs -mkdir hadoop-file-system-test1
### COPY FROM LOCAL FS TO HDFS ###
hadoop fs -copyFromLocal /deepakdubey-starterkit/hdfs/commands/stocks-exchange.cvs hadoop-file-system-test1
### COPY TO HDFS TO LOCAL FS ###
hadoop fs -copyToLocal hadoop-file-system-test1/stocks-exchange.cvs .
hadoop fs -ls hadoop-file-system-test1
### CREATE 2 MORE DIRECTORIES ###
hadoop fs -mkdir hadoop-file-system-test2
hadoop fs -mkdir hadoop-file-system-test3
### COPY A FILE FROM ONE FOLDER TO ANOTHER ###
hadoop fs -cp hadoop-file-system-test1/stocks-exchange.cvs hadoop-file-system-test2
### MOVE A FILE FROM ONE FOLDER TO ANOTHER ###
hadoop fs -mv hadoop-file-system-test1/stocks-exchange.cvs hadoop-file-system-test3
### CHECK REPLICATION ###
hadoop fs -ls hadoop-file-system-test3
### CHANGE OR SET REPLICATION FACTOR ###
hadoop fs -Ddfs.replication=2 -cp hadoop-file-system-test2/stocks-exchange.cvs hadoop-file-system-test2/test-with-replication-factor-2.csv
hadoop fs -ls hadoop-file-system-test2
hadoop fs -ls hadoop-file-system-test2/test-with-replication-factor-2.csv
### CHANGING PERMISSIONS ###
hadoop fs -chmod 777 hadoop-file-system-test2/test-with-replication-factor-2.csv
### FILE SYSTEM CHECK - REQUIRES ADMIN PREVILEGES ###
sudo -u hdfs hdfs fsck /user/deepakdubey/hadoop-file-system-test2 -files -blocks -locations
sudo -u hdfs hdfs fsck /user/deepakdubey/hadoop-file-system-test3 -files -blocks -locations
sudo -u hdfs hdfs fsck /user/ubuntu/input/yelp/academic_dataset_review.json -files -blocks -locations
vi /etc/hadoop/conf/hdfs-site.xml
/data/1/dfs/dn/current/BP-2125152513-172.31.45.216-1410037307133/current/finalized
### DELETE DIR/FILES IN HDFS ###
hadoop fs -rm hadoop-file-system-test2/test-with-replication-factor-5.csv
hadoop fs -rm -r hadoop-file-system-test1
hadoop fs -rm -r hadoop-file-system-test2
hadoop fs -rm -r hadoop-file-system-test3
Hadoop Kernel Level Tuning
--Disk Swapping --Look up existing values cd /proc/sys/vm cat swappiness sysctl vm.swappiness=0 --To make swappiness permanent vi /etc/sysctl.conf vm.swappiness = 0 --Memory Allocation (Over Commit) --Deny all memory requests over RAM+SWAP vm.overcommit=0 --Approve memory requests over RAM+SWAP as defined by vm.overcommit_ratio vm.overcommit=1 --Always approve all memory requests vm.overcommit=2 --With 1 GB RAM; permit memory request up to 1.5 GB RAM + SWAP vm.overcommit_ratio=50 --Look up existing values cd /proc/sys/vm cat overcommit_memory cat overcommit_ratio --To change value online sysctl vm.overcommit_memory=1 --To make the change permanent vi /etc/sysctl.conf vm.overcommit_memory=1 vm.overcommit_ratio=50
Cluster Installation with Apache Ambari
--Ambari system requirements
https://docs.hortonworks.com/HDPDocuments/Ambari-2.1.2.1/bk_Installing_HDP_AMB/content/_operating_systems_requirements.html
Ambari 1
ec2-10-10-10-10.compute-1.amazonaws.com
ip-20-20-20-20.ec2.internal
Ambari 2
ec2-30-30-30-30.compute-1.amazonaws.com
ip-40-40-40-40.ec2.internal
Ambari 3
ec2-50-50-50-50.compute-1.amazonaws.com
ip-60-60-60-60.ec2.internal
Ambari 4
ec2-70-70-70-70.compute-1.amazonaws.com
ip-80-80-80-80.ec2.internal
--Setup id_rsa on all nodes
cd .ssh
vi id_rsa
sudo chown ubuntu:ubuntu id_rsa
chmod 600 id_rsa
--Copy the downloaded JDK to other instances
scp jdk-8u131-linux-x64.tar.gz ip-40-40-40-40.ec2.internal:/home/ubuntu/
scp jdk-8u131-linux-x64.tar.gz ip-60-60-60-60.ec2.internal:/home/ubuntu/
scp jdk-8u131-linux-x64.tar.gz ip-80-80-80-80.ec2.internal:/home/ubuntu/
--Untar JDK
tar -xvf jdk-8u131-linux-x64.tar.gz
sudo mkdir -p /usr/lib/jvm
sudo mv ./jdk1.8.0_131 /usr/lib/jvm/
sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.8.0_131/bin/java" 1
sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.8.0_131/bin/javac" 1
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.8.0_131/bin/javaws" 1
--Set permissions
sudo chmod a+x /usr/bin/java
sudo chmod a+x /usr/bin/javac
sudo chmod a+x /usr/bin/javaws
sudo chown -R root:root /usr/lib/jvm/jdk1.8.0_131
--Set JAVA_HOME (on all nodes) in /etc/environment
sudo vi /etc/environment
JAVA_HOME=/usr/lib/jvm/jdk1.8.0_131
--Ambari repository
sudo wget -nv http://public-repo-1.hortonworks.com/ambari/ubuntu14/2.x/updates/2.2.2.0/ambari.list -O /etc/apt/sources.list.d/ambari.list
sudo apt-get update
--Install ambari server only one one node
sudo apt-get install ambari-server
--Setup Ambari server
sudo ambari-server setup
sudo ambari-server start
sudo ambari-server status
http://ec2-10-10-10-10.compute-1.amazonaws.com:8080
admin/admin
--Verification
sudo -u hdfs hadoop fs -mkdir /user/ubuntu
sudo -u hdfs hadoop fs -chown ubuntu:ubuntu /user/ubuntu
ubuntu@ip-172-31-44-14:~$ hadoop fs -mkdir input
ubuntu@ip-172-31-44-14:~$ hadoop fs -copyFromLocal stocks input
ubuntu@ip-172-31-44-14:~$ hadoop jar MaxClosePrice-1.0.jar com.hirw.maxcloseprice.MaxClosePrice input output
Troubleshooting - Namenode Stuck In Safe Mode
--Name node in safe mode
hadoop fs -copyFromLocal test /tmp/
copyFromLocal: org.apache.hadoop.hdfs.server.namenode.SafeModeException: Cannot create file /tmp/test. Name node is in safe mode.
--From name node web UI or logs
Safe mode is ON. The reported blocks 8900092 needs additional 6476 blocks to reach the threshold 1.0000 of total blocks 8906567
--hdfs-site.xml
dfs.namenode.safemode.threshold-pct
####Reason 1 - loss of datanodes or the cluster is running low on resources.####
sudo -u hdfs hdfs dfsadmin -report
Safe mode is ON
Configured Capacity: 6807953326080 (6.19 TB)
Present Capacity: 5076746797056 (4.62 TB)
DFS Remaining: 5076745936896 (4.62 TB)
DFS Used: 860160 (840 KB)
DFS Used%: 0.00%
Under replicated blocks: 0
Blocks with corrupt replicas: 0
Missing blocks: 0
Missing blocks (with replication factor 1): 0
-------------------------------------------------
Live datanodes (5):
Name: 10.15.230.42:50010 (node2)
Hostname: node2
Rack: /default
Decommission Status : Normal
Configured Capacity: 1361590665216 (1.24 TB)
DFS Used: 172032 (168 KB)
Non DFS Used: 425847939072 (396.60 GB)
DFS Remaining: 935742554112 (871.48 GB)
DFS Used%: 0.00%
DFS Remaining%: 68.72%
Configured Cache Capacity: 4294967296 (4 GB)
Cache Used: 0 (0 B)
Cache Remaining: 4294967296 (4 GB)
Cache Used%: 0.00%
Cache Remaining%: 100.00%
Xceivers: 2
Last contact: Thu May 07 21:52:10 EDT 2018
Name: 10.15.230.44:50010 (node4)
Hostname: node4
Rack: /default
Decommission Status : Normal
Configured Capacity: 1361590665216 (1.24 TB)
DFS Used: 172032 (168 KB)
Non DFS Used: 219371347968 (204.31 GB)
DFS Remaining: 1142219145216 (1.04 TB)
DFS Used%: 0.00%
DFS Remaining%: 83.89%
Configured Cache Capacity: 4294967296 (4 GB)
Cache Used: 0 (0 B)
Cache Remaining: 4294967296 (4 GB)
Cache Used%: 0.00%
Cache Remaining%: 100.00%
Xceivers: 2
Last contact: Thu May 07 21:52:10 EDT 2018
sudo -u hdfs hdfs dfsadmin -report
Safe mode is ON
Configured Capacity: 52710469632 (49.09 GB)
Present Capacity: 213811200 (203.91 MB)
DFS Remaining: 0 (0 B)
DFS Used: 213811200 (203.91 MB)
DFS Used%: 100.00%
Under replicated blocks: 39
Blocks with corrupt replicas: 0
Missing blocks: 0
####Reason 2 - Block corruption####
hdfs fsck /
Connecting to namenode via http://master:50070
FSCK started by hdfs (auth:SIMPLE) from /10.15.230.22 for path / at Thu May 07 21:56:17 EDT 2018
..
/accumulo/tables/!0/table_info/A00009pl.rf: CORRUPT blockpool BP-2034730372-10.15.230.22-1428441473000 block blk_1073806971
/accumulo/tables/!0/table_info/A00009pl.rf: MISSING 1 blocks of total size 891 B..
/accumulo/tables/!0/table_info/A00009pm.rf: CORRUPT blockpool BP-2034730372-10.15.230.22-1428441473000 block blk_1073806989
/accumulo/tables/!0/table_info/A00009pm.rf: MISSING 1 blocks of total size 891 B..
/accumulo/tables/!0/table_info/F00009pn.rf: CORRUPT blockpool BP-2034730372-10.15.230.22-1428441473000 block blk_1073807006
............................................
/user/oozie/share/lib/lib_20180408141046/sqoop/geronimo-jaspic_1.0_spec-1.0.jar: MISSING 1 blocks of total size 30548 B..
/user/oozie/share/lib/lib_20180408141046/sqoop/geronimo-jta_1.1_spec-1.1.1.jar: CORRUPT blockpool BP-2034730372-10.15.230.22-1428441473000 block blk_1073743585
/user/oozie/share/lib/lib_20180408141046/sqoop/geronimo-jta_1.1_spec-1.1.1.jar: MISSING 1 blocks of total size 16030 B..
/user/oozie/share/lib/lib_20180408141046/sqoop/groovy-all-2.1.6.jar: CORRUPT blockpool BP-2034730372-10.15.230.22-1428441473000 block blk_1073743592
............................................
/tmp/logs/fincalc/logs/application_1430405794825_0003/DAST-node5_8041: MISSING 9 blocks of total size 1117083218 B..
/tmp/logs/fincalc/logs/application_1430405794825_0004/DAST-node1_8041: CORRUPT blockpool BP-2034730372-10.15.230.22-1428441473000 block blk_1073800217
/tmp/logs/fincalc/logs/application_1430405794825_0004/DAST-node1_8041: CORRUPT blockpool BP-2034730372-10.15.230.22-1428441473000 block blk_1073800222
/tmp/logs/fincalc/logs/application_1430405794825_0004/DAST-node1_8041: CORRUPT blockpool BP-2034730372-10.15.230.22-1428441473000 block blk_1073800230
Total size: 154126314807 B (Total open files size: 186 B)
Total dirs: 3350
Total files: 1790
Total symlinks: 0 (Files currently being written: 2)
Total blocks (validated): 2776 (avg. block size 55521006 B) (Total open file blocks (not validated): 2)
********************************
CORRUPT FILES: 1764
MISSING BLOCKS: 2776
MISSING SIZE: 154126314807 B
CORRUPT BLOCKS: 2776
********************************
Minimally replicated blocks: 0 (0.0 %)
Over-replicated blocks: 0 (0.0 %)
Under-replicated blocks: 0 (0.0 %)
Mis-replicated blocks: 0 (0.0 %)
Default replication factor: 2
Average block replication: 0.0
Corrupt blocks: 2776
Missing replicas: 0
Number of data-nodes: 5
Number of racks: 1
FSCK ended at Thu May 07 21:56:18 EDT 2018 in 516 milliseconds
The filesystem under path '/' is CORRUPT
hdfs fsck / -list-corruptfileblocks
Connecting to namenode via http://ec2-80-80-80-80.compute-1.amazonaws.com:50070
The filesystem under path '/' has 0 CORRUPT files
hdfs@ip-172-31-45-216:~$ hdfs fsck /user/hirw/input/stocks -files -blocks -locations
Connecting to namenode via http://ec2-80-80-80-80.compute-1.amazonaws.com:50070
FSCK started by hdfs (auth:SIMPLE) from /172.31.45.216 for path /user/hirw/input/stocks at Mon Sep 18 11:22:00 UTC 2017
/user/hirw/input/stocks <dir>
/user/hirw/input/stocks/stocks 428223209 bytes, 4 block(s): OK
0. BP-2125152513-172.31.45.216-1410037307133:blk_1074178780_437980 len=134217728 Live_repl=3 [DatanodeInfoWithStorage[172.31.45.216:50010,DS-d0d9eb5c-f35f-4a12-bfdf-544085d693a3,DISK], DatanodeInfoWithStorage[172.31.46.124:50010,DS-fe24aecb-f56f-4c9c-8cf9-a3b1259bc0d0,DISK], DatanodeInfoWithStorage[172.31.45.217:50010,DS-7e4a4aef-39b9-4087-b0ff-3199c5b8b8bb,DISK]]
1. BP-2125152513-172.31.45.216-1410037307133:blk_1074178781_437981 len=134217728 Live_repl=3 [DatanodeInfoWithStorage[172.31.45.216:50010,DS-d0d9eb5c-f35f-4a12-bfdf-544085d693a3,DISK], DatanodeInfoWithStorage[172.31.46.124:50010,DS-fe24aecb-f56f-4c9c-8cf9-a3b1259bc0d0,DISK], DatanodeInfoWithStorage[172.31.45.217:50010,DS-7e4a4aef-39b9-4087-b0ff-3199c5b8b8bb,DISK]]
2. BP-2125152513-172.31.45.216-1410037307133:blk_1074178782_437982 len=134217728 Live_repl=3 [DatanodeInfoWithStorage[172.31.45.216:50010,DS-d0d9eb5c-f35f-4a12-bfdf-544085d693a3,DISK], DatanodeInfoWithStorage[172.31.46.124:50010,DS-fe24aecb-f56f-4c9c-8cf9-a3b1259bc0d0,DISK], DatanodeInfoWithStorage[172.31.45.217:50010,DS-7e4a4aef-39b9-4087-b0ff-3199c5b8b8bb,DISK]]
3. BP-2125152513-172.31.45.216-1410037307133:blk_1074178783_437983 len=25570025 Live_repl=3 [DatanodeInfoWithStorage[172.31.45.216:50010,DS-d0d9eb5c-f35f-4a12-bfdf-544085d693a3,DISK], DatanodeInfoWithStorage[172.31.46.124:50010,DS-fe24aecb-f56f-4c9c-8cf9-a3b1259bc0d0,DISK], DatanodeInfoWithStorage[172.31.45.217:50010,DS-7e4a4aef-39b9-4087-b0ff-3199c5b8b8bb,DISK]]
Status: HEALTHY
$ hdfs fsck /user/hadooptest/test1 -locations -blocks -files
FSCK started by hadoop (auth:SIMPLE) from /10-10-10-10 for path /user/hadooptest/test1 at Thu Dec 15 23:32:30 PST 2016
/user/hadooptest/test1 339281920 bytes, 3 block(s):
/user/hadooptest/test1: CORRUPT blockpool BP-762523015-10-10-10-10-1480061879099 block blk_1073741830
/user/hadooptest/test1: CORRUPT blockpool BP-762523015-10-10-10-10-1480061879099 block blk_1073741831
/user/hadooptest/test1: CORRUPT blockpool BP-762523015-10-10-10-10-1480061879099 block blk_1073741832
MISSING 3 blocks of total size 339281920 B
0. BP-762523015-10-10-10-10-1480061879099:blk_1073741830_1006 len=134217728 MISSING!
1. BP-762523015-10-10-10-10-1480061879099:blk_1073741831_1007 len=134217728 MISSING!
2. BP-762523015-10-10-10-10-1480061879099:blk_1073741832_1008 len=70846464 MISSING!
--Leave safe mode and delete the file
hdfs dfsadmin -safemode leave
hadoop fs -rm /user/hadooptest/test1
Subscribe to:
Posts (Atom)