Thursday, August 10, 2017

Extending MapR PACC

                                           

                   Extending MapR PACC

Although we cannot modify a MapR-provided Docker image directly we can build a custom image that is based on MapR Persistent Application Client Container (PACC). This blog shows a custom Dockerfile that is used to create a new Docker image. 

Requirement I :  In this example, I am creating a PACC image with CentOS 7.3, hadoop, Fuse and mariadb ( Open source Mysql ) .

1) Create a directory where we will write a Docker file with set of instructions to built a custom image and download maps-setup.sh script.

mkdir abizer ; cd abizer/

wget http://package.mapr.com/releases/installer/mapr-setup.sh

chmod 777 mapr-setup.sh

2) Now vi to create Docker file with set of instructions .

[root@node112rhel72 abizer]# vi Dockerfile 
FROM centos:centos7
ENV container docker
RUN yum -y upgrade && yum install -y curl file net-tools openssl sudo syslinux wget which mysql java-1.8.0-openjdk-devel && yum -q clean all
LABEL mapr.os=centos7 mapr.version=5.2.1 mapr.mep_version=3.0
COPY mapr-setup.sh /opt/mapr/installer/docker/
RUN /opt/mapr/installer/docker/mapr-setup.sh -r http://package.mapr.com/releases container client 5.2.1 3.0 mapr-client mapr-posix-client-container
ENTRYPOINT ["/opt/mapr/installer/docker/mapr-setup.sh", "container"]

3) Ensure both scripts are executable . 

[root@node112rhel72 abizer]# ls -l mapr-*
-rwxrwxrwx. 1 root root   2476 Aug 10 17:12 mapr-docker-client.sh
-rwxrwxrwx. 1 root root 106152 Aug  9 11:24 mapr-setup.sh

4) Modify mapr-docker-client.sh script with cluster name , CLDB IP and Docker image TAG (abizer:5.2.1_3.0_centos7_mysql)

[root@node112rhel72 abizer]# vi mapr-docker-client.sh 
--------------------------------------------------------------------------------------
#!/bin/sh

# The environment variables in this file are for example only. These variables
# must be altered to match your docker container deployment needs

MAPR_CLUSTER=ClusterNFS4
MAPR_CLDB_HOSTS=10.10.70.117

# MapR POSIX client mount path to enable direct MapR-FS access
MAPR_MOUNT_PATH=/mapr

# MapR secure cluster ticket file path
MAPR_TICKETFILE_LOCATION=

# MapR client user / group
MAPR_CONTAINER_USER=$(id -u -n)
MAPR_CONTAINER_UID=$(id -u)
MAPR_CONTAINER_GROUP=$(id -g -n)
MAPR_CONTAINER_GID=$(id -g)
MAPR_CONTAINER_PASSWORD=

# Container memory: specify host XX[kmg] or 0 for no limit. Ex: 8192m, 12g
MAPR_MEMORY=0

# Container timezone: filename from /usr/share/zoneinfo
MAPR_TZ=${TZ:-"America/New_York"}

# Container network mode: "host" causes the container's sshd service to conflict
# with the host's sshd port (22) and so it will not be enabled in that case
MAPR_DOCKER_NETWORK=bridge

# Container security: --privileged or --cap-add SYS_ADMIN /dev/<device>
MAPR_DOCKER_SECURITY="$([ -n $"MAPR_MOUNT_PATH" ] && echo "--cap-add SYS_ADMIN --cap-add SYS_RESOURCE --device /dev/fuse")"

# Other Docker run args:
MAPR_DOCKER_ARGS=""

### do not edit below this line ###
grep -q -s DISTRIB_ID=Ubuntu /etc/lsb-release && \
  MAPR_DOCKER_SECURITY="$MAPR_DOCKER_SECURITY --security-opt apparmor:unconfined"

MAPR_DOCKER_ARGS="$MAPR_DOCKER_SECURITY \
  --memory $MAPR_MEMORY \
  --network=$MAPR_DOCKER_NETWORK \
  -e MAPR_DISKS=$MAPR_DISKS \
  -e MAPR_CLUSTER=$MAPR_CLUSTER \
  -e MAPR_LICENSE_MODULES=$MAPR_LICENSE_MODULES \
  -e MAPR_MEMORY=$MAPR_MEMORY \
  -e MAPR_MOUNT_PATH=$MAPR_MOUNT_PATH \
  -e MAPR_SECURITY=$MAPR_SECURITY \
  -e MAPR_TZ=$MAPR_TZ \
  -e MAPR_USER=$MAPR_USER \
  -e MAPR_CONTAINER_USER=$MAPR_CONTAINER_USER \
  -e MAPR_CONTAINER_UID=$MAPR_CONTAINER_UID \
  -e MAPR_CONTAINER_GROUP=$MAPR_CONTAINER_GROUP \
  -e MAPR_CONTAINER_GID=$MAPR_CONTAINER_GID \
  -e MAPR_CONTAINER_PASSWORD=$MAPR_CONTAINER_PASSWORD \
  -e MAPR_CLDB_HOSTS=$MAPR_CLDB_HOSTS \
  -e MAPR_HS_HOST=$MAPR_HS_HOST \
  -e MAPR_OT_HOSTS=$MAPR_OT_HOSTS \
  -e MAPR_ZK_HOSTS=$MAPR_ZK_HOSTS \
  $MAPR_DOCKER_ARGS"

