本文为您介绍如何通过命令方式访问Trino控制台。
前提条件
已创建包含Trino服务的集群。创建详情请参见创建集群。
普通集群
说明 如果创建集群时未打开Kerberos身份认证开关,则创建的集群即为普通集群。
- 通过SSH方式登录集群,详情请参见登录集群。
- 执行如下命令,进入Trino控制台。
trino --server master-1-1:9090 --catalog hive --schema default --user hadoop
如果您创建的是Hadoop集群,请使用以下命令。presto --server emr-header-1:9090 --catalog hive --schema default --user hadoop
- 执行如下命令,查看当前Catalog下的Schema。
show schemas;
返回如下信息。Schema -------------------- default emr_presto_init__ information_schema (3 rows)
- 可选: 执行
quit;
,可以退出Trino控制台。
高安全集群
说明 如果创建集群时打开了Kerberos身份认证开关,则创建的集群即为高安全集群。EMR-3.43及之后版本、EMR-5.9及之后版本的Datalake和自定义集群的Trino支开启持高安全(Kerberos)。
Datalake和自定义集群
集群创建完成后,执行以下命令连接Trino。
trino --server https://${FQDN}:7778 \
--krb5-config-path /etc/krb5.conf \
--keystore-path /etc/emr/trino-conf/keystore \
--keystore-password ${pwd} \
--krb5-keytab-path /etc/emr/trino-conf/trino.keytab \
--krb5-principal trino/${FQDN}@${REALM} \
--krb5-remote-service-name trino \
--user trino/${FQDN}
参数 | 说明 |
---|---|
${FQDN} | master-1-1节点的FQDN,可通过hostname -f 命令获取,格式为master-1-1.c-xxxxxxx.cn-xxxxxx.emr.aliyuncs.com 。 |
--krb5-config-path | config.properties中http.authentication.krb5.config 的值,固定为/etc/krb5.conf 。 |
--keystore-path | config.properties中http-server.https.keystore.path 的值,固定为/etc/emr/trino-conf/keystore 。 |
--keystore-password | config.properties中http-server.https.keystore.key 的值,即${pwd},需自行获取,可以在master-1-1节点上执行命令awk -F= '/http-server.https.keystore.key/{print $2}' ${TRINO_CONF_DIR}/config.properties 查看。 |
--krb5-keytab-path | config.properties中http-server.authentication.krb5.keytab 的值,固定为/etc/emr/trino-conf/trino.keytab 。 |
${REALM} | config.properties中http-server.authentication.krb5.user-mapping.pattern 的值,需自行获取,EMR内部KERBEROS的REALM格式为EMR.C-XXXXXX.COM 。 |
--krb5-remote-service-name | config.properties中的http-server.authentication.krb5.service-name 的值,固定为trino 。 |
Hadoop集群
- 通过SSH方式登录集群,详情请参见登录集群。
- 添加Principal并导出keytab文件。
- 执行如下命令,进入Presto控制台。
presto --server https://<hostname>:7778 \ --catalog hive \ --schema default \ --keystore-path /etc/ecm/presto-conf/keystore \ --keystore-password <passwd> \ --krb5-keytab-path <keytab_file> \ --krb5-principal <username>@EMR.<cluster_id>.COM \ --krb5-remote-service-name presto \ --user <username>
参数 描述 hostname 需要您在集群emr-header-1节点上执行 hostname
命令获取,格式为emr-header-1.cluster-xxx。passwd 需要您在集群emr-header-1节点上执行 sed -n 's/http-server.https.keystore.key=\([^;]*\)/\1/p' /etc/ecm/presto-conf/config.properties
命令获取。keytab_file 导出的keytab文件的路径。本文示例为/home/test.keytab。 username 创建的keytab文件的Principal。本文示例为test。 cluster_id 需要您在集群emr-header-1节点上执行 hostname | grep -Eo '[0-9]+$'
命令获取。 - 执行如下命令,查看当前Catalog下的Schema。
show schemas;
- 可选: 执行
quit;
,可以退出Presto控制台。