3. Hive安裝

qdice007@gmail.com 2018-04-23 15:00

寫在前面的廢話

我們要基于之前搭建的Hadoop集群上安裝,配置和使用Hive.下面對整個環(huán)境做個回憶:

集群概況

三臺虛擬機(CentOS7): bd-1, bd-2, bd-3

  • bd-1: NameNode主, ResourceManager備
  • bd-2: NameNdoe備, ResourceManager主
  • bd-3: DataNode, NodeManager

啟動Hadoop環(huán)境

如無特殊說明,下列操作機器均為Hadoop集群中的bd-2主機,操作用戶均為之前安裝
Hadoop時的libing用戶,其家目錄是/home/libing

1. 啟動ZooKeeper

下面是啟動ZooKeeper的腳本內(nèi)容(就不需要在每個節(jié)點上重復(fù)操作了)

[libing@bd-1 ~]$ cat zkStartAll.sh 
#!/bin/bash
echo "Start ZooKeeper service ..."
for i in 1 2 3
do
    ssh bd-$i "source /etc/profile ; zkServer.sh start"
done
echo "ZooKeeper started!"

在bd-1上執(zhí)行該腳本

[libing@bd-1 ~]$ ./zkStartAll.sh 
Start ZooKeeper service ...
ZooKeeper JMX enabled by default
Using config: /home/libing/zookeeper-3.4.10/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
ZooKeeper JMX enabled by default
Using config: /home/libing/zookeeper-3.4.10/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
ZooKeeper JMX enabled by default
Using config: /home/libing/zookeeper-3.4.10/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
ZooKeeper started!

2. 啟動HDFS(NameNode, DataNode)

[libing@bd-1 ~]$ /home/libing/hadoop-2.9.0/sbin/start-dfs.sh
Starting namenodes on [bd-1 bd-2]
bd-1: starting namenode, logging to /home/libing/hadoop-2.9.0/logs/hadoop-libing-namenode-bd-1.out
bd-2: starting namenode, logging to /home/libing/hadoop-2.9.0/logs/hadoop-libing-namenode-bd-2.out
bd-3: starting datanode, logging to /home/libing/hadoop-2.9.0/logs/hadoop-libing-datanode-bd-3.out
Starting journal nodes [bd-3]
bd-3: starting journalnode, logging to /home/libing/hadoop-2.9.0/logs/hadoop-libing-journalnode-bd-3.out
Starting ZK Failover Controllers on NN hosts [bd-1 bd-2]
bd-1: zkfc running as process 2026. Stop it first.
bd-2: starting zkfc, logging to /home/libing/hadoop-2.9.0/logs/hadoop-libing-zkfc-bd-2.out

3. 啟動YARN(ResourceManager主, NodeManager)

[libing@bd-2 ~]$ /home/libing/hadoop-2.9.0/sbin/start-yarn.sh
starting yarn daemons
starting resourcemanager, logging to /home/libing/hadoop-2.9.0/logs/yarn-libing-resourcemanager-bd-2.out
bd-3: starting nodemanager, logging to /home/libing/hadoop-2.9.0/logs/yarn-libing-nodemanager-bd-3.out

4. 啟動YARN(ResourceManager備)

[libing@bd-1 ~]$ /home/libing/hadoop-2.9.0/sbin/yarn-daemon.sh start resourcemanager
starting resourcemanager, logging to /home/libing/hadoop-2.9.0/logs/yarn-libing-resourcemanager-bd-1.out

5. 啟動HistoryServer

[libing@bd-2 ~]$ /home/libing/hadoop-2.9.0/sbin/mr-jobhistory-daemon.sh start historyserver
starting historyserver, logging to /home/libing/hadoop-2.9.0/logs/mapred-libing-historyserver-bd-2.out

6. 檢查每臺虛擬機中的JPS

[libing@bd-1 ~]$ jps
2592 ResourceManager
1747 QuorumPeerMain
2026 DFSZKFailoverController
2191 NameNode
[libing@bd-2 ~]$ jps
2032 JobHistoryServer
1379 QuorumPeerMain
1731 ResourceManager
1607 DFSZKFailoverController
1485 NameNode
[libing@bd-3 ~]$ jps
1408 NodeManager
1299 JournalNode
1095 QuorumPeerMain
1194 DataNode

7. 查看NameNode的HA狀態(tài)

[libing@bd-1 ~]$ hdfs haadmin -getAllServiceState
bd-1:9000                                          active    
bd-2:9000                                          standby

