Thursday, August 31, 2017

Running Fuse and Mysql in PACC/Docker container

                                Running Fuse and Mysql in PACC/Docker container 


Recently I worked on an interesting issue where the requirement was to start 2 services in a container at the same time, A container’s main running process is the ENTRYPOINT and/or CMD at the end of the Dockerfile. It is generally recommended to have one service per container and then connect multiple containers using user-defined networks and shared volumes etc but this was against our requirement where i wanted to mount Fuse and then start mysql to write data to remote MapR cluster via Fuse.

Ideal way to achieve this would be using supervisord to manage the start and sequence of services to be started as suggested by docker below.

https://docs.docker.com/engine/admin/multi-service_container/

But this would require sometime to stitch things together we had another idea to use system bashrc to achieve this and as second workaround use CMD in docker file.  This blog will describe two ways we worked around docker limitation to have only one entry point and were able to start fuse and Mysql in PACC container.

Work Around 1 :

1) Below is docker file we wrote and it has comments to make things clear

[root@noderhel73 PACC_MYSQL]# cat Dockerfile 
#use PACC image to start from
FROM maprtech/pacc:5.2.2_3.0.1_centos7 

# add our user and group first to make sure their IDs get assigned consistently, regardless of\ whatever dependencies get added

RUN groupadd -r mysql && useradd -r -g mysql mysql
# Install Percona Mysql

RUN rpm --import https://www.percona.com/downloads/RPM-GPG-KEY-percona

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 \

# Clean up YUM when done.
&& yum clean all && rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql /var/log/mysql \
&& chown -R mysql:mysql /var/lib/mysql /var/log/mysql && chmod -R 755 /var/lib/mysql /var/log/mysql

ADD my.cnf /etc/my.cnf
VOLUME ["/var/lib/mysql","/var/lib/mysqld/", "/var/log/mysql"]

# Install server

COPY ps-entry.sh /entrypoint.sh
RUN chmod 755 /entrypoint.sh

# start Mysql once login shell is avail only once.
COPY bashrc /root/.bashrc

#Copy master_nc file and give it executable permission into docker

COPY master_nc /usr/bin/master_nc
RUN chmod 755 /usr/bin/master_nc

EXPOSE 3306
CMD ["mysqld","-umysql"]

[root@noderhel73 PACC_MYSQL]# 


2) Now there are few files which are in play and i would like to point out . Here master_nc,my.cnf and ps-entry.sh are Mysql start up scripts and configs while rest i will talk about in next steps.


[root@noderhel73 PACC_MYSQL_clean]# ls

bashrc  Dockerfile  mapr-docker-client.sh master_nc  my.cnf  ps-entry.sh

3) Looking at below step in Docker file I wanted to explain why i am copying customer bashrc file , This file has logic which will trigger start of Mysql once the container shell comes up.


# start Mysql once login shell is avail only once.

COPY bashrc /root/.bashrc

Also as seen below I have added extra logic to start Mysql only once to take care of case when folks login into bash shell of container multiple times Mysql shouldn't be attempted to be started.


[root@noderhel73 PACC_MYSQL]# cat bashrc 

# .bashrc



# User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

if [ -f /root/entry.pid ]; then
   echo "Mysql started"
else 

# If file don't exist run mysql startup and create a pid file   
   /entrypoint.sh
pidof mysqld > /root/entry.pid

fi
[root@noderhel73 PACC_MYSQL]#


4)  Now I will go ahead and build my Image successfully.


[root@noderhel73 PACC_MYSQL]# docker build -t my_mapr_pacc_mysql_slim .

Sending build context to Docker daemon  123.4kB

Step 1/13 : FROM maprtech/pacc:5.2.2_3.0.1_centos7

 ---> 4c0ff48eae3d
Step 2/13 : RUN groupadd -r mysql && useradd -r -g mysql mysql
 ---> Using cache
 ---> 7cf3fc7871dc
Step 3/13 : RUN rpm --import https://www.percona.com/downloads/RPM-GPG-KEY-percona
 ---> Using cache
 ---> 50437632122f