[ -f "$MAPR_TICKETFILE_LOCATION" ] && MAPR_DOCKER_ARGS="$MAPR_DOCKER_ARGS \
  -e MAPR_TICKETFILE_LOCATION=/tmp/mapr_ticket \
  -v $MAPR_TICKETFILE_LOCATION:/tmp/mapr_ticket:ro"
[ -d /sys/fs/cgroup ] && MAPR_DOCKER_ARGS="$MAPR_DOCKER_ARGS -v /sys/fs/cgroup:/sys/fs/cgroup:ro"

echo $MAPR_DOCKER_ARGS
docker run -it $MAPR_DOCKER_ARGS abizer:5.2.1_3.0_centos7_mysql "$@"
--------------------------------------------------------------------------------------

5) Now built the docker image , this has 7 steps which we defined in Docker file.

i) Pull CentOS 7 image
ii) Built the ENV which is docker container.
iii) Yum install required packages.
iv) Label the image or add metadata to an image  
v) Copy mapr-setup.sh in docker container ( Image to be built )
vi) Run mapr-setup.sh script in docker which will download all kinds PACC rpms needed.
vii) ENTRYPOINT will configure the container and built the image 

Running below commands reads docker file from current location and builts and image .

[root@node112rhel72 abizer]# docker build -t abizer:5.2.1_3.0_centos7_mysql .
Sending build context to Docker daemon 112.6 kB
Step 1/7 : FROM centos:centos7
centos7: Pulling from library/centos
Digest: sha256:26f74cefad82967f97f3eeeef88c1b6262f9b42bc96f2ad61d6f3fdf544759b8
Status: Downloaded newer image for centos:centos7
 ---> 328edcd84f1b
Step 2/7 : ENV container docker
 ---> Using cache
 ---> 4f5d082615b7
Step 3/7 : RUN yum -y upgrade && yum install -y curl file net-tools openssl sudo syslinux wget which mysql java-1.8.0-openjdk-devel && yum -q clean all
 ---> Using cache
 ---> 6dd287d2a77f
Step 4/7 : LABEL mapr.os centos7 mapr.version 5.2.1 mapr.mep_version 3.0
 ---> Using cache
 ---> 5c1a0b1e55de
Step 5/7 : COPY mapr-setup.sh /opt/mapr/installer/docker/
 ---> Using cache
 ---> b1aaadae2bce
Step 6/7 : RUN /opt/mapr/installer/docker/mapr-setup.sh -r http://package.mapr.com/releases container client 5.2.1 3.0 mapr-client mapr-posix-client-container
 ---> Using cache
 ---> cec7a8030014
Step 7/7 : ENTRYPOINT /opt/mapr/installer/docker/mapr-setup.sh container
 ---> Using cache
 ---> 5065d2d71c57
Successfully built 5065d2d71c57

6) Image (5.2.1_3.0_centos7_mysql) is built as expected without errors.

[root@node112rhel72 abizer]# docker images
REPOSITORY           TAG                       IMAGE ID            CREATED             SIZE
abizer               5.2.1_3.0_centos7_mysql   5065d2d71c57        50 minutes ago      1.03 GB
centos               centos7                   328edcd84f1b        7 days ago          193 MB
maprtech/installer   ubuntu16                  c7cbc778e81e        2 weeks ago         480 MB

7) Now to connect to container run below script which will connect to container and start Fuse as well.

[root@node112rhel72 abizer]# sh mapr-docker-client.sh 

Testing for cluster user account... 

Enter MapR cluster user name: root
 ...Success 

Configuring MapR client ( -c -C 10.10.70.117 -N ClusterNFS4)... 

create /opt/mapr/conf/conf.old
Configuring Hadoop-2.7.0 at /opt/mapr/hadoop/hadoop-2.7.0
Done configuring Hadoop
CLDB node list: 10.10.70.117:7222
Zookeeper node list: 

...Success 

Starting services (mapr-posix-client-container)... 

Started service mapr-posix-client-container 

...Success 

Validation : Fuse mount is mounted and mariaDB package is installed .

