כתיבת נתונים למסד הנתונים של Firestore

בדף הזה מתואר השלב השני בתהליך ההעברה, שבו מגדירים פייפליין של Dataflow ומתחילים בהעברת נתונים בו-זמנית מקטגוריה של Cloud Storage למסד הנתונים של Firestore עם תאימות ל-MongoDB. הפעולה הזו תפעל במקביל לזרם Datastream.

הפעלת צינור עיבוד הנתונים של Dataflow

הפקודה הבאה מפעילה צינור Dataflow חדש עם שם ייחודי.

הפורמטים הבאים קבילים:

  • inputFilePattern=gs://bucket-name/migration/attempt_1/
  • inputFilePattern=gs://bucket-name/migration/
  • inputFilePattern=gs://bucket-name/

לא אפשרי:

  • inputFilePattern=gs://bucket-name/**/*
DATAFLOW_START_TIME="$(date +'%Y%m%d%H%M%S')"

gcloud dataflow flex-template run "dataflow-mongodb-to-firestore-$DATAFLOW_START_TIME" \
--template-file-gcs-location gs://dataflow-templates-us-central1/latest/flex/Cloud_Datastream_MongoDB_to_Firestore \
--region $LOCATION \
--num-workers $NUM_WORKERS \
--temp-location $TEMP_OUTPUT_LOCATION \
--additional-user-labels "" \
--parameters inputFilePattern=$INPUT_FILE_LOCATION,\
inputFileFormat=avro,\
fileReadConcurrency=10,\
connectionUri=$FIRESTORE_CONNECTION_URI,\
databaseName=$FIRESTORE_DATABASE_NAME,\
shadowCollectionPrefix=shadow_,\
batchSize=500,\
deadLetterQueueDirectory=$DLQ_LOCATION,\
dlqRetryMinutes=10,\
dlqMaxRetryCount=500,\
processBackfillFirst=false,\
useShadowTablesForBackfill=true,\
runMode=regular,\
directoryWatchDurationInMinutes=20,\
streamName=$DATASTREAM_NAME,\
stagingLocation=$STAGING_LOCATION,\
autoscalingAlgorithm=THROUGHPUT_BASED,\
maxNumWorkers=$MAX_WORKERS,\
workerMachineType=$WORKER_TYPE

מידע נוסף על מעקב אחרי צינורות Dataflow זמין במאמר פתרון בעיות.

המאמרים הבאים

עוברים אל העברת תנועה ל-Firestore.