Step 4/13 : 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 && yum clean all && rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql /var/log/mysql && chown -R mysql:mysql /var/lib/mysql /var/log/mysql && chmod -R 755 /var/lib/mysql /var/log/mysql
 ---> Using cache
 ---> 352ddd303fd2
Step 5/13 : ADD my.cnf /etc/my.cnf
 ---> Using cache
 ---> bfda5e73eb5a
Step 6/13 : VOLUME /var/lib/mysql /var/lib/mysqld/ /var/log/mysql
 ---> Using cache
 ---> d75a54f5f1d2
Step 7/13 : COPY ps-entry.sh /entrypoint.sh
 ---> Using cache
 ---> aa501ee7b56b
Step 8/13 : RUN chmod 755 /entrypoint.sh
 ---> Using cache
 ---> 2af88e821949
Step 9/13 : COPY bashrc /root/.bashrc
 ---> 7ffd9722beab
Removing intermediate container 84444f107c82
Step 10/13 : COPY master_nc /usr/bin/master_nc
 ---> 9710594e7d49
Removing intermediate container 5f98352760af
Step 11/13 : RUN chmod 755 /usr/bin/master_nc
 ---> Running in 6601f0a0339e
 ---> cb0b2ef92b2d
Removing intermediate container 6601f0a0339e
Step 12/13 : EXPOSE 3306
 ---> Running in 2e5f63c80695
 ---> ab77631bfbb9
Removing intermediate container 2e5f63c80695
Step 13/13 : CMD mysqld -umysql
 ---> Running in 0ea3d8d3dd87
 ---> b0a7dc6f38dc
Removing intermediate container 0ea3d8d3dd87
Successfully built b0a7dc6f38dc
[root@noderhel73 PACC_MYSQL_clean]#

5) Docker image is built and ready to be deployed .

[root@noderhel73 PACC_MYSQL]# docker images | grep slim
my_mapr_pacc_mysql_slim    latest                b0a7dc6f38dc        53 seconds ago      1.34GB

6)  Below script is nothing but gathers all the arguments and runs docker start with required options.


[root@noderhel73 PACC_MYSQL]# cat 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=dsemapr
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="-e MYSQL_ROOT_PASSWORD=<MySQL passwd>"

### 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 my_mapr_pacc_mysql_slim:latest "$@"
[root@noderhel73 PACC_MYSQL]#


7) You should see below log messages on the screen where Fuse will start first and then mysql will startup .


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

--cap-add SYS_ADMIN --cap-add SYS_RESOURCE --device /dev/fuse --memory 0 --network=bridge -e MAPR_DISKS= -e MAPR_CLUSTER=dsemapr -e MAPR_LICENSE_MODULES= -e MAPR_MEMORY=0 -e MAPR_MOUNT_PATH=/mapr -e MAPR_SECURITY= -e MAPR_TZ=America/New_York -e MAPR_USER= -e MAPR_CONTAINER_USER=root -e MAPR_CONTAINER_UID=0 -e MAPR_CONTAINER_GROUP=root -e MAPR_CONTAINER_GID=0 -e MAPR_CONTAINER_PASSWORD= -e MAPR_CLDB_HOSTS=10.10.70.117 -e MAPR_HS_HOST= -e MAPR_OT_HOSTS= -e MAPR_ZK_HOSTS= -e MYSQL_ROOT_PASSWORD=<MySQL passwd> -v /sys/fs/cgroup:/sys/fs/cgroup:ro



Testing for cluster user account... 

Enter MapR cluster user name: root
 ...Success 

/opt/mapr/installer/docker/mapr-setup.sh: line 1815: /home/root/.bashrc: No such file or directory
Configuring MapR client ( -c -C 10.10.70.117 -N dsemapr)... 

create /opt/mapr/conf/conf.old
CLDB node list: 10.10.70.117:7222
Zookeeper node list: 
Cluster conf:  /opt/mapr/conf/mapr-clusters.conf
Log can be found at:  /opt/mapr/logs/configure.log

Note: No Hadoop configuration with this configure script.

...Success 

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

Started service mapr-posix-client-container 

...Success 