[root@373bb434b21c /]# df -hP
Filesystem              Size  Used Avail Use% Mounted on
overlay                  39G  7.1G   32G  19% /
tmpfs                    32G     0   32G   0% /dev
/dev/mapper/rhel-root    39G  7.1G   32G  19% /etc/hosts
shm                      64M     0   64M   0% /dev/shm
tmpfs                    32G     0   32G   0% /sys/fs/cgroup
tmpfs                    32G     0   32G   0% /sys/firmware
posix-client-container  119G  504M  118G   1% /mapr

[root@373bb434b21c /]# rpm -qa| grep -i maria
mariadb-5.5.52-1.el7.x86_64
mariadb-libs-5.5.52-1.el7.x86_64


Requirement II :

I had a similar requirement to built docker Image with OEL and have packages for Percona Server for MySQL 5.7 installed and pre-built docker Image .

Created below docker file and followed all the steps listed earlier in this blog to built and image.

[root@node112rhel72 abizeroraclemysql]# cat Dockerfile 
# Download base image OEL 7.3
FROM oraclelinux:7.3
# Define Env
ENV container docker
# Install java and other packages needed by MapR Fuse
RUN yum -y upgrade && yum install -y curl file net-tools openssl sudo syslinux wget which java-1.8.0-openjdk-devel && yum -q clean all
# Import Keys for percona packages
RUN rpm --import https://www.percona.com/downloads/RPM-GPG-KEY-percona
# Install required percona packages
RUN yum install -y http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && yum -y update && yum install -y which nc sysbench perl-Digest-MD5 percona-xtrabackup-24 Percona-Server-{client,server,shared,test}-57 
# Label the image or add metadata to an image
LABEL mapr.os=OEL7 mapr.version=5.2.1 mapr.mep_version=3.0
# Copy mapr-setup.sh in docker container ( Image to be built )
COPY mapr-setup.sh /opt/mapr/installer/docker/
# Run mapr-setup.sh script in docker to download all PACC rpms
RUN /opt/mapr/installer/docker/mapr-setup.sh -r http://package.mapr.com/releases container client 5.2.1 3.0 mapr-client mapr-posix-client-container
# Built the container image

ENTRYPOINT ["/opt/mapr/installer/docker/mapr-setup.sh", "container"]

During the Built stage below was logged on the Screen .

[root@node112rhel72 abizeroraclemysql]# docker build -t abizer:5.2.1_3.0_OEL_PerconaServer .
Sending build context to Docker daemon 112.6 kB
Step 1/9 : FROM oraclelinux:7.3
 ---> 1046eb4afff7
Step 2/9 : ENV container docker
 ---> Using cache
 ---> 93c6b4c14d49
Step 3/9 : RUN yum -y upgrade && yum install -y curl file net-tools openssl sudo syslinux wget which java-1.8.0-openjdk-devel && yum -q clean all
 ---> Using cache
 ---> 70dc76cbcaf4
Step 4/9 : RUN rpm --import https://www.percona.com/downloads/RPM-GPG-KEY-percona
 ---> Running in 1eb5c8f53cd0
 ---> 130781585df6
Removing intermediate container 1eb5c8f53cd0
Step 5/9 : RUN yum install -y http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona-release-0.1-4.noarch.rpm https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && yum -y update && yum install -y which nc sysbench perl-Digest-MD5 percona-xtrabackup-24 Percona-Server-{client,server,shared,test}-57

---  ---
---  ---
---  ---

Removing intermediate container 04c231aa66f2
Step 9/9 : ENTRYPOINT /opt/mapr/installer/docker/mapr-setup.sh container
 ---> Running in a7ef6b58fa66
 ---> 6e65cc2a18ba
Removing intermediate container a7ef6b58fa66
Successfully built 6e65cc2a18ba


Now I could see new image built .


[root@node112rhel72 abizeroraclemysql]# docker images
REPOSITORY           TAG                           IMAGE ID            CREATED             SIZE
abizer               5.2.1_3.0_OEL_PerconaServer   6e65cc2a18ba        51 seconds ago      2.73 GB
abizeroracle         5.2.1_3.0_centos7_mysql       9f7d491aa8fc        17 hours ago        1.39 GB
pacc                 5.2.1_3.0_centos7_mysql       38b24a3d40cb        20 hours ago        1.03 GB
abizer               5.2.1_3.0_centos7_mysql       5065d2d71c57        20 hours ago        1.03 GB
centos               centos7                       328edcd84f1b        7 days ago          193 MB
maprtech/installer   ubuntu16                      c7cbc778e81e        2 weeks ago         480 MB
oraclelinux          7.3                           1046eb4afff7        4 weeks ago         225 MB


Modified Image tag in the script. 

[root@node112rhel72 abizeroraclemysql]# tail -1 mapr-docker-client.sh 

docker run -it $MAPR_DOCKER_ARGS abizer:5.2.1_3.0_OEL_PerconaServer "$@"

Verified : I was able to spin up Docker container and it had access to cluster via FUSE and had packages needed .


