问题
I'm using avro tools to generate a schema file from an avro file in HDFS and dump it to the Linux file system using this command:
hadoop jar /usr/bin/Avro/avro-tools-1.8.1.jar getschema /dw/hpm/ap_drg/ap_drg.avro > usr/bin/StageSchema/ap_drg.avsc
This works great and gets me the file I need. However; I would like the schema file to be in HDFS and not the Linux file system. How can I change this command to accomplish this? Is there another way I should be doing this?
回答1:
Played around for a bit and finally figured out something that worked:
hadoop jar /usr/bin/Avro/avro-tools-1.8.1.jar getschema /dw/hpm/ap_drg/ap_drg.avro | hadoop fs -put -f - /dw/schemas/hpm/ap_drg/ap_drg.avsc
This will extract an Avro schema from an Avro file on hdfs and write to an Avro schema file in hdfs. The -f
will make sure any existing schema file will be overwritten.
来源:https://stackoverflow.com/questions/39667843/generate-avro-schema-file-and-store-in-hdfs