Friday, August 26, 2016

Apache HBase - Standalone mode (Part I)


This is the default mode. In standalone mode, HBase does not use HDFS -- it uses the local filesystem instead -- and it runs all HBase daemons and a local ZooKeeper all up in the same JVM. Zookeeper binds to a well known port so clients may talk to HBase.

Prepare Docker container

ubuntu@node2:~$ docker network create \
> --driver=bridge \
> --subnet=172.29.0.0/16 \
> --ip-range=172.29.5.0/24 \
> --gateway=172.29.5.254 \
> my-net
6f5295c3ac2c7aa3c980e5ebd9140714f31000ef483d07aa1c8c6162bea12e5a
ubuntu@node2:~$ 
ubuntu@node2:~$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
38916a17da9f        bridge              bridge              local               
844343d53939        host                host                local               
6f5295c3ac2c        my-net              bridge              local               
8150faa4b0d4        none                null                local               
ubuntu@node2:~$ docker network inspect my-net
[
    {
        "Name": "my-net",
        "Id": "6f5295c3ac2c7aa3c980e5ebd9140714f31000ef483d07aa1c8c6162bea12e5a",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": {},
            "Config": [
                {
                    "Subnet": "172.29.0.0/16",
                    "IPRange": "172.29.5.0/24",
                    "Gateway": "172.29.5.254"
                }
            ]
        },
        "Internal": false,
        "Containers": {},
        "Options": {},
        "Labels": {}
    }
]
ubuntu@node2:~$ docker run --name hbase -it -P \
> --net="my-net" \
> --mac-address="52:1d:44:ff:b8:40" \
> --add-host="hbase:172.29.5.1" \
> --ip="172.29.5.1" ubuntu:14.04 bash
148087c38a7fa0297629a5701d958978b3f537d1f5d9b74ae049e0cc91f1836d
root@0fb87ce32de3:/#




Install JDK 8 (instruction from here)

$ sudo apt-get install python-software-properties
$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update

$ sudo apt-get install oracle-java8-installer

-- change java when has more than one Java Home
$ sudo update-alternatives --config java


--- COMMIT first stage after install JDK
--- $ docker commit  0fb87ce32de3 hbase:install_jdk8

Now we use software folder from host directory as a mount point in container. So we run new container with a latest committed image ( hbase:install_jdk8 ).


Install HBase

ubuntu@node2:~/software$ docker run --name hbase -it -P \
>  --net="my-net" \
>  --mac-address="52:1d:44:ff:b8:40" \
>  --add-host="hbase:172.29.5.1" \
>  --ip="172.29.5.1" \
>  -v /home/ubuntu/software:/software \
> hbase:install_jdk8 bash
root@637c83896b9d:/#             
root@637c83896b9d:/# 
root@637c83896b9d:/# df -k
Filesystem     1K-blocks     Used Available Use% Mounted on
none           103080204 13881500  83939496  15% /
tmpfs            5120624        0   5120624   0% /dev
tmpfs            5120624        0   5120624   0% /sys/fs/cgroup
/dev/sda1      103080204 13881500  83939496  15% /software
shm                65536        0     65536   0% /dev/shm
root@637c83896b9d:/# 
root@637c83896b9d:/# 
root@637c83896b9d:/# 
root@637c83896b9d:/# java -version
java version "1.8.0_101"
Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
root@637c83896b9d:/# 
root@637c83896b9d:/# useradd hbase -m -s /bin/bash
root@637c83896b9d:/# exit

Logon with non-root user


ubuntu@node2:~/software$ docker start hbase
hbase
ubuntu@node2:~/software$ docker exec -it --user hbase hbase bash
hbase@637c83896b9d:/$ 


hbase@637c83896b9d:~$ tar xzvf /software/hbase-1.2.2-bin.tar.gz
hbase@637c83896b9d:~$ cd hbase-1.2.2/
hbase@637c83896b9d:~/hbase-1.2.2$ ls 
CHANGES.txt  LEGAL  LICENSE.txt  NOTICE.txt  README.txt  bin  conf  docs  hbase-webapps  lib


