首页 > 解决方案 > 使用 gcloud cli 执行 Dataflow 作业时出现“无法识别的参数”错误

问题描述

我在 Dataflow UI 中创建了一个工作,它工作正常。现在我想用一个小的 bash 脚本从命令行自动化它:

#GLOBAL VARIABLES
export PROJECT="cf-businessintelligence"
export GCS_LOCATION="gs://dataflow-templates/latest/Jdbc_to_BigQuery"
export MAX_WORKERS="15"
export NETWORK="businessintelligence"
export REGION_ID="us-central1"
export STAGING_LOCATION="gs://dataflow_temporary_directory/temp_dir"
export SUBNETWORK="bidw-dataflow-usc1"
export WORKER_MACHINE_TYPE="n1-standard-96"
export ZONE="us-central1-a"
export JOBNAME="test"

#COMMAND
gcloud dataflow jobs run $JOBNAME --project=$PROJECT --gcs-location=$GCS_LOCATION \
--max-workers=$MAX_WORKERS \
--network=$NETWORK \
--parameters ^:^query="select current_date":connectionURL="jdbc:mysql://mysqldbhost:3306/bidw":user="xyz",password="abc":driverClassName="com.mysql.jdbc.Driver":driverJars="gs://jdbc_drivers/mysql-connector-java-8.0.16.jar":outputTable="cf-businessintelligence:bidw.mytest":tempLocation="gs://dataflow_temporary_directory/tmp" \
--region=$REGION_ID \
--staging-location=$STAGING_LOCATION \
--subnetwork=$SUBNETWORK \
--worker-machine-type=$WORKER_MACHINE_TYPE \
--zone=$ZONE

当我运行它时,它失败并出现以下错误:

ERROR: (gcloud.dataflow.jobs.run) unrecognized arguments:
  --network=businessintelligence

按照 中的说明gcloud topic escaping,我相信我正确地转义了我的参数,所以我真的很困惑。为什么 NETWORK 参数失败?

标签: google-cloud-dataflow

解决方案


Try getting help for your command, to see which options are currently accepted by it:

gcloud dataflow jobs run --help

For me, this displays a number of options, but not the --network option.


I then checked the beta channel:

gcloud beta dataflow jobs run --help

And it does display the --network option. So you'll want to launch your job with gcloud beta dataflow....


推荐阅读