Kudu异常总结

面试:你懂什么是分布式系统吗?Redis分布式锁都不会?>>>   hot3.png

1、impala不支持kudu表的关键字:PARTITIONED - LOCATION - ROWFORMAT(官方链接:Impala Keywords Not Supported for Kudu Tables),例如执行如下语句会报错:

CREATE TABLE my_first_table2
(
  id BIGINT,
  name STRING,
  PRIMARY KEY(id)
)
PARTITION BY HASH PARTITIONS 16
STORED AS KUDU
LOCATION 'hdfs://namenodetest01.bi/user/impala';

异常信息:

ERROR: AnalysisException: LOCATION cannot be specified for a Kudu table.

2、kudu表的主键必须在建表语句中列的最前面,并且不为空,例如执行如下语句会报错:

CREATE TABLE `t_scd_order_kudu_2` (
  `id` bigint,
  `order_no` string,
  `member_id` bigint,
  `driver_id` bigint,
  `vehicle_id` bigint,
  `origin` smallint,
  `start_city_id` int,
  `end_city_id` int,
  `estimate_board_time` string,
  `actual_board_time` string,
  `estimate_car_type` int,
  `actual_car_type` int,
  `service_type_id` smallint,
  `status` smallint,
  `balance_status` smallint,
  `balance_time` string,
  `passenger` string,
  `passenger_mobile` string,
  `comment_status` tinyint,
  `remark` string,
  `create_emp` bigint,
  `create_time` string,
  `modify_emp` bigint,
  `modify_time` string,
  `ts` string,
  `dispatch_status` smallint,
  `device_no` string,
  `ent_id` bigint,
  `invalid_type` smallint,
  `dispatch_flag` smallint,
  `share_status` smallint,
  `last_dispatch_flag` smallint,
  `home_popup` tinyint,
  `detail_popup` tinyint,
  `red_point` tinyint,
  `free_ride` tinyint,
  `ent_dept_id` bigint,
  `ent_type_id` int,
  `member_name` string,
  `member_mobile` string,
  `driver_name` string,
  `driver_mobile` string,
  `vehicle_no` string,
  `car_type_name` string,
  `ent_name` string,
  `ent_dept_name` string,
  `ent_type_name` string,
  `ent_pay_type` tinyint,
  `ent_code` string,
  `effect_response_rate` tinyint,
  `confirm_board_time` string,
  `invoice_status` smallint,
  `init_estimate_board_time` string,
  `passenger_country_code` smallint,
  `member_country_code` smallint,
  `delay_dispatch_time` int,
  `virtual_member_mobile` string,
  `virtual_passenger_mobile` string,
  `end_pl_city_code` string,
  `pl_city_code` string,
  `estimate_start_city_code` string,
  `estimate_end_city_code` string,
  `pay_mode` tinyint,
  day_of_time string,
  PRIMARY KEY (id, day_of_time)
)PARTITION BY HASH(day_of_time) PARTITIONS 16 STORED AS KUDU;

异常信息:

ERROR: ImpalaRuntimeException: Error creating Kudu table 'impala::kudu_test.t_scd_order_kudu_2'
CAUSED BY: NonRecoverableException: Got out-of-order key column: name: "day_of_time" type: STRING is_key: true is_nullable: false cfile_block_size: 0

原因:

[https://kudu.apache.org/docs/known_issues.html#_primary_keys](https://kudu.apache.org/docs/known_issues.html#_primary_keys)
[https://community.cloudera.com/t5/Interactive-Short-cycle-SQL/Received-ImpalaRuntimeException-Error-creating-Kudu-table/m-p/52449](https://community.cloudera.com/t5/Interactive-Short-cycle-SQL/Received-ImpalaRuntimeException-Error-creating-Kudu-table/m-p/52449)

3、kudu表的分区键必须为主键,例如执行如下语句会报错:

CREATE TABLE `t_scd_order_kudu_time` (
  `id` bigint,
  `order_no` string,
  `member_id` bigint,
  `driver_id` bigint,
  `vehicle_id` bigint,
  `origin` smallint,
  `start_city_id` int,
  `end_city_id` int,
  `estimate_board_time` string,
  `actual_board_time` string,
  `estimate_car_type` int,
  `actual_car_type` int,
  `service_type_id` smallint,
  `status` smallint,
  `balance_status` smallint,
  `balance_time` string,
  `passenger` string,
  `passenger_mobile` string,
  `comment_status` tinyint,
  `remark` string,
  `create_emp` bigint,
  `create_time` string,
  `modify_emp` bigint,
  `modify_time` string,
  `ts` string,
  `dispatch_status` smallint,
  `device_no` string,
  `ent_id` bigint,
  `invalid_type` smallint,
  `dispatch_flag` smallint,
  `share_status` smallint,
  `last_dispatch_flag` smallint,
  `home_popup` tinyint,
  `detail_popup` tinyint,
  `red_point` tinyint,
  `free_ride` tinyint,
  `ent_dept_id` bigint,
  `ent_type_id` int,
  `member_name` string,
  `member_mobile` string,
  `driver_name` string,
  `driver_mobile` string,
  `vehicle_no` string,
  `car_type_name` string,
  `ent_name` string,
  `ent_dept_name` string,
  `ent_type_name` string,
  `ent_pay_type` tinyint,
  `ent_code` string,
  `effect_response_rate` tinyint,
  `confirm_board_time` string,
  `invoice_status` smallint,
  `init_estimate_board_time` string,
  `passenger_country_code` smallint,
  `member_country_code` smallint,
  `delay_dispatch_time` int,
  `virtual_member_mobile` string,
  `virtual_passenger_mobile` string,
  `end_pl_city_code` string,
  `pl_city_code` string,
  `estimate_start_city_code` string,
  `estimate_end_city_code` string,
  `pay_mode` tinyint,
  day_of_time string,
  PRIMARY KEY (id)
)PARTITION BY HASH(day_of_time) PARTITIONS 16 STORED AS KUDU;

异常信息:

ERROR: AnalysisException: Column 'day_of_time' in 'HASH (day_of_time) PARTITIONS 16' is not a key column. Only key columns can be used in PARTITION BY.

4、impala内存溢出异常:

异常一:

Memory limit exceeded: Failed to allocate tuple buffer
HDFS_SCAN_NODE (id=0) could not allocate 2.64 MB without exceeding limit.
Error occurred on backend hadoop_datanode06_lbs:22000 by fragment 784458fdf0078462:e531b08600000002
Memory left in process limit: 1.64 MB
Query(784458fdf0078462:e531b08600000000): Reservation=0 ReservationLimit=60.40 GB OtherMemory=35.81 GB Total=35.81 GB Peak=35.81 GB
  Fragment 784458fdf0078462:e531b08600000002: Reservation=0 OtherMemory=35.81 GB Total=35.81 GB Peak=35.81 GB
    SORT_NODE (id=1): Total=35.72 GB Peak=35.72 GB
    HDFS_SCAN_NODE (id=0): Total=95.60 MB Peak=238.35 MB
    KrpcDataStreamSender (dst_id=2): Total=48.00 B Peak=48.00 B
    CodeGen: Total=80.92 KB Peak=11.54 MBProcess: Limit=75.49 GB Total=75.49 GB Peak=76.44 GB
  Buffer Pool: Free Buffers: Total=0
  Buffer Pool: Clean Pages: Total=0
  Buffer Pool: Unused Reservation: Total=-4.00 MB
  Data Stream Service Queue: Limit=3.77 GB Total=0 Peak=2.79 MB
  Data Stream Manager Early RPCs: Total=0 Peak=0
  TCMalloc Overhead: Total=98.69 MB
  RequestPool=fe-eval-exprs: Total=0 Peak=4.00 KB
  RequestPool=default-pool: Total=74.87 GB Peak=75.45 GB
    Query(784458fdf0078462:e531b08600000000): Reservation=0 ReservationLimit=60.40 GB OtherMemory=35.81 GB Total=35.81 GB Peak=35.81 GB
    Query(a4489e09d0418e18:8e8f242700000000): Reservation=4.00 MB ReservationLimit=60.40 GB OtherMemory=39.06 GB Total=39.06 GB Peak=39.07 GB
  Untracked Memory: Total=539.32 MB

异常二:

ERROR: ExecQueryFInstances rpc query_id=6e4e24d671c517d2:d9f6f13400000000 failed: Failed to get minimum memory reservation of 4.00 MB on daemon hadoop_datanode10_lbs:22000 for query 6e4e24d671c517d2:d9f6f13400000000 due to following error: Failed to increase reservation by 4.00 MB because it would exceed the applicable reservation limit for the "Process" ReservationTracker: reservation_limit=64.16 GB reservation=64.16 GB used_reservation=0 child_reservations=64.16 GB
The top 5 queries that allocated memory under this tracker are:
Query(b47f89cec2af2be:3012ffb200000000): Reservation=52.54 GB ReservationLimit=60.39 GB OtherMemory=38.42 MB Total=52.57 GB Peak=52.57 GB
Query(d84d2c69745c56e3:6698908700000000): Reservation=11.59 GB ReservationLimit=60.39 GB OtherMemory=38.33 MB Total=11.63 GB Peak=12.45 GB
Query(6e4e24d671c517d2:d9f6f13400000000): Reservation=0 ReservationLimit=60.39 GB OtherMemory=0 Total=0 Peak=0

参考链接:Impala - Memory limit exceeded

5、从hive的parquet表往kudu迁移数据时出现的主键重复警告,解决办法是改变主键列的值生成策略,警告如下:

WARNINGS: Key already present in Kudu table 'impala::kudu_test.t_scd_order_h_dt_month_range'. (1 of 3658 similar)

6、kudu新加入节点异常:

F1225 17:40:53.693409 11791 master_main.cc:77] Check failed: _s.ok() Bad status: Invalid argument: Unable to initialize catalog manager: Failed to initialize sys tables async: on-disk master list (hadoop-bi06-test1-rgtj5-tj1:7051, hadoop-bi07-test1-rgtj5-tj1:7051, hadoop20-test1-rgtj5-tj1:7051, hadoop21-test1-rgtj5-tj1:7051, hadoop22-test1-rgtj5-tj1:7051) and provided master list (hadoop20-test1-rgtj5-tj1:7051, hadoop21-test1-rgtj5-tj1:7051, hadoop22-test1-rgtj5-tj1:7051) differ. Their symmetric difference is: hadoop-bi06-test1-rgtj5-tj1:7051, hadoop-bi07-test1-rgtj5-tj1:7051

解决方案:

https://kudu.apache.org/docs/administration.html#migrate_to_multi_master

https://community.cloudera.com/t5/Interactive-Short-cycle-SQL/Adding-a-master-server-in-kudu/td-p/64612

7、impala集成kudu信息不完整报错:

Negotiation complete: Network error: Server connection negotiation failed: server connection from 10.104.132.72:12691: BlockingRecv error: Recv() got EOF from remote (error 108)
Metrics: {"server-negotiator.queue_time_us":84,"thread_start_us":41,"threads_started":1}

这主要是由于kudu节点改变后,impala配置文件中设置的kudu服务器地址不完全导致的,可以将/etc/default/impala中的kudu_master_hosts设置完全解决。

<think>好的,我现在需要解决用户关于Kudu 1.10版本中缺少`setBatchingMaxRows`参数的问题。首先,我得确认用户提到的这个参数具体是在哪个上下文中使用的。根据之前的对话,用户在使用Flink CDC连接Kudu时遇到了问题,特别是关于写入配置的参数设置。用户提到在Kudu 1.10中找不到`setBatchingMaxRows`,这可能是指Kudu客户端的配置参数,或者是Flink连接器中的某个设置。 首先,我需要回忆一下Kudu 1.10版本的API文档。Kudu本身在写入时确实有批次处理的相关配置,比如`KuduSession`的设置,包括`setMutationBufferSpace`和`flushMode`。可能用户提到的`setBatchingMaxRows`是某个特定连接器或客户端库中的方法,而在Kudu 1.10的原生API中可能没有这个确切的参数名称,或者有不同的实现方式。 接下来,参考用户提供的站内引用,特别是引用[1]中提到使用原生API进行删除操作时,只能使用主键作为条件,而用Impala则可以像普通SQL一样处理。这可能意味着用户在使用原生Kudu API时遇到了限制,而Impala作为上层工具提供了更灵活的操作方式。但用户当前的问题是关于写入批次的参数缺失,所以需要关注Kudu的写入配置。 用户引用的内容还提到了Kudu Tablet Server的内存配置调整,比如`block_cache_capacity_mb`和`memory_limit_hard_bytes`,这可能与写入性能有关,但并不是直接的批次行数设置。需要区分客户端参数和服务端参数的不同。 用户的问题是关于Kudu 1.10版本中缺少`setBatchingMaxRows`参数的替代方案。我需要考虑以下几点: 1. **确认Kudu 1.10的API是否有等效参数**:检查Kudu 1.10的官方文档,特别是`KuduSession`或相关写入配置的参数。例如,Kudu的`KuduSession`可能使用`setMutationBufferSpace`来限制缓冲区中的操作数,或者通过`setBatchSize`来控制批次大小。 2. **Flink连接器的版本兼容性**:用户之前提到使用Flink CDC连接Kudu,可能需要确认Flink Kudu连接器的版本是否与Kudu 1.10兼容,以及该连接器是否支持批次大小配置。例如,某些连接器可能封装了Kudu的API,并提供自己的配置参数,如`BatchingMaxRows`。 3. **替代方法实现批次控制**:如果原生API不支持直接设置批次行数,可能需要通过调整其他参数(如缓冲区大小、刷新间隔)或手动控制批次的提交来实现类似效果。 根据用户提供的引用[1],当使用原生API时,删除操作只能基于主键,而Impala可以处理更复杂的条件,这说明原生API的限制较多。因此,可能用户在使用Flink写入Kudu时,依赖的连接器或客户端库在Kudu 1.10中不支持`setBatchingMaxRows`参数,需要找到替代方法。 进一步分析,Kudu的写入批次通常由`KuduSession`管理,默认情况下会自动批量处理写入操作。相关参数可能包括: - `setMutationBufferSpace(int size)`:设置会话缓冲区中可以缓存的最大操作数。 - `setFlushInterval(long interval)`:设置自动刷新的时间间隔。 - `flushMode`:设置刷新模式,如手动刷新或自动刷新。 如果用户需要控制每个批次的行数,可以通过`setMutationBufferSpace`来限制缓冲区中的操作数量,当达到该数量时,会自动触发刷新。例如,设置为1000,则每积累1000个操作就会提交一次批次,相当于控制批次的行数。 另外,用户提到的`setBatchingMaxRows`可能来自某个特定的连接器或工具,比如Apache Beam的Kudu IO或其他第三方库。如果Flink的Kudu连接器在1.10版本中没有该参数,可能需要查看该连接器的文档,寻找替代配置,或者考虑升级连接器版本。 此外,用户可能需要手动实现批次控制。例如,在Flink的SinkFunction中累积一定数量的记录后,手动调用`flush`方法提交批次。这需要自定义代码来管理缓冲区和刷新逻辑。 最后,考虑版本升级的可能性。如果Kudu的更高版本或Flink连接器的更新版本支持所需的参数,建议用户升级到兼容的版本,以获得更好的功能和稳定性。 总结解决方案: 1. **使用Kudu原生API的缓冲区设置**:通过`KuduSession.setMutationBufferSpace`控制批次大小。 2. **调整刷新间隔**:结合`setFlushInterval`来定期提交批次。 3. **手动刷新控制**:在自定义Sink中累积行数,手动触发刷新。 4. **检查连接器文档**:确认使用的Flink Kudu连接器是否有其他替代参数。 5. **版本升级**:考虑升级Kudu或连接器到支持所需参数的版本。</think>### 针对 Kudu 1.10 缺少 `setBatchingMaxRows` 的替代方案 --- #### 问题根源分析 在 **Kudu 1.10 版本的原生 API** 中,确实没有直接提供 `setBatchingMaxRows` 参数,但可以通过以下方式实现类似效果: 1. **KuduSession 缓冲区控制**:通过 `setMutationBufferSpace` 限制内存中暂存的未提交操作数量[^1] 2. **刷新策略组合**:结合自动刷新间隔与缓冲区大小间接控制批次行数 3. **客户端手动分批**:在 Flink Sink 中自行实现行数累计逻辑 --- ### 分步解决方案 #### 方法 1:通过 KuduSession 缓冲区配置(原生 API) 在初始化 Kudu 客户端时配置会话参数: ```java KuduClient client = new KuduClient.KuduClientBuilder(kuduMasterAddresses).build(); KuduSession session = client.newSession(); // 关键配置项 session.setMutationBufferSpace(1000); // 缓冲区最多缓存1000条操作 session.setFlushInterval(500); // 每500ms自动刷新一次 session.setTimeoutMillis(60_000); // 超时时间60秒 // 写入逻辑 for (RowData row : dataStream) { Insert insert = table.newInsert(); // 填充数据... session.apply(insert); // 手动触发刷新(可选) if (session.getPendingOperations() >= 1000) { session.flush(); } } ``` #### 方法 2:Flink 自定义批量提交 通过 Flink 的 `RichSinkFunction` 实现行数累计控制: ```java public class KuduBatchSink extends RichSinkFunction<RowData> { private transient KuduSession session; private transient List<Operation> buffer; private final int batchSize = 1000; // 自定义批次大小 @Override public void open(Configuration parameters) { KuduClient client = new KuduClient.KuduClientBuilder(masterAddresses).build(); session = client.newSession(); buffer = new ArrayList<>(batchSize); } @Override public void invoke(RowData value, Context context) { Operation insert = convertToKuduOperation(value); buffer.add(insert); if (buffer.size() >= batchSize) { flushBuffer(); } } private void flushBuffer() { try { for (Operation op : buffer) { session.apply(op); } session.flush(); // 显式提交批次 } catch (KuduException e) { // 异常处理 } buffer.clear(); } @Override public void close() { flushBuffer(); // 提交剩余数据 session.close(); } } ``` #### 方法 3:参数映射适配(针对 Flink Connector) 若使用 **Flink Kudu Connector**,通过 `KuduWriterConfig` 兼容性调整: ```java KuduWriterConfig config = KuduWriterConfig.Builder .setBatchingMaxOperations(1000) // 等效替代 setBatchingMaxRows .setBatchingMaxDelayMs(500) // 最大等待时间 .setOperationTimeoutMs(60_000) .build(); ``` --- ### 参数对照表(1.10 vs 新版) | 功能需求 | Kudu 1.10 实现方式 | 新版参数(如1.15+) | |---------------------|----------------------------------|---------------------------| | 控制批次行数 | `session.setMutationBufferSpace` | `setBatchingMaxRows` | | 批量延迟提交 | `session.setFlushInterval` | `setBatchingMaxDelayMs` | | 操作超时 | `session.setTimeoutMillis` | `setOperationTimeoutMs` | --- ### 版本兼容性建议 1. **升级至 CDH 6.3.4+** Kudu 1.10.0-cdh6.3.4 开始支持更完善的批量参数: ```shell # 升级示例(需匹配原有环境) yum upgrade kudu-tserver-1.10.0+cdh6.3.4* ``` 2. **调整 Kudu 服务端配置** 在 `/etc/kudu/conf/tserver.gflagfile` 中优化写入性能: ```properties --tablet_server_max_payload_size=10485760 # 单次RPC最大负载10MB --tablet_server_default_memory_limit=3221225472 # 内存限制3GB ``` --- ### 监控与验证 1. **验证批次提交效果**: ```java // 在 flush 后检查状态 List<OperationResponse> responses = session.getPendingOperations().getRowErrors(); if (!responses.isEmpty()) { // 处理失败记录 } ``` 2. **通过 Kudu Web UI 监控** 访问 `http://kudu-tserver:8050/` 查看 `ops/inserts` 和 `batch_size` 指标 --- #### 相关问题 1. 如何优化 Kudu 的批量写入性能? 2. Flink 如何实现 Exactly-Once 语义的 Kudu 写入? 3. KuduImpala 在 SQL 操作上有哪些差异?
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值