bash 如何确定 Hive 数据库大小?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/45691447/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How determine Hive database size?
提问by Aleks Ya
How determine Hive's database size from Bash
or from Hive CLI
?
如何确定 Hive 的数据库大小 fromBash
或 from Hive CLI
?
hdfs
and hadoop
commands are also avaliable in Bash
.
hdfs
和hadoop
命令也可以在Bash
.
回答by Alex Libov
A database in hive is a metadata storage - meaning it holds information about tables and has a default location. Tables in a database can also be stored anywhere in hdfs
if location
is specified when creating a table.
hive 中的数据库是元数据存储 - 这意味着它保存有关表的信息并具有默认位置。数据库中的表也可以存储在任何地方在hdfs
,如果location
在创建表时指定。
You can see all tables in a database using show tables
command in Hive CLI
.
您可以使用show tables
in中的命令查看数据库中的所有表Hive CLI
。
Then, for each table, you can find its location in hdfs
using describe formatted <table name>
(again in Hive CLI
).
然后,对于每个表,您可以在hdfs
using 中找到它的位置describe formatted <table name>
(再次在 中Hive CLI
)。
Last, for each table you can find its size using hdfs dfs -du -s -h /table/location/
最后,对于每个表,您可以使用 hdfs dfs -du -s -h /table/location/
I don't think there's a single command to measure the sum of sizes of all tables of a database. However, it should be fairly easy to write a script that automates the above steps. Hive can also be invoked from bash CLI
using: hive -e '<hive command>'
我认为没有一个命令可以测量数据库所有表的大小总和。但是,编写一个自动执行上述步骤的脚本应该相当容易。也可以bash CLI
使用以下方法调用 Hive :hive -e '<hive command>'
回答by Aleks Ya
Show Hive databases on HDFS
在 HDFS 上显示 Hive 数据库
sudo hadoop fs -ls /apps/hive/warehouse
Show Hive database size
显示 Hive 数据库大小
sudo hadoop fs -du -s -h /apps/hive/warehouse/{db_name}
回答by pranav
if you want the size of your complete database run this on your "warehouse"
如果您希望完整数据库的大小在您的“仓库”上运行
hdfs dfs -du -h /apps/hive/warehouse
this gives you the size of each DB in your warehouse
这为您提供了仓库中每个数据库的大小
if you want the size of tables in a specific DB run:
如果您想要特定数据库运行中表的大小:
hdfs dfs -du -h /apps/hive/warehouse/<db_name>
run a "grep warehouse" on hive-site.xml to find your warehouse path
在 hive-site.xml 上运行“grep 仓库”以找到您的仓库路径