Scrivi dati nel database Firestore

Questa pagina descrive la seconda fase del processo di migrazione in cui configuri una pipeline Dataflow e avvii uno spostamento simultaneo dei dati dal bucket Cloud Storage al database di destinazione Firestore con compatibilità MongoDB. Questa operazione verrà eseguita contemporaneamente allo stream Datastream.

Avvia la pipeline Dataflow

Il seguente comando avvia una nuova pipeline Dataflow con un nome univoco.

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

Per saperne di più sul monitoraggio della pipeline Dataflow, consulta la sezione Risoluzione dei problemi.

Passaggi successivi

Vai a Eseguire la migrazione del traffico a Firestore.