Skip to content

Latest commit

 

History

History
160 lines (109 loc) · 3.75 KB

File metadata and controls

160 lines (109 loc) · 3.75 KB

docker

In this Lab we are going to use a Docker Container to create second node to the one already installed.

a) We are going to Install Docker in the CentOS VM
b) Create Centos Docker Image using a DockerFile
c) Instantiate a container
c) Use the AmbariUi to add a Node

Install Docker Binaries

CentOS 7

The following steps are to setup docker on CentOS 7.


   $ sudo yum update

   $ curl -sSL https://get.docker.com/ | sh

   $ sudo service docker start

   $ sudo docker run hello-world

To create the docker group and add your user (not needed if you are root user):

  • Log into Centos as a user with sudo privileges.
  • Create the docker group and add your user.
  • sudo usermod -aG docker your_username
  • Log out and log back in.
  • This ensures your user is running with the correct permissions.
  • Verify your work by running docker without sudo.
  $ docker run hello-world

Ensure Docker is running as a service


  sudo chkconfig docker on

Create Docker images

Use the Dockerfile in the repo to create a CentOS image for HDP Slave Node


  $ mkdir dockerimage
  $ cp DockerFile dockerimage/
  $ docker build --file=dockerimage/DockerFile ./dockerimage

  • This will list the newly create image

  $ docker images 

  • Tag the image

  $docker tag shivajid/centos:hdp23 __imageid__

  • Create the docker instance.

  $docker run -it -h node0 -P --privileged=true shivajid/centos:hdp23 /bin/bash

  • User CTRL (P+Q) to exit the container. Do not use exit command.

  • List all the running containers


  $docker ps
 
  • Re-enter the docker
    
        $ docker exec -it __docker_container_name__
     

Setup the ssh keys


$service sshd start
$ssh-copy-id root@node0
$ ifconfig


  • Add an entry for node0 to the host /etc/host file
  • Update /etc/hosts/ file for node0 Docker Container for ip address mapping for hdpdemo.hortonworks.com

Services on the node may fail to start. It looks for /usr/java/default which is missing. Create an appropriate link to /usr/java/default

Install Slave Node on the docker images

  • Use the Ambari wizard to add the docker container.

  • Under the Hosts -> Actions Add Hosts

  • Choose the name of the host. In our lab case it is node0Select you private ssh key [log into the docker container, cat the id_rsa key and provide the information under Provide your ssh key. Put the node information

  • Ignore the host checks for the lab. (Please take care in your actual lab sessions)

![Warning](/images/Screen Shot 2015-10-11 at 10.54.42 PM.png)

  • Select the service (Select atleast the DataNode and NodeManager) ![](/images/Screen Shot 2015-10-11 at 10.55.04 PM.png)

  • Click Next and start the install process ![Install](/images/Screen Shot 2015-10-11 at 10.55.48 PM.png) Install ![install](/images/Screen Shot 2015-10-11 at 10.58.07 PM.png)

Issues and Resolution

  • If a Service does not start up. Start the individual Service on the node.

![Start Service](/images/Screen Shot 2015-10-11 at 10.58.24 PM.png)

Docker Reference Commands

  • Stop a container

$docker stop __container_name_OR_id

  • Remove a container

$docker rm __container_name_OR_id

  • To Validate. The container should be gone

    $ docker ps

  • To delete an image. Get the image id from running "docker image"

$docker rmi __image_id

  • To Validae. Run

$ docker image