gpt4 book ai didi

python - 如何指定分配给 hive 中查询的最大 vcores?

转载 作者:行者123 更新时间:2023-12-02 06:39:41 30 4
gpt4 key购买 nike

我正在配置单元上运行多个查询。我有一个 6 个节点的 Hadoop 集群。集群中的 vcore 总数为 21。

我只需要将 2 个核心分配给 python 进程,以便其余可用核心将由另一个主进程使用。

代码

from pyhive import hive
hive_host_name = "subdomain.domain.com"
hive_port = 20000
hive_user = "user"
hive_password = "password"
hive_database = "database"

conn = hive.Connection(host=hive_host_name, port=hive_port,username=hive_user, database=hive_database, configuration={})
cursor = conn.cursor()
cursor.execute('select count(distinct field) from somedata')

最佳答案

尝试在配置映射中传递以下设置:

yarn.nodemanager.resource.cpu-vcores=2

此设置的默认值为 8。

描述:可以为容器分配的CPU核心数。

您更新后的代码将类似于:

from pyhive import hive
hive_host_name = "subdomain.domain.com"
hive_port = 20000
hive_user = "user"
hive_password = "password"
hive_database = "database"
configuration = {
"yarn.nodemanager.resource.cpu-vcores": 2
}

conn = hive.Connection( \
host=hive_host_name,
port=hive_port,
username=hive_user,
database=hive_database,
configuration=configuration
)
cursor = conn.cursor()
cursor.execute('select count(distinct field) from somedata')

Reference URL

关于python - 如何指定分配给 hive 中查询的最大 vcores?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58831467/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com