順便寫一下關(guān)閉Hadoop環(huán)境的步驟

[libing@bd-2 conf]$ mr-jobhistory-daemon.sh stop historyserver
stopping historyserver
[libing@bd-2 conf]$ 
[libing@bd-2 conf]$ stop-yarn.sh
stopping yarn daemons
stopping resourcemanager
bd-3: stopping nodemanager
bd-3: nodemanager did not stop gracefully after 5 seconds: killing with kill -9
no proxyserver to stop
[libing@bd-1 wordcount]$ yarn-daemon.sh stop resourcemanager
stopping resourcemanager
[libing@bd-1 wordcount]$ stop-dfs.sh
Stopping namenodes on [bd-1 bd-2]
bd-2: stopping namenode
bd-1: stopping namenode
bd-3: stopping datanode
Stopping journal nodes [bd-3]
bd-3: stopping journalnode
Stopping ZK Failover Controllers on NN hosts [bd-1 bd-2]
bd-1: stopping zkfc
bd-2: stopping zkfc
[libing@bd-1 wordcount]$ cd
[libing@bd-1 ~]$ ./zkStopAll.sh 
Stop ZooKeeper service ...
ZooKeeper JMX enabled by default
Using config: /home/libing/zookeeper-3.4.10/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
ZooKeeper JMX enabled by default
Using config: /home/libing/zookeeper-3.4.10/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
ZooKeeper JMX enabled by default
Using config: /home/libing/zookeeper-3.4.10/bin/../conf/zoo.cfg
Stopping zookeeper ... STOPPED
ZooKeeper stopped!

開始

準(zhǔn)備

1. 啟動Hadoop環(huán)境至正常使用狀態(tài)

步驟請參考上面的內(nèi)容

2. 下載Hive安裝包

從Apache Hive官網(wǎng)下載安裝包,放入目錄/home/libing/softwares下

  • apache-hive-2.3.2-bin.tar.gz

3. 下載MySQL安裝包及其JDBC軟件包

從MySQL官網(wǎng)下載安裝包,放入目錄/home/libing/softwares下

  • mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz
  • mysql-connector-java-5.1.46.tar.gz

安裝MySQL

Hive可以使用內(nèi)置的Derby數(shù)據(jù)庫來作為其元數(shù)據(jù)的存儲數(shù)據(jù)庫,但也可以使用外部的
數(shù)據(jù)庫來存放其元數(shù)據(jù),這里我們使用MySQL數(shù)據(jù)庫.

1. 解壓MySQL軟件包,并拷貝到/usr/loca/目錄下,目錄改名為mysql

[libing@bd-2 softwares]$ tar xzf mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz 
[libing@bd-2 softwares]$ sudo cp -r mysql-5.7.18-linux-glibc2.5-x86_64 /usr/local/mysql
[libing@bd-2 softwares]$ ll /usr/local/mysql
總用量 36
drwxr-xr-x  2 root root  4096 4月  12 13:53 bin
-rw-r--r--  1 root root 17987 4月  12 13:53 COPYING
drwxr-xr-x  2 root root    55 4月  12 13:53 docs
drwxr-xr-x  3 root root  4096 4月  12 13:53 include
drwxr-xr-x  5 root root   229 4月  12 13:53 lib
drwxr-xr-x  4 root root    30 4月  12 13:53 man
-rw-r--r--  1 root root  2478 4月  12 13:53 README
drwxr-xr-x 28 root root  4096 4月  12 13:53 share
drwxr-xr-x  2 root root    90 4月  12 13:53 support-files

2. 增加mysql組和用戶,并修改軟件目錄的組和屬主

[libing@bd-2 softwares]$ sudo groupadd mysql
[libing@bd-2 softwares]$ sudo useradd -r -g mysql mysql
[libing@bd-2 softwares]$ cd /usr/local/mysql
[libing@bd-2 mysql]$ sudo chown -R mysql:mysql ./
[libing@bd-2 mysql]$ ll
總用量 36
drwxr-xr-x  2 mysql mysql  4096 4月  12 13:53 bin
-rw-r--r--  1 mysql mysql 17987 4月  12 13:53 COPYING
drwxr-xr-x  2 mysql mysql    55 4月  12 13:53 docs
drwxr-xr-x  3 mysql mysql  4096 4月  12 13:53 include
drwxr-xr-x  5 mysql mysql   229 4月  12 13:53 lib
drwxr-xr-x  4 mysql mysql    30 4月  12 13:53 man
-rw-r--r--  1 mysql mysql  2478 4月  12 13:53 README
drwxr-xr-x 28 mysql mysql  4096 4月  12 13:53 share
drwxr-xr-x  2 mysql mysql    90 4月  12 13:53 support-files

