1.在kmr集群所有节点Presto的/etc/presto/catalog
目录下创建mysql.properties
,并加入以下内容:
connector.name=mysql
connection-url=jdbc:mysql://$host:$port
connection-user=ambari
connection-password=ambari
其中$host
为集群master节点的IP,$port
为您的端口号。
2.在Ambari控制台界面中 Services>Presto>Service Actions重启。
然后切换到 presto-client
文件夹中,并且使用 Presto 连接 Mysql:
/usr/lib/presto/bin/presto-cli --server kmr-4014e7ad-gn-bdf258f3-master-1-001.ksc.com:8285 --catalog mysql
其中 --catalog
参数表示要操纵的数据库类型,执行成功后即可进入 Presto 的界面,并且直接进入指定的数据库。可以使用Mysql 来查看数据库中的表:
#查看所有MySQL数据库
presto> SHOW SCHEMAS FROM mysql;
Schema
--------------------
ambari
hive
hue
information_schema
performance_schema
test
(6 rows)
Query 20210202_100436_00008_ujqvm, FINISHED, 4 nodes
Splits: 53 total, 53 done (100.00%)
0:00 [6 rows, 83B] [30 rows/s, 417B/s]
# 查看某个MySQL数据库下的所有表
presto> SHOW TABLES FROM hive;
Table
---------------------------
aux_table
bucketing_cols
cds
columns_v2
compaction_queue
completed_compactions
completed_txn_components
database_params
#查看某个表的所有列
presto> SHOW COLUMNS FROM hive.db_privs;
Column | Type | Extra | Comment
----------------+--------------+-------+---------
db_grant_id | bigint | |
create_time | integer | |
db_id | bigint | |
grant_option | smallint | |
grantor | varchar(128) | |
grantor_type | varchar(128) | |
principal_name | varchar(128) | |
principal_type | varchar(128) | |
db_priv | varchar(128) | |
(9 rows)
文档内容是否对您有帮助?
评价建议不能为空
非常感谢您的反馈,我们会继续努力做到更好!