HMS standalone 버전을 이용하지 않고, HMS(메타스토어)와 HS2 를 분리하여 설치하고, 연동시킨다.
🏳️🌈 [궁금한점]
📚 [외부문서연결있음]
컨테이너명을 meta 라고 하였다. 메타 저장소인 derby 의 데이터 확인을 위해 라이브러리를 마운트 하였다. hs2와 hms 도커 간 연결을 위해 네트워크를 mynetwork 로 설정하였다.
docker create network mynetwork
docker run -d -p 9083:9083 --env SERVICE_NAME=metastore --name hms -v ~/hive/db-derby-10.14.2.0-bin/lib:/opt/hive/derby/lib/ --network mynetwork apache/hive:4.0.1
<property>
<name>hive.metastore.uris</name>
<value>thrift://hms:9083</value>
</property>
alias d=docker
d stop hs2
d rm hs2 -v
d run -d -p 10000:10000 -p 10002:10002 --env SERVICE_NAME=hiveserver2 \
--env SERVICE_OPTS="-Dhive.metastore.uris=thrift://hms:9083" \
--env IS_RESUME="true" \
-v ~/hive/hs2/hive-site.xml:/opt/hive/conf/hive-site.xml \
--network mynetwork \
--name hs2 apache/hive:4.0.1
docker exec -it hs2 beeline -u jdbc:hive2://localhost:10000
0: jdbc:hive2://localhost:10000> create database mydb;
0: jdbc:hive2://localhost:10000> show databases;
+----------------+
| database_name |
+----------------+
| default |
| mydb |
+----------------+
2 rows selected (0.028 seconds)
0: jdbc:hive2://localhost:10000> create table employees (id int, name string, age int);
0: jdbc:hive2://localhost:10000> insert into employees(name,age) values ("alex",10);
----------------------------------------------------------------------------------------------
VERTICES MODE STATUS TOTAL COMPLETED RUNNING PENDING FAILED KILLED
----------------------------------------------------------------------------------------------
Map 1 .......... container SUCCEEDED 1 1 0 0 0 0
Reducer 2 ...... container SUCCEEDED 1 1 0 0 0 0
----------------------------------------------------------------------------------------------
VERTICES: 02/02 [==========================>>] 100% ELAPSED TIME: 1.54 s
----------------------------------------------------------------------------------------------
1 row affected (10.8 seconds)
0: jdbc:hive2://localhost:10000> show tables;
+------------+
| tab_name |
+------------+
| employees |
+------------+
1 row selected (0.18 seconds)
ubuntu@DESKTOP-SCOK45O:~$ docker exec -it hms bash
hive@5ce2a3f8c1c4:/opt/hive$ rm -f /opt/hive/metastore_db/db.lck
hive@5ce2a3f8c1c4:/opt/hive$ rm -f /opt/hive/metastore_db/dbex.lck
java -jar /opt/hive/derby/lib/derbyrun.jar ij
ij version 10.14
ij> CONNECT 'jdbc:derby:/opt/hive/metastore_db';
ij> select tbl_name from tbls;
TBL_NAME
--------------------------------------------------------------------------------------------------------------------------------
employees
1 row selected