3. 編輯配置文件my.cnf

[libing@bd-2 mysql]$ ll /etc/my.cnf
-rw-r--r--. 1 root root 570 6月   8 2017 /etc/my.cnf
[libing@bd-2 mysql]$ sudo cp /etc/my.cnf /etc/my.cnf.bak
[libing@bd-2 mysql]$ sudo cat /dev/null>/etc/my.cnf && vim /etc/my.cnf
[libing@bd-2 ~]$ cat /etc/my.cnf
[client]
port=3306
socket=/tmp/mysql.sock
[mysqld]
character_set_server=utf8
init_connect="SET NAMES utf8"
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
log-error=/var/log/mysqld.log
pid-file=/usr/local/mysql/mysqld.pid
lower_case_table_names=1
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
max_connections=5000

4. 安裝庫libaio

[libing@bd-2 mysql]$ sudo yum install libaio
......
軟件包 libaio-0.3.109-13.el7.x86_64 已安裝并且是最新版本
無須任何處理

5. 創(chuàng)建日志文件mysqld.log

[libing@bd-2 mysql]$ sudo touch /var/log/mysqld.log
[libing@bd-2 mysql]$ sudo chown mysql:mysql /var/log/mysqld.log 
[libing@bd-2 mysql]$ ll /var/log/mysqld.log 
-rw-r--r-- 1 mysql mysql 0 4月  12 14:04 /var/log/mysqld.log

6. 初始化數(shù)據(jù)庫

[libing@bd-2 mysql]$ sudo /usr/local/mysql/bin/mysqld  --initialize --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data
[libing@bd-2 mysql]$ cat /var/log/mysqld.log 
2018-04-12T06:16:12.818857Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-04-12T06:16:12.978432Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-04-12T06:16:13.044058Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-04-12T06:16:13.119656Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 0013b18d-3e19-11e8-abcc-000c29a0ecc2.
2018-04-12T06:16:13.122469Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-04-12T06:16:13.124245Z 1 [Note] A temporary password is generated for root@localhost: *se<LkQH6opT

注意,最后有個字符串 *se<LkQH6opT 一定要記住,這是MySQL root用戶的初始密碼,
后面登錄MySQL時需要用到它.

7. 配置系統(tǒng)環(huán)境

編輯/etc/profile

[libing@bd-2 mysql]$ sudo vim /etc/profile

在文件的最后添加如下內(nèi)容

# Added for MySQL
PATH=$PATH:/usr/local/mysql/bin
export PATH

使之馬上生效

[libing@bd-2 mysql]$ source /etc/profile

8. 啟動MySQL服務(wù),并查看其狀態(tài),以及停止服務(wù)

[libing@bd-2 mysql]$ sudo cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
[libing@bd-2 mysql]$ sudo service mysql start
Starting MySQL. SUCCESS! 
[libing@bd-2 mysql]$ sudo service mysql status
 SUCCESS! MySQL running (2530)
[libing@bd-2 mysql]$ sudo service mysql stop
Shutting down MySQL.. SUCCESS! 

9. 將MySQL加入到開機自啟動服務(wù),并啟動它

[libing@bd-2 mysql]$ sudo chkconfig --add mysql
[libing@bd-2 mysql]$ sudo service mysql start
Starting MySQL. SUCCESS!

10. 使用root用戶登錄MySQL,并修改其密碼和可以在遠(yuǎn)程主機訪問它

[libing@bd-2 mysql]$ mysql -u root -p
Enter password: 
......
mysql> set password = password('root123');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> use mysql
Database changed
mysql> select host,user,authentication_string from user;
+-----------+-----------+-------------------------------------------+
| host      | user      | authentication_string                     |
+-----------+-----------+-------------------------------------------+
| localhost | root      | *FAAFFE644E901CFAFAEC7562415E5FAEC243B8B2 |
| localhost | mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE |
+-----------+-----------+-------------------------------------------+
2 rows in set (0.00 sec)
mysql> update user set host='%' where user = 'root' ;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0
mysql> commit ;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges ;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye

11. 在MySQL中創(chuàng)建hive_db數(shù)據(jù)庫和hive用戶

