add hive:2.3.3

This commit is contained in:
Newnius 2018-08-06 21:08:28 +08:00
parent ea4dc5d428
commit 93f18c1989
7 changed files with 170 additions and 8 deletions

View File

@ -39,6 +39,11 @@ $HADOOP_HOME/bin/hdfs dfs -chmod g+w /user/hive/warehouse
schematool --dbType mysql --initSchema
```
#### Start MetaStore service
```bash
nohup hive --service metastore &
```
#### Validate Installation
Run `hive` to start the hive shell
@ -48,3 +53,20 @@ If the following command is executed successfully, then the installation is fine
```hive
CREATE TABLE pokes (foo INT, bar STRING);
```
## Custom configuration
To persist data or modify the conf files, refer to the following script.
The `/config/hive` path is where new conf files to be replaces, you don't have to put all the files.
```bash
docker service create \
--name hive \
--hostname hive \
--network swarm-net \
--replicas 1 \
--detach=true \
--mount type=bind,source=/etc/localtime,target=/etc/localtime \
--mount type=bind,source=/data/hive/config,target=/config/hive \
newnius/hive:2.1.1
```

View File

@ -1,8 +0,0 @@
#!/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

28
hive/2.3.3/Dockerfile Normal file
View File

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

72
hive/2.3.3/README.md Normal file
View File

@ -0,0 +1,72 @@
Run Aapache Hive with Docker
## Prequirements
Assume you already have one Hadoop cluster whose master node host is `hadoop-master`;
Assume you already have a Mysql server whose host is `mysql`;
You can specify them in `conf/hive-site.xml`;
## Start Hive Node
```
docker service create \
--name hive \
--hostname hive \
--network swarm-net \
--replicas 1 \
--detach=true \
--mount type=bind,source=/etc/localtime,target=/etc/localtime \
newnius/hive:2.3.3
```
## Init && Test
Init HIVE for the first time
#### Create HIVE dir in HDFS
```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
```
#### Init MetaStore
```bash
schematool --dbType mysql --initSchema
```
#### Start MetaStore service
```bash
nohup hive --service metastore &
```
#### Validate Installation
Run `hive` to start the hive shell
If the following command is executed successfully, then the installation is fine.
```hive
CREATE TABLE pokes (foo INT, bar STRING);
```
## Custom configuration
To persist data or modify the conf files, refer to the following script.
The `/config/hive` path is where new conf files to be replaces, you don't have to put all the files.
```bash
docker service create \
--name hive \
--hostname hive \
--network swarm-net \
--replicas 1 \
--detach=true \
--mount type=bind,source=/etc/localtime,target=/etc/localtime \
--mount type=bind,source=/data/hive/config,target=/config/hive \
newnius/hive:2.3.3
```

18
hive/2.3.3/bootstrap.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
## replace config
: ${EXTRA_CONF_DIR:=/config/hive}
if [ -d "$EXTRA_CONF_DIR" ]; then
cp $EXTRA_CONF_DIR/* /usr/local/hive/conf
fi
hive --service metastore
if [[ $1 == "-d" ]]; then
while true; do sleep 1000; done
fi
if [[ $1 == "-bash" ]]; then
/bin/bash
fi

30
hive/2.3.3/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://localhost:9083</value>
</property>
<property>
<name>hive.metastore.schema.verification</name>
<value>false</value>
</property>
</configuration>