Running --initialize-insecure
2017-09-01T04:32:26.710049Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-09-01T04:32:35.632814Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-09-01T04:32:36.829590Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-09-01T04:32:37.200327Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 94fb705c-8ece-11e7-acc7-0242ac110002.
2017-09-01T04:32:37.216356Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-09-01T04:32:37.744596Z 0 [Warning] CA certificate ca.pem is self signed.
2017-09-01T04:32:37.953911Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
Finished --initialize-insecure
MySQL init process in progress...

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


MySQL init process done. Ready for start up.



Starting listener for slave requests

9)  Docker container has started wait for couple of minutes for Mysql to come up completely and be available to serve requests.


[root@noderhel73 ~]# docker ps

CONTAINER ID        IMAGE                            COMMAND                  CREATED             STATUS              PORTS               NAMES

cdb89498ef2f        my_mapr_pacc_mysql_slim:latest   "/opt/mapr/install..."   8 minutes ago       Up 8 minutes        3306/tcp            nostalgic_thompson

[root@noderhel73 ~]#

10 )  After you have waited a few mins you can login into Mysql inside the container as below and validate . 


[root@noderhel73 ~]# docker exec -it nostalgic_thompson mysql -u root -p<MySQL passwd>

mysql: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 3
Server version: 5.7.19-17-log Percona Server (GPL), Release 17, Revision e19a6b7b73f

Copyright (c) 2009-2017 Percona LLC and/or its affiliates
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> 


11)   Once you login into bash shell you should see message as below and get dropped into container shell, validate Fuse is mounted .


[root@noderhel73 ~]# docker exec -it nostalgic_thompson bash

Mysql started

[root@cdb89498ef2f /]# df -hP /mapr

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

We can validate the lock file for pid is created .


[root@cdb89498ef2f /]# ps -ef| grep 533 | grep -v grep

mysql      533     1  0 00:32 ?        00:00:01 mysqld --user=mysql --server-id=2886795266 --log-error=/var/lib/mysql/error.log

[root@cdb89498ef2f /]# cat /root/entry.pid 

533
[root@cdb89498ef2f /]# ps -ef| grep 533 | grep -v grep
mysql      533     1  0 00:32 ?        00:00:01 mysqld --user=mysql --server-id=2886795266 --log-error=/var/lib/mysql/error.log
[root@cdb89498ef2f /]# 

Now even if multiple folks execute exec command , mysql will not be attempted to be started.


[root@cdb89498ef2f /]# exit

exit

[root@noderhel73 ~]# docker exec -it nostalgic_thompson bash

Mysql started
[root@cdb89498ef2f /]# exit
exit
[root@noderhel73 ~]# docker exec -it nostalgic_thompson bash
Mysql started
[root@cdb89498ef2f /]# exit
exit
[root@noderhel73 ~]# docker exec -it nostalgic_thompson bash
Mysql started
[root@cdb89498ef2f /]#




Work Around 2 :



An easier way to achieve the same objective using modified docker file.


1) Below is docker file we modified and it has comments to make things clear

FROM maprtech/pacc:5.2.2_3.0.1_centos7 

# add our user and group first to make sure their IDs get assigned consistently, regardless of whatever dependencies get added
RUN groupadd -r mysql && useradd -r -g mysql mysql
# Install Percona Mysql
RUN rpm --import https://www.percona.com/downloads/RPM-GPG-KEY-percona

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 \
# Clean up YUM when done.
&& yum clean all && rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql /var/log/mysql \
&& chown -R mysql:mysql /var/lib/mysql /var/log/mysql && chmod -R 755 /var/lib/mysql /var/log/mysql

ADD my.cnf /etc/my.cnf
VOLUME ["/var/lib/mysql","/var/lib/mysqld/", "/var/log/mysql"]

# Install server

COPY ps-entry.sh /entrypoint.sh
RUN chmod 755 /entrypoint.sh

#Copy master_nc file and give it executable permission into docker

COPY master_nc /usr/bin/master_nc
RUN chmod 755 /usr/bin/master_nc

EXPOSE 3306
# start Mysql
CMD ["/entrypoint.sh"]

2) Now build the image .