[root@node112rhel72 abizeroraclemysql]# sh mapr-docker-client.sh 

Testing for cluster user account... 

Enter MapR cluster user name: root
 ...Success 

Configuring MapR client ( -c -C 10.10.70.117 -N ClusterNFS4)... 

create /opt/mapr/conf/conf.old
Configuring Hadoop-2.7.0 at /opt/mapr/hadoop/hadoop-2.7.0
Done configuring Hadoop
CLDB node list: 10.10.70.117:7222
Zookeeper node list: 

...Success 

Starting services (mapr-posix-client-container)... 

Started service mapr-posix-client-container 

...Success 

[root@6042662bc958 /]# df -hP /mapr
Filesystem              Size  Used Avail Use% Mounted on
posix-client-container  119G  504M  118G   1% /mapr
[root@6042662bc958 /]# ls /mapr/ClusterNFS4/
abizer  apps  hbase  opt  softlink  test  tmp  user  var
[root@6042662bc958 /]# rpm -qa | grep percona
percona-release-0.1-4.noarch
percona-xtrabackup-24-2.4.8-1.el7.x86_64
[root@6042662bc958 /]# rpm -qa | grep -i percona
percona-release-0.1-4.noarch
Percona-Server-shared-compat-57-5.7.18-16.1.el7.x86_64
percona-xtrabackup-24-2.4.8-1.el7.x86_64
Percona-Server-test-57-5.7.18-16.1.el7.x86_64
Percona-Server-shared-57-5.7.18-16.1.el7.x86_64
Percona-Server-client-57-5.7.18-16.1.el7.x86_64
Percona-Server-server-57-5.7.18-16.1.el7.x86_64






Wednesday, August 2, 2017

Deploying PACC container ( Pre-builting and Porting)

                                       Deploying PACC container ( Pre-builting and Porting)


This Blog can be treated as extension of earlier PACC blog for systems which cannot connect to the internet due to which assumption of "mapr-setup.sh" script fail about connecting to internet and downloading packages on the go  . In this one we will see how we can use "mapr-setup.sh" to container images and then copy the containers to nodes which have no internet access alternatively it can also be hosted on internal registry where host might have access.
http://abizeradenwala.blogspot.com/2017/05/pacc-docker.html

1) This Blog assumes you have a system where docker is running and All the steps till Step 5 have been followed properly to get below log line

Successfully built 7351f3e4dc0d

Edit '/tmp/docker_images/client/mapr-docker-client.sh' to set MAPR_CLUSTER and MAPR_CLDB_HOSTS and then execute it to start the container 

2) We can see Image 5.2.1_3.0_centos7_yarn_fuse this exists which we plan to port to another system.

[root@noderhel73 tmp]# docker images
REPOSITORY          TAG                           IMAGE ID            CREATED             SIZE
maprtech/pacc       5.2.1_3.0_centos7_yarn_fuse   7351f3e4dc0d        15 minutes ago      965MB
centos              centos7                       36540f359ca3        4 weeks ago         193MB
maprtech/pacc       5.2.1_3.0_centos7             71f7895f4618        3 months ago        583MB
maprtech/pacc       latest                        71f7895f4618        3 months ago        583MB

3) Save the docker Image into a file which i can copy to any host.

[root@noderhel73 tmp]# docker save maprtech/pacc:5.2.1_3.0_centos7_yarn_fuse -o /tmp/5.2.1_3.0_centos7_yarn_fuse
[root@noderhel73 tmp]# du -sh /tmp/5.2.1_3.0_centos7_yarn_fuse
932M /tmp/5.2.1_3.0_centos7_yarn_fuse

4) Now remove the image from the hosts, Since we already have downloaded Image file we need to port.

[root@noderhel73 tmp]# docker rmi maprtech/pacc:5.2.1_3.0_centos7_yarn_fuse
Untagged: maprtech/pacc:5.2.1_3.0_centos7_yarn_fuse
Deleted: sha256:7351f3e4dc0de79cb28594bcb45739e50a08da7fd39e5f402875b5bdc27ffa36
Deleted: sha256:8da89880e023bdf8a91311dfab13b846965c02f6822170ffadc5dc2b74ac9bc5
Deleted: sha256:cb8a082d2f4038bbccce84aeefa2ceb8a8eaed7e16cd9b843c5fa5e2d75389e3
Deleted: sha256:41fa2482071eca11206ddfdafb27bd1d225f724d59806a18908f578ad8ba775f
Deleted: sha256:7445f128a5ea1118702ffd4519fe3d9bd03ec34220da538cb79c7f78d7292e91
Deleted: sha256:9393a64c0356642749e42364485d42ca26590a76ac3fbf020e0234cc51d7dc77
Deleted: sha256:7d3938dcc12005912615189b2bc62644532789d615fd7e81bf449e6e630d2159
Deleted: sha256:3bf0c11add438bd161fb8038b12f250232ec6766a43378e3ede9a59b89480eb0
Deleted: sha256:bcc298a830c7a7ff2ac7b24fb628f95d22d220edb94f1868e854f104a35c92be
Deleted: sha256:5070d6a1c579860ae93a4818c09b8262926d0cbe4da7b4e355b2ece2d4c117e9
[root@noderhel73 tmp]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              centos7             36540f359ca3        4 weeks ago         193MB
maprtech/pacc       5.2.1_3.0_centos7   71f7895f4618        3 months ago        583MB
maprtech/pacc       latest              71f7895f4618        3 months ago        583MB

5) You can copy "5.2.1_3.0_centos7_yarn_fuse" file which was created in Step 3 to Host which has no internet access under /tmp and run below command to load the image on that node.

[root@noderhel73 tmp]# docker load -i /tmp/5.2.1_3.0_centos7_yarn_fuse
c3166ac2e651: Loading layer [==================================================>]  236.8MB/236.8MB
8462671e0b31: Loading layer [==================================================>]  89.09kB/89.09kB
b3d3c7d1bf0b: Loading layer [==================================================>]  539.6MB/539.6MB
Loaded image: maprtech/pacc:5.2.1_3.0_centos7_yarn_fuse

Verify Image is loaded.

[root@noderhel73 tmp]# docker images
REPOSITORY          TAG                           IMAGE ID            CREATED             SIZE
maprtech/pacc       5.2.1_3.0_centos7_yarn_fuse   7351f3e4dc0d        21 minutes ago      965MB
centos              centos7                       36540f359ca3        4 weeks ago         193MB
maprtech/pacc       5.2.1_3.0_centos7             71f7895f4618        3 months ago        583MB
maprtech/pacc       latest                        71f7895f4618        3 months ago        583MB
[root@noderhel73 tmp]# 

6) Copy /tmp/docker_images/client/mapr-docker-client.sh script to the node where you would like to spin up PACC container .  This script is nothing but takes all the input for different variables and runs "docker run" command to spin up a container.

[root@noderhel73 tmp]# mkdir abizertest
[root@noderhel73 tmp]# cp /tmp/docker_images/client/mapr-docker-client.sh abizertest/
[root@noderhel73 tmp]# cd abizertest/

7) Modify mapr-docker-client.sh script to list "Cluster Name","CLDB hostname" and PosixMount path. 

[root@noderhel73 abizertest]# vi mapr-docker-client.sh 
#!/bin/sh
MAPR_CLUSTER=ClusterNFS4
MAPR_CLDB_HOSTS=10.10.70.117
# MapR POSIX client mount path to enable direct MapR-FS access
MAPR_MOUNT_PATH=/mapr

8) Run the script , It will connect you to docker container with access to cluster via Hadoop distributed commands or Posix mount as seen below .

[root@noderhel73 abizertest]# sh mapr-docker-client.sh 

Testing for cluster user account... 
Enter MapR cluster user name: root
 ...Success 

Configuring MapR client ( -c -C 10.10.70.117 -N ClusterNFS4)... 

create /opt/mapr/conf/conf.old
Configuring Hadoop-2.7.0 at /opt/mapr/hadoop/hadoop-2.7.0
Done configuring Hadoop
CLDB node list: 10.10.70.117:7222
Zookeeper node list: 

...Success 

Starting services (mapr-posix-client-container)... 

Started service mapr-posix-client-container 

...Success 


Posix Mounted :

[root@d388255453b8 /]# df -hP /mapr
Filesystem              Size  Used Avail Use% Mounted on
posix-client-container  119G  504M  118G   1% /mapr

[root@d388255453b8 /]# ls /mapr/ClusterNFS4/
apps  hbase  opt  test  tmp  user  var

Hadoop Command :

[root@d388255453b8 /]# hadoop fs -ls /
Found 8 items
-rw-r--r--   3 root       root                0 2017-04-27 01:20 /a
drwxr-xr-x   - 2147483632 2147483632          0 2017-04-20 16:08 /apps
drwxr-xr-x   - 2147483632 2147483632          0 2017-04-20 16:08 /hbase
drwxr-xr-x   - 2147483632 2147483632          0 2017-04-20 16:09 /opt
-rw-r--r--   3 root       root                0 2017-04-27 21:15 /test
drwxrwxrwx   - 2147483632 2147483632          0 2017-04-20 16:07 /tmp
drwxr-xr-x   - 2147483632 2147483632          0 2017-04-20 16:09 /user
drwxr-xr-x   - 2147483632 2147483632          1 2017-04-20 16:08 /var


Wednesday, July 26, 2017

Job affecting other Jobs in cluster

                                       Job affecting other Jobs in cluster

Recently we saw interesting occurrence of an issue described earlier ( below ), only variation was some Bad job was impacting a very important job by killing its containers randomly with "Killing taskAttempt because it is running on unusable node" message.


One Bad job was causing to fill up NM cache local dirs on various nodes (/opt/mapr/tmp/hadoop-mapr/nm-local-dir) causing node to go bad and terminate all running containers as explained in earlier blog .

Now to find the job which was Culprit below are the steps which were followed .

1) Found the latest attempt of my job which was killed and got the node name on which it ran ( Killed due to NM being unstable ) . 

2) On that node got all the NM logs from the time below message was logged to the time when other consecutive message was logged.

Start Message :    "local-dirs are bad"
------
------
-----
End Message :    " local-dirs are good"

3) Between this time as we know all the running containers would be killed and cleanups would happen for the NM to get back to healthy state . Got a list of all the containers which were killed to get sense and narrow down jobs which can be culprit, Alternatively we can also grep for applications which are cleaned up between the time NM goes bad and becomes good .

Example log line :


INFO org.apache.hadoop.yarn.server.nodemanager.LinuxContainerExecutor: Deleting absolute path : /opt/mapr/tmp/hadoop-mapr/nm-local-dir/usercache/User/appcache/application_1496463308975_240690


4)  Repeated above steps for another similar occurrence to find out common jobs to narrow down the job suspects( Incase suspected job count is huge) . 

5) In my case I was left with 3 Jobs which were suspect due to which imp job was impacted since some App seemed to be having Data skew or some kind of issue which was filling up local NM cache.

 Bingo on inspecting the Jobs we saw one of the job had 8K maps completed and ~1K reducers where all attempts completed but one of them was still running .  On checking the reducer stats it was clear this reducer was down pretty much all the work due to possible skew, since the shuffle byte was ~262 GB + and increasing .  On checking further it was seen this reducer spun up on multiple nodes and was killed every time since it utilized all the local NM space to make the node unusable , now we were clear this job will not succeed and need to be stopped after getting app team involved ( To make sure such issues don't happen in future ) .

Name                          Value
Combine input records 0
Combine output records 0
CPU time spent (ms) 1,533,690
Failed Shuffles 0
GC time elapsed (ms) 85,562
Merged Map outputs 3,702
Physical memory (bytes) snapshot 7,814,942,720
Reduce input groups 0
Reduce input records 0
Reduce output records 0
Reduce shuffle bytes 262,595,013,166
Shuffled Maps 3,750
Spilled Records 0
Total committed heap usage (bytes) 7,265,714,176
Virtual memory (bytes) snapshot 9,836,429,312 

Now As long term solution: Application team was informed about this issue and were asked to fix this kind of skews to prevent other production impact.

ADMIN TASK : To pro-actively find such bad job and kill them before they impact production users.

We realized we need to monitor usage for NM local dir and find out if there is any job which is filling up the space and alert the admin to take action.  Below is an example when we caught a culprit Job filling up NM local dir live and we were able to point out the application ID.

[mapr@NodeA:/opt/mapr/tmp/hadoop-mapr/nm-local-dir/usercache] sudo du -sh *  |grep G
1.2G    UserA
98G     UserB
5.4G    UserC

[mapr@NodeA:/opt/mapr/tmp/hadoop-mapr/nm-local-dir/usercache/UserB] sudo du -sh *  |grep G
99G     appcache
[mapr@dbslp1027:/opt/mapr/tmp/hadoop-mapr/nm-local-dir/usercache/UserB/appcache] sudo du -sh *  |grep G
99G     application_1499818693665_1082462

Automation :

So to automate this, wrote small script which would monitor and find any huge files under NM local dir which could be suspect .

[root@node107rhel72 ~]# cat NM_Temp_SpaceMonitor.sh 
##################################################################

#!/bin/bash

##################################################################
#
#     This script will find any huge files (50 GB) under NM_LOCAL_DIR
#     and report, for Admin to take action.
#
##################################################################
NM_LOCAL_DIR=/opt/mapr/tmp/hadoop-mapr/nm-local-dir/

if [ ! -d $NM_LOCAL_DIR ]; then
  echo ERROR: Not a directory: $logDir
  exit 1
fi

CULPRIT_FILE_LOC=`find $NM_LOCAL_DIR -type f -size +50G -print0 | xargs -0`
echo "Complete Path $CULPRIT_FILE_LOC" 
echo "$CULPRIT_FILE_LOC"  | sed 's,/, ,g' | tr " " "\n" | grep -i app |  xargs -0 echo  CULPRIT_APPLICATION is 


##################################################################


Note :- Above script only catches only files which are greater then 50 GB but recently i found a Spark job which was causing NM to be unusable since they were having huge blockmgr dir but individual files were only ~2-3 GB. I used below command to give me culprit application ID and added extra automation to find such spark jobs as well.

[root@tssperf09 ~]# du -h /opt/mapr/tmp/hadoop-mapr/nm-local-dir |awk '$1 ~ /[0-9]*G/ {print}' |sort -nr|sed 's/G//g' |awk '{ if ( $1 > 50.0 ) print }' | grep blockmgr |cut -d'/' -f10

application_1521597354345_3389657


[root@tssperf09 ~]# 

Thursday, July 20, 2017

Distcp Across Secure MapR clusters

                                   Distcp Across Secure MapR clusters 



This Blog assumes you have 2 clusters up and running securely


Note :-  For this Blog i just have 1 node in each cluster but as needed will mention what files are needed on all nodes.

Source Cluster  - Node node106rhel72/10.10.70.106
Destination Cluster  - Node node107rhel72/10.10.70.107  

1)  i) On all node in SOURCE CLUSTER verify that maprserverticket , cldb.key , ssl_truststore, ssl_keystore are same. Run md5sum on these file on each node to confirm.
ii) Make sure destination cluster details are added to "
mapr-clusters.conf" file


[root@node106rhel72 ~]# cat /opt/mapr/conf/mapr-clusters.conf
Container-cluster secure=true 10.10.70.106:7222
Container-cluster2 secure=true 10.10.70.107:7222

2) On all node in DESTINATION CLUSTER verify that maprserverticket , cldb.key , ssl_truststore, ssl_keystore are same. Run md5sum on these file on each node to confirm.
3)  i) Copy /opt/mapr/conf/ssl_truststore from DESTINATION CLUSTER to cldb node of SOURCE CLUSTER under /tmp/

[root@node107rhel72 conf]# scp  /opt/mapr/conf/ssl_truststore  10.10.70.106:/tmp/
root@10.10.70.106's password: 
ssl_truststore                                                                                                                         100%  798     0.8KB/s   00:00    
[root@node107rhel72 conf]#

 2) Now run the below command to merge ssl_truststore on SOURCE CLUSTER

Note: Ignore ssl_truststore merge step if in case you have already done it earlier.
$ chmod 644 /opt/mapr/conf/ssl_truststore
$ /opt/mapr/server/
manageSSLKeys.sh merge /tmp/ssl_truststore /opt/mapr/conf/ssl_truststore 
$ chmod 444 /opt/mapr/conf/ssl_truststore 

4) Copy the merged truststore file '/opt/mapr/conf/ssl_truststore' on all the node in SOURCE CLUSTER under /opt/mapr/conf/ 

5) Generate cross-cluster ticket from DESTINATION CLUSTER for user who wants to do distcp ( MapR in our case), in this case i created ticket to last for 10 years

$ maprlogin generateticket -type crosscluster -out /tmp/destination-ticket -duration 3650:0:0 

Note: - It is critical to specify an appropriate value for the duration. After the ticket expires, communication between the clusters will stop. In this example, the duration of ten years is given for convenience of explanation. Use a value that is consistent with your security policies.

6) Copy file /tmp/destination-ticket from DESTINATION CLUSTER to SOURCE CLUSTER's cldb node under /tmp. 


scp /tmp/destination-ticket  10.10.70.106:/tmp/

7) At SOURCE CLUSTER append the content of file /tmp/destination-ticket in /opt/mapr/conf/maprserverticket .

$ cat /tmp/destination-ticket >> /opt/mapr/conf/maprserverticket


8) Copy file /opt/mapr/conf/maprserverticket on all the nodes in SOURCE CLUSTER . 

9) Stop warden and 
zookeeper in SOURCE CLUSTER followed by starting ZK and then warden once ZK is up

10) On SOURCE CLUSTER create user ticket for user mapr for source and destination cluster .

maprlogin password
maprlogin password -cluster Dest

cat /tmp/maprticket_2000
Source KV34qQ0jtmQXObJglDiZqqHHm507pbYOsHd4qIEEavC+0PGDlB/YeTBGReOxf+EleSEO78pYvNqzoqK5uK+5Gibx0v+XPEyl2UuDgBR6GUBwx4yUUxnUY7Ct4STdcHmvcyE47AVM4gXc9ivQCvkokyIvZwYiGtwVQ8rnTNrLuzuUPAH8GMbR486UgMQ8axy8QIcA2zexIT0K0Ct7Fj612UPVonXZDfnAB2yG5gEhdmxLOMPmQLm9qt6f49Pzrn96IwHGLXQtUAmfrTwrbPPPOSUshA==
Dest 4D9Z469Y3j7h3sy2CVZwQrlXDEWHCtmCENQQGFvVzoGsytXp4K3OLOf+BZhLIoTBZuu2uzmV/1SbnqYUfO9NXsxAx3Bomez9iZ3ni7Kfk9m9CTEPydl9updp8IFQZ83jQ7IERM3WgN/rouEg3T/BnwPA2+U2cnGjeeCgXH3lmopJGiYFCegXWhhn9TmKawH0Vp4f3tDBBo2nWjr1sCnBvsBXhYP6DQzA3vLdmbGWQn6d2IJRNUA0irG8MSjxzZ4E9y4S2hu4gnLYE0IXgXNoWWhawQ==


Validation :


1) Created a test file and pushed in source cluster
[root@node106rhel72 ~]# vi abi
[mapr@node106rhel72 ~]# hadoop fs -put abi /
[mapr@node106rhel72 ~]# hadoop fs -ls /abi
Found 7 items
-rwxr-xr-x   3 root root        266 2017-07-20 19:16 /abi

2) Now distcp across clusters and preserve the permissions. 

[root@node106rhel72 ~]# hadoop distcp -p /mapr/Container-cluster/abi /mapr/Container-cluster2/tmp/
17/07/20 19:16:59 INFO tools.DistCp: Input Options: DistCpOptions{atomicCommit=false, syncFolder=false, deleteMissing=false, ignoreFailures=false, maxMaps=20, sslConfigurationFile='null', copyStrategy='uniformsize', sourceFileListing=null, sourcePaths=[/mapr/Container-cluster/abi], targetPath=/mapr/Container-cluster2/tmp, targetPathExists=true, preserveRawXattrs=false}
17/07/20 19:16:59 INFO client.MapRZKBasedRMFailoverProxyProvider: Updated RM address to node106rhel72/10.10.70.106:8032
17/07/20 19:17:00 INFO Configuration.deprecation: io.sort.mb is deprecated. Instead, use mapreduce.task.io.sort.mb
17/07/20 19:17:00 INFO Configuration.deprecation: io.sort.factor is deprecated. Instead, use mapreduce.task.io.sort.factor
17/07/20 19:17:00 INFO client.MapRZKBasedRMFailoverProxyProvider: Updated RM address to node106rhel72/10.10.70.106:8032
17/07/20 19:17:00 INFO mapreduce.JobSubmitter: number of splits:1
17/07/20 19:17:00 INFO mapreduce.JobSubmitter: Submitting tokens for job: job_1500592302342_0009
17/07/20 19:17:01 INFO security.ExternalTokenManagerFactory: Initialized external token manager class - com.mapr.hadoop.yarn.security.MapRTicketManager
17/07/20 19:17:01 INFO impl.YarnClientImpl: Submitted application application_1500592302342_0009
17/07/20 19:17:01 INFO mapreduce.Job: The url to track the job: https://node106rhel72:8090/proxy/application_1500592302342_0009/
17/07/20 19:17:01 INFO tools.DistCp: DistCp job-id: job_1500592302342_0009
17/07/20 19:17:01 INFO mapreduce.Job: Running job: job_1500592302342_0009
17/07/20 19:17:09 INFO mapreduce.Job: Job job_1500592302342_0009 running in uber mode : false
17/07/20 19:17:09 INFO mapreduce.Job:  map 0% reduce 0%
17/07/20 19:17:14 INFO mapreduce.Job:  map 100% reduce 0%
17/07/20 19:17:14 INFO mapreduce.Job: Job job_1500592302342_0009 completed successfully
17/07/20 19:17:14 INFO mapreduce.Job: Counters: 34
File System Counters
FILE: Number of bytes read=0
FILE: Number of bytes written=100285
FILE: Number of read operations=0
FILE: Number of large read operations=0
FILE: Number of write operations=0
MAPRFS: Number of bytes read=631
MAPRFS: Number of bytes written=266
MAPRFS: Number of read operations=33
MAPRFS: Number of large read operations=0
MAPRFS: Number of write operations=1
Job Counters 
Launched map tasks=1
Other local map tasks=1
Total time spent by all maps in occupied slots (ms)=2800
Total time spent by all reduces in occupied slots (ms)=0
Total time spent by all map tasks (ms)=2800
Total vcore-seconds taken by all map tasks=2800
Total megabyte-seconds taken by all map tasks=2867200
DISK_MILLIS_MAPS=1400
Map-Reduce Framework
Map input records=1
Map output records=0
Input split bytes=144
Spilled Records=0
Failed Shuffles=0
Merged Map outputs=0
GC time elapsed (ms)=0
CPU time spent (ms)=440
Physical memory (bytes) snapshot=271511552
Virtual memory (bytes) snapshot=2987470848
Total committed heap usage (bytes)=904396800
File Input Format Counters 
Bytes Read=221
File Output Format Counters 
Bytes Written=0
org.apache.hadoop.tools.mapred.CopyMapper$Counter
BYTESCOPIED=266
BYTESEXPECTED=266
COPY=1

3) Validated file exists on destination cluster .

[root@node106rhel72 ~]# hadoop fs -ls /mapr/Container-cluster2/tmp/abi
-rwxr-xr-x   3 root root        266 2017-07-20 19:16 /mapr/Container-cluster2/tmp/abi