[libing@bd-2 ~]$ mysql -uroot -p
Enter password: 
......
mysql> create database hive_db ;
Query OK, 1 row affected (0.01 sec)
mysql> show databases ;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| hive_db            |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)
mysql> create user hive identified by 'hive123';
Query OK, 0 rows affected (0.02 sec)
mysql> grant all privileges on hive_db.* to 'hive'@'%' identified by 'hive123' ;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> quit
Bye

驗證

[libing@bd-2 conf]$ mysql -uhive -p
Enter password: 
......
mysql> use hive_db ;
Database changed
mysql> quit
Bye

安裝Hive

1. 解壓Hive軟件包,并做鏈接

[libing@bd-2 ~]$ cd /home/libing/softwares
[libing@bd-2 softwares]$ ll
總用量 808360
-rw-rw-r--  1 libing libing 231740978 4月  12 14:50 apache-hive-2.3.2-bin.tar.gz
-rw-rw-r--. 1 libing libing 366744329 12月 20 12:36 hadoop-2.9.0.tar.gz
-rw-rw-r--. 1 libing libing 189784266 12月 21 15:25 jdk-8u152-linux-x64.tar.gz
drwxr-xr-x  3 libing libing       178 2月  26 21:28 mysql-connector-java-5.1.46
-rw-rw-r--  1 libing libing   4434926 4月  12 14:48 mysql-connector-java-5.1.46.tar.gz
-rw-rw-r--. 1 libing libing  35042811 12月 20 12:36 zookeeper-3.4.10.tar.gz
[libing@bd-2 softwares]$ cp apache-hive-2.3.2-bin.tar.gz ../
[libing@bd-2 softwares]$ cd ../
[libing@bd-2 ~]$ tar xzf apache-hive-2.3.2-bin.tar.gz 
[libing@bd-2 ~]$ ll
總用量 226348
drwxrwxr-x  10 libing libing       184 4月  12 14:51 apache-hive-2.3.2-bin
......
[libing@bd-2 ~]$ sudo ln -s /home/libing/apache-hive-2.3.2-bin/ /usr/local/hive
[libing@bd-2 ~]$ ll /usr/local
......
lrwxrwxrwx   1 root  root   35 4月  12 14:53 hive -> /home/libing/apache-hive-2.3.2-bin/

2. 將MySQL JDBC包解壓,并拷貝jar文件到Hive軟件目錄中的lib子目錄下

[libing@bd-2 ~]$ cd /home/libing/softwares
[libing@bd-2 softwares]$ tar xzf mysql-connector-java-5.1.46.tar.gz 
[libing@bd-2 softwares]$ ll
......
drwxr-xr-x  3 libing libing       178 2月  26 21:28 mysql-connector-java-5.1.46
[libing@bd-2 softwares]$ ll mysql-connector-java-5.1.46
......
-rw-r--r-- 1 libing libing 1004840 2月  26 21:28 mysql-connector-java-5.1.46-bin.jar
-rw-r--r-- 1 libing libing 1004838 2月  26 21:28 mysql-connector-java-5.1.46.jar
......
[libing@bd-2 softwares]$ cp mysql-connector-java-5.1.46/mysql-connector-java-5.1.46*.jar ~/apache-hive-2.3.2-bin/lib

3. 配置系統(tǒng)環(huán)境

[libing@bd-2 ~]$ sudo vim /etc/profile

在文件的最后增加如下內(nèi)容

# Added for Hive
HIVE_HOME=/usr/local/hive
export HIVE_HOME
PATH=$PATH:${HIVE_HOME}/bin
export PATH

使之馬上生效

[libing@bd-2 ~]$ source /etc/profile

配置Hive

1. 在HDFS中創(chuàng)建一些目錄

