简体   繁体   English

在 airflow bashOperator 中使用 HBase put 命令

[英]Using HBase put command in airflow bashOperator

I'm trying to insert some data into a Hbase table with a Airflow BashOperator task.我正在尝试使用 Airflow BashOperator任务将一些数据插入到 Hbase 表中。 I try to first call the hbase shell and then insert some data into my table:我尝试先调用 hbase shell 然后将一些数据插入我的表中:

logg_data_to_hbase = BashOperator(
    task_id='data_to_hbase',
    dag=test_dag,
    bash_command="hbase shell && put 'tablename', 'rowname','columnvalue', 1000")

I get an error saying ERROR - Bash command failed.我收到一条错误消息,提示错误 - Bash 命令失败。

[2022-01-06 11:01:17,077] {bash_operator.py:100} INFO - Temporary script location: /tmp/airflowtmpcKRT8C/data_to_hbaseY7y25j [2022-01-06 11:01:17,077] {bash_operator.py:100} INFO - 临时脚本位置:/tmp/airflowtmpcKRT8C/data_to_hbaseY7y25j

[2022-01-06 11:01:17,077] {bash_operator.py:110} INFO - Running command: hbase shell && put 'tablename', 'rowname','columnvalue', 1000 [2022-01-06 11:01:17,077] {bash_operator.py:110} INFO - 运行命令:hbase shell && put 'tablename', 'rowname','columnvalue', 1000

[2022-01-06 11:01:17,091] {bash_operator.py:119} INFO - Output: [2022-01-06 11:01:17,091] {bash_operator.py:119} 信息 - Output:

[2022-01-06 11:01:28,659] {bash_operator.py:123} INFO - /tmp/airflowtmpcKRT8C/data_to_hbaseY7y25j: line 1: put: command not found [2022-01-06 11:01:28,659] {bash_operator.py:123} INFO - /tmp/airflowtmpcKRT8C/data_to_hbaseY7y25j:第 1 行:put:找不到命令

[2022-01-06 11:01:28,660] {bash_operator.py:127} INFO - Command exited with return code 127 [2022-01-06 11:01:28,660] {bash_operator.py:127} INFO - 命令退出并返回代码 127

[2022-01-06 11:01:28,672] {models.py:1788} ERROR - Bash command failed [2022-01-06 11:01:28,672] {models.py:1788} 错误 - Bash 命令失败

Traceback (most recent call last): File "/opt/python-2.7.16-AF-1.10.2-XXX/lib/python2.7/site-packages/airflow/models.py", line 1652, in _run_raw_task result = task_copy.execute(context=context) File "/opt/python-2.7.16-AF-1.10.2-XXX/lib/python2.7/site-packages/airflow/operators/bash_operator.py", line 131, in execute raise AirflowException("Bash command failed") AirflowException: Bash command failed回溯(最后一次调用):文件“/opt/python-2.7.16-AF-1.10.2-XXX/lib/python2.7/site-packages/airflow/models.py”,第 1652 行,在 _run_raw_task 结果中= task_copy.execute(context=context) 文件“/opt/python-2.7.16-AF-1.10.2-XXX/lib/python2.7/site-packages/airflow/operators/bash_operator.py”,第 131 行,在执行 raise AirflowException("Bash command failed") AirflowException: Bash command failed

What do I need to change in order to execute the put-command?为了执行 put-command,我需要更改什么?

The last line needs to be changed.最后一行需要更改。

bash_command = "echo \"put 'tablename', 'rowname','columnvalue', '1000'\" | hbase shell"

This way the put command gets executed in hbase shell with the help of |这样put命令在hbase shell的帮助下执行| . .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM