python - 如何指定要分配给 hive 中的查询的最大 vcores?
问题描述
我在蜂巢上运行多个查询。我有一个有 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。
描述:Number of CPU cores that can be allocated for containers.
您更新的代码将如下所示:
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')
推荐阅读
- laravel - Lavarel & Vue 电子商务:如何将订单发布为一系列产品而不是单个产品
- docker - 使用 docker 的 keycloak 存在凭证密钥问题
- javascript - Angular:了解 DI 如何在动态加载的组件中工作
- sorting - 排序不适用于自定义 ProductListComponentService。(CustomProductListComponentService)
- php - 在 laravel 功能测试中断言 200 与 302 相同失败
- c++ - 错误:找不到 Visual Studio 2019 Fortran 支持的 CMAKE_Fortran_COMPILER
- javascript - 如何比较 javascript 中的 CSS 变量?
- matlab - 如何对齐原始信号和滤波信号以进行分析?
- javascript - 将整数列表从 AJAX 调用传递给 C# 方法返回 null
- python - “conda env list”总是返回“y/N”,并且两个答案都没有返回任何东西,但是“conda info --envs”工作得很好吗?