hbase@637c83896b9d:~/hbase-1.2.2/conf$ cat hbase-site.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
/**
 *
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-->
<configuration>
<property>
    <name>hbase.rootdir</name>
    <value>file:///home/hbase/hbase-1.2.2</value>
  </property>
  <property>
    <name>hbase.zookeeper.property.dataDir</name>
    <value>/home/hbase/zookeeper</value>
  </property>
</configuration>
hbase@637c83896b9d:~/hbase-1.2.2/conf$ cd



hbase@637c83896b9d:~/hbase-1.2.2/logs$ echo $JAVA_HOME

hbase@637c83896b9d:~/hbase-1.2.2/logs$ update-alternatives --config java
There is only one alternative in link group java (providing /usr/bin/java): /usr/lib/jvm/java-8-oracle/jre/bin/java
Nothing to configure.
hbase@637c83896b9d:~/hbase-1.2.2/logs$ 
hbase@637c83896b9d:~/hbase-1.2.2/logs$ JAVA_HOME=/usr/lib/jvm/java-8-oracle
hbase@637c83896b9d:~/hbase-1.2.2/logs$ export JAVA_HOME
hbase@637c83896b9d:~/hbase-1.2.2/logs$ 
hbase@637c83896b9d:~/hbase-1.2.2/logs$ 
hbase@637c83896b9d:~/hbase-1.2.2/logs$ cd ../bin
hbase@637c83896b9d:~/hbase-1.2.2/bin$ ls    
draining_servers.rb   hbase-common.sh   hbase-jruby             master-backup.sh  rolling-restart.sh        stop-hbase.sh
get-active-master.rb  hbase-config.cmd  hbase.cmd               region_mover.rb   shutdown_regionserver.rb  test
graceful_stop.sh      hbase-config.sh   hirb.rb                 region_status.rb  start-hbase.cmd           thread-pool.rb
hbase                 hbase-daemon.sh   local-master-backup.sh  regionservers.sh  start-hbase.sh            zookeepers.sh
hbase-cleanup.sh      hbase-daemons.sh  local-regionservers.sh  replication       stop-hbase.cmd
hbase@637c83896b9d:~/hbase-1.2.2/bin$ ./stop-hbase.sh
stopping hbase..................
hbase@637c83896b9d:~/hbase-1.2.2/bin$ ./start-hbase.sh 
starting master, logging to /home/hbase/hbase-1.2.2/bin/../logs/hbase--master-637c83896b9d.out
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option PermSize=128m; support was removed in 8.0
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=128m; support was removed in 8.0
hbase@637c83896b9d:~/hbase-1.2.2/bin$ 


-- COMMIT container as stage two ( hbase:standalone )


hbase@637c83896b9d:~/hbase-1.2.2/bin$ ./stop-hbase.sh 
stopping hbase...................
hbase@637c83896b9d:~/hbase-1.2.2/bin$ exit
exit
ubuntu@node2:~$ docker ps -a
CONTAINER ID        IMAGE                COMMAND             CREATED             STATUS              PORTS               NAMES
637c83896b9d        hbase:install_jdk8   "bash"              About an hour ago   Up 56 minutes                           hbase
ubuntu@node2:~$ docker ps -a
CONTAINER ID        IMAGE                COMMAND             CREATED             STATUS              PORTS               NAMES
637c83896b9d        hbase:install_jdk8   "bash"              About an hour ago   Up 56 minutes                           hbase
ubuntu@node2:~$ docker commit 637c83896b9d hbase:standalone
sha256:00c7c409fdc7d291939d3924b8dfa07eb014ec70c0476abdd13c4ebf2690c07e
ubuntu@node2:~$ docker ps -a
CONTAINER ID        IMAGE                COMMAND             CREATED             STATUS              PORTS               NAMES
637c83896b9d        hbase:install_jdk8   "bash"              About an hour ago   Up 57 minutes                           hbase
ubuntu@node2:~$ docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
hbase                   standalone          00c7c409fdc7        30 seconds ago      1.189 GB
hbase                   install_jdk8        0ab667093b9b        6 hours ago         840.2 MB
ubuntu                  14.04               ff6011336327        2 weeks ago         188 MB
cloudera/quickstart     latest              4239cd2958c6        4 months ago        6.336 GB
shipyard/docker-proxy   latest              cfee14e5d6f2        8 months ago        9.468 MB

Push to Docker Hub


ubuntu@node2:~/.docker$ docker ps -a
CONTAINER ID        IMAGE                COMMAND             CREATED             STATUS              PORTS               NAMES
637c83896b9d        hbase:install_jdk8   "bash"              21 hours ago        Up About an hour                        hbase
ubuntu@node2:~/.docker$ docker commit 637c83896b9d nutthaphon/hbase:1.2.2
sha256:a01016dd24ec89508d5e93e13b2bc3d3d2a898bf6945fb4b0af8256aec08f82b
ubuntu@node2:~/.docker$ docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username (nutthaphon): nutthaphon
Password: 
Login Succeeded
ubuntu@node2:~/.docker$ docker images
REPOSITORY              TAG                 IMAGE ID            CREATED             SIZE
nutthaphon/hbase        1.2.2               a01016dd24ec        45 seconds ago      1.189 GB
hbase                   1.2.2               00c7c409fdc7        20 hours ago        1.189 GB
hbase                   standalone          00c7c409fdc7        20 hours ago        1.189 GB
hbase                   install_jdk8        0ab667093b9b        26 hours ago        840.2 MB
ubuntu                  14.04               ff6011336327        2 weeks ago         188 MB
cloudera/quickstart     latest              4239cd2958c6        4 months ago        6.336 GB
shipyard/docker-proxy   latest              cfee14e5d6f2        8 months ago        9.468 MB
ubuntu@node2:~/.docker$ docker push nutthaphon/hbase:1.2.2
The push refers to a repository [docker.io/nutthaphon/hbase]
cafd3a1794b0: Pushed 
01e76fc6590f: Pushed 
447f88c8358f: Pushed 
df9a135a6949: Pushed 
dbaa8ea1faf9: Pushed 
8a14f84e5837: Pushed 
1.2.2: digest: sha256:917e7387ac064e9c2daa0cdcc63279a39d78e06ef2bb6568558adfd06d172cf1 size: 1578
ubuntu@node2:~/.docker$ 








No comments:

Post a Comment