Public Repository

Last pushed: 3 years ago
Short Description
ubuntu14 hbase v1.0.0
Full Description


For Mac

$ boot2docker upgrade
$ boot2docker init
$ VBoxManage sharedfolder add boot2docker-vm --name Users --hostpath $HOME

$ boot2docker up && boot2docker ssh

nsenterのコンテナ起動( docker-enterコマンド実行環境)

$ docker run --rm -v /usr/local/bin:/target jpetazzo/nsenter


$ docker pull gorohayakawa/hbase1.0.0:latest

Start Container

$ mkdir -p /User/work
$ chmod -R 777 /User/work
$ vi
# Script to start docker and update the /etc/hosts file to point to
# the hbase-docker container
# hbase thrift and master server logs are written to the local
# logs directory

echo "Starting HBase container"
rm -rf logs
mkdir -p logs
rm -rf /work/hbase
mkdir -p /work/hbase
id=$(docker run -d -v $PWD/logs:/opt/hbase/logs --name hbase1.0.0 -v /Users/work:/work -p :2181 -p :9090 -p :60000 -p :60020 gorohayakawa/hbase1.0.0)

echo "Container has ID $id"

# Get the hostname and IP inside the container
docker inspect $id > config.json
docker_hostname=`python -c 'import json; c=json.load(open("config.json")); print c[0]["Config"]["Hostname"]'`
docker_ip=`python -c 'import json; c=json.load(open("config.json")); print c[0]["NetworkSettings"]["IPAddress"]'`
rm -f config.json

echo "Updating /etc/hosts to make hbase-docker point to $docker_ip ($docker_hostname)"
if grep 'hbase-docker' /etc/hosts >/dev/null; then
  sudo sed -i "s/^.*hbase-docker.*\$/$docker_ip hbase-docker $docker_hostname/" /etc/hosts
  sudo sh -c "echo '$docker_ip hbase-docker $docker_hostname' >> /etc/hosts"

echo "Now connect to hbase at localhost on the standard ports"
echo "  ZK 2181, Thrift 9090, Master 60000, Region 60020"
echo "Or connect to host hbase-docker (in the container) on the same ports"
echo ""
echo "For docker status:"
echo "$ id=$id"
echo "$ docker ps $$id"

(Macのboot2dockerではホストPC の$HOME/workがコンテナの/workにマウントされて共有ディレクトリとなる)

$ sh
$ sudo docker ps -a|grep hbase1.0.0
a41ba0e11762        gorohayakawa/hbase1.0.0:latest      "./bin/hbase master    About a minute ago   Up 58 seconds               60010/tcp, 60030/tcp,>2181/tcp,>60000/tcp,>60020/tcp,>9090/tcp   hbase1.0.0

Login Container

$ docker-enter hbase1.0.0  


$ docker exec -it hbase1.0.0 bash  


root@a41ba0e11762:/# /opt/hbase/bin/hbase shell
2015-03-19 09:42:03,250 WARN  [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.0.0, r6c98bff7b719efdb16f71606f3b7d8229445eb81, Thu Mar 19 09:32:18 UTC 2015

hbase(main):001:0> create_namespace 'test1'
0 row(s) in 0.1950 seconds

hbase(main):001:0> create 'test1:sample', {NAME => 'user1', VERSIONS => 1}
0 row(s) in 0.3840 seconds

=> Hbase::Table - test1:sample

hbase(main):001:0> ('a'..'z').each{|i| put 'test1:sample', "row-#{i}", 'user1:data:', i}
0 row(s) in 0.0720 seconds

0 row(s) in 0.0030 seconds

=> "a".."z"

hbase(main):001:0> list
1 row(s) in 0.0210 seconds

=> ["test1:sample"]

hbase(main):001:0> scan 'test1:sample'
ROW                                      COLUMN+CELL
 row-a                                   column=user1:data, timestamp=1426758327228, value=a
 row-b                                   column=user1:data, timestamp=1426758327240, value=b
 row-c                                   column=user1:data, timestamp=1426758327244, value=c
 row-d                                   column=user1:data, timestamp=1426758327248, value=d
 row-e                                   column=user1:data, timestamp=1426758327251, value=e
 row-f                                   column=user1:data, timestamp=1426758327254, value=f
 row-g                                   column=user1:data, timestamp=1426758327257, value=g
 row-h                                   column=user1:data, timestamp=1426758327260, value=h
 row-i                                   column=user1:data, timestamp=1426758327263, value=i
 row-j                                   column=user1:data, timestamp=1426758327266, value=j
 row-k                                   column=user1:data, timestamp=1426758327270, value=k
 row-l                                   column=user1:data, timestamp=1426758327273, value=l
 row-m                                   column=user1:data, timestamp=1426758327276, value=m
 row-n                                   column=user1:data, timestamp=1426758327279, value=n
 row-o                                   column=user1:data, timestamp=1426758327283, value=o
 row-p                                   column=user1:data, timestamp=1426758327287, value=p
 row-q                                   column=user1:data, timestamp=1426758327290, value=q
 row-r                                   column=user1:data, timestamp=1426758327293, value=r
 row-s                                   column=user1:data, timestamp=1426758327296, value=s
 row-t                                   column=user1:data, timestamp=1426758327299, value=t
 row-u                                   column=user1:data, timestamp=1426758327302, value=u
 row-v                                   column=user1:data, timestamp=1426758327305, value=v
 row-w                                   column=user1:data, timestamp=1426758327307, value=w
 row-x                                   column=user1:data, timestamp=1426758327311, value=x
 row-y                                   column=user1:data, timestamp=1426758327313, value=y
 row-z                                   column=user1:data, timestamp=1426758327316, value=z
26 row(s) in 0.0620 seconds

hbase(main):001:0> exit


FROM ubuntu:14.04
MAINTAINER gorohayakawa
RUN apt-get update

# Install Vim
RUN apt-get install -y vim

# Install Git
RUN apt-get install -y git

# Install JRuby
RUN apt-get install -y jruby

# Install Java7
RUN apt-get install -y software-properties-common
RUN add-apt-repository -y ppa:webupd8team/java
RUN apt-get update
RUN echo debconf shared/accepted-oracle-license-v1-1 select true | debconf-set-selections
RUN echo debconf shared/accepted-oracle-license-v1-1 seen true | debconf-set-selections

RUN apt-get install -y openjdk-7-jdk
ENV JAVA_HOME /usr/lib/jvm/java-7-openjdk-amd64

# Install build tools
RUN apt-get install -y git
RUN apt-get install -y maven

# Install HBase
RUN git clone git:// /opt/hbase
WORKDIR /opt/hbase
RUN cd /opt/hbase
RUN git checkout -b 1.0.0 refs/tags/1.0.0 # use other version
RUN mvn clean package -DskipTests

# ZooKeeper

# HMaster
EXPOSE 60000

# HMaster Web
EXPOSE 60010

# RegionServer
EXPOSE 60020

# RegionServer Web
EXPOSE 60030

CMD ["./bin/hbase", "master", "start"]



Docker Pull Command