[root@noderhel73 PACC_MYSQL]# docker build -t my_mapr_pacc_mysql_final .

Sending build context to Docker daemon  15.36kB
Step 1/12 : FROM maprtech/pacc:5.2.2_3.0.1_centos7
 ---> 4c0ff48eae3d
Step 2/12 : RUN groupadd -r mysql && useradd -r -g mysql mysql
 ---> Using cache
 ---> 7cf3fc7871dc
Step 3/12 : RUN rpm --import https://www.percona.com/downloads/RPM-GPG-KEY-percona
 ---> Using cache
 ---> 50437632122f
Step 4/12 : 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 && yum clean all && rm -rf /var/lib/mysql && mkdir -p /var/lib/mysql /var/log/mysql && chown -R mysql:mysql /var/lib/mysql /var/log/mysql && chmod -R 755 /var/lib/mysql /var/log/mysql
 ---> Using cache
 ---> 352ddd303fd2
Step 5/12 : ADD my.cnf /etc/my.cnf
 ---> Using cache
 ---> bfda5e73eb5a
Step 6/12 : VOLUME /var/lib/mysql /var/lib/mysqld/ /var/log/mysql
 ---> Using cache
 ---> d75a54f5f1d2
Step 7/12 : COPY ps-entry.sh /entrypoint.sh
 ---> Using cache
 ---> f762ec517e41
Step 8/12 : RUN chmod 755 /entrypoint.sh
 ---> Using cache
 ---> 73e6491b44aa
Step 9/12 : COPY master_nc /usr/bin/master_nc
 ---> Using cache
 ---> 09f5857690f9
Step 10/12 : RUN chmod 755 /usr/bin/master_nc
 ---> Using cache
 ---> 704149f5de7b
Step 11/12 : EXPOSE 3306
 ---> Using cache
 ---> 27ff296a096e
Step 12/12 : CMD sudo -E /entrypoint.sh
 ---> Running in 74ac2c167b50
 ---> 7d171e429741
Removing intermediate container 74ac2c167b50
Successfully built 7d171e429741
[root@noderhel73 PACC_MYSQL]# 

3) Below script is nothing but gathers all the arguments and runs docker start with required options.


[root@noderhel73 PACC_MYSQL_APP]# cat 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=dsemapr
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="-e MYSQL_ROOT_PASSWORD=<MySQL passwd>"

### 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 my_mapr_pacc_mysql_final:latest "$@"

[root@noderhel73 PACC_MYSQL_APP]# 

4) Executing mapr-docker-client.sh script as ROOT starts the container and services we need.


[root@noderhel73 ~]# docker ps
CONTAINER ID        IMAGE                             COMMAND                  CREATED             STATUS              PORTS               NAMES
1145ee401a57        my_mapr_pacc_mysql_final:latest   "/opt/mapr/install..."   52 seconds ago      Up 51 seconds       3306/tcp            elated_neumann
cdb89498ef2f        my_mapr_pacc_mysql_slim:latest    "/opt/mapr/install..."   11 hours ago        Up 11 hours         3306/tcp            nostalgic_thompson


Validation :

[root@noderhel73 ~]# docker exec -it elated_neumann bash
[root@1145ee401a57 /]# df -hP
Filesystem              Size  Used Avail Use% Mounted on
overlay                  50G   30G   21G  60% /
tmpfs                   7.8G     0  7.8G   0% /dev
/dev/mapper/rhel-root    50G   30G   21G  60% /etc/hosts
shm                      64M     0   64M   0% /dev/shm
tmpfs                   7.8G     0  7.8G   0% /sys/fs/cgroup
tmpfs                   7.8G     0  7.8G   0% /sys/firmware
posix-client-container  119G  497M  118G   1% /mapr
[root@1145ee401a57 /]# exit
exit
[root@noderhel73 ~]# docker exec -it elated_neumann mysql -u root -p<MySQL passwd>
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.19-17-log Percona Server (GPL), Release 17, Revision e19a6b7b73f

Copyright (c) 2009-2017 Percona LLC and/or its affiliates
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)


mysql> 

Bingo ! we achieved our objective in 2 different ways.


No comments:

Post a Comment