[libing@bd-2 ~]$ hadoop fs -mkdir /tmp
mkdir: `/tmp': File exists
[libing@bd-2 ~]$ hadoop fs -mkdir -p /user/hive/warehouse
[libing@bd-2 ~]$ hadoop fs -chmod 777 /tmp
[libing@bd-2 ~]$ hadoop fs -chmod 777 /user/hive/warehouse

2. 創(chuàng)建Hive配置文件,并編輯

[libing@bd-2 conf]$ cd /usr/local/hive/conf
[libing@bd-2 conf]$ ll
總用量 288
-rw-r--r-- 1 libing libing   1596 11月 10 00:25 beeline-log4j2.properties.template
-rw-r--r-- 1 libing libing 257573 11月 10 01:11 hive-default.xml.template
-rw-r--r-- 1 libing libing   2365 11月 10 00:25 hive-env.sh.template
-rw-r--r-- 1 libing libing   2274 11月 10 00:25 hive-exec-log4j2.properties.template
-rw-r--r-- 1 libing libing   2925 11月 10 00:26 hive-log4j2.properties.template
-rw-r--r-- 1 libing libing   2060 11月 10 00:25 ivysettings.xml
-rw-r--r-- 1 libing libing   2719 11月 10 00:26 llap-cli-log4j2.properties.template
-rw-r--r-- 1 libing libing   7041 11月 10 00:26 llap-daemon-log4j2.properties.template
-rw-r--r-- 1 libing libing   2662 11月 10 00:25 parquet-logging.properties
[libing@bd-2 conf]$ cp hive-env.sh.template hive-env.sh
[libing@bd-2 conf]$ cp hive-default.xml.template hive-site.xml
[libing@bd-2 conf]$ cp hive-log4j2.properties.template hive-log4j2.properties
[libing@bd-2 conf]$ cp hive-exec-log4j2.properties.template hive-exec-log4j2.properties

其中 hive-env.sh, hive-log4j2.properties, hive-exec-log4j2.properties內(nèi)容可以保持默認(rèn),暫時不必改動.
重點是 hive-site.xml 文件的修改

啟動Hive

1. 初始化

[libing@bd-2 ~]$ /usr/local/hive/bin/schematool -dbType mysql -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/libing/apache-hive-2.3.2-bin/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/libing/hadoop-2.9.0/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Metastore connection URL:    jdbc:mysql://localhost/hive_db?createDatabaseIfNotExist=true
Metastore Connection Driver :    org.apache.derby.jdbc.EmbeddedDriver
Metastore connection User:   hive
Fri Apr 13 10:30:18 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Starting metastore schema initialization to 2.3.0
Initialization script hive-schema-2.3.0.mysql.sql
Fri Apr 13 10:30:19 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
Initialization script completed
Fri Apr 13 10:30:21 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
schemaTool completed

2. 使用hive客戶端,并簡單創(chuàng)建一個表

[libing@bd-2 ~]$ hive
which: no hbase in (/home/libing/zookeeper-3.4.10/bin:/usr/local/jdk//bin:/home/libing/zookeeper-3.4.10/bin:/usr/local/jdk//bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/libing/hadoop-2.9.0/bin:/home/libing/hadoop-2.9.0/sbin:/usr/local/mysql/bin:{/usr/local/hive}/bin:/home/libing/.local/bin:/home/libing/bin:/home/libing/hadoop-2.9.0/bin:/home/libing/hadoop-2.9.0/sbin:/usr/local/mysql/bin:/usr/local/hive/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/libing/apache-hive-2.3.2-bin/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/libing/hadoop-2.9.0/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]

Logging initialized using configuration in file:/home/libing/apache-hive-2.3.2-bin/conf/hive-log4j2.properties Async: true
Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
hive> create table test(id int, name string);
OK
Time taken: 10.034 seconds
hive> show tables;
OK
test
Time taken: 0.577 seconds, Fetched: 1 row(s)
hive> quit;

可以到MySQL中查看Hive的元數(shù)據(jù)(以剛創(chuàng)建的test表為例)

[libing@bd-2 conf]$ mysql -uhive -p
Enter password: 
......
mysql> use hive_db;
Database changed
mysql> select * from tbls;
+--------+-------------+-------+------------------+--------+-----------+-------+----------+---------------+--------------------+--------------------+--------------------+
| TBL_ID | CREATE_TIME | DB_ID | LAST_ACCESS_TIME | OWNER  | RETENTION | SD_ID | TBL_NAME | TBL_TYPE      | VIEW_EXPANDED_TEXT | VIEW_ORIGINAL_TEXT | IS_REWRITE_ENABLED |
+--------+-------------+-------+------------------+--------+-----------+-------+----------+---------------+--------------------+--------------------+--------------------+
|      1 |  1523589322 |     1 |                0 | libing |         0 |     1 | test     | MANAGED_TABLE | NULL               | NULL               |                    |
+--------+-------------+-------+------------------+--------+-----------+-------+----------+---------------+--------------------+--------------------+--------------------+
2 rows in set (0.00 sec)
mysql> quit
Bye

SQL實驗

結(jié)束

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容