This commit is contained in:
newnius
2017-09-02 14:44:57 +08:00
parent 3c2b40e598
commit b5e3da77c1
6 changed files with 140 additions and 0 deletions

24
hive/2.1.1/Dockerfile Normal file
View File

@@ -0,0 +1,24 @@
FROM newnius/hadoop:2.7.4
MAINTAINER Newnius <newnius.cn@gmail.com>
USER root
# Install Apche Hive
RUN wget -O apache-hive.tar.gz http://www-eu.apache.org/dist/hive/hive-2.1.1/apache-hive-2.1.1-bin.tar.gz && \
tar -xzf apache-hive.tar.gz -C /usr/local/ && rm apache-hive.tar.gz
RUN ln -s /usr/local/apache-hive-2.1.1-bin /usr/local/hive
ENV HIVE_HOME /usr/local/apache-hive-2.1.1-bin
ENV PATH $PATH:$HIVE_HOME/bin
ADD mysql-connector-java-5.1.44-bin.jar $HIVE_HOME/lib
ADD hive-site.xml $HIVE_HOME/conf
RUN mv /etc/bootstrap.sh /etc/start_hadoop.sh
ADD bootstrap.sh /etc/bootstrap.sh
ADD init_hive.sh /etc/init_hive.sh
CMD ["/etc/bootstrap.sh", "-d"]

64
hive/2.1.1/README Normal file
View File

@@ -0,0 +1,64 @@
Run Aapache Hive with Docker
## Create a hadoop cluster with Hive supported in swarm mode
`--hostname` needs 1.13 or higher
```
docker service create \
--name hadoop-master \
--network swarm-net \
--hostname hadoop-master \
--replicas 1 \
--endpoint-mode dnsrr \
newnius/hive:2.1.1
```
```
docker service create \
--name hadoop-slave1 \
--network swarm-net \
--hostname hadoop-slave1 \
--replicas 1 \
--endpoint-mode dnsrr \
newnius/hadoop:2.7.4
```
```
docker service create \
--name hadoop-slave2 \
--network swarm-net \
--hostname hadoop-slave2 \
--replicas 1 \
--endpoint-mode dnsrr \
newnius/hadoop:2.7.4
```
```
docker service create \
--name hadoop-slave3 \
--network swarm-net \
--hostname hadoop-slave3 \
--replicas 1 \
--endpoint-mode dnsrr \
newnius/hadoop:2.7.4
```
## Init && Test
#### Start Hadoop
Read `newnius/hadoop` to learn how to init hadoop
#### Mysql
```bash
docker service create \
--name mysql \
--network swarm-net \
-e MYSQL_ROOT_PWDDWORD=123456 \
mysql:5.7
```
#### init hive
```bash
bash /etc/init_hive.sh
```

14
hive/2.1.1/bootstrap.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
# setup hadoop
bash /etc/start_hadoop.sh -bash
hive --service metastore
if [[ $1 == "-d" ]]; then
while true; do sleep 1000; done
fi
if [[ $1 == "-bash" ]]; then
/bin/bash
fi

30
hive/2.1.1/hive-site.xml Normal file
View File

@@ -0,0 +1,30 @@
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://mysql:3306/hive?createDatabaseIfNotExist=true&amp;useSSL=false</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
<description>username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
<description>password to use against metastore database</description>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://hadoop-master:9083</value>
</property>
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
</configuration>

8
hive/2.1.1/init_hive.sh Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/bash
$HADOOP_HOME/bin/hdfs dfs -mkdir /tmp
$HADOOP_HOME/bin/hdfs dfs -mkdir -p /user/hive/warehouse
$HADOOP_HOME/bin/hdfs dfs -chmod g+w /tmp
$HADOOP_HOME/bin/hdfs dfs -chmod g+w /user/hive/warehouse
schematool --dbType mysql --initSchema

